Rename vector icon header files.
[chromium-blink-merge.git] / chrome / browser / chrome_content_browser_client.h
blobbb818e43d477892f7e25cc0a7681313eaa9320c3
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 bool ShouldLockToOrigin(content::BrowserContext* browser_context,
77 const GURL& effective_site_url) override;
78 GURL GetEffectiveURL(content::BrowserContext* browser_context,
79 const GURL& url) override;
80 void GetAdditionalWebUISchemes(
81 std::vector<std::string>* additional_schemes) override;
82 void GetAdditionalWebUIHostsToIgnoreParititionCheck(
83 std::vector<std::string>* hosts) override;
84 net::URLRequestContextGetter* CreateRequestContext(
85 content::BrowserContext* browser_context,
86 content::ProtocolHandlerMap* protocol_handlers,
87 content::URLRequestInterceptorScopedVector request_interceptors) override;
88 net::URLRequestContextGetter* CreateRequestContextForStoragePartition(
89 content::BrowserContext* browser_context,
90 const base::FilePath& partition_path,
91 bool in_memory,
92 content::ProtocolHandlerMap* protocol_handlers,
93 content::URLRequestInterceptorScopedVector request_interceptors) override;
94 bool IsHandledURL(const GURL& url) override;
95 bool CanCommitURL(content::RenderProcessHost* process_host,
96 const GURL& url) override;
97 bool IsIllegalOrigin(content::ResourceContext* resource_context,
98 int child_process_id,
99 const GURL& origin) override;
100 bool ShouldAllowOpenURL(content::SiteInstance* site_instance,
101 const GURL& url) override;
102 bool IsSuitableHost(content::RenderProcessHost* process_host,
103 const GURL& site_url) override;
104 bool MayReuseHost(content::RenderProcessHost* process_host) override;
105 bool ShouldTryToUseExistingProcessHost(
106 content::BrowserContext* browser_context,
107 const GURL& url) override;
108 void SiteInstanceGotProcess(content::SiteInstance* site_instance) override;
109 void SiteInstanceDeleting(content::SiteInstance* site_instance) override;
110 bool ShouldSwapBrowsingInstancesForNavigation(
111 content::SiteInstance* site_instance,
112 const GURL& current_url,
113 const GURL& new_url) override;
114 bool ShouldSwapProcessesForRedirect(
115 content::ResourceContext* resource_context,
116 const GURL& current_url,
117 const GURL& new_url) override;
118 bool ShouldAssignSiteForURL(const GURL& url) override;
119 std::string GetCanonicalEncodingNameByAliasName(
120 const std::string& alias_name) override;
121 void AppendExtraCommandLineSwitches(base::CommandLine* command_line,
122 int child_process_id) override;
123 std::string GetApplicationLocale() override;
124 std::string GetAcceptLangs(content::BrowserContext* context) override;
125 const gfx::ImageSkia* GetDefaultFavicon() override;
126 bool AllowAppCache(const GURL& manifest_url,
127 const GURL& first_party,
128 content::ResourceContext* context) override;
129 bool AllowServiceWorker(const GURL& scope,
130 const GURL& first_party,
131 content::ResourceContext* context,
132 int render_process_id,
133 int render_frame_id) override;
134 bool AllowGetCookie(const GURL& url,
135 const GURL& first_party,
136 const net::CookieList& cookie_list,
137 content::ResourceContext* context,
138 int render_process_id,
139 int render_frame_id) override;
140 bool AllowSetCookie(const GURL& url,
141 const GURL& first_party,
142 const std::string& cookie_line,
143 content::ResourceContext* context,
144 int render_process_id,
145 int render_frame_id,
146 net::CookieOptions* options) override;
147 bool AllowSaveLocalState(content::ResourceContext* context) override;
148 bool AllowWorkerDatabase(
149 const GURL& url,
150 const base::string16& name,
151 const base::string16& display_name,
152 unsigned long estimated_size,
153 content::ResourceContext* context,
154 const std::vector<std::pair<int, int>>& render_frames) override;
155 void AllowWorkerFileSystem(
156 const GURL& url,
157 content::ResourceContext* context,
158 const std::vector<std::pair<int, int>>& render_frames,
159 base::Callback<void(bool)> callback) override;
160 bool AllowWorkerIndexedDB(
161 const GURL& url,
162 const base::string16& name,
163 content::ResourceContext* context,
164 const std::vector<std::pair<int, int>>& render_frames) override;
166 #if defined(ENABLE_WEBRTC)
167 bool AllowWebRTCIdentityCache(const GURL& url,
168 const GURL& first_party_url,
169 content::ResourceContext* context) override;
170 #endif // defined(ENABLE_WEBRTC)
172 net::URLRequestContext* OverrideRequestContextForURL(
173 const GURL& url,
174 content::ResourceContext* context) override;
175 content::QuotaPermissionContext* CreateQuotaPermissionContext() override;
176 void AllowCertificateError(
177 int render_process_id,
178 int render_frame_id,
179 int cert_error,
180 const net::SSLInfo& ssl_info,
181 const GURL& request_url,
182 content::ResourceType resource_type,
183 bool overridable,
184 bool strict_enforcement,
185 bool expired_previous_decision,
186 const base::Callback<void(bool)>& callback,
187 content::CertificateRequestResultType* request) override;
188 void SelectClientCertificate(
189 content::WebContents* web_contents,
190 net::SSLCertRequestInfo* cert_request_info,
191 scoped_ptr<content::ClientCertificateDelegate> delegate) override;
192 void AddCertificate(net::CertificateMimeType cert_type,
193 const void* cert_data,
194 size_t cert_size,
195 int render_process_id,
196 int render_frame_id) override;
197 content::MediaObserver* GetMediaObserver() override;
198 content::PlatformNotificationService* GetPlatformNotificationService()
199 override;
200 bool CanCreateWindow(const GURL& opener_url,
201 const GURL& opener_top_level_frame_url,
202 const GURL& source_origin,
203 WindowContainerType container_type,
204 const GURL& target_url,
205 const content::Referrer& referrer,
206 WindowOpenDisposition disposition,
207 const blink::WebWindowFeatures& features,
208 bool user_gesture,
209 bool opener_suppressed,
210 content::ResourceContext* context,
211 int render_process_id,
212 int opener_render_view_id,
213 int opener_render_frame_id,
214 bool* no_javascript_access) override;
215 void ResourceDispatcherHostCreated() override;
216 content::SpeechRecognitionManagerDelegate*
217 CreateSpeechRecognitionManagerDelegate() override;
218 net::NetLog* GetNetLog() override;
219 content::AccessTokenStore* CreateAccessTokenStore() override;
220 bool IsFastShutdownPossible() override;
221 void OverrideWebkitPrefs(content::RenderViewHost* rvh,
222 content::WebPreferences* prefs) override;
223 void BrowserURLHandlerCreated(content::BrowserURLHandler* handler) override;
224 void ClearCache(content::RenderFrameHost* rfh) override;
225 void ClearCookies(content::RenderFrameHost* rfh) override;
226 base::FilePath GetDefaultDownloadDirectory() override;
227 std::string GetDefaultDownloadName() override;
228 base::FilePath GetShaderDiskCacheDirectory() override;
229 void DidCreatePpapiPlugin(content::BrowserPpapiHost* browser_host) override;
230 content::BrowserPpapiHost* GetExternalBrowserPpapiHost(
231 int plugin_process_id) override;
232 bool AllowPepperSocketAPI(
233 content::BrowserContext* browser_context,
234 const GURL& url,
235 bool private_api,
236 const content::SocketPermissionRequest* params) override;
237 ui::SelectFilePolicy* CreateSelectFilePolicy(
238 content::WebContents* web_contents) override;
239 void GetAdditionalAllowedSchemesForFileSystem(
240 std::vector<std::string>* additional_schemes) override;
241 void GetURLRequestAutoMountHandlers(
242 std::vector<storage::URLRequestAutoMountHandler>* handlers) override;
243 void GetAdditionalFileSystemBackends(
244 content::BrowserContext* browser_context,
245 const base::FilePath& storage_partition_path,
246 ScopedVector<storage::FileSystemBackend>* additional_backends) override;
247 content::DevToolsManagerDelegate* GetDevToolsManagerDelegate() override;
248 content::TracingDelegate* GetTracingDelegate() override;
249 bool IsPluginAllowedToCallRequestOSFileHandle(
250 content::BrowserContext* browser_context,
251 const GURL& url) override;
252 bool IsPluginAllowedToUseDevChannelAPIs(
253 content::BrowserContext* browser_context,
254 const GURL& url) override;
255 void OverridePageVisibilityState(
256 content::RenderFrameHost* render_frame_host,
257 blink::WebPageVisibilityState* visibility_state) override;
259 #if defined(OS_ANDROID)
260 void GetAdditionalMappedFilesForChildProcess(
261 const base::CommandLine& command_line,
262 int child_process_id,
263 content::FileDescriptorInfo* mappings,
264 std::map<int, base::MemoryMappedFile::Region>* regions) override;
265 #elif defined(OS_POSIX) && !defined(OS_MACOSX)
266 void GetAdditionalMappedFilesForChildProcess(
267 const base::CommandLine& command_line,
268 int child_process_id,
269 content::FileDescriptorInfo* mappings) override;
270 #endif // defined(OS_ANDROID)
271 #if defined(OS_WIN)
272 const wchar_t* GetResourceDllName() override;
273 void PreSpawnRenderer(sandbox::TargetPolicy* policy, bool* success) override;
274 base::string16 GetAppContainerSidForSandboxType(
275 int sandbox_type) const override;
276 #endif
277 void RegisterFrameMojoShellServices(
278 content::ServiceRegistry* registry,
279 content::RenderFrameHost* render_frame_host) override;
280 void RegisterInProcessMojoApplications(
281 StaticMojoApplicationMap* apps) override;
282 void OpenURL(content::BrowserContext* browser_context,
283 const content::OpenURLParams& params,
284 const base::Callback<void(content::WebContents*)>& callback)
285 override;
286 content::PresentationServiceDelegate* GetPresentationServiceDelegate(
287 content::WebContents* web_contents) override;
289 void RecordURLMetric(const std::string& metric, const GURL& url) override;
291 private:
292 friend class DisableWebRtcEncryptionFlagTest;
294 #if defined(ENABLE_WEBRTC)
295 // Copies disable WebRTC encryption switch depending on the channel.
296 static void MaybeCopyDisableWebRtcEncryptionSwitch(
297 base::CommandLine* to_command_line,
298 const base::CommandLine& from_command_line,
299 version_info::Channel channel);
300 #endif
302 void FileSystemAccessed(
303 const GURL& url,
304 const std::vector<std::pair<int, int> >& render_frames,
305 base::Callback<void(bool)> callback,
306 bool allow);
308 #if defined(ENABLE_EXTENSIONS)
309 void GuestPermissionRequestHelper(
310 const GURL& url,
311 const std::vector<std::pair<int, int> >& render_frames,
312 base::Callback<void(bool)> callback,
313 bool allow);
315 static void RequestFileSystemPermissionOnUIThread(
316 int render_process_id,
317 int render_frame_id,
318 const GURL& url,
319 bool allowed_by_default,
320 const base::Callback<void(bool)>& callback);
321 #endif
323 #if defined(ENABLE_PLUGINS)
324 // Set of origins that can use TCP/UDP private APIs from NaCl.
325 std::set<std::string> allowed_socket_origins_;
326 // Set of origins that can get a handle for FileIO from NaCl.
327 std::set<std::string> allowed_file_handle_origins_;
328 // Set of origins that can use "dev chanel" APIs from NaCl, even on stable
329 // versions of Chrome.
330 std::set<std::string> allowed_dev_channel_origins_;
331 #endif
333 // Vector of additional ChromeContentBrowserClientParts.
334 // Parts are deleted in the reverse order they are added.
335 std::vector<ChromeContentBrowserClientParts*> extra_parts_;
337 base::WeakPtrFactory<ChromeContentBrowserClient> weak_factory_;
339 DISALLOW_COPY_AND_ASSIGN(ChromeContentBrowserClient);
342 } // namespace chrome
344 #endif // CHROME_BROWSER_CHROME_CONTENT_BROWSER_CLIENT_H_