Update broken references to image assets
[chromium-blink-merge.git] / chrome / browser / chrome_content_browser_client.h
blob1d3dd33fb9e437b956a17415da81262849c9a6dc
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 "content/public/browser/content_browser_client.h"
19 class ChromeContentBrowserClientParts;
21 namespace base {
22 class CommandLine;
25 namespace content {
26 class QuotaPermissionContext;
29 namespace extensions {
30 class BrowserPermissionsPolicyDelegate;
33 namespace user_prefs {
34 class PrefRegistrySyncable;
37 namespace version_info {
38 enum class Channel;
41 namespace chrome {
43 class ChromeContentBrowserClient : public content::ContentBrowserClient {
44 public:
45 ChromeContentBrowserClient();
46 ~ChromeContentBrowserClient() override;
48 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry);
50 // Notification that the application locale has changed. This allows us to
51 // update our I/O thread cache of this value.
52 static void SetApplicationLocale(const std::string& locale);
54 content::BrowserMainParts* CreateBrowserMainParts(
55 const content::MainFunctionParams& parameters) override;
56 void PostAfterStartupTask(const tracked_objects::Location& from_here,
57 const scoped_refptr<base::TaskRunner>& task_runner,
58 const base::Closure& task) override;
59 std::string GetStoragePartitionIdForSite(
60 content::BrowserContext* browser_context,
61 const GURL& site) override;
62 bool IsValidStoragePartitionId(content::BrowserContext* browser_context,
63 const std::string& partition_id) override;
64 void GetStoragePartitionConfigForSite(
65 content::BrowserContext* browser_context,
66 const GURL& site,
67 bool can_be_default,
68 std::string* partition_domain,
69 std::string* partition_name,
70 bool* in_memory) override;
71 content::WebContentsViewDelegate* GetWebContentsViewDelegate(
72 content::WebContents* web_contents) override;
73 void RenderProcessWillLaunch(content::RenderProcessHost* host) override;
74 bool ShouldUseProcessPerSite(content::BrowserContext* browser_context,
75 const GURL& effective_url) override;
76 GURL GetEffectiveURL(content::BrowserContext* browser_context,
77 const GURL& url) override;
78 void GetAdditionalWebUISchemes(
79 std::vector<std::string>* additional_schemes) override;
80 void GetAdditionalWebUIHostsToIgnoreParititionCheck(
81 std::vector<std::string>* hosts) override;
82 net::URLRequestContextGetter* CreateRequestContext(
83 content::BrowserContext* browser_context,
84 content::ProtocolHandlerMap* protocol_handlers,
85 content::URLRequestInterceptorScopedVector request_interceptors) override;
86 net::URLRequestContextGetter* CreateRequestContextForStoragePartition(
87 content::BrowserContext* browser_context,
88 const base::FilePath& partition_path,
89 bool in_memory,
90 content::ProtocolHandlerMap* protocol_handlers,
91 content::URLRequestInterceptorScopedVector request_interceptors) override;
92 bool IsHandledURL(const GURL& url) override;
93 bool CanCommitURL(content::RenderProcessHost* process_host,
94 const GURL& url) override;
95 bool IsIllegalOrigin(content::ResourceContext* resource_context,
96 int child_process_id,
97 const GURL& origin) override;
98 bool ShouldAllowOpenURL(content::SiteInstance* site_instance,
99 const GURL& url) override;
100 bool IsSuitableHost(content::RenderProcessHost* process_host,
101 const GURL& site_url) override;
102 bool MayReuseHost(content::RenderProcessHost* process_host) override;
103 bool ShouldTryToUseExistingProcessHost(
104 content::BrowserContext* browser_context,
105 const GURL& url) override;
106 void SiteInstanceGotProcess(content::SiteInstance* site_instance) override;
107 void SiteInstanceDeleting(content::SiteInstance* site_instance) override;
108 bool ShouldSwapBrowsingInstancesForNavigation(
109 content::SiteInstance* site_instance,
110 const GURL& current_url,
111 const GURL& new_url) override;
112 bool ShouldSwapProcessesForRedirect(
113 content::ResourceContext* resource_context,
114 const GURL& current_url,
115 const GURL& new_url) override;
116 bool ShouldAssignSiteForURL(const GURL& url) override;
117 std::string GetCanonicalEncodingNameByAliasName(
118 const std::string& alias_name) override;
119 void AppendExtraCommandLineSwitches(base::CommandLine* command_line,
120 int child_process_id) override;
121 std::string GetApplicationLocale() override;
122 std::string GetAcceptLangs(content::BrowserContext* context) override;
123 const gfx::ImageSkia* GetDefaultFavicon() override;
124 bool AllowAppCache(const GURL& manifest_url,
125 const GURL& first_party,
126 content::ResourceContext* context) override;
127 bool AllowServiceWorker(const GURL& scope,
128 const GURL& first_party,
129 content::ResourceContext* context,
130 int render_process_id,
131 int render_frame_id) override;
132 bool AllowGetCookie(const GURL& url,
133 const GURL& first_party,
134 const net::CookieList& cookie_list,
135 content::ResourceContext* context,
136 int render_process_id,
137 int render_frame_id) override;
138 bool AllowSetCookie(const GURL& url,
139 const GURL& first_party,
140 const std::string& cookie_line,
141 content::ResourceContext* context,
142 int render_process_id,
143 int render_frame_id,
144 net::CookieOptions* options) override;
145 bool AllowSaveLocalState(content::ResourceContext* context) override;
146 bool AllowWorkerDatabase(
147 const GURL& url,
148 const base::string16& name,
149 const base::string16& display_name,
150 unsigned long estimated_size,
151 content::ResourceContext* context,
152 const std::vector<std::pair<int, int>>& render_frames) override;
153 void AllowWorkerFileSystem(
154 const GURL& url,
155 content::ResourceContext* context,
156 const std::vector<std::pair<int, int>>& render_frames,
157 base::Callback<void(bool)> callback) override;
158 bool AllowWorkerIndexedDB(
159 const GURL& url,
160 const base::string16& name,
161 content::ResourceContext* context,
162 const std::vector<std::pair<int, int>>& render_frames) override;
164 #if defined(ENABLE_WEBRTC)
165 bool AllowWebRTCIdentityCache(const GURL& url,
166 const GURL& first_party_url,
167 content::ResourceContext* context) override;
168 #endif // defined(ENABLE_WEBRTC)
170 net::URLRequestContext* OverrideRequestContextForURL(
171 const GURL& url,
172 content::ResourceContext* context) override;
173 content::QuotaPermissionContext* CreateQuotaPermissionContext() override;
174 void AllowCertificateError(
175 int render_process_id,
176 int render_frame_id,
177 int cert_error,
178 const net::SSLInfo& ssl_info,
179 const GURL& request_url,
180 content::ResourceType resource_type,
181 bool overridable,
182 bool strict_enforcement,
183 bool expired_previous_decision,
184 const base::Callback<void(bool)>& callback,
185 content::CertificateRequestResultType* request) override;
186 void SelectClientCertificate(
187 content::WebContents* web_contents,
188 net::SSLCertRequestInfo* cert_request_info,
189 scoped_ptr<content::ClientCertificateDelegate> delegate) override;
190 void AddCertificate(net::CertificateMimeType cert_type,
191 const void* cert_data,
192 size_t cert_size,
193 int render_process_id,
194 int render_frame_id) override;
195 content::MediaObserver* GetMediaObserver() override;
196 content::PlatformNotificationService* GetPlatformNotificationService()
197 override;
198 bool CanCreateWindow(const GURL& opener_url,
199 const GURL& opener_top_level_frame_url,
200 const GURL& source_origin,
201 WindowContainerType container_type,
202 const GURL& target_url,
203 const content::Referrer& referrer,
204 WindowOpenDisposition disposition,
205 const blink::WebWindowFeatures& features,
206 bool user_gesture,
207 bool opener_suppressed,
208 content::ResourceContext* context,
209 int render_process_id,
210 int opener_render_view_id,
211 int opener_render_frame_id,
212 bool* no_javascript_access) override;
213 void ResourceDispatcherHostCreated() override;
214 content::SpeechRecognitionManagerDelegate*
215 CreateSpeechRecognitionManagerDelegate() override;
216 net::NetLog* GetNetLog() override;
217 content::AccessTokenStore* CreateAccessTokenStore() override;
218 bool IsFastShutdownPossible() override;
219 void OverrideWebkitPrefs(content::RenderViewHost* rvh,
220 content::WebPreferences* prefs) override;
221 void BrowserURLHandlerCreated(content::BrowserURLHandler* handler) override;
222 void ClearCache(content::RenderFrameHost* rfh) override;
223 void ClearCookies(content::RenderFrameHost* rfh) override;
224 base::FilePath GetDefaultDownloadDirectory() override;
225 std::string GetDefaultDownloadName() override;
226 void DidCreatePpapiPlugin(content::BrowserPpapiHost* browser_host) override;
227 content::BrowserPpapiHost* GetExternalBrowserPpapiHost(
228 int plugin_process_id) override;
229 bool AllowPepperSocketAPI(
230 content::BrowserContext* browser_context,
231 const GURL& url,
232 bool private_api,
233 const content::SocketPermissionRequest* params) override;
234 ui::SelectFilePolicy* CreateSelectFilePolicy(
235 content::WebContents* web_contents) override;
236 void GetAdditionalAllowedSchemesForFileSystem(
237 std::vector<std::string>* additional_schemes) override;
238 void GetURLRequestAutoMountHandlers(
239 std::vector<storage::URLRequestAutoMountHandler>* handlers) override;
240 void GetAdditionalFileSystemBackends(
241 content::BrowserContext* browser_context,
242 const base::FilePath& storage_partition_path,
243 ScopedVector<storage::FileSystemBackend>* additional_backends) override;
244 content::DevToolsManagerDelegate* GetDevToolsManagerDelegate() override;
245 content::TracingDelegate* GetTracingDelegate() override;
246 bool IsPluginAllowedToCallRequestOSFileHandle(
247 content::BrowserContext* browser_context,
248 const GURL& url) override;
249 bool IsPluginAllowedToUseDevChannelAPIs(
250 content::BrowserContext* browser_context,
251 const GURL& url) override;
252 void OverridePageVisibilityState(
253 content::RenderFrameHost* render_frame_host,
254 blink::WebPageVisibilityState* visibility_state) override;
256 #if defined(OS_ANDROID)
257 void GetAdditionalMappedFilesForChildProcess(
258 const base::CommandLine& command_line,
259 int child_process_id,
260 content::FileDescriptorInfo* mappings,
261 std::map<int, base::MemoryMappedFile::Region>* regions) override;
262 #elif defined(OS_POSIX) && !defined(OS_MACOSX)
263 void GetAdditionalMappedFilesForChildProcess(
264 const base::CommandLine& command_line,
265 int child_process_id,
266 content::FileDescriptorInfo* mappings) override;
267 #endif // defined(OS_ANDROID)
268 #if defined(OS_WIN)
269 const wchar_t* GetResourceDllName() override;
270 void PreSpawnRenderer(sandbox::TargetPolicy* policy, bool* success) override;
271 base::string16 GetAppContainerSidForSandboxType(
272 int sandbox_type) const override;
273 #endif
274 void RegisterFrameMojoShellServices(
275 content::ServiceRegistry* registry,
276 content::RenderFrameHost* render_frame_host) override;
277 void RegisterInProcessMojoApplications(
278 StaticMojoApplicationMap* apps) override;
279 void OpenURL(content::BrowserContext* browser_context,
280 const content::OpenURLParams& params,
281 const base::Callback<void(content::WebContents*)>& callback)
282 override;
283 content::PresentationServiceDelegate* GetPresentationServiceDelegate(
284 content::WebContents* web_contents) override;
286 void RecordURLMetric(const std::string& metric, const GURL& url) 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 version_info::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 // Vector of additional ChromeContentBrowserClientParts.
331 // Parts are deleted in the reverse order they are added.
332 std::vector<ChromeContentBrowserClientParts*> extra_parts_;
334 base::WeakPtrFactory<ChromeContentBrowserClient> weak_factory_;
336 DISALLOW_COPY_AND_ASSIGN(ChromeContentBrowserClient);
339 } // namespace chrome
341 #endif // CHROME_BROWSER_CHROME_CONTENT_BROWSER_CLIENT_H_