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

Side by Side 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, 6 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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.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.util.Log; 10 import android.util.Log;
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 * @param topControlsOffsetYPix The Y offset of the top controls in physical pixels. 46 * @param topControlsOffsetYPix The Y offset of the top controls in physical pixels.
47 * @param contentOffsetYPix The Y offset of the content in physical pixels. 47 * @param contentOffsetYPix The Y offset of the content in physical pixels.
48 * @param overdrawBottomHeightPix The overdraw height. 48 * @param overdrawBottomHeightPix The overdraw height.
49 */ 49 */
50 public void onOffsetsForFullscreenChanged( 50 public void onOffsetsForFullscreenChanged(
51 float topControlsOffsetYPix, float contentOffsetYPix, float overdraw BottomHeightPix) { 51 float topControlsOffsetYPix, float contentOffsetYPix, float overdraw BottomHeightPix) {
52 } 52 }
53 53
54 public boolean shouldOverrideKeyEvent(KeyEvent event) { 54 public boolean shouldOverrideKeyEvent(KeyEvent event) {
55 int keyCode = event.getKeyCode(); 55 int keyCode = event.getKeyCode();
56 // We need to send almost every key to WebKit. However: 56
57 // 1. We don't want to block the device on the renderer for 57 if (!shouldPropagateKey(keyCode)) return true;
58 // some keys like menu, home, call.
59 // 2. There are no WebKit equivalents for some of these keys
60 // (see app/keyboard_codes_win.h)
61 // Note that these are not the same set as KeyEvent.isSystemKey:
62 // for instance, AKEYCODE_MEDIA_* will be dispatched to webkit.
63 if (keyCode == KeyEvent.KEYCODE_MENU ||
64 keyCode == KeyEvent.KEYCODE_HOME ||
65 keyCode == KeyEvent.KEYCODE_BACK ||
66 keyCode == KeyEvent.KEYCODE_CALL ||
67 keyCode == KeyEvent.KEYCODE_ENDCALL ||
68 keyCode == KeyEvent.KEYCODE_POWER ||
69 keyCode == KeyEvent.KEYCODE_HEADSETHOOK ||
70 keyCode == KeyEvent.KEYCODE_CAMERA ||
71 keyCode == KeyEvent.KEYCODE_FOCUS ||
72 keyCode == KeyEvent.KEYCODE_VOLUME_DOWN ||
73 keyCode == KeyEvent.KEYCODE_VOLUME_MUTE ||
74 keyCode == KeyEvent.KEYCODE_VOLUME_UP) {
75 return true;
76 }
77 58
78 // We also have to intercept some shortcuts before we send them to the C ontentView. 59 // We also have to intercept some shortcuts before we send them to the C ontentView.
79 if (event.isCtrlPressed() && ( 60 if (event.isCtrlPressed() && (
80 keyCode == KeyEvent.KEYCODE_TAB || 61 keyCode == KeyEvent.KEYCODE_TAB ||
81 keyCode == KeyEvent.KEYCODE_W || 62 keyCode == KeyEvent.KEYCODE_W ||
82 keyCode == KeyEvent.KEYCODE_F4)) { 63 keyCode == KeyEvent.KEYCODE_F4)) {
83 return true; 64 return true;
84 } 65 }
85 66
86 return false; 67 return false;
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 154
174 /** 155 /**
175 * Called when BrowserMediaPlayerManager wants to load a media resource. 156 * Called when BrowserMediaPlayerManager wants to load a media resource.
176 * @param url the URL of media resource to load. 157 * @param url the URL of media resource to load.
177 * @return true to prevent the resource from being loaded. 158 * @return true to prevent the resource from being loaded.
178 */ 159 */
179 public boolean shouldBlockMediaRequest(String url) { 160 public boolean shouldBlockMediaRequest(String url) {
180 return false; 161 return false;
181 } 162 }
182 163
164 /**
165 * Check whether a key should be propagated to the embedder or not.
166 * We need to send almost every key to Blink. However:
167 * 1. We don't want to block the device on the renderer for
168 * some keys like menu, home, call.
169 * 2. There are no WebKit equivalents for some of these keys
170 * (see app/keyboard_codes_win.h)
171 * Note that these are not the same set as KeyEvent.isSystemKey:
172 * for instance, AKEYCODE_MEDIA_* will be dispatched to webkit*.
173 */
174 public static boolean shouldPropagateKey(int keyCode) {
175 if (keyCode == KeyEvent.KEYCODE_MENU ||
176 keyCode == KeyEvent.KEYCODE_HOME ||
177 keyCode == KeyEvent.KEYCODE_BACK ||
178 keyCode == KeyEvent.KEYCODE_CALL ||
179 keyCode == KeyEvent.KEYCODE_ENDCALL ||
180 keyCode == KeyEvent.KEYCODE_POWER ||
181 keyCode == KeyEvent.KEYCODE_HEADSETHOOK ||
182 keyCode == KeyEvent.KEYCODE_CAMERA ||
183 keyCode == KeyEvent.KEYCODE_FOCUS ||
184 keyCode == KeyEvent.KEYCODE_VOLUME_DOWN ||
185 keyCode == KeyEvent.KEYCODE_VOLUME_MUTE ||
186 keyCode == KeyEvent.KEYCODE_VOLUME_UP) {
187 return false;
188 }
189 return true;
190 }
183 } 191 }
OLDNEW
« 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