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