| 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; | |
| 11 import android.graphics.RectF; | |
| 12 import android.util.Log; | 10 import android.util.Log; |
| 13 import android.view.ActionMode; | 11 import android.view.ActionMode; |
| 14 import android.view.KeyEvent; | 12 import android.view.KeyEvent; |
| 15 | 13 |
| 16 import org.chromium.base.AccessedByNative; | |
| 17 import org.chromium.base.CalledByNative; | |
| 18 import org.chromium.base.JNINamespace; | |
| 19 import org.chromium.content.browser.SelectActionModeCallback.ActionHandler; | 14 import org.chromium.content.browser.SelectActionModeCallback.ActionHandler; |
| 20 | 15 |
| 21 import java.net.URISyntaxException; | 16 import java.net.URISyntaxException; |
| 22 | 17 |
| 23 /** | 18 /** |
| 24 * Main callback class used by ContentView. | 19 * Main callback class used by ContentView. |
| 25 * | 20 * |
| 26 * This contains the superset of callbacks required to implement the browser UI
and the callbacks | 21 * This contains the superset of callbacks required to implement the browser UI
and the callbacks |
| 27 * required to implement the WebView API. | 22 * required to implement the WebView API. |
| 28 * The memory and reference ownership of this class is unusual - see the .cc fi
le and ContentView | 23 * The memory and reference ownership of this class is unusual - see the .cc fi
le and ContentView |
| 29 * for more details. | 24 * for more details. |
| 30 * | 25 * |
| 31 * TODO(mkosiba): Rid this guy of default implementations. This class is used b
y both WebView and | 26 * 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 | 27 * the browser and we don't want a the browser-specific default implementation
to accidentally leak |
| 33 * over to WebView. | 28 * over to WebView. |
| 34 */ | 29 */ |
| 35 public class ContentViewClient { | 30 public class ContentViewClient { |
| 36 // Tag used for logging. | 31 // Tag used for logging. |
| 37 private static final String TAG = "ContentViewClient"; | 32 private static final String TAG = "ContentViewClient"; |
| 38 | 33 |
| 39 // Native class pointer which will be set by nativeInit() | |
| 40 @AccessedByNative | |
| 41 private int mNativeClazz = 0; | |
| 42 | |
| 43 public void onUpdateTitle(String title) { | 34 public void onUpdateTitle(String title) { |
| 44 } | 35 } |
| 45 | 36 |
| 46 public void onTabCrash(int pid) { | 37 public void onTabCrash() { |
| 47 } | 38 } |
| 48 | 39 |
| 49 public boolean shouldOverrideKeyEvent(KeyEvent event) { | 40 public boolean shouldOverrideKeyEvent(KeyEvent event) { |
| 50 int keyCode = event.getKeyCode(); | 41 int keyCode = event.getKeyCode(); |
| 51 // We need to send almost every key to WebKit. However: | 42 // We need to send almost every key to WebKit. However: |
| 52 // 1. We don't want to block the device on the renderer for | 43 // 1. We don't want to block the device on the renderer for |
| 53 // some keys like menu, home, call. | 44 // some keys like menu, home, call. |
| 54 // 2. There are no WebKit equivalents for some of these keys | 45 // 2. There are no WebKit equivalents for some of these keys |
| 55 // (see app/keyboard_codes_win.h) | 46 // (see app/keyboard_codes_win.h) |
| 56 // Note that these are not the same set as KeyEvent.isSystemKey: | 47 // Note that these are not the same set as KeyEvent.isSystemKey: |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 return; | 133 return; |
| 143 } | 134 } |
| 144 | 135 |
| 145 try { | 136 try { |
| 146 context.startActivity(intent); | 137 context.startActivity(intent); |
| 147 } catch (ActivityNotFoundException ex) { | 138 } catch (ActivityNotFoundException ex) { |
| 148 Log.w(TAG, "No application can handle " + intentUrl); | 139 Log.w(TAG, "No application can handle " + intentUrl); |
| 149 } | 140 } |
| 150 } | 141 } |
| 151 } | 142 } |
| OLD | NEW |