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