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