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.
5 #ifndef CONTENT_SHELL_BROWSER_SHELL_CONTENT_BROWSER_CLIENT_H_
6 #define CONTENT_SHELL_BROWSER_SHELL_CONTENT_BROWSER_CLIENT_H_
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"
18 class ShellBrowserContext
;
19 class ShellBrowserMainParts
;
20 class ShellNotificationManager
;
21 class ShellResourceDispatcherHostDelegate
;
23 class ShellContentBrowserClient
: public ContentBrowserClient
{
25 // Gets the current instance.
26 static ShellContentBrowserClient
* Get();
28 static void SetSwapProcessesForRedirect(bool swap
);
30 ShellContentBrowserClient();
31 virtual ~ShellContentBrowserClient();
33 // Will be lazily created when running layout tests.
34 ShellNotificationManager
* GetShellNotificationManager();
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
,
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
,
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
)
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
;
79 #if defined(OS_POSIX) && !defined(OS_MACOSX)
80 virtual void GetAdditionalMappedFilesForChildProcess(
81 const base::CommandLine
& command_line
,
83 std::vector
<FileDescriptorInfo
>* mappings
) OVERRIDE
;
86 virtual void PreSpawnRenderer(sandbox::TargetPolicy
* policy
,
87 bool* success
) OVERRIDE
;
90 ShellBrowserContext
* browser_context();
91 ShellBrowserContext
* off_the_record_browser_context();
92 ShellResourceDispatcherHostDelegate
* resource_dispatcher_host_delegate() {
93 return resource_dispatcher_host_delegate_
.get();
95 ShellBrowserMainParts
* shell_browser_main_parts() {
96 return shell_browser_main_parts_
;
100 ShellBrowserContext
* ShellBrowserContextForBrowserContext(
101 BrowserContext
* content_browser_context
);
103 scoped_ptr
<ShellNotificationManager
> shell_notification_manager_
;
105 scoped_ptr
<ShellResourceDispatcherHostDelegate
>
106 resource_dispatcher_host_delegate_
;
108 base::FilePath webkit_source_dir_
;
110 ShellBrowserMainParts
* shell_browser_main_parts_
;
113 } // namespace content
115 #endif // CONTENT_SHELL_BROWSER_SHELL_CONTENT_BROWSER_CLIENT_H_