Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(279)

Unified Diff: content/public/android/java/src/org/chromium/content/browser/ContentViewClient.java

Issue 308313004: Extract shouldPropagateKey method from ContentViewClient. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/public/android/java/src/org/chromium/content/browser/ContentViewClient.java
diff --git a/content/public/android/java/src/org/chromium/content/browser/ContentViewClient.java b/content/public/android/java/src/org/chromium/content/browser/ContentViewClient.java
index 7885f3ccfcdb685598da2e49da39e56ae646fbc8..81825090adeb07caa1924cdc56684c2637a75c5e 100644
--- a/content/public/android/java/src/org/chromium/content/browser/ContentViewClient.java
+++ b/content/public/android/java/src/org/chromium/content/browser/ContentViewClient.java
@@ -53,27 +53,8 @@ public class ContentViewClient {
public boolean shouldOverrideKeyEvent(KeyEvent event) {
int keyCode = event.getKeyCode();
- // We need to send almost every key to WebKit. However:
- // 1. We don't want to block the device on the renderer for
- // some keys like menu, home, call.
- // 2. There are no WebKit equivalents for some of these keys
- // (see app/keyboard_codes_win.h)
- // Note that these are not the same set as KeyEvent.isSystemKey:
- // for instance, AKEYCODE_MEDIA_* will be dispatched to webkit.
- if (keyCode == KeyEvent.KEYCODE_MENU ||
- keyCode == KeyEvent.KEYCODE_HOME ||
- keyCode == KeyEvent.KEYCODE_BACK ||
- keyCode == KeyEvent.KEYCODE_CALL ||
- keyCode == KeyEvent.KEYCODE_ENDCALL ||
- keyCode == KeyEvent.KEYCODE_POWER ||
- keyCode == KeyEvent.KEYCODE_HEADSETHOOK ||
- keyCode == KeyEvent.KEYCODE_CAMERA ||
- keyCode == KeyEvent.KEYCODE_FOCUS ||
- keyCode == KeyEvent.KEYCODE_VOLUME_DOWN ||
- keyCode == KeyEvent.KEYCODE_VOLUME_MUTE ||
- keyCode == KeyEvent.KEYCODE_VOLUME_UP) {
- return true;
- }
+
+ if (!shouldPropagateKey(keyCode)) return true;
// We also have to intercept some shortcuts before we send them to the ContentView.
if (event.isCtrlPressed() && (
@@ -180,4 +161,31 @@ public class ContentViewClient {
return false;
}
+ /**
+ * Check whether a key should be propagated to the embedder or not.
+ * We need to send almost every key to Blink. However:
+ * 1. We don't want to block the device on the renderer for
+ * some keys like menu, home, call.
+ * 2. There are no WebKit equivalents for some of these keys
+ * (see app/keyboard_codes_win.h)
+ * Note that these are not the same set as KeyEvent.isSystemKey:
+ * for instance, AKEYCODE_MEDIA_* will be dispatched to webkit*.
+ */
+ public static boolean shouldPropagateKey(int keyCode) {
+ if (keyCode == KeyEvent.KEYCODE_MENU ||
+ keyCode == KeyEvent.KEYCODE_HOME ||
+ keyCode == KeyEvent.KEYCODE_BACK ||
+ keyCode == KeyEvent.KEYCODE_CALL ||
+ keyCode == KeyEvent.KEYCODE_ENDCALL ||
+ keyCode == KeyEvent.KEYCODE_POWER ||
+ keyCode == KeyEvent.KEYCODE_HEADSETHOOK ||
+ keyCode == KeyEvent.KEYCODE_CAMERA ||
+ keyCode == KeyEvent.KEYCODE_FOCUS ||
+ keyCode == KeyEvent.KEYCODE_VOLUME_DOWN ||
+ keyCode == KeyEvent.KEYCODE_VOLUME_MUTE ||
+ keyCode == KeyEvent.KEYCODE_VOLUME_UP) {
+ return false;
+ }
+ return true;
+ }
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698