Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / content / shell / browser / shell_content_browser_client.h
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef CONTENT_SHELL_BROWSER_SHELL_CONTENT_BROWSER_CLIENT_H_
6 #define CONTENT_SHELL_BROWSER_SHELL_CONTENT_BROWSER_CLIENT_H_
7
8 #include <string>
9
10 #include "base/compiler_specific.h"
11 #include "base/files/file_path.h"
12 #include "base/memory/scoped_ptr.h"
13 #include "content/public/browser/content_browser_client.h"
14 #include "content/shell/browser/shell_speech_recognition_manager_delegate.h"
15
16 namespace content {
17
18 class ShellBrowserContext;
19 class ShellBrowserMainParts;
20 class ShellNotificationManager;
21 class ShellResourceDispatcherHostDelegate;
22
23 class ShellContentBrowserClient : public ContentBrowserClient {
24  public:
25   // Gets the current instance.
26   static ShellContentBrowserClient* Get();
27
28   static void SetSwapProcessesForRedirect(bool swap);
29
30   ShellContentBrowserClient();
31   virtual ~ShellContentBrowserClient();
32
33   // Will be lazily created when running layout tests.
34   ShellNotificationManager* GetShellNotificationManager();
35
36   // ContentBrowserClient overrides.
37   virtual BrowserMainParts* CreateBrowserMainParts(
38       const MainFunctionParams& parameters) OVERRIDE;
39   virtual void RenderProcessWillLaunch(RenderProcessHost* host) OVERRIDE;
40   virtual net::URLRequestContextGetter* CreateRequestContext(
41       BrowserContext* browser_context,
42       ProtocolHandlerMap* protocol_handlers,
43       URLRequestInterceptorScopedVector request_interceptors) OVERRIDE;
44   virtual net::URLRequestContextGetter* CreateRequestContextForStoragePartition(
45       BrowserContext* browser_context,
46       const base::FilePath& partition_path,
47       bool in_memory,
48       ProtocolHandlerMap* protocol_handlers,
49       URLRequestInterceptorScopedVector request_interceptors) OVERRIDE;
50   virtual bool IsHandledURL(const GURL& url) OVERRIDE;
51   virtual void AppendExtraCommandLineSwitches(base::CommandLine* command_line,
52                                               int child_process_id) OVERRIDE;
53   virtual void OverrideWebkitPrefs(RenderViewHost* render_view_host,
54                                    const GURL& url,
55                                    WebPreferences* prefs) OVERRIDE;
56   virtual void ResourceDispatcherHostCreated() OVERRIDE;
57   virtual AccessTokenStore* CreateAccessTokenStore() OVERRIDE;
58   virtual std::string GetDefaultDownloadName() OVERRIDE;
59   virtual WebContentsViewDelegate* GetWebContentsViewDelegate(
60       WebContents* web_contents) OVERRIDE;
61   virtual QuotaPermissionContext* CreateQuotaPermissionContext() OVERRIDE;
62   virtual void RequestDesktopNotificationPermission(
63       const GURL& source_origin,
64       RenderFrameHost* render_frame_host,
65       const base::Callback<void(blink::WebNotificationPermission)>& callback)
66           OVERRIDE;
67   virtual blink::WebNotificationPermission
68       CheckDesktopNotificationPermission(
69           const GURL& source_url,
70           ResourceContext* context,
71           int render_process_id) OVERRIDE;
72   virtual SpeechRecognitionManagerDelegate*
73       GetSpeechRecognitionManagerDelegate() OVERRIDE;
74   virtual net::NetLog* GetNetLog() OVERRIDE;
75   virtual bool ShouldSwapProcessesForRedirect(ResourceContext* resource_context,
76                                               const GURL& current_url,
77                                               const GURL& new_url) OVERRIDE;
78
79 #if defined(OS_POSIX) && !defined(OS_MACOSX)
80   virtual void GetAdditionalMappedFilesForChildProcess(
81       const base::CommandLine& command_line,
82       int child_process_id,
83       std::vector<FileDescriptorInfo>* mappings) OVERRIDE;
84 #endif
85 #if defined(OS_WIN)
86   virtual void PreSpawnRenderer(sandbox::TargetPolicy* policy,
87                                 bool* success) OVERRIDE;
88 #endif
89
90   ShellBrowserContext* browser_context();
91   ShellBrowserContext* off_the_record_browser_context();
92   ShellResourceDispatcherHostDelegate* resource_dispatcher_host_delegate() {
93     return resource_dispatcher_host_delegate_.get();
94   }
95   ShellBrowserMainParts* shell_browser_main_parts() {
96     return shell_browser_main_parts_;
97   }
98
99  private:
100   ShellBrowserContext* ShellBrowserContextForBrowserContext(
101       BrowserContext* content_browser_context);
102
103   scoped_ptr<ShellNotificationManager> shell_notification_manager_;
104
105   scoped_ptr<ShellResourceDispatcherHostDelegate>
106       resource_dispatcher_host_delegate_;
107
108   base::FilePath webkit_source_dir_;
109
110   ShellBrowserMainParts* shell_browser_main_parts_;
111 };
112
113 }  // namespace content
114
115 #endif  // CONTENT_SHELL_BROWSER_SHELL_CONTENT_BROWSER_CLIENT_H_