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.
5 #ifndef XWALK_RUNTIME_BROWSER_XWALK_CONTENT_BROWSER_CLIENT_H_
6 #define XWALK_RUNTIME_BROWSER_XWALK_CONTENT_BROWSER_CLIENT_H_
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"
19 class ResourceContext;
20 class QuotaPermissionContext;
21 class SpeechRecognitionManagerDelegate;
23 class WebContentsViewDelegate;
27 class URLRequestContextGetter;
33 class XWalkBrowserMainParts;
36 class XWalkContentBrowserClient : public content::ContentBrowserClient {
38 static XWalkContentBrowserClient* Get();
40 explicit XWalkContentBrowserClient(XWalkRunner* xwalk_runner);
41 virtual ~XWalkContentBrowserClient();
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,
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;
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,
79 net::CookieOptions* options) OVERRIDE;
81 virtual void AllowCertificateError(
82 int render_process_id,
85 const net::SSLInfo& ssl_info,
86 const GURL& request_url,
87 content::ResourceType resource_type,
89 bool strict_enforcement,
90 bool expired_previous_decision,
91 const base::Callback<void(bool)>& callback, // NOLINT
92 content::CertificateRequestResultType* result) OVERRIDE;
94 virtual content::SpeechRecognitionManagerDelegate*
95 GetSpeechRecognitionManagerDelegate() OVERRIDE;
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,
114 const GURL& requesting_frame,
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,
128 bool opener_suppressed,
129 content::ResourceContext* context,
130 int render_process_id,
132 bool* no_javascript_access) OVERRIDE;
135 virtual void DidCreatePpapiPlugin(
136 content::BrowserPpapiHost* browser_host) OVERRIDE;
137 virtual content::BrowserPpapiHost* GetExternalBrowserPpapiHost(
138 int plugin_process_id) OVERRIDE;
140 #if defined(OS_ANDROID) || defined(OS_TIZEN) || defined(OS_LINUX)
141 virtual void ResourceDispatcherHostCreated() OVERRIDE;
144 virtual void GetStoragePartitionConfigForSite(
145 content::BrowserContext* browser_context,
148 std::string* partition_domain,
149 std::string* partition_name,
150 bool* in_memory) OVERRIDE;
152 virtual content::DevToolsManagerDelegate*
153 GetDevToolsManagerDelegate() OVERRIDE;
155 XWalkBrowserMainParts* main_parts() { return main_parts_; }
157 #if defined(OS_ANDROID)
158 RuntimeResourceDispatcherHostDelegate* resource_dispatcher_host_delegate() {
159 return resource_dispatcher_host_delegate_.get();
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_;
171 scoped_ptr<RuntimeResourceDispatcherHostDelegate>
172 resource_dispatcher_host_delegate_;
174 DISALLOW_COPY_AND_ASSIGN(XWalkContentBrowserClient);
179 #endif // XWALK_RUNTIME_BROWSER_XWALK_CONTENT_BROWSER_CLIENT_H_