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 ShellResourceDispatcherHostDelegate
;
22 class ShellContentBrowserClient
: public ContentBrowserClient
{
24 // Gets the current instance.
25 static ShellContentBrowserClient
* Get();
27 static void SetSwapProcessesForRedirect(bool swap
);
29 ShellContentBrowserClient();
30 ~ShellContentBrowserClient() override
;
32 // ContentBrowserClient overrides.
33 BrowserMainParts
* CreateBrowserMainParts(
34 const MainFunctionParams
& parameters
) override
;
35 void RenderProcessWillLaunch(RenderProcessHost
* host
) override
;
36 net::URLRequestContextGetter
* CreateRequestContext(
37 BrowserContext
* browser_context
,
38 ProtocolHandlerMap
* protocol_handlers
,
39 URLRequestInterceptorScopedVector request_interceptors
) override
;
40 net::URLRequestContextGetter
* CreateRequestContextForStoragePartition(
41 BrowserContext
* browser_context
,
42 const base::FilePath
& partition_path
,
44 ProtocolHandlerMap
* protocol_handlers
,
45 URLRequestInterceptorScopedVector request_interceptors
) override
;
46 bool IsHandledURL(const GURL
& url
) override
;
47 bool IsNPAPIEnabled() override
;
48 void AppendExtraCommandLineSwitches(base::CommandLine
* command_line
,
49 int child_process_id
) override
;
50 void OverrideWebkitPrefs(RenderViewHost
* render_view_host
,
51 WebPreferences
* prefs
) override
;
52 void ResourceDispatcherHostCreated() override
;
53 AccessTokenStore
* CreateAccessTokenStore() override
;
54 std::string
GetDefaultDownloadName() override
;
55 WebContentsViewDelegate
* GetWebContentsViewDelegate(
56 WebContents
* web_contents
) override
;
57 QuotaPermissionContext
* CreateQuotaPermissionContext() override
;
58 void SelectClientCertificate(
59 WebContents
* web_contents
,
60 net::SSLCertRequestInfo
* cert_request_info
,
61 scoped_ptr
<ClientCertificateDelegate
> delegate
) override
;
63 SpeechRecognitionManagerDelegate
* CreateSpeechRecognitionManagerDelegate()
65 net::NetLog
* GetNetLog() override
;
66 bool ShouldSwapProcessesForRedirect(ResourceContext
* resource_context
,
67 const GURL
& current_url
,
68 const GURL
& new_url
) override
;
69 DevToolsManagerDelegate
* GetDevToolsManagerDelegate() override
;
71 void OpenURL(BrowserContext
* browser_context
,
72 const OpenURLParams
& params
,
73 const base::Callback
<void(WebContents
*)>& callback
) override
;
75 #if defined(OS_ANDROID)
76 void GetAdditionalMappedFilesForChildProcess(
77 const base::CommandLine
& command_line
,
79 content::FileDescriptorInfo
* mappings
,
80 std::map
<int, base::MemoryMappedFile::Region
>* regions
) override
;
81 #elif defined(OS_POSIX) && !defined(OS_MACOSX)
82 void GetAdditionalMappedFilesForChildProcess(
83 const base::CommandLine
& command_line
,
85 content::FileDescriptorInfo
* mappings
) override
;
86 #endif // defined(OS_ANDROID)
88 void PreSpawnRenderer(sandbox::TargetPolicy
* policy
, bool* success
) override
;
91 ShellBrowserContext
* browser_context();
92 ShellBrowserContext
* off_the_record_browser_context();
93 ShellResourceDispatcherHostDelegate
* resource_dispatcher_host_delegate() {
94 return resource_dispatcher_host_delegate_
.get();
96 ShellBrowserMainParts
* shell_browser_main_parts() {
97 return shell_browser_main_parts_
;
100 // Used for content_browsertests.
101 void set_select_client_certificate_callback(
102 base::Closure select_client_certificate_callback
) {
103 select_client_certificate_callback_
= select_client_certificate_callback
;
107 ShellBrowserContext
* ShellBrowserContextForBrowserContext(
108 BrowserContext
* content_browser_context
);
110 scoped_ptr
<ShellResourceDispatcherHostDelegate
>
111 resource_dispatcher_host_delegate_
;
113 base::Closure select_client_certificate_callback_
;
115 ShellBrowserMainParts
* shell_browser_main_parts_
;
118 } // namespace content
120 #endif // CONTENT_SHELL_BROWSER_SHELL_CONTENT_BROWSER_CLIENT_H_