Remove no longer needed toolbar layer method.
[chromium-blink-merge.git] / chrome / browser / chrome_content_browser_client.h
blob9166286be8386012bbf038351a2ec952916d2da3
1 // Copyright (c) 2012 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 CHROME_BROWSER_CHROME_CONTENT_BROWSER_CLIENT_H_
6 #define CHROME_BROWSER_CHROME_CONTENT_BROWSER_CLIENT_H_
8 #include <set>
9 #include <string>
10 #include <utility>
11 #include <vector>
13 #include "base/compiler_specific.h"
14 #include "base/gtest_prod_util.h"
15 #include "base/memory/scoped_ptr.h"
16 #include "base/memory/weak_ptr.h"
17 #include "chrome/common/chrome_version_info.h"
18 #include "content/public/browser/content_browser_client.h"
20 class ChromeContentBrowserClientParts;
22 namespace base {
23 class CommandLine;
26 namespace content {
27 class QuotaPermissionContext;
30 namespace extensions {
31 class BrowserPermissionsPolicyDelegate;
34 namespace user_prefs {
35 class PrefRegistrySyncable;
38 namespace chrome {
40 class ChromeContentBrowserClient : public content::ContentBrowserClient {
41 public:
42 ChromeContentBrowserClient();
43 ~ChromeContentBrowserClient() override;
45 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry);
47 // Notification that the application locale has changed. This allows us to
48 // update our I/O thread cache of this value.
49 static void SetApplicationLocale(const std::string& locale);
51 content::BrowserMainParts* CreateBrowserMainParts(
52 const content::MainFunctionParams& parameters) override;
53 std::string GetStoragePartitionIdForSite(
54 content::BrowserContext* browser_context,
55 const GURL& site) override;
56 bool IsValidStoragePartitionId(content::BrowserContext* browser_context,
57 const std::string& partition_id) override;
58 void GetStoragePartitionConfigForSite(
59 content::BrowserContext* browser_context,
60 const GURL& site,
61 bool can_be_default,
62 std::string* partition_domain,
63 std::string* partition_name,
64 bool* in_memory) override;
65 content::WebContentsViewDelegate* GetWebContentsViewDelegate(
66 content::WebContents* web_contents) override;
67 void RenderProcessWillLaunch(content::RenderProcessHost* host) override;
68 bool ShouldUseProcessPerSite(content::BrowserContext* browser_context,
69 const GURL& effective_url) override;
70 GURL GetEffectiveURL(content::BrowserContext* browser_context,
71 const GURL& url) override;
72 void GetAdditionalWebUISchemes(
73 std::vector<std::string>* additional_schemes) override;
74 void GetAdditionalWebUIHostsToIgnoreParititionCheck(
75 std::vector<std::string>* hosts) override;
76 net::URLRequestContextGetter* CreateRequestContext(
77 content::BrowserContext* browser_context,
78 content::ProtocolHandlerMap* protocol_handlers,
79 content::URLRequestInterceptorScopedVector request_interceptors) override;
80 net::URLRequestContextGetter* CreateRequestContextForStoragePartition(
81 content::BrowserContext* browser_context,
82 const base::FilePath& partition_path,
83 bool in_memory,
84 content::ProtocolHandlerMap* protocol_handlers,
85 content::URLRequestInterceptorScopedVector request_interceptors) override;
86 bool IsHandledURL(const GURL& url) override;
87 bool CanCommitURL(content::RenderProcessHost* process_host,
88 const GURL& url) override;
89 bool ShouldAllowOpenURL(content::SiteInstance* site_instance,
90 const GURL& url) override;
91 bool IsSuitableHost(content::RenderProcessHost* process_host,
92 const GURL& site_url) override;
93 bool MayReuseHost(content::RenderProcessHost* process_host) override;
94 bool ShouldTryToUseExistingProcessHost(
95 content::BrowserContext* browser_context,
96 const GURL& url) override;
97 void SiteInstanceGotProcess(content::SiteInstance* site_instance) override;
98 void SiteInstanceDeleting(content::SiteInstance* site_instance) override;
99 bool ShouldSwapBrowsingInstancesForNavigation(
100 content::SiteInstance* site_instance,
101 const GURL& current_url,
102 const GURL& new_url) override;
103 bool ShouldSwapProcessesForRedirect(
104 content::ResourceContext* resource_context,
105 const GURL& current_url,
106 const GURL& new_url) override;
107 bool ShouldAssignSiteForURL(const GURL& url) override;
108 std::string GetCanonicalEncodingNameByAliasName(
109 const std::string& alias_name) override;
110 void AppendExtraCommandLineSwitches(base::CommandLine* command_line,
111 int child_process_id) override;
112 std::string GetApplicationLocale() override;
113 std::string GetAcceptLangs(content::BrowserContext* context) override;
114 const gfx::ImageSkia* GetDefaultFavicon() override;
115 bool AllowAppCache(const GURL& manifest_url,
116 const GURL& first_party,
117 content::ResourceContext* context) override;
118 bool AllowServiceWorker(const GURL& scope,
119 const GURL& first_party,
120 content::ResourceContext* context) override;
121 bool AllowGetCookie(const GURL& url,
122 const GURL& first_party,
123 const net::CookieList& cookie_list,
124 content::ResourceContext* context,
125 int render_process_id,
126 int render_frame_id) override;
127 bool AllowSetCookie(const GURL& url,
128 const GURL& first_party,
129 const std::string& cookie_line,
130 content::ResourceContext* context,
131 int render_process_id,
132 int render_frame_id,
133 net::CookieOptions* options) override;
134 bool AllowSaveLocalState(content::ResourceContext* context) override;
135 bool AllowWorkerDatabase(
136 const GURL& url,
137 const base::string16& name,
138 const base::string16& display_name,
139 unsigned long estimated_size,
140 content::ResourceContext* context,
141 const std::vector<std::pair<int, int>>& render_frames) override;
142 void AllowWorkerFileSystem(
143 const GURL& url,
144 content::ResourceContext* context,
145 const std::vector<std::pair<int, int>>& render_frames,
146 base::Callback<void(bool)> callback) override;
147 bool AllowWorkerIndexedDB(
148 const GURL& url,
149 const base::string16& name,
150 content::ResourceContext* context,
151 const std::vector<std::pair<int, int>>& render_frames) override;
152 net::URLRequestContext* OverrideRequestContextForURL(
153 const GURL& url,
154 content::ResourceContext* context) override;
155 content::QuotaPermissionContext* CreateQuotaPermissionContext() override;
156 void AllowCertificateError(
157 int render_process_id,
158 int render_frame_id,
159 int cert_error,
160 const net::SSLInfo& ssl_info,
161 const GURL& request_url,
162 content::ResourceType resource_type,
163 bool overridable,
164 bool strict_enforcement,
165 bool expired_previous_decision,
166 const base::Callback<void(bool)>& callback,
167 content::CertificateRequestResultType* request) override;
168 void SelectClientCertificate(
169 int render_process_id,
170 int render_frame_id,
171 net::SSLCertRequestInfo* cert_request_info,
172 const base::Callback<void(net::X509Certificate*)>& callback) override;
173 void AddCertificate(net::CertificateMimeType cert_type,
174 const void* cert_data,
175 size_t cert_size,
176 int render_process_id,
177 int render_frame_id) override;
178 content::MediaObserver* GetMediaObserver() override;
179 content::PlatformNotificationService* GetPlatformNotificationService()
180 override;
181 void RequestPermission(
182 content::PermissionType permission,
183 content::WebContents* web_contents,
184 int bridge_id,
185 const GURL& requesting_frame,
186 bool user_gesture,
187 const base::Callback<void(content::PermissionStatus)>& callback) override;
188 content::PermissionStatus GetPermissionStatus(
189 content::PermissionType permission,
190 content::BrowserContext* browser_context,
191 const GURL& requesting_origin,
192 const GURL& embedding_origin) override;
193 void ResetPermission(
194 content::PermissionType permission,
195 content::BrowserContext* browser_context,
196 const GURL& requesting_origin,
197 const GURL& embedding_origin) override;
198 void CancelPermissionRequest(content::PermissionType permission,
199 content::WebContents* web_contents,
200 int bridge_id,
201 const GURL& requesting_frame) override;
202 void RegisterPermissionUsage(content::PermissionType permission,
203 content::WebContents* web_contents,
204 const GURL& frame_url,
205 const GURL& main_frame_url) override;
206 bool CanCreateWindow(const GURL& opener_url,
207 const GURL& opener_top_level_frame_url,
208 const GURL& source_origin,
209 WindowContainerType container_type,
210 const GURL& target_url,
211 const content::Referrer& referrer,
212 WindowOpenDisposition disposition,
213 const blink::WebWindowFeatures& features,
214 bool user_gesture,
215 bool opener_suppressed,
216 content::ResourceContext* context,
217 int render_process_id,
218 int opener_id,
219 bool* no_javascript_access) override;
220 void ResourceDispatcherHostCreated() override;
221 content::SpeechRecognitionManagerDelegate*
222 CreateSpeechRecognitionManagerDelegate() override;
223 net::NetLog* GetNetLog() override;
224 content::AccessTokenStore* CreateAccessTokenStore() override;
225 bool IsFastShutdownPossible() override;
226 void OverrideWebkitPrefs(content::RenderViewHost* rvh,
227 content::WebPreferences* prefs) override;
228 void BrowserURLHandlerCreated(content::BrowserURLHandler* handler) override;
229 void ClearCache(content::RenderViewHost* rvh) override;
230 void ClearCookies(content::RenderViewHost* rvh) override;
231 base::FilePath GetDefaultDownloadDirectory() override;
232 std::string GetDefaultDownloadName() override;
233 void DidCreatePpapiPlugin(content::BrowserPpapiHost* browser_host) override;
234 content::BrowserPpapiHost* GetExternalBrowserPpapiHost(
235 int plugin_process_id) override;
236 bool AllowPepperSocketAPI(
237 content::BrowserContext* browser_context,
238 const GURL& url,
239 bool private_api,
240 const content::SocketPermissionRequest* params) override;
241 ui::SelectFilePolicy* CreateSelectFilePolicy(
242 content::WebContents* web_contents) override;
243 void GetAdditionalAllowedSchemesForFileSystem(
244 std::vector<std::string>* additional_schemes) override;
245 void GetURLRequestAutoMountHandlers(
246 std::vector<storage::URLRequestAutoMountHandler>* handlers) override;
247 void GetAdditionalFileSystemBackends(
248 content::BrowserContext* browser_context,
249 const base::FilePath& storage_partition_path,
250 ScopedVector<storage::FileSystemBackend>* additional_backends) override;
251 content::DevToolsManagerDelegate* GetDevToolsManagerDelegate() override;
252 content::TracingDelegate* GetTracingDelegate() override;
253 bool IsPluginAllowedToCallRequestOSFileHandle(
254 content::BrowserContext* browser_context,
255 const GURL& url) override;
256 bool IsPluginAllowedToUseDevChannelAPIs(
257 content::BrowserContext* browser_context,
258 const GURL& url) override;
259 void OverridePageVisibilityState(
260 content::RenderFrameHost* render_frame_host,
261 blink::WebPageVisibilityState* visibility_state) override;
263 #if defined(OS_POSIX) && !defined(OS_MACOSX)
264 void GetAdditionalMappedFilesForChildProcess(
265 const base::CommandLine& command_line,
266 int child_process_id,
267 content::FileDescriptorInfo* mappings) override;
268 #endif
269 #if defined(OS_WIN)
270 virtual const wchar_t* GetResourceDllName() override;
271 virtual void PreSpawnRenderer(sandbox::TargetPolicy* policy,
272 bool* success) override;
273 #endif
274 bool CheckMediaAccessPermission(content::BrowserContext* browser_context,
275 const GURL& security_origin,
276 content::MediaStreamType type) override;
278 void OpenURL(content::BrowserContext* browser_context,
279 const content::OpenURLParams& params,
280 const base::Callback<void(content::WebContents*)>& callback)
281 override;
283 void RecordURLMetric(const std::string& metric, const GURL& url) override;
285 private:
286 friend class DisableWebRtcEncryptionFlagTest;
288 #if defined(ENABLE_WEBRTC)
289 // Copies disable WebRTC encryption switch depending on the channel.
290 static void MaybeCopyDisableWebRtcEncryptionSwitch(
291 base::CommandLine* to_command_line,
292 const base::CommandLine& from_command_line,
293 VersionInfo::Channel channel);
294 #endif
296 void FileSystemAccessed(
297 const GURL& url,
298 const std::vector<std::pair<int, int> >& render_frames,
299 base::Callback<void(bool)> callback,
300 bool allow);
302 #if defined(ENABLE_EXTENSIONS)
303 void GuestPermissionRequestHelper(
304 const GURL& url,
305 const std::vector<std::pair<int, int> >& render_frames,
306 base::Callback<void(bool)> callback,
307 bool allow);
309 static void RequestFileSystemPermissionOnUIThread(
310 int render_process_id,
311 int render_frame_id,
312 const GURL& url,
313 bool allowed_by_default,
314 const base::Callback<void(bool)>& callback);
315 #endif
317 #if defined(ENABLE_PLUGINS)
318 // Set of origins that can use TCP/UDP private APIs from NaCl.
319 std::set<std::string> allowed_socket_origins_;
320 // Set of origins that can get a handle for FileIO from NaCl.
321 std::set<std::string> allowed_file_handle_origins_;
322 // Set of origins that can use "dev chanel" APIs from NaCl, even on stable
323 // versions of Chrome.
324 std::set<std::string> allowed_dev_channel_origins_;
325 #endif
327 #if defined(OS_POSIX) && !defined(OS_MACOSX)
328 base::ScopedFD v8_natives_fd_;
329 base::ScopedFD v8_snapshot_fd_;
330 #endif // OS_POSIX && !OS_MACOSX
332 // Vector of additional ChromeContentBrowserClientParts.
333 // Parts are deleted in the reverse order they are added.
334 std::vector<ChromeContentBrowserClientParts*> extra_parts_;
336 base::WeakPtrFactory<ChromeContentBrowserClient> weak_factory_;
338 DISALLOW_COPY_AND_ASSIGN(ChromeContentBrowserClient);
341 } // namespace chrome
343 #endif // CHROME_BROWSER_CHROME_CONTENT_BROWSER_CLIENT_H_