Upstream version 7.36.149.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / chrome_content_browser_client.h
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.
4
5 #ifndef CHROME_BROWSER_CHROME_CONTENT_BROWSER_CLIENT_H_
6 #define CHROME_BROWSER_CHROME_CONTENT_BROWSER_CLIENT_H_
7
8 #include <set>
9 #include <string>
10 #include <utility>
11 #include <vector>
12
13 #include "base/compiler_specific.h"
14 #include "base/gtest_prod_util.h"
15 #include "chrome/common/chrome_version_info.h"
16 #include "content/public/browser/content_browser_client.h"
17
18 #if defined(OS_ANDROID)
19 #include "base/memory/scoped_ptr.h"
20 #endif
21
22 namespace base {
23 class CommandLine;
24 }
25
26 namespace content {
27 class QuotaPermissionContext;
28 }
29
30 namespace extensions {
31 class BrowserPermissionsPolicyDelegate;
32 }
33
34 namespace user_prefs {
35 class PrefRegistrySyncable;
36 }
37
38 namespace chrome {
39
40 class ChromeContentBrowserClient : public content::ContentBrowserClient {
41  public:
42   ChromeContentBrowserClient();
43   virtual ~ChromeContentBrowserClient();
44
45   static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry);
46
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);
50
51   virtual content::BrowserMainParts* CreateBrowserMainParts(
52       const content::MainFunctionParams& parameters) OVERRIDE;
53   virtual std::string GetStoragePartitionIdForSite(
54       content::BrowserContext* browser_context,
55       const GURL& site) OVERRIDE;
56   virtual bool IsValidStoragePartitionId(
57       content::BrowserContext* browser_context,
58       const std::string& partition_id) OVERRIDE;
59   virtual void GetStoragePartitionConfigForSite(
60       content::BrowserContext* browser_context,
61       const GURL& site,
62       bool can_be_default,
63       std::string* partition_domain,
64       std::string* partition_name,
65       bool* in_memory) OVERRIDE;
66   virtual content::WebContentsViewDelegate* GetWebContentsViewDelegate(
67       content::WebContents* web_contents) OVERRIDE;
68   virtual void GuestWebContentsCreated(
69       content::SiteInstance* guest_site_instance,
70       content::WebContents* guest_web_contents,
71       content::WebContents* opener_web_contents,
72       content::BrowserPluginGuestDelegate** guest_delegate,
73       scoped_ptr<base::DictionaryValue> extra_params) OVERRIDE;
74   virtual void GuestWebContentsAttached(
75       content::WebContents* guest_web_contents,
76       content::WebContents* embedder_web_contents,
77       const base::DictionaryValue& extra_params) OVERRIDE;
78   virtual void RenderProcessWillLaunch(
79       content::RenderProcessHost* host) OVERRIDE;
80   virtual bool ShouldUseProcessPerSite(content::BrowserContext* browser_context,
81                                        const GURL& effective_url) OVERRIDE;
82   virtual GURL GetEffectiveURL(content::BrowserContext* browser_context,
83                                const GURL& url) OVERRIDE;
84   virtual void GetAdditionalWebUISchemes(
85       std::vector<std::string>* additional_schemes) OVERRIDE;
86   virtual void GetAdditionalWebUIHostsToIgnoreParititionCheck(
87       std::vector<std::string>* hosts) OVERRIDE;
88   virtual net::URLRequestContextGetter* CreateRequestContext(
89       content::BrowserContext* browser_context,
90       content::ProtocolHandlerMap* protocol_handlers,
91       content::ProtocolHandlerScopedVector protocol_interceptors) OVERRIDE;
92   virtual net::URLRequestContextGetter* CreateRequestContextForStoragePartition(
93       content::BrowserContext* browser_context,
94       const base::FilePath& partition_path,
95       bool in_memory,
96       content::ProtocolHandlerMap* protocol_handlers,
97       content::ProtocolHandlerScopedVector protocol_interceptors) OVERRIDE;
98   virtual bool IsHandledURL(const GURL& url) OVERRIDE;
99   virtual bool CanCommitURL(content::RenderProcessHost* process_host,
100                             const GURL& url) OVERRIDE;
101   virtual bool ShouldAllowOpenURL(content::SiteInstance* site_instance,
102                                   const GURL& url) OVERRIDE;
103   virtual bool IsSuitableHost(content::RenderProcessHost* process_host,
104                               const GURL& site_url) OVERRIDE;
105   virtual bool ShouldTryToUseExistingProcessHost(
106       content::BrowserContext* browser_context, const GURL& url) OVERRIDE;
107   virtual void SiteInstanceGotProcess(
108       content::SiteInstance* site_instance) OVERRIDE;
109   virtual void SiteInstanceDeleting(content::SiteInstance* site_instance)
110       OVERRIDE;
111   virtual void WorkerProcessCreated(content::SiteInstance* site_instance,
112                                     int worker_process_id) OVERRIDE;
113   virtual void WorkerProcessTerminated(content::SiteInstance* site_instance,
114                                        int worker_process_id) OVERRIDE;
115   virtual bool ShouldSwapBrowsingInstancesForNavigation(
116       content::SiteInstance* site_instance,
117       const GURL& current_url,
118       const GURL& new_url) OVERRIDE;
119   virtual bool ShouldSwapProcessesForRedirect(
120       content::ResourceContext* resource_context,
121       const GURL& current_url,
122       const GURL& new_url) OVERRIDE;
123   virtual bool ShouldAssignSiteForURL(const GURL& url) OVERRIDE;
124   virtual std::string GetCanonicalEncodingNameByAliasName(
125       const std::string& alias_name) OVERRIDE;
126   virtual void AppendExtraCommandLineSwitches(base::CommandLine* command_line,
127                                               int child_process_id) OVERRIDE;
128   virtual std::string GetApplicationLocale() OVERRIDE;
129   virtual std::string GetAcceptLangs(
130       content::BrowserContext* context) OVERRIDE;
131   virtual gfx::ImageSkia* GetDefaultFavicon() OVERRIDE;
132   virtual bool AllowAppCache(const GURL& manifest_url,
133                              const GURL& first_party,
134                              content::ResourceContext* context) OVERRIDE;
135   virtual bool AllowGetCookie(const GURL& url,
136                               const GURL& first_party,
137                               const net::CookieList& cookie_list,
138                               content::ResourceContext* context,
139                               int render_process_id,
140                               int render_frame_id) OVERRIDE;
141   virtual bool AllowSetCookie(const GURL& url,
142                               const GURL& first_party,
143                               const std::string& cookie_line,
144                               content::ResourceContext* context,
145                               int render_process_id,
146                               int render_frame_id,
147                               net::CookieOptions* options) OVERRIDE;
148   virtual bool AllowSaveLocalState(content::ResourceContext* context) OVERRIDE;
149   virtual bool AllowWorkerDatabase(
150       const GURL& url,
151       const base::string16& name,
152       const base::string16& display_name,
153       unsigned long estimated_size,
154       content::ResourceContext* context,
155       const std::vector<std::pair<int, int> >& render_frames) OVERRIDE;
156   virtual bool AllowWorkerFileSystem(
157       const GURL& url,
158       content::ResourceContext* context,
159       const std::vector<std::pair<int, int> >& render_frames) OVERRIDE;
160   virtual 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;
165   virtual net::URLRequestContext* OverrideRequestContextForURL(
166       const GURL& url, content::ResourceContext* context) OVERRIDE;
167   virtual content::QuotaPermissionContext*
168       CreateQuotaPermissionContext() OVERRIDE;
169   virtual void AllowCertificateError(
170       int render_process_id,
171       int render_frame_id,
172       int cert_error,
173       const net::SSLInfo& ssl_info,
174       const GURL& request_url,
175       ResourceType::Type resource_type,
176       bool overridable,
177       bool strict_enforcement,
178       const base::Callback<void(bool)>& callback,
179       content::CertificateRequestResultType* request) OVERRIDE;
180   virtual void SelectClientCertificate(
181       int render_process_id,
182       int render_frame_id,
183       const net::HttpNetworkSession* network_session,
184       net::SSLCertRequestInfo* cert_request_info,
185       const base::Callback<void(net::X509Certificate*)>& callback) OVERRIDE;
186   virtual void AddCertificate(
187       net::URLRequest* request,
188       net::CertificateMimeType cert_type,
189       const void* cert_data,
190       size_t cert_size,
191       int render_process_id,
192       int render_view_id) OVERRIDE;
193   virtual content::MediaObserver* GetMediaObserver() OVERRIDE;
194   virtual void RequestDesktopNotificationPermission(
195       const GURL& source_origin,
196       content::RenderFrameHost* render_frame_host,
197       base::Closure& callback) OVERRIDE;
198   virtual blink::WebNotificationPresenter::Permission
199       CheckDesktopNotificationPermission(
200           const GURL& source_origin,
201           content::ResourceContext* context,
202           int render_process_id) OVERRIDE;
203   virtual void ShowDesktopNotification(
204       const content::ShowDesktopNotificationHostMsgParams& params,
205       content::RenderFrameHost* render_frame_host,
206       content::DesktopNotificationDelegate* delegate,
207       base::Closure* cancel_callback) OVERRIDE;
208   virtual bool CanCreateWindow(const GURL& opener_url,
209                                const GURL& opener_top_level_frame_url,
210                                const GURL& source_origin,
211                                WindowContainerType container_type,
212                                const GURL& target_url,
213                                const content::Referrer& referrer,
214                                WindowOpenDisposition disposition,
215                                const blink::WebWindowFeatures& features,
216                                bool user_gesture,
217                                bool opener_suppressed,
218                                content::ResourceContext* context,
219                                int render_process_id,
220                                bool is_guest,
221                                int opener_id,
222                                bool* no_javascript_access) OVERRIDE;
223   virtual std::string GetWorkerProcessTitle(
224       const GURL& url, content::ResourceContext* context) OVERRIDE;
225   virtual void ResourceDispatcherHostCreated() OVERRIDE;
226   virtual content::SpeechRecognitionManagerDelegate*
227       GetSpeechRecognitionManagerDelegate() OVERRIDE;
228   virtual net::NetLog* GetNetLog() OVERRIDE;
229   virtual content::AccessTokenStore* CreateAccessTokenStore() OVERRIDE;
230   virtual bool IsFastShutdownPossible() OVERRIDE;
231   virtual void OverrideWebkitPrefs(content::RenderViewHost* rvh,
232                                    const GURL& url,
233                                    WebPreferences* prefs) OVERRIDE;
234   virtual void UpdateInspectorSetting(content::RenderViewHost* rvh,
235                                       const std::string& key,
236                                       const std::string& value) OVERRIDE;
237   virtual void BrowserURLHandlerCreated(
238       content::BrowserURLHandler* handler) OVERRIDE;
239   virtual void ClearCache(content::RenderViewHost* rvh) OVERRIDE;
240   virtual void ClearCookies(content::RenderViewHost* rvh) OVERRIDE;
241   virtual base::FilePath GetDefaultDownloadDirectory() OVERRIDE;
242   virtual std::string GetDefaultDownloadName() OVERRIDE;
243   virtual void DidCreatePpapiPlugin(
244       content::BrowserPpapiHost* browser_host) OVERRIDE;
245   virtual content::BrowserPpapiHost* GetExternalBrowserPpapiHost(
246       int plugin_process_id) OVERRIDE;
247   virtual bool AllowPepperSocketAPI(
248       content::BrowserContext* browser_context,
249       const GURL& url,
250       bool private_api,
251       const content::SocketPermissionRequest* params) OVERRIDE;
252   virtual ui::SelectFilePolicy* CreateSelectFilePolicy(
253       content::WebContents* web_contents) OVERRIDE;
254   virtual void GetAdditionalAllowedSchemesForFileSystem(
255       std::vector<std::string>* additional_schemes) OVERRIDE;
256   virtual void GetURLRequestAutoMountHandlers(
257       std::vector<fileapi::URLRequestAutoMountHandler>* handlers) OVERRIDE;
258   virtual void GetAdditionalFileSystemBackends(
259       content::BrowserContext* browser_context,
260       const base::FilePath& storage_partition_path,
261       ScopedVector<fileapi::FileSystemBackend>* additional_backends) OVERRIDE;
262
263 #if defined(OS_POSIX) && !defined(OS_MACOSX)
264   virtual void GetAdditionalMappedFilesForChildProcess(
265       const base::CommandLine& command_line,
266       int child_process_id,
267       std::vector<content::FileDescriptorInfo>* mappings) OVERRIDE;
268 #endif
269 #if defined(OS_WIN)
270   virtual const wchar_t* GetResourceDllName() OVERRIDE;
271   virtual void PreSpawnRenderer(sandbox::TargetPolicy* policy,
272                                 bool* success) OVERRIDE;
273 #endif
274
275   virtual bool IsPluginAllowedToCallRequestOSFileHandle(
276       content::BrowserContext* browser_context,
277       const GURL& url) OVERRIDE;
278
279   virtual bool IsPluginAllowedToUseDevChannelAPIs() OVERRIDE;
280
281  private:
282 #if defined(ENABLE_WEBRTC)
283   // Copies disable WebRTC encryption switch depending on the channel.
284   static void MaybeCopyDisableWebRtcEncryptionSwitch(
285       base::CommandLine* to_command_line,
286       const base::CommandLine& from_command_line,
287       VersionInfo::Channel channel);
288 #endif
289
290 #if defined(ENABLE_PLUGINS)
291   // Set of origins that can use TCP/UDP private APIs from NaCl.
292   std::set<std::string> allowed_socket_origins_;
293   // Set of origins that can get a handle for FileIO from NaCl.
294   std::set<std::string> allowed_file_handle_origins_;
295 #endif
296   scoped_ptr<extensions::BrowserPermissionsPolicyDelegate>
297       permissions_policy_delegate_;
298
299   friend class DisableWebRtcEncryptionFlagTest;
300
301   DISALLOW_COPY_AND_ASSIGN(ChromeContentBrowserClient);
302 };
303
304 }  // namespace chrome
305
306 #endif  // CHROME_BROWSER_CHROME_CONTENT_BROWSER_CLIENT_H_