Upstream version 5.34.104.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 "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 RenderProcessWillLaunch(
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 void WorkerProcessCreated(content::SiteInstance* site_instance,
102                                     int worker_process_id) OVERRIDE;
103   virtual void WorkerProcessTerminated(content::SiteInstance* site_instance,
104                                        int worker_process_id) OVERRIDE;
105   virtual bool ShouldSwapBrowsingInstancesForNavigation(
106       content::SiteInstance* site_instance,
107       const GURL& current_url,
108       const GURL& new_url) OVERRIDE;
109   virtual bool ShouldSwapProcessesForRedirect(
110       content::ResourceContext* resource_context,
111       const GURL& current_url,
112       const GURL& new_url) OVERRIDE;
113   virtual bool ShouldAssignSiteForURL(const GURL& url) OVERRIDE;
114   virtual std::string GetCanonicalEncodingNameByAliasName(
115       const std::string& alias_name) OVERRIDE;
116   virtual void AppendExtraCommandLineSwitches(CommandLine* command_line,
117                                               int child_process_id) OVERRIDE;
118   virtual std::string GetApplicationLocale() OVERRIDE;
119   virtual std::string GetAcceptLangs(
120       content::BrowserContext* context) OVERRIDE;
121   virtual gfx::ImageSkia* GetDefaultFavicon() OVERRIDE;
122   virtual bool AllowAppCache(const GURL& manifest_url,
123                              const GURL& first_party,
124                              content::ResourceContext* context) OVERRIDE;
125   virtual bool AllowGetCookie(const GURL& url,
126                               const GURL& first_party,
127                               const net::CookieList& cookie_list,
128                               content::ResourceContext* context,
129                               int render_process_id,
130                               int render_frame_id) OVERRIDE;
131   virtual bool AllowSetCookie(const GURL& url,
132                               const GURL& first_party,
133                               const std::string& cookie_line,
134                               content::ResourceContext* context,
135                               int render_process_id,
136                               int render_frame_id,
137                               net::CookieOptions* options) OVERRIDE;
138   virtual bool AllowSaveLocalState(content::ResourceContext* context) OVERRIDE;
139   virtual bool AllowWorkerDatabase(
140       const GURL& url,
141       const base::string16& name,
142       const base::string16& display_name,
143       unsigned long estimated_size,
144       content::ResourceContext* context,
145       const std::vector<std::pair<int, int> >& render_frames) OVERRIDE;
146   virtual bool AllowWorkerFileSystem(
147       const GURL& url,
148       content::ResourceContext* context,
149       const std::vector<std::pair<int, int> >& render_frames) OVERRIDE;
150   virtual bool AllowWorkerIndexedDB(
151       const GURL& url,
152       const base::string16& name,
153       content::ResourceContext* context,
154       const std::vector<std::pair<int, int> >& render_frames) OVERRIDE;
155   virtual net::URLRequestContext* OverrideRequestContextForURL(
156       const GURL& url, content::ResourceContext* context) OVERRIDE;
157   virtual content::QuotaPermissionContext*
158       CreateQuotaPermissionContext() OVERRIDE;
159   virtual void AllowCertificateError(
160       int render_process_id,
161       int render_frame_id,
162       int cert_error,
163       const net::SSLInfo& ssl_info,
164       const GURL& request_url,
165       ResourceType::Type resource_type,
166       bool overridable,
167       bool strict_enforcement,
168       const base::Callback<void(bool)>& callback,
169       content::CertificateRequestResultType* request) OVERRIDE;
170   virtual void SelectClientCertificate(
171       int render_process_id,
172       int render_frame_id,
173       const net::HttpNetworkSession* network_session,
174       net::SSLCertRequestInfo* cert_request_info,
175       const base::Callback<void(net::X509Certificate*)>& callback) OVERRIDE;
176   virtual void AddCertificate(
177       net::URLRequest* request,
178       net::CertificateMimeType cert_type,
179       const void* cert_data,
180       size_t cert_size,
181       int render_process_id,
182       int render_view_id) OVERRIDE;
183   virtual content::MediaObserver* GetMediaObserver() OVERRIDE;
184   virtual void RequestDesktopNotificationPermission(
185       const GURL& source_origin,
186       int callback_context,
187       int render_process_id,
188       int render_view_id) OVERRIDE;
189   virtual blink::WebNotificationPresenter::Permission
190       CheckDesktopNotificationPermission(
191           const GURL& source_origin,
192           content::ResourceContext* context,
193           int render_process_id) OVERRIDE;
194   virtual void ShowDesktopNotification(
195       const content::ShowDesktopNotificationHostMsgParams& params,
196       int render_process_id,
197       int render_view_id,
198       bool worker) OVERRIDE;
199   virtual void CancelDesktopNotification(
200       int render_process_id,
201       int render_view_id,
202       int notification_id) OVERRIDE;
203   virtual bool CanCreateWindow(const GURL& opener_url,
204                                const GURL& opener_top_level_frame_url,
205                                const GURL& source_origin,
206                                WindowContainerType container_type,
207                                const GURL& target_url,
208                                const content::Referrer& referrer,
209                                WindowOpenDisposition disposition,
210                                const blink::WebWindowFeatures& features,
211                                bool user_gesture,
212                                bool opener_suppressed,
213                                content::ResourceContext* context,
214                                int render_process_id,
215                                bool is_guest,
216                                int opener_id,
217                                bool* no_javascript_access) OVERRIDE;
218   virtual std::string GetWorkerProcessTitle(
219       const GURL& url, content::ResourceContext* context) OVERRIDE;
220   virtual void ResourceDispatcherHostCreated() OVERRIDE;
221   virtual content::SpeechRecognitionManagerDelegate*
222       GetSpeechRecognitionManagerDelegate() OVERRIDE;
223   virtual net::NetLog* GetNetLog() OVERRIDE;
224   virtual content::AccessTokenStore* CreateAccessTokenStore() OVERRIDE;
225   virtual bool IsFastShutdownPossible() OVERRIDE;
226   virtual void OverrideWebkitPrefs(content::RenderViewHost* rvh,
227                                    const GURL& url,
228                                    WebPreferences* prefs) OVERRIDE;
229   virtual void UpdateInspectorSetting(content::RenderViewHost* rvh,
230                                       const std::string& key,
231                                       const std::string& value) OVERRIDE;
232   virtual void BrowserURLHandlerCreated(
233       content::BrowserURLHandler* handler) OVERRIDE;
234   virtual void ClearCache(content::RenderViewHost* rvh) OVERRIDE;
235   virtual void ClearCookies(content::RenderViewHost* rvh) OVERRIDE;
236   virtual base::FilePath GetDefaultDownloadDirectory() OVERRIDE;
237   virtual std::string GetDefaultDownloadName() OVERRIDE;
238   virtual void DidCreatePpapiPlugin(
239       content::BrowserPpapiHost* browser_host) OVERRIDE;
240   virtual content::BrowserPpapiHost* GetExternalBrowserPpapiHost(
241       int plugin_process_id) OVERRIDE;
242   virtual bool SupportsBrowserPlugin(content::BrowserContext* browser_context,
243                                      const GURL& site_url) OVERRIDE;
244   virtual bool AllowPepperSocketAPI(
245       content::BrowserContext* browser_context,
246       const GURL& url,
247       bool private_api,
248       const content::SocketPermissionRequest* params) OVERRIDE;
249   virtual ui::SelectFilePolicy* CreateSelectFilePolicy(
250       content::WebContents* web_contents) OVERRIDE;
251   virtual void GetAdditionalAllowedSchemesForFileSystem(
252       std::vector<std::string>* additional_schemes) OVERRIDE;
253   virtual void GetAdditionalFileSystemBackends(
254       content::BrowserContext* browser_context,
255       const base::FilePath& storage_partition_path,
256       ScopedVector<fileapi::FileSystemBackend>* additional_backends) OVERRIDE;
257
258 #if defined(OS_POSIX) && !defined(OS_MACOSX)
259   virtual void GetAdditionalMappedFilesForChildProcess(
260       const CommandLine& command_line,
261       int child_process_id,
262       std::vector<content::FileDescriptorInfo>* mappings) OVERRIDE;
263 #endif
264 #if defined(OS_WIN)
265   virtual const wchar_t* GetResourceDllName() OVERRIDE;
266   virtual void PreSpawnRenderer(sandbox::TargetPolicy* policy,
267                                 bool* success) OVERRIDE;
268 #endif
269
270   virtual bool IsPluginAllowedToCallRequestOSFileHandle(
271       content::BrowserContext* browser_context,
272       const GURL& url) OVERRIDE;
273
274   virtual bool IsPluginAllowedToUseDevChannelAPIs() OVERRIDE;
275
276  private:
277 #if defined(ENABLE_PLUGINS)
278   // Set of origins that can use TCP/UDP private APIs from NaCl.
279   std::set<std::string> allowed_socket_origins_;
280   // Set of origins that can get a handle for FileIO from NaCl.
281   std::set<std::string> allowed_file_handle_origins_;
282 #endif
283   scoped_ptr<extensions::BrowserPermissionsPolicyDelegate>
284       permissions_policy_delegate_;
285
286   DISALLOW_COPY_AND_ASSIGN(ChromeContentBrowserClient);
287 };
288
289 }  // namespace chrome
290
291 #endif  // CHROME_BROWSER_CHROME_CONTENT_BROWSER_CLIENT_H_