6018266084183d35c31c6246b33caa37730f992c
[platform/framework/web/crosswalk.git] / src / xwalk / runtime / browser / xwalk_content_browser_client.h
1 // Copyright (c) 2013 Intel Corporation. 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 XWALK_RUNTIME_BROWSER_XWALK_CONTENT_BROWSER_CLIENT_H_
6 #define XWALK_RUNTIME_BROWSER_XWALK_CONTENT_BROWSER_CLIENT_H_
7
8 #include <string>
9 #include <vector>
10
11 #include "base/compiler_specific.h"
12 #include "content/public/browser/content_browser_client.h"
13 #include "content/public/common/main_function_params.h"
14 #include "xwalk/runtime/browser/runtime_geolocation_permission_context.h"
15 #include "xwalk/runtime/browser/runtime_resource_dispatcher_host_delegate.h"
16
17 namespace content {
18 class BrowserContext;
19 class ResourceContext;
20 class QuotaPermissionContext;
21 class SpeechRecognitionManagerDelegate;
22 class WebContents;
23 class WebContentsViewDelegate;
24 }
25
26 namespace net {
27 class URLRequestContextGetter;
28 }
29
30 namespace xwalk {
31
32 class RuntimeContext;
33 class XWalkBrowserMainParts;
34 class XWalkRunner;
35
36 class XWalkContentBrowserClient : public content::ContentBrowserClient {
37  public:
38   static XWalkContentBrowserClient* Get();
39
40   explicit XWalkContentBrowserClient(XWalkRunner* xwalk_runner);
41   virtual ~XWalkContentBrowserClient();
42
43   // ContentBrowserClient overrides.
44   virtual content::BrowserMainParts* CreateBrowserMainParts(
45       const content::MainFunctionParams& parameters) OVERRIDE;
46   virtual net::URLRequestContextGetter* CreateRequestContext(
47       content::BrowserContext* browser_context,
48       content::ProtocolHandlerMap* protocol_handlers,
49       content::URLRequestInterceptorScopedVector request_interceptors) OVERRIDE;
50   virtual net::URLRequestContextGetter* CreateRequestContextForStoragePartition(
51       content::BrowserContext* browser_context,
52       const base::FilePath& partition_path,
53       bool in_memory,
54       content::ProtocolHandlerMap* protocol_handlers,
55       content::URLRequestInterceptorScopedVector request_interceptors) OVERRIDE;
56   virtual void AppendExtraCommandLineSwitches(CommandLine* command_line,
57                                               int child_process_id) OVERRIDE;
58   virtual content::QuotaPermissionContext*
59       CreateQuotaPermissionContext() OVERRIDE;
60   virtual content::AccessTokenStore* CreateAccessTokenStore() OVERRIDE;
61   virtual content::WebContentsViewDelegate* GetWebContentsViewDelegate(
62       content::WebContents* web_contents) OVERRIDE;
63   virtual void RenderProcessWillLaunch(
64       content::RenderProcessHost* host) OVERRIDE;
65   virtual content::MediaObserver* GetMediaObserver() OVERRIDE;
66
67   virtual bool AllowGetCookie(const GURL& url,
68                               const GURL& first_party,
69                               const net::CookieList& cookie_list,
70                               content::ResourceContext* context,
71                               int render_process_id,
72                               int render_frame_id) OVERRIDE;
73   virtual bool AllowSetCookie(const GURL& url,
74                               const GURL& first_party,
75                               const std::string& cookie_line,
76                               content::ResourceContext* context,
77                               int render_process_id,
78                               int render_frame_id,
79                               net::CookieOptions* options) OVERRIDE;
80
81   virtual void AllowCertificateError(
82       int render_process_id,
83       int render_frame_id,
84       int cert_error,
85       const net::SSLInfo& ssl_info,
86       const GURL& request_url,
87       content::ResourceType resource_type,
88       bool overridable,
89       bool strict_enforcement,
90       bool expired_previous_decision,
91       const base::Callback<void(bool)>& callback, // NOLINT
92       content::CertificateRequestResultType* result) OVERRIDE;
93
94   virtual content::SpeechRecognitionManagerDelegate*
95       GetSpeechRecognitionManagerDelegate() OVERRIDE;
96
97   virtual void RequestDesktopNotificationPermission(
98       const GURL& source_origin,
99       content::RenderFrameHost* render_frame_host,
100       const base::Callback<void(blink::WebNotificationPermission)>& callback) OVERRIDE; // NOLINT
101   virtual blink::WebNotificationPermission
102   CheckDesktopNotificationPermission(
103       const GURL& source_url,
104       content::ResourceContext* context,
105       int render_process_id) OVERRIDE;
106   virtual void ShowDesktopNotification(
107       const content::ShowDesktopNotificationHostMsgParams& params,
108       content::RenderFrameHost* render_frame_host,
109       scoped_ptr<content::DesktopNotificationDelegate> delegate,
110       base::Closure* cancel_callback) OVERRIDE;
111   virtual void RequestGeolocationPermission(
112       content::WebContents* web_contents,
113       int bridge_id,
114       const GURL& requesting_frame,
115       bool user_gesture,
116       base::Callback<void(bool)> result_callback,
117       base::Closure* cancel_callback) OVERRIDE;
118 #if !defined(OS_ANDROID)
119   virtual bool CanCreateWindow(const GURL& opener_url,
120                                const GURL& opener_top_level_frame_url,
121                                const GURL& source_origin,
122                                WindowContainerType container_type,
123                                const GURL& target_url,
124                                const content::Referrer& referrer,
125                                WindowOpenDisposition disposition,
126                                const blink::WebWindowFeatures& features,
127                                bool user_gesture,
128                                bool opener_suppressed,
129                                content::ResourceContext* context,
130                                int render_process_id,
131                                int opener_id,
132                                bool* no_javascript_access) OVERRIDE;
133 #endif
134
135   virtual void DidCreatePpapiPlugin(
136       content::BrowserPpapiHost* browser_host) OVERRIDE;
137   virtual content::BrowserPpapiHost* GetExternalBrowserPpapiHost(
138       int plugin_process_id) OVERRIDE;
139
140 #if defined(OS_ANDROID) || defined(OS_TIZEN)  || defined(OS_LINUX)
141   virtual void ResourceDispatcherHostCreated() OVERRIDE;
142 #endif
143
144   virtual void GetStoragePartitionConfigForSite(
145       content::BrowserContext* browser_context,
146       const GURL& site,
147       bool can_be_default,
148       std::string* partition_domain,
149       std::string* partition_name,
150       bool* in_memory) OVERRIDE;
151
152   virtual content::DevToolsManagerDelegate*
153       GetDevToolsManagerDelegate() OVERRIDE;
154
155   XWalkBrowserMainParts* main_parts() { return main_parts_; }
156
157 #if defined(OS_ANDROID)
158   RuntimeResourceDispatcherHostDelegate* resource_dispatcher_host_delegate() {
159     return resource_dispatcher_host_delegate_.get();
160   }
161 #endif
162
163  private:
164   XWalkRunner* xwalk_runner_;
165   net::URLRequestContextGetter* url_request_context_getter_;
166   scoped_refptr<RuntimeGeolocationPermissionContext>
167     geolocation_permission_context_;
168   XWalkBrowserMainParts* main_parts_;
169   RuntimeContext* runtime_context_;
170
171   scoped_ptr<RuntimeResourceDispatcherHostDelegate>
172       resource_dispatcher_host_delegate_;
173
174   DISALLOW_COPY_AND_ASSIGN(XWalkContentBrowserClient);
175 };
176
177 }  // namespace xwalk
178
179 #endif  // XWALK_RUNTIME_BROWSER_XWALK_CONTENT_BROWSER_CLIENT_H_