Upstream version 7.36.149.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
15 namespace content {
16 class BrowserContext;
17 class ResourceContext;
18 class QuotaPermissionContext;
19 class SpeechRecognitionManagerDelegate;
20 class WebContents;
21 class WebContentsViewDelegate;
22 }
23
24 namespace net {
25 class URLRequestContextGetter;
26 }
27
28 namespace xwalk {
29
30 class RuntimeContext;
31 class XWalkBrowserMainParts;
32 class XWalkRunner;
33
34 class XWalkContentBrowserClient : public content::ContentBrowserClient {
35  public:
36   static XWalkContentBrowserClient* Get();
37
38   explicit XWalkContentBrowserClient(XWalkRunner* xwalk_runner);
39   virtual ~XWalkContentBrowserClient();
40
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,
51       bool in_memory,
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;
64
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,
76                               int render_frame_id,
77                               net::CookieOptions* options) OVERRIDE;
78
79   virtual void AllowCertificateError(
80       int render_process_id,
81       int render_frame_id,
82       int cert_error,
83       const net::SSLInfo& ssl_info,
84       const GURL& request_url,
85       ResourceType::Type resource_type,
86       bool overridable,
87       bool strict_enforcement,
88       const base::Callback<void(bool)>& callback, // NOLINT
89       content::CertificateRequestResultType* result) OVERRIDE;
90
91   virtual content::SpeechRecognitionManagerDelegate*
92       GetSpeechRecognitionManagerDelegate() OVERRIDE;
93
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,
117                                bool user_gesture,
118                                bool opener_suppressed,
119                                content::ResourceContext* context,
120                                int render_process_id,
121                                bool is_guest,
122                                int opener_id,
123                                bool* no_javascript_access) OVERRIDE;
124 #endif
125
126   virtual void DidCreatePpapiPlugin(
127       content::BrowserPpapiHost* browser_host) OVERRIDE;
128   virtual content::BrowserPpapiHost* GetExternalBrowserPpapiHost(
129       int plugin_process_id) OVERRIDE;
130
131 #if defined(OS_ANDROID)
132   virtual void ResourceDispatcherHostCreated();
133 #endif
134
135   virtual void GetStoragePartitionConfigForSite(
136       content::BrowserContext* browser_context,
137       const GURL& site,
138       bool can_be_default,
139       std::string* partition_domain,
140       std::string* partition_name,
141       bool* in_memory) OVERRIDE;
142
143
144   XWalkBrowserMainParts* main_parts() { return main_parts_; }
145
146  private:
147   XWalkRunner* xwalk_runner_;
148   net::URLRequestContextGetter* url_request_context_getter_;
149   XWalkBrowserMainParts* main_parts_;
150
151   DISALLOW_COPY_AND_ASSIGN(XWalkContentBrowserClient);
152 };
153
154 }  // namespace xwalk
155
156 #endif  // XWALK_RUNTIME_BROWSER_XWALK_CONTENT_BROWSER_CLIENT_H_