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.
5 #ifndef XWALK_RUNTIME_BROWSER_ANDROID_XWALK_CONTENTS_CLIENT_BRIDGE_BASE_H_
6 #define XWALK_RUNTIME_BROWSER_ANDROID_XWALK_CONTENTS_CLIENT_BRIDGE_BASE_H_
8 #include "base/callback_forward.h"
9 #include "base/supports_user_data.h"
10 #include "content/public/browser/javascript_dialog_manager.h"
16 class DesktopNotificationDelegate;
17 class RenderFrameHost;
18 struct ShowDesktopNotificationHostMsgParams;
23 class X509Certificate;
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 {
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,
42 static XWalkContentsClientBridgeBase* FromRenderFrameID(int render_process_id,
44 static XWalkContentsClientBridgeBase* FromRenderFrameHost(
45 content::RenderFrameHost* render_frame_host);
47 virtual ~XWalkContentsClientBridgeBase();
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;
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)
62 virtual void RunBeforeUnloadDialog(
63 const GURL& origin_url,
64 const base::string16& message_text,
65 const content::JavaScriptDialogManager::DialogClosedCallback& callback)
67 virtual void ShowNotification(
68 const content::ShowDesktopNotificationHostMsgParams& params,
69 content::RenderFrameHost* render_frame_host,
70 content::DesktopNotificationDelegate* delegate,
71 base::Closure* cancel_callback)
73 virtual void UpdateNotificationIcon(
77 virtual void OnWebLayoutPageScaleFactorChanged(float page_scale_factor) = 0;
82 #endif // XWALK_RUNTIME_BROWSER_ANDROID_XWALK_CONTENTS_CLIENT_BRIDGE_BASE_H_