555e890666df2dd004a8b84bb3f4129c9ab15069
[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 struct ShowDesktopNotificationHostMsgParams;
17 class WebContents;
18 }
19
20 namespace net {
21 class X509Certificate;
22 }
23
24 namespace xwalk {
25
26 // browser/ layer interface for XWalkContentsClientBridge, as DEPS prevents
27 // this layer from depending on native/ where the implementation lives. The
28 // implementor of the base class plumbs the request to the Java side and
29 // eventually to the XWalkClient. This layering hides the details of
30 // native/ from browser/ layer.
31 class XWalkContentsClientBridgeBase {
32  public:
33   // Adds the handler to the UserData registry.
34   static void Associate(content::WebContents* web_contents,
35                         XWalkContentsClientBridgeBase* handler);
36   static XWalkContentsClientBridgeBase* FromWebContents(
37       content::WebContents* web_contents);
38   static XWalkContentsClientBridgeBase* FromID(int render_process_id,
39                                             int render_view_id);
40
41   virtual ~XWalkContentsClientBridgeBase();
42
43   virtual void AllowCertificateError(int cert_error,
44                                      net::X509Certificate* cert,
45                                      const GURL& request_url,
46                                      const base::Callback<void(bool)>& callback,
47                                      bool* cancel_request) = 0;
48
49   virtual void RunJavaScriptDialog(
50       content::JavaScriptMessageType message_type,
51       const GURL& origin_url,
52       const base::string16& message_text,
53       const base::string16& default_prompt_text,
54       const content::JavaScriptDialogManager::DialogClosedCallback& callback)
55       = 0;
56   virtual void RunBeforeUnloadDialog(
57       const GURL& origin_url,
58       const base::string16& message_text,
59       const content::JavaScriptDialogManager::DialogClosedCallback& callback)
60       = 0;
61   virtual void ShowNotification(
62       const content::ShowDesktopNotificationHostMsgParams& params,
63       bool worker,
64       int process_id,
65       int route_id)
66       = 0;
67   virtual void UpdateNotificationIcon(
68       int notification_id,
69       const SkBitmap& icon)
70       = 0;
71   virtual void CancelNotification(
72       int notification_id,
73       int process_id,
74       int route_id)
75       = 0;
76 };
77
78 }  // namespace xwalk
79
80 #endif  // XWALK_RUNTIME_BROWSER_ANDROID_XWALK_CONTENTS_CLIENT_BRIDGE_BASE_H_