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