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"
17 class ResourceContext;
18 class QuotaPermissionContext;
19 class SpeechRecognitionManagerDelegate;
21 class WebContentsViewDelegate;
25 class URLRequestContextGetter;
31 class XWalkBrowserMainParts;
34 class XWalkContentBrowserClient : public content::ContentBrowserClient {
36 static XWalkContentBrowserClient* Get();
38 explicit XWalkContentBrowserClient(XWalkRunner* xwalk_runner);
39 virtual ~XWalkContentBrowserClient();
41 // ContentBrowserClient overrides.
42 virtual content::BrowserMainParts* CreateBrowserMainParts(
43 const content::MainFunctionParams& parameters) OVERRIDE;
44 virtual net::URLRequestContextGetter* CreateRequestContext(
45 content::BrowserContext* browser_context,
46 content::ProtocolHandlerMap* protocol_handlers,
47 content::ProtocolHandlerScopedVector protocol_interceptors) OVERRIDE;
48 virtual net::URLRequestContextGetter* CreateRequestContextForStoragePartition(
49 content::BrowserContext* browser_context,
50 const base::FilePath& partition_path,
52 content::ProtocolHandlerMap* protocol_handlers,
53 content::ProtocolHandlerScopedVector protocol_interceptors) OVERRIDE;
54 virtual void AppendExtraCommandLineSwitches(CommandLine* command_line,
55 int child_process_id) OVERRIDE;
56 virtual content::QuotaPermissionContext*
57 CreateQuotaPermissionContext() OVERRIDE;
58 virtual content::AccessTokenStore* CreateAccessTokenStore() OVERRIDE;
59 virtual content::WebContentsViewDelegate* GetWebContentsViewDelegate(
60 content::WebContents* web_contents) OVERRIDE;
61 virtual void RenderProcessWillLaunch(
62 content::RenderProcessHost* host) OVERRIDE;
63 virtual content::MediaObserver* GetMediaObserver() OVERRIDE;
65 virtual bool AllowGetCookie(const GURL& url,
66 const GURL& first_party,
67 const net::CookieList& cookie_list,
68 content::ResourceContext* context,
69 int render_process_id,
70 int render_frame_id) OVERRIDE;
71 virtual bool AllowSetCookie(const GURL& url,
72 const GURL& first_party,
73 const std::string& cookie_line,
74 content::ResourceContext* context,
75 int render_process_id,
77 net::CookieOptions* options) OVERRIDE;
79 virtual void AllowCertificateError(
80 int render_process_id,
83 const net::SSLInfo& ssl_info,
84 const GURL& request_url,
85 ResourceType::Type resource_type,
87 bool strict_enforcement,
88 const base::Callback<void(bool)>& callback, // NOLINT
89 content::CertificateRequestResultType* result) OVERRIDE;
91 virtual content::SpeechRecognitionManagerDelegate*
92 GetSpeechRecognitionManagerDelegate() OVERRIDE;
94 virtual void RequestDesktopNotificationPermission(
95 const GURL& source_origin,
96 content::RenderFrameHost* render_frame_host,
97 base::Closure& callback) OVERRIDE; // NOLINT
98 virtual blink::WebNotificationPresenter::Permission
99 CheckDesktopNotificationPermission(
100 const GURL& source_url,
101 content::ResourceContext* context,
102 int render_process_id) OVERRIDE;
103 virtual void ShowDesktopNotification(
104 const content::ShowDesktopNotificationHostMsgParams& params,
105 content::RenderFrameHost* render_frame_host,
106 content::DesktopNotificationDelegate* delegate,
107 base::Closure* cancel_callback) OVERRIDE;
108 #if !defined(OS_ANDROID)
109 virtual bool CanCreateWindow(const GURL& opener_url,
110 const GURL& opener_top_level_frame_url,
111 const GURL& source_origin,
112 WindowContainerType container_type,
113 const GURL& target_url,
114 const content::Referrer& referrer,
115 WindowOpenDisposition disposition,
116 const blink::WebWindowFeatures& features,
118 bool opener_suppressed,
119 content::ResourceContext* context,
120 int render_process_id,
123 bool* no_javascript_access) OVERRIDE;
126 virtual void DidCreatePpapiPlugin(
127 content::BrowserPpapiHost* browser_host) OVERRIDE;
128 virtual content::BrowserPpapiHost* GetExternalBrowserPpapiHost(
129 int plugin_process_id) OVERRIDE;
131 #if defined(OS_ANDROID)
132 virtual void ResourceDispatcherHostCreated();
135 virtual void GetStoragePartitionConfigForSite(
136 content::BrowserContext* browser_context,
139 std::string* partition_domain,
140 std::string* partition_name,
141 bool* in_memory) OVERRIDE;
144 XWalkBrowserMainParts* main_parts() { return main_parts_; }
147 XWalkRunner* xwalk_runner_;
148 net::URLRequestContextGetter* url_request_context_getter_;
149 XWalkBrowserMainParts* main_parts_;
151 DISALLOW_COPY_AND_ASSIGN(XWalkContentBrowserClient);
156 #endif // XWALK_RUNTIME_BROWSER_XWALK_CONTENT_BROWSER_CLIENT_H_