Upstream version 6.34.113.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) OVERRIDE;
47   virtual net::URLRequestContextGetter* CreateRequestContextForStoragePartition(
48       content::BrowserContext* browser_context,
49       const base::FilePath& partition_path,
50       bool in_memory,
51       content::ProtocolHandlerMap* protocol_handlers) OVERRIDE;
52   virtual void AppendExtraCommandLineSwitches(CommandLine* command_line,
53                                               int child_process_id) OVERRIDE;
54   virtual content::QuotaPermissionContext*
55       CreateQuotaPermissionContext() OVERRIDE;
56   virtual content::AccessTokenStore* CreateAccessTokenStore() OVERRIDE;
57   virtual content::WebContentsViewDelegate* GetWebContentsViewDelegate(
58       content::WebContents* web_contents) OVERRIDE;
59   virtual void RenderProcessWillLaunch(
60       content::RenderProcessHost* host) OVERRIDE;
61   virtual content::MediaObserver* GetMediaObserver() OVERRIDE;
62
63   virtual bool AllowGetCookie(const GURL& url,
64                               const GURL& first_party,
65                               const net::CookieList& cookie_list,
66                               content::ResourceContext* context,
67                               int render_process_id,
68                               int render_frame_id) OVERRIDE;
69   virtual bool AllowSetCookie(const GURL& url,
70                               const GURL& first_party,
71                               const std::string& cookie_line,
72                               content::ResourceContext* context,
73                               int render_process_id,
74                               int render_frame_id,
75                               net::CookieOptions* options) OVERRIDE;
76
77   virtual void AllowCertificateError(
78       int render_process_id,
79       int render_frame_id,
80       int cert_error,
81       const net::SSLInfo& ssl_info,
82       const GURL& request_url,
83       ResourceType::Type resource_type,
84       bool overridable,
85       bool strict_enforcement,
86       const base::Callback<void(bool)>& callback,
87       content::CertificateRequestResultType* result) OVERRIDE;
88
89   virtual content::SpeechRecognitionManagerDelegate*
90       GetSpeechRecognitionManagerDelegate() OVERRIDE;
91
92   virtual void RequestDesktopNotificationPermission(
93       const GURL& source_origin,
94       int callback_context,
95       int render_process_id,
96       int render_view_id) OVERRIDE;
97   virtual blink::WebNotificationPresenter::Permission
98   CheckDesktopNotificationPermission(
99       const GURL& source_url,
100       content::ResourceContext* context,
101       int render_process_id) OVERRIDE;
102   virtual void ShowDesktopNotification(
103       const content::ShowDesktopNotificationHostMsgParams& params,
104       int render_process_id,
105       int render_view_id,
106       bool worker) OVERRIDE;
107   virtual void CancelDesktopNotification(
108       int render_process_id,
109       int render_view_id,
110       int notification_id) OVERRIDE;
111 #if defined(OS_TIZEN)
112   virtual bool CanCommitURL(
113       content::RenderProcessHost* process_host, const GURL& url) OVERRIDE;
114 #endif
115
116 #if defined(OS_ANDROID)
117   virtual void ResourceDispatcherHostCreated();
118 #endif
119   XWalkBrowserMainParts* main_parts() { return main_parts_; }
120
121  private:
122   XWalkRunner* xwalk_runner_;
123   net::URLRequestContextGetter* url_request_context_getter_;
124   XWalkBrowserMainParts* main_parts_;
125
126   DISALLOW_COPY_AND_ASSIGN(XWalkContentBrowserClient);
127 };
128
129 }  // namespace xwalk
130
131 #endif  // XWALK_RUNTIME_BROWSER_XWALK_CONTENT_BROWSER_CLIENT_H_