Upstream version 8.37.187.0
[platform/framework/web/crosswalk.git] / src / xwalk / runtime / browser / android / xwalk_contents_client_bridge_base.h
1 // Copyright (c) 2013 The Chromium Authors. 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_ANDROID_XWALK_CONTENTS_CLIENT_BRIDGE_BASE_H_
6 #define XWALK_RUNTIME_BROWSER_ANDROID_XWALK_CONTENTS_CLIENT_BRIDGE_BASE_H_
7
8 #include "base/callback_forward.h"
9 #include "base/supports_user_data.h"
10 #include "content/public/browser/javascript_dialog_manager.h"
11
12 class GURL;
13 class SkBitmap;
14
15 namespace content {
16 class DesktopNotificationDelegate;
17 class RenderFrameHost;
18 struct ShowDesktopNotificationHostMsgParams;
19 class WebContents;
20 }
21
22 namespace net {
23 class X509Certificate;
24 }
25
26 namespace xwalk {
27
28 // browser/ layer interface for XWalkContentsClientBridge, as DEPS prevents
29 // this layer from depending on native/ where the implementation lives. The
30 // implementor of the base class plumbs the request to the Java side and
31 // eventually to the XWalkClient. This layering hides the details of
32 // native/ from browser/ layer.
33 class XWalkContentsClientBridgeBase {
34  public:
35   // Adds the handler to the UserData registry.
36   static void Associate(content::WebContents* web_contents,
37                         XWalkContentsClientBridgeBase* handler);
38   static XWalkContentsClientBridgeBase* FromWebContents(
39       content::WebContents* web_contents);
40   static XWalkContentsClientBridgeBase* FromRenderViewID(int render_process_id,
41                                             int render_view_id);
42   static XWalkContentsClientBridgeBase* FromRenderFrameID(int render_process_id,
43                                             int render_frame_id);
44   static XWalkContentsClientBridgeBase* FromRenderFrameHost(
45       content::RenderFrameHost* render_frame_host);
46
47   virtual ~XWalkContentsClientBridgeBase();
48
49   virtual void AllowCertificateError(int cert_error,
50                                      net::X509Certificate* cert,
51                                      const GURL& request_url,
52                                      const base::Callback<void(bool)>& callback,
53                                      bool* cancel_request) = 0;
54
55   virtual void RunJavaScriptDialog(
56       content::JavaScriptMessageType message_type,
57       const GURL& origin_url,
58       const base::string16& message_text,
59       const base::string16& default_prompt_text,
60       const content::JavaScriptDialogManager::DialogClosedCallback& callback)
61       = 0;
62   virtual void RunBeforeUnloadDialog(
63       const GURL& origin_url,
64       const base::string16& message_text,
65       const content::JavaScriptDialogManager::DialogClosedCallback& callback)
66       = 0;
67   virtual void ShowNotification(
68       const content::ShowDesktopNotificationHostMsgParams& params,
69       content::RenderFrameHost* render_frame_host,
70       content::DesktopNotificationDelegate* delegate,
71       base::Closure* cancel_callback)
72       = 0;
73   virtual void UpdateNotificationIcon(
74       int notification_id,
75       const SkBitmap& icon)
76       = 0;
77   virtual void OnWebLayoutPageScaleFactorChanged(float page_scale_factor) = 0;
78 };
79
80 }  // namespace xwalk
81
82 #endif  // XWALK_RUNTIME_BROWSER_ANDROID_XWALK_CONTENTS_CLIENT_BRIDGE_BASE_H_