| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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.content.browser; | 5 package org.chromium.content.browser; |
| 6 | 6 |
| 7 import android.content.ActivityNotFoundException; | 7 import android.content.ActivityNotFoundException; |
| 8 import android.content.Context; | 8 import android.content.Context; |
| 9 import android.content.Intent; | 9 import android.content.Intent; |
| 10 import android.graphics.Rect; | 10 import android.graphics.Rect; |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 * This contains the superset of callbacks required to implement the browser UI
and the callbacks | 26 * This contains the superset of callbacks required to implement the browser UI
and the callbacks |
| 27 * required to implement the WebView API. | 27 * required to implement the WebView API. |
| 28 * The memory and reference ownership of this class is unusual - see the .cc fi
le and ContentView | 28 * The memory and reference ownership of this class is unusual - see the .cc fi
le and ContentView |
| 29 * for more details. | 29 * for more details. |
| 30 * | 30 * |
| 31 * TODO(mkosiba): Rid this guy of default implementations. This class is used b
y both WebView and | 31 * TODO(mkosiba): Rid this guy of default implementations. This class is used b
y both WebView and |
| 32 * the browser and we don't want a the browser-specific default implementation
to accidentally leak | 32 * the browser and we don't want a the browser-specific default implementation
to accidentally leak |
| 33 * over to WebView. | 33 * over to WebView. |
| 34 */ | 34 */ |
| 35 public class ContentViewClient { | 35 public class ContentViewClient { |
| 36 | |
| 37 // Tag used for logging. | 36 // Tag used for logging. |
| 38 private static final String TAG = "ContentViewClient"; | 37 private static final String TAG = "ContentViewClient"; |
| 39 | 38 |
| 40 // Native class pointer which will be set by nativeInit() | 39 // Native class pointer which will be set by nativeInit() |
| 41 @AccessedByNative | 40 @AccessedByNative |
| 42 private int mNativeClazz = 0; | 41 private int mNativeClazz = 0; |
| 43 | 42 |
| 44 // These ints must match up to the native values in content_view_client.h. | 43 // These ints must match up to the native values in content_view_client.h. |
| 45 // Generic error | 44 // Generic error |
| 46 public static final int ERROR_UNKNOWN = -1; | 45 public static final int ERROR_UNKNOWN = -1; |
| (...skipping 20 matching lines...) Expand all Loading... |
| 67 // Malformed URL | 66 // Malformed URL |
| 68 public static final int ERROR_BAD_URL = -12; | 67 public static final int ERROR_BAD_URL = -12; |
| 69 // Generic file error | 68 // Generic file error |
| 70 public static final int ERROR_FILE = -13; | 69 public static final int ERROR_FILE = -13; |
| 71 // File not found | 70 // File not found |
| 72 public static final int ERROR_FILE_NOT_FOUND = -14; | 71 public static final int ERROR_FILE_NOT_FOUND = -14; |
| 73 // Too many requests during this load | 72 // Too many requests during this load |
| 74 public static final int ERROR_TOO_MANY_REQUESTS = -15; | 73 public static final int ERROR_TOO_MANY_REQUESTS = -15; |
| 75 | 74 |
| 76 @CalledByNative | 75 @CalledByNative |
| 77 public void openNewTab(String url, boolean incognito) { | |
| 78 } | |
| 79 | |
| 80 @CalledByNative | |
| 81 public boolean addNewContents(int nativeSourceWebContents, int nativeWebCont
ents, | |
| 82 int disposition, Rect initialPosition, boolean
userGesture) { | |
| 83 return false; | |
| 84 } | |
| 85 | |
| 86 @CalledByNative | |
| 87 public void closeContents() { | |
| 88 } | |
| 89 | |
| 90 @CalledByNative | |
| 91 public void onUrlStarredChanged(boolean starred) { | |
| 92 } | |
| 93 | |
| 94 @CalledByNative | |
| 95 public void onPageStarted(String url) { | 76 public void onPageStarted(String url) { |
| 96 } | 77 } |
| 97 | 78 |
| 98 @CalledByNative | 79 @CalledByNative |
| 99 public void onPageFinished(String url) { | 80 public void onPageFinished(String url) { |
| 100 } | 81 } |
| 101 | 82 |
| 102 @CalledByNative | 83 @CalledByNative |
| 103 public void onLoadStarted() { | |
| 104 } | |
| 105 | |
| 106 @CalledByNative | |
| 107 public void onLoadStopped() { | |
| 108 } | |
| 109 | |
| 110 @CalledByNative | |
| 111 public void onReceivedError(int errorCode, String description, String failin
gUrl) { | 84 public void onReceivedError(int errorCode, String description, String failin
gUrl) { |
| 112 } | 85 } |
| 113 | 86 |
| 114 @CalledByNative | 87 @CalledByNative |
| 115 public void onMainFrameCommitted(String url, String baseUrl) { | 88 public void onMainFrameCommitted(String url, String baseUrl) { |
| 116 } | 89 } |
| 117 | 90 |
| 118 @CalledByNative | |
| 119 public void onTabHeaderStateChanged() { | |
| 120 } | |
| 121 | |
| 122 @CalledByNative | |
| 123 public void onLoadProgressChanged(double progress) { | |
| 124 } | |
| 125 | |
| 126 public void onUpdateTitle(String title) { | 91 public void onUpdateTitle(String title) { |
| 127 } | 92 } |
| 128 | 93 |
| 129 @CalledByNative | 94 @CalledByNative |
| 130 public void onUpdateUrl(String url) { | |
| 131 } | |
| 132 | |
| 133 @CalledByNative | |
| 134 public void onReceiveFindMatchRects(int version, float[] rect_data, | |
| 135 RectF activeRect) { | |
| 136 } | |
| 137 | |
| 138 @CalledByNative | |
| 139 public void onInterstitialShown() { | 95 public void onInterstitialShown() { |
| 140 } | 96 } |
| 141 | 97 |
| 142 @CalledByNative | 98 @CalledByNative |
| 143 public void onInterstitialHidden() { | 99 public void onInterstitialHidden() { |
| 144 } | 100 } |
| 145 | 101 |
| 146 @CalledByNative | |
| 147 public boolean takeFocus(boolean reverse) { | |
| 148 return false; | |
| 149 } | |
| 150 | |
| 151 public void onTabCrash(int pid) { | 102 public void onTabCrash(int pid) { |
| 152 } | 103 } |
| 153 | 104 |
| 154 @CalledByNative | |
| 155 public boolean shouldOverrideUrlLoading(String url) { | |
| 156 return false; | |
| 157 } | |
| 158 | |
| 159 public boolean shouldOverrideKeyEvent(KeyEvent event) { | 105 public boolean shouldOverrideKeyEvent(KeyEvent event) { |
| 160 int keyCode = event.getKeyCode(); | 106 int keyCode = event.getKeyCode(); |
| 161 // We need to send almost every key to WebKit. However: | 107 // We need to send almost every key to WebKit. However: |
| 162 // 1. We don't want to block the device on the renderer for | 108 // 1. We don't want to block the device on the renderer for |
| 163 // some keys like menu, home, call. | 109 // some keys like menu, home, call. |
| 164 // 2. There are no WebKit equivalents for some of these keys | 110 // 2. There are no WebKit equivalents for some of these keys |
| 165 // (see app/keyboard_codes_win.h) | 111 // (see app/keyboard_codes_win.h) |
| 166 // Note that these are not the same set as KeyEvent.isSystemKey: | 112 // Note that these are not the same set as KeyEvent.isSystemKey: |
| 167 // for instance, AKEYCODE_MEDIA_* will be dispatched to webkit. | 113 // for instance, AKEYCODE_MEDIA_* will be dispatched to webkit. |
| 168 if (keyCode == KeyEvent.KEYCODE_MENU || | 114 if (keyCode == KeyEvent.KEYCODE_MENU || |
| (...skipping 20 matching lines...) Expand all Loading... |
| 189 } | 135 } |
| 190 | 136 |
| 191 return false; | 137 return false; |
| 192 } | 138 } |
| 193 | 139 |
| 194 // Called when an ImeEvent is sent to the page. Can be used to know when som
e text is entered | 140 // Called when an ImeEvent is sent to the page. Can be used to know when som
e text is entered |
| 195 // in a page. | 141 // in a page. |
| 196 public void onImeEvent() { | 142 public void onImeEvent() { |
| 197 } | 143 } |
| 198 | 144 |
| 199 public void onUnhandledKeyEvent(KeyEvent event) { | |
| 200 // TODO(bulach): we probably want to re-inject the KeyEvent back into | |
| 201 // the system. Investigate if this is at all possible. | |
| 202 } | |
| 203 | |
| 204 @CalledByNative | |
| 205 void handleKeyboardEvent(KeyEvent event) { | |
| 206 onUnhandledKeyEvent(event); | |
| 207 } | |
| 208 | |
| 209 @CalledByNative | |
| 210 public void runFileChooser(FileChooserParams params) { | |
| 211 } | |
| 212 | |
| 213 // Return true if the client will handle the JS alert. | 145 // Return true if the client will handle the JS alert. |
| 214 @CalledByNative | 146 @CalledByNative |
| 215 public boolean onJsAlert(String url, String Message) { | 147 public boolean onJsAlert(String url, String Message) { |
| 216 return false; | 148 return false; |
| 217 } | 149 } |
| 218 | 150 |
| 219 // Return true if the client will handle the JS before unload dialog. | 151 // Return true if the client will handle the JS before unload dialog. |
| 220 @CalledByNative | 152 @CalledByNative |
| 221 public boolean onJsBeforeUnload(String url, String message) { | 153 public boolean onJsBeforeUnload(String url, String message) { |
| 222 return false; | 154 return false; |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 290 return; | 222 return; |
| 291 } | 223 } |
| 292 | 224 |
| 293 try { | 225 try { |
| 294 context.startActivity(intent); | 226 context.startActivity(intent); |
| 295 } catch (ActivityNotFoundException ex) { | 227 } catch (ActivityNotFoundException ex) { |
| 296 Log.w(TAG, "No application can handle " + contentUrl); | 228 Log.w(TAG, "No application can handle " + contentUrl); |
| 297 } | 229 } |
| 298 } | 230 } |
| 299 } | 231 } |
| OLD | NEW |