[cros new GAIA] Update GAIA card size
[chromium-blink-merge.git] / chrome / browser / chrome_content_browser_client.h
blob6af499c3ae677e53299592079bf14ddefd40fd40
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 content::WebContents* web_contents,
170 net::SSLCertRequestInfo* cert_request_info,
171 scoped_ptr<content::ClientCertificateDelegate> delegate) override;
172 void AddCertificate(net::CertificateMimeType cert_type,
173 const void* cert_data,
174 size_t cert_size,
175 int render_process_id,
176 int render_frame_id) override;
177 content::MediaObserver* GetMediaObserver() override;
178 content::PlatformNotificationService* GetPlatformNotificationService()
179 override;
180 bool CanCreateWindow(const GURL& opener_url,
181 const GURL& opener_top_level_frame_url,
182 const GURL& source_origin,
183 WindowContainerType container_type,
184 const GURL& target_url,
185 const content::Referrer& referrer,
186 WindowOpenDisposition disposition,
187 const blink::WebWindowFeatures& features,
188 bool user_gesture,
189 bool opener_suppressed,
190 content::ResourceContext* context,
191 int render_process_id,
192 int opener_id,
193 bool* no_javascript_access) override;
194 void ResourceDispatcherHostCreated() override;
195 content::SpeechRecognitionManagerDelegate*
196 CreateSpeechRecognitionManagerDelegate() override;
197 net::NetLog* GetNetLog() override;
198 content::AccessTokenStore* CreateAccessTokenStore() override;
199 bool IsFastShutdownPossible() override;
200 void OverrideWebkitPrefs(content::RenderViewHost* rvh,
201 content::WebPreferences* prefs) override;
202 void BrowserURLHandlerCreated(content::BrowserURLHandler* handler) override;
203 void ClearCache(content::RenderFrameHost* rfh) override;
204 void ClearCookies(content::RenderFrameHost* rfh) override;
205 base::FilePath GetDefaultDownloadDirectory() override;
206 std::string GetDefaultDownloadName() override;
207 void DidCreatePpapiPlugin(content::BrowserPpapiHost* browser_host) override;
208 content::BrowserPpapiHost* GetExternalBrowserPpapiHost(
209 int plugin_process_id) override;
210 bool AllowPepperSocketAPI(
211 content::BrowserContext* browser_context,
212 const GURL& url,
213 bool private_api,
214 const content::SocketPermissionRequest* params) override;
215 ui::SelectFilePolicy* CreateSelectFilePolicy(
216 content::WebContents* web_contents) override;
217 void GetAdditionalAllowedSchemesForFileSystem(
218 std::vector<std::string>* additional_schemes) override;
219 void GetURLRequestAutoMountHandlers(
220 std::vector<storage::URLRequestAutoMountHandler>* handlers) override;
221 void GetAdditionalFileSystemBackends(
222 content::BrowserContext* browser_context,
223 const base::FilePath& storage_partition_path,
224 ScopedVector<storage::FileSystemBackend>* additional_backends) override;
225 content::DevToolsManagerDelegate* GetDevToolsManagerDelegate() override;
226 content::TracingDelegate* GetTracingDelegate() override;
227 bool IsPluginAllowedToCallRequestOSFileHandle(
228 content::BrowserContext* browser_context,
229 const GURL& url) override;
230 bool IsPluginAllowedToUseDevChannelAPIs(
231 content::BrowserContext* browser_context,
232 const GURL& url) override;
233 void OverridePageVisibilityState(
234 content::RenderFrameHost* render_frame_host,
235 blink::WebPageVisibilityState* visibility_state) override;
237 #if defined(OS_POSIX) && !defined(OS_MACOSX)
238 void GetAdditionalMappedFilesForChildProcess(
239 const base::CommandLine& command_line,
240 int child_process_id,
241 content::FileDescriptorInfo* mappings) override;
242 #endif
243 #if defined(OS_WIN)
244 virtual const wchar_t* GetResourceDllName() override;
245 virtual void PreSpawnRenderer(sandbox::TargetPolicy* policy,
246 bool* success) override;
247 #endif
248 bool CheckMediaAccessPermission(content::BrowserContext* browser_context,
249 const GURL& security_origin,
250 content::MediaStreamType type) override;
252 void OpenURL(content::BrowserContext* browser_context,
253 const content::OpenURLParams& params,
254 const base::Callback<void(content::WebContents*)>& callback)
255 override;
257 void RecordURLMetric(const std::string& metric, const GURL& url) override;
259 private:
260 friend class DisableWebRtcEncryptionFlagTest;
262 #if defined(ENABLE_WEBRTC)
263 // Copies disable WebRTC encryption switch depending on the channel.
264 static void MaybeCopyDisableWebRtcEncryptionSwitch(
265 base::CommandLine* to_command_line,
266 const base::CommandLine& from_command_line,
267 VersionInfo::Channel channel);
268 #endif
270 void FileSystemAccessed(
271 const GURL& url,
272 const std::vector<std::pair<int, int> >& render_frames,
273 base::Callback<void(bool)> callback,
274 bool allow);
276 #if defined(ENABLE_EXTENSIONS)
277 void GuestPermissionRequestHelper(
278 const GURL& url,
279 const std::vector<std::pair<int, int> >& render_frames,
280 base::Callback<void(bool)> callback,
281 bool allow);
283 static void RequestFileSystemPermissionOnUIThread(
284 int render_process_id,
285 int render_frame_id,
286 const GURL& url,
287 bool allowed_by_default,
288 const base::Callback<void(bool)>& callback);
289 #endif
291 #if defined(ENABLE_PLUGINS)
292 // Set of origins that can use TCP/UDP private APIs from NaCl.
293 std::set<std::string> allowed_socket_origins_;
294 // Set of origins that can get a handle for FileIO from NaCl.
295 std::set<std::string> allowed_file_handle_origins_;
296 // Set of origins that can use "dev chanel" APIs from NaCl, even on stable
297 // versions of Chrome.
298 std::set<std::string> allowed_dev_channel_origins_;
299 #endif
301 #if defined(OS_POSIX) && !defined(OS_MACOSX)
302 base::ScopedFD v8_natives_fd_;
303 base::ScopedFD v8_snapshot_fd_;
304 #endif // OS_POSIX && !OS_MACOSX
306 // Vector of additional ChromeContentBrowserClientParts.
307 // Parts are deleted in the reverse order they are added.
308 std::vector<ChromeContentBrowserClientParts*> extra_parts_;
310 base::WeakPtrFactory<ChromeContentBrowserClient> weak_factory_;
312 DISALLOW_COPY_AND_ASSIGN(ChromeContentBrowserClient);
315 } // namespace chrome
317 #endif // CHROME_BROWSER_CHROME_CONTENT_BROWSER_CLIENT_H_