OLD | NEW |
| (Empty) |
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 ANDROID_WEBVIEW_BROWSER_AW_CONTENTS_CLIENT_BRIDGE_BASE_H_ | |
6 #define ANDROID_WEBVIEW_BROWSER_AW_CONTENTS_CLIENT_BRIDGE_BASE_H_ | |
7 | |
8 #include <memory> | |
9 | |
10 #include "android_webview/browser/net/aw_web_resource_request.h" | |
11 #include "base/supports_user_data.h" | |
12 #include "content/public/browser/certificate_request_result_type.h" | |
13 #include "content/public/browser/javascript_dialog_manager.h" | |
14 #include "content/public/browser/resource_request_info.h" | |
15 #include "net/http/http_response_headers.h" | |
16 | |
17 class GURL; | |
18 | |
19 namespace content { | |
20 class ClientCertificateDelegate; | |
21 class WebContents; | |
22 } | |
23 | |
24 namespace net { | |
25 class SSLCertRequestInfo; | |
26 class X509Certificate; | |
27 } | |
28 | |
29 namespace android_webview { | |
30 | |
31 // browser/ layer interface for AwContensClientBridge, as DEPS prevents this | |
32 // layer from depending on native/ where the implementation lives. The | |
33 // implementor of the base class plumbs the request to the Java side and | |
34 // eventually to the webviewclient. This layering hides the details of | |
35 // native/ from browser/ layer. | |
36 class AwContentsClientBridgeBase { | |
37 public: | |
38 // Adds the handler to the UserData registry. | |
39 static void Associate(content::WebContents* web_contents, | |
40 AwContentsClientBridgeBase* handler); | |
41 static AwContentsClientBridgeBase* FromWebContents( | |
42 content::WebContents* web_contents); | |
43 static AwContentsClientBridgeBase* FromWebContentsGetter( | |
44 const content::ResourceRequestInfo::WebContentsGetter& | |
45 web_contents_getter); | |
46 static AwContentsClientBridgeBase* FromID(int render_process_id, | |
47 int render_frame_id); | |
48 | |
49 virtual ~AwContentsClientBridgeBase(); | |
50 | |
51 virtual void AllowCertificateError( | |
52 int cert_error, | |
53 net::X509Certificate* cert, | |
54 const GURL& request_url, | |
55 const base::Callback<void(content::CertificateRequestResultType)>& | |
56 callback, | |
57 bool* cancel_request) = 0; | |
58 virtual void SelectClientCertificate( | |
59 net::SSLCertRequestInfo* cert_request_info, | |
60 std::unique_ptr<content::ClientCertificateDelegate> delegate) = 0; | |
61 | |
62 virtual void RunJavaScriptDialog( | |
63 content::JavaScriptDialogType dialog_type, | |
64 const GURL& origin_url, | |
65 const base::string16& message_text, | |
66 const base::string16& default_prompt_text, | |
67 const content::JavaScriptDialogManager::DialogClosedCallback& | |
68 callback) = 0; | |
69 | |
70 virtual void RunBeforeUnloadDialog( | |
71 const GURL& origin_url, | |
72 const content::JavaScriptDialogManager::DialogClosedCallback& callback) | |
73 = 0; | |
74 | |
75 virtual bool ShouldOverrideUrlLoading(const base::string16& url, | |
76 bool has_user_gesture, | |
77 bool is_redirect, | |
78 bool is_main_frame) = 0; | |
79 | |
80 virtual void NewDownload(const GURL& url, | |
81 const std::string& user_agent, | |
82 const std::string& content_disposition, | |
83 const std::string& mime_type, | |
84 int64_t content_length) = 0; | |
85 | |
86 // Called when a new login request is detected. See the documentation for | |
87 // WebViewClient.onReceivedLoginRequest for arguments. Note that |account| | |
88 // may be empty. | |
89 virtual void NewLoginRequest(const std::string& realm, | |
90 const std::string& account, | |
91 const std::string& args) = 0; | |
92 | |
93 // Called when a resource loading error has occured (e.g. an I/O error, | |
94 // host name lookup failure etc.) | |
95 virtual void OnReceivedError(const AwWebResourceRequest& request, | |
96 int error_code) = 0; | |
97 | |
98 // Called when a response from the server is received with status code >= 400. | |
99 virtual void OnReceivedHttpError( | |
100 const AwWebResourceRequest& request, | |
101 const scoped_refptr<const net::HttpResponseHeaders>& | |
102 response_headers) = 0; | |
103 }; | |
104 | |
105 } // namespace android_webview | |
106 | |
107 #endif // ANDROID_WEBVIEW_BROWSER_AW_CONTENTS_CLIENT_BRIDGE_BASE_H_ | |
OLD | NEW |