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"
18 class ResourceContext;
19 class QuotaPermissionContext;
20 class SpeechRecognitionManagerDelegate;
22 class WebContentsViewDelegate;
26 class URLRequestContextGetter;
32 class XWalkBrowserMainParts;
35 class XWalkContentBrowserClient : public content::ContentBrowserClient {
37 static XWalkContentBrowserClient* Get();
39 explicit XWalkContentBrowserClient(XWalkRunner* xwalk_runner);
40 virtual ~XWalkContentBrowserClient();
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,
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;
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,
78 net::CookieOptions* options) OVERRIDE;
80 virtual void AllowCertificateError(
81 int render_process_id,
84 const net::SSLInfo& ssl_info,
85 const GURL& request_url,
86 content::ResourceType resource_type,
88 bool strict_enforcement,
89 bool expired_previous_decision,
90 const base::Callback<void(bool)>& callback, // NOLINT
91 content::CertificateRequestResultType* result) OVERRIDE;
93 virtual content::SpeechRecognitionManagerDelegate*
94 GetSpeechRecognitionManagerDelegate() OVERRIDE;
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,
113 const GURL& requesting_frame,
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,
127 bool opener_suppressed,
128 content::ResourceContext* context,
129 int render_process_id,
131 bool* no_javascript_access) OVERRIDE;
134 virtual void DidCreatePpapiPlugin(
135 content::BrowserPpapiHost* browser_host) OVERRIDE;
136 virtual content::BrowserPpapiHost* GetExternalBrowserPpapiHost(
137 int plugin_process_id) OVERRIDE;
139 #if defined(OS_ANDROID)
140 virtual void ResourceDispatcherHostCreated();
143 virtual void GetStoragePartitionConfigForSite(
144 content::BrowserContext* browser_context,
147 std::string* partition_domain,
148 std::string* partition_name,
149 bool* in_memory) OVERRIDE;
151 virtual content::DevToolsManagerDelegate*
152 GetDevToolsManagerDelegate() OVERRIDE;
154 XWalkBrowserMainParts* main_parts() { return main_parts_; }
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_;
164 DISALLOW_COPY_AND_ASSIGN(XWalkContentBrowserClient);
169 #endif // XWALK_RUNTIME_BROWSER_XWALK_CONTENT_BROWSER_CLIENT_H_