OLD | NEW |
---|---|
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 package org.chromium.android_webview; | 5 package org.chromium.android_webview; |
6 | 6 |
7 import android.app.Activity; | 7 import android.app.Activity; |
8 import android.content.Intent; | 8 import android.content.Intent; |
9 import android.content.pm.ActivityInfo; | 9 import android.content.pm.ActivityInfo; |
10 import android.graphics.Bitmap; | 10 import android.graphics.Bitmap; |
11 import android.graphics.Picture; | 11 import android.graphics.Picture; |
12 import android.net.Uri; | 12 import android.net.Uri; |
13 import android.net.http.SslError; | 13 import android.net.http.SslError; |
14 import android.os.Looper; | 14 import android.os.Looper; |
15 import android.os.Message; | 15 import android.os.Message; |
16 import android.view.KeyEvent; | 16 import android.view.KeyEvent; |
17 import android.view.View; | 17 import android.view.View; |
18 import android.webkit.ConsoleMessage; | 18 import android.webkit.ConsoleMessage; |
19 import android.webkit.GeolocationPermissions; | 19 import android.webkit.GeolocationPermissions; |
20 import android.webkit.ValueCallback; | 20 import android.webkit.ValueCallback; |
21 import android.webkit.WebChromeClient; | 21 import android.webkit.WebChromeClient; |
22 import android.webkit.WebResourceRequest; | |
23 import android.webkit.WebResourceResponse; | |
22 | 24 |
23 import org.chromium.android_webview.permission.AwPermissionRequest; | 25 import org.chromium.android_webview.permission.AwPermissionRequest; |
26 import org.chromium.base.VisibleForTesting; | |
24 | 27 |
25 import java.security.Principal; | 28 import java.security.Principal; |
26 import java.util.HashMap; | 29 import java.util.HashMap; |
30 import java.util.Map; | |
27 | 31 |
28 /** | 32 /** |
29 * Base-class that an AwContents embedder derives from to receive callbacks. | 33 * Base-class that an AwContents embedder derives from to receive callbacks. |
30 * This extends ContentViewClient, as in many cases we want to pass-thru Content ViewCore | 34 * This extends ContentViewClient, as in many cases we want to pass-thru Content ViewCore |
31 * callbacks right to our embedder, and this setup facilities that. | 35 * callbacks right to our embedder, and this setup facilities that. |
32 * For any other callbacks we need to make transformations of (e.g. adapt parame ters | 36 * For any other callbacks we need to make transformations of (e.g. adapt parame ters |
33 * or perform filtering) we can provide final overrides for methods here, and th en introduce | 37 * or perform filtering) we can provide final overrides for methods here, and th en introduce |
34 * new abstract methods that the our own client must implement. | 38 * new abstract methods that the our own client must implement. |
35 * i.e.: all methods in this class should either be final, or abstract. | 39 * i.e.: all methods in this class should either be final, or abstract. |
36 */ | 40 */ |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
72 mCachedRendererBackgroundColor = color == INVALID_COLOR ? 1 : color; | 76 mCachedRendererBackgroundColor = color == INVALID_COLOR ? 1 : color; |
73 } | 77 } |
74 | 78 |
75 //-------------------------------------------------------------------------- ------------------ | 79 //-------------------------------------------------------------------------- ------------------ |
76 // WebView specific methods that map directly to WebViewClient / WebChromeClient | 80 // WebView specific methods that map directly to WebViewClient / WebChromeClient |
77 //-------------------------------------------------------------------------- ------------------ | 81 //-------------------------------------------------------------------------- ------------------ |
78 | 82 |
79 /** | 83 /** |
80 * Parameters for the {@link AwContentsClient#shouldInterceptRequest} method . | 84 * Parameters for the {@link AwContentsClient#shouldInterceptRequest} method . |
81 */ | 85 */ |
82 public static class AwWebResourceRequest { | 86 public static class WebResourceRequestImpl implements WebResourceRequest { |
83 // Url of the request. | 87 // Url of the request. |
84 public String url; | 88 public String mUrl; |
mnaganov (inactive)
2015/03/06 09:58:44
Should these fields become private and final?
| |
85 // Is this for the main frame or a child iframe? | 89 // Is this for the main frame or a child iframe? |
86 public boolean isMainFrame; | 90 public boolean mIsMainFrame; |
87 // Was a gesture associated with the request? Don't trust can easily be spoofed. | 91 // Was a gesture associated with the request? Don't trust can easily be spoofed. |
88 public boolean hasUserGesture; | 92 public boolean mHasUserGesture; |
89 // Method used (GET/POST/OPTIONS) | 93 // Method used (GET/POST/OPTIONS) |
90 public String method; | 94 public String mMethod; |
91 // Headers that would have been sent to server. | 95 // Headers that would have been sent to server. |
92 public HashMap<String, String> requestHeaders; | 96 public Map<String, String> mRequestHeaders; |
97 | |
98 public WebResourceRequestImpl(String url, boolean isMainFrame, boolean h asUserGesture, | |
99 String method, HashMap<String, String> requestHeaders) { | |
100 mUrl = url; | |
101 mIsMainFrame = isMainFrame; | |
102 mHasUserGesture = hasUserGesture; | |
103 mMethod = method; | |
104 mRequestHeaders = requestHeaders; | |
105 } | |
106 | |
107 @VisibleForTesting | |
108 public String getUrlString() { | |
109 return mUrl; | |
110 } | |
111 | |
112 @Override | |
113 public Uri getUrl() { | |
114 return Uri.parse(mUrl); | |
115 } | |
116 | |
117 @Override | |
118 public boolean isForMainFrame() { | |
119 return mIsMainFrame; | |
120 } | |
121 | |
122 @Override | |
123 public boolean hasGesture() { | |
mnaganov (inactive)
2015/03/06 09:58:44
Let's stick to hasUserGesture, as it is traceable
| |
124 return mHasUserGesture; | |
125 } | |
126 | |
127 @Override | |
128 public String getMethod() { | |
129 return mMethod; | |
130 } | |
131 | |
132 @Override | |
133 public Map<String, String> getRequestHeaders() { | |
134 return mRequestHeaders; | |
135 } | |
93 } | 136 } |
94 | 137 |
95 public abstract void getVisitedHistory(ValueCallback<String[]> callback); | 138 public abstract void getVisitedHistory(ValueCallback<String[]> callback); |
96 | 139 |
97 public abstract void doUpdateVisitedHistory(String url, boolean isReload); | 140 public abstract void doUpdateVisitedHistory(String url, boolean isReload); |
98 | 141 |
99 public abstract void onProgressChanged(int progress); | 142 public abstract void onProgressChanged(int progress); |
100 | 143 |
101 public abstract AwWebResourceResponse shouldInterceptRequest( | 144 public abstract WebResourceResponse shouldInterceptRequest(WebResourceReques tImpl request); |
102 AwWebResourceRequest request); | |
103 | 145 |
104 public abstract boolean shouldOverrideKeyEvent(KeyEvent event); | 146 public abstract boolean shouldOverrideKeyEvent(KeyEvent event); |
105 | 147 |
106 public abstract boolean shouldOverrideUrlLoading(String url); | 148 public abstract boolean shouldOverrideUrlLoading(String url); |
107 | 149 |
108 public abstract void onLoadResource(String url); | 150 public abstract void onLoadResource(String url); |
109 | 151 |
110 public abstract void onUnhandledKeyEvent(KeyEvent event); | 152 public abstract void onUnhandledKeyEvent(KeyEvent event); |
111 | 153 |
112 public abstract boolean onConsoleMessage(ConsoleMessage consoleMessage); | 154 public abstract boolean onConsoleMessage(ConsoleMessage consoleMessage); |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
281 public abstract void onFindResultReceived(int activeMatchOrdinal, int number OfMatches, | 323 public abstract void onFindResultReceived(int activeMatchOrdinal, int number OfMatches, |
282 boolean isDoneCounting); | 324 boolean isDoneCounting); |
283 | 325 |
284 /** | 326 /** |
285 * Called whenever there is a new content picture available. | 327 * Called whenever there is a new content picture available. |
286 * @param picture New picture. | 328 * @param picture New picture. |
287 */ | 329 */ |
288 public abstract void onNewPicture(Picture picture); | 330 public abstract void onNewPicture(Picture picture); |
289 | 331 |
290 } | 332 } |
OLD | NEW |