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