[ServiceWorker] Implement WebServiceWorkerContextClient::openWindow().
[chromium-blink-merge.git] / chrome / browser / chrome_content_browser_client.h
blob40e700f311f5a8e0a4f411c57f4cde31cd8cd317
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 const GURL& url,
232 content::WebPreferences* prefs) override;
233 void BrowserURLHandlerCreated(content::BrowserURLHandler* handler) override;
234 void ClearCache(content::RenderViewHost* rvh) override;
235 void ClearCookies(content::RenderViewHost* rvh) override;
236 base::FilePath GetDefaultDownloadDirectory() override;
237 std::string GetDefaultDownloadName() override;
238 void DidCreatePpapiPlugin(content::BrowserPpapiHost* browser_host) override;
239 content::BrowserPpapiHost* GetExternalBrowserPpapiHost(
240 int plugin_process_id) override;
241 bool AllowPepperSocketAPI(
242 content::BrowserContext* browser_context,
243 const GURL& url,
244 bool private_api,
245 const content::SocketPermissionRequest* params) override;
246 ui::SelectFilePolicy* CreateSelectFilePolicy(
247 content::WebContents* web_contents) override;
248 void GetAdditionalAllowedSchemesForFileSystem(
249 std::vector<std::string>* additional_schemes) override;
250 void GetURLRequestAutoMountHandlers(
251 std::vector<storage::URLRequestAutoMountHandler>* handlers) override;
252 void GetAdditionalFileSystemBackends(
253 content::BrowserContext* browser_context,
254 const base::FilePath& storage_partition_path,
255 ScopedVector<storage::FileSystemBackend>* additional_backends) override;
256 content::DevToolsManagerDelegate* GetDevToolsManagerDelegate() override;
257 bool IsPluginAllowedToCallRequestOSFileHandle(
258 content::BrowserContext* browser_context,
259 const GURL& url) override;
260 bool IsPluginAllowedToUseDevChannelAPIs(
261 content::BrowserContext* browser_context,
262 const GURL& url) override;
263 net::CookieStore* OverrideCookieStoreForRenderProcess(
264 int render_process_id) override;
265 void OverridePageVisibilityState(
266 content::RenderFrameHost* render_frame_host,
267 blink::WebPageVisibilityState* visibility_state) override;
269 #if defined(OS_POSIX) && !defined(OS_MACOSX)
270 void GetAdditionalMappedFilesForChildProcess(
271 const base::CommandLine& command_line,
272 int child_process_id,
273 content::FileDescriptorInfo* mappings) override;
274 #endif
275 #if defined(OS_WIN)
276 virtual const wchar_t* GetResourceDllName() override;
277 virtual void PreSpawnRenderer(sandbox::TargetPolicy* policy,
278 bool* success) override;
279 #endif
280 bool CheckMediaAccessPermission(content::BrowserContext* browser_context,
281 const GURL& security_origin,
282 content::MediaStreamType type) override;
284 content::WebContents* OpenURL(content::BrowserContext* browser_context,
285 const content::OpenURLParams& params) override;
287 private:
288 friend class DisableWebRtcEncryptionFlagTest;
290 #if defined(ENABLE_WEBRTC)
291 // Copies disable WebRTC encryption switch depending on the channel.
292 static void MaybeCopyDisableWebRtcEncryptionSwitch(
293 base::CommandLine* to_command_line,
294 const base::CommandLine& from_command_line,
295 VersionInfo::Channel channel);
296 #endif
298 void FileSystemAccessed(
299 const GURL& url,
300 const std::vector<std::pair<int, int> >& render_frames,
301 base::Callback<void(bool)> callback,
302 bool allow);
304 #if defined(ENABLE_EXTENSIONS)
305 void GuestPermissionRequestHelper(
306 const GURL& url,
307 const std::vector<std::pair<int, int> >& render_frames,
308 base::Callback<void(bool)> callback,
309 bool allow);
311 static void RequestFileSystemPermissionOnUIThread(
312 int render_process_id,
313 int render_frame_id,
314 const GURL& url,
315 bool allowed_by_default,
316 const base::Callback<void(bool)>& callback);
317 #endif
319 #if defined(ENABLE_PLUGINS)
320 // Set of origins that can use TCP/UDP private APIs from NaCl.
321 std::set<std::string> allowed_socket_origins_;
322 // Set of origins that can get a handle for FileIO from NaCl.
323 std::set<std::string> allowed_file_handle_origins_;
324 // Set of origins that can use "dev chanel" APIs from NaCl, even on stable
325 // versions of Chrome.
326 std::set<std::string> allowed_dev_channel_origins_;
327 #endif
329 // The prerender tracker used to determine whether a render process is used
330 // for prerendering and an override cookie store must be provided.
331 // This needs to be kept as a member rather than just looked up from
332 // the profile due to initialization ordering, as well as due to threading.
333 // It is initialized on the UI thread when the ResoureDispatcherHost is
334 // created. It is used only the IO thread.
335 prerender::PrerenderTracker* prerender_tracker_;
337 // Vector of additional ChromeContentBrowserClientParts.
338 // Parts are deleted in the reverse order they are added.
339 std::vector<ChromeContentBrowserClientParts*> extra_parts_;
341 base::WeakPtrFactory<ChromeContentBrowserClient> weak_factory_;
343 DISALLOW_COPY_AND_ASSIGN(ChromeContentBrowserClient);
346 } // namespace chrome
348 #endif // CHROME_BROWSER_CHROME_CONTENT_BROWSER_CLIENT_H_