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

Unified Diff: chrome/browser/guest_view/web_view/web_view_guest.cc

Issue 288113005: <webview>: Cleanup Pointer Lock & Simplify HandleKeyboardEvent (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Removed unnecessary braces 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
Index: chrome/browser/guest_view/web_view/web_view_guest.cc
diff --git a/chrome/browser/guest_view/web_view/web_view_guest.cc b/chrome/browser/guest_view/web_view/web_view_guest.cc
index 91d46d280e9eff253aeb473397b4ae2ee347b421..02279b2e0bc0b0b2479e46eac2a63c8e623bca27 100644
--- a/chrome/browser/guest_view/web_view/web_view_guest.cc
+++ b/chrome/browser/guest_view/web_view/web_view_guest.cc
@@ -402,36 +402,22 @@ void WebViewGuest::GuestProcessGone(base::TerminationStatus status) {
DispatchEvent(new GuestViewBase::Event(webview::kEventExit, args.Pass()));
}
-bool WebViewGuest::HandleKeyboardEvent(
+void WebViewGuest::HandleKeyboardEvent(
const content::NativeWebKeyboardEvent& event) {
- if (event.type != blink::WebInputEvent::RawKeyDown)
- return false;
-
-#if defined(OS_MACOSX)
- if (event.modifiers != blink::WebInputEvent::MetaKey)
- return false;
-
- if (event.windowsKeyCode == ui::VKEY_OEM_4) {
- Go(-1);
- return true;
- }
+ if (!attached())
+ return;
- if (event.windowsKeyCode == ui::VKEY_OEM_6) {
- Go(1);
- return true;
- }
-#else
- if (event.windowsKeyCode == ui::VKEY_BROWSER_BACK) {
- Go(-1);
- return true;
- }
+ if (HandleKeyboardShortcuts(event))
+ return;
- if (event.windowsKeyCode == ui::VKEY_BROWSER_FORWARD) {
- Go(1);
- return true;
- }
-#endif
- return false;
+ // Send the unhandled keyboard events back to the embedder to reprocess them.
+ // TODO(fsamuel): This introduces the possibility of out-of-order keyboard
+ // events because the guest may be arbitrarily delayed when responding to
+ // keyboard events. In that time, the embedder may have received and processed
+ // additional key events. This needs to be fixed as soon as possible.
+ // See http://crbug.com/229882.
+ embedder_web_contents()->GetDelegate()->HandleKeyboardEvent(
+ web_contents(), event);
}
bool WebViewGuest::IsDragAndDropEnabled() {
@@ -1082,6 +1068,46 @@ int WebViewGuest::RequestPermissionInternal(
return request_id;
}
+bool WebViewGuest::HandleKeyboardShortcuts(
+ const content::NativeWebKeyboardEvent& event) {
+ if (event.type != blink::WebInputEvent::RawKeyDown)
+ return false;
+
+ // If the user hits the escape key without any modifiers then unlock the
+ // mouse if necessary.
+ if ((event.windowsKeyCode == ui::VKEY_ESCAPE) &&
+ !(event.modifiers & blink::WebInputEvent::InputModifiers)) {
+ return guest_web_contents()->GotResponseToLockMouseRequest(false);
+ }
+
+#if defined(OS_MACOSX)
+ if (event.modifiers != blink::WebInputEvent::MetaKey)
+ return false;
+
+ if (event.windowsKeyCode == ui::VKEY_OEM_4) {
+ Go(-1);
+ return true;
+ }
+
+ if (event.windowsKeyCode == ui::VKEY_OEM_6) {
+ Go(1);
+ return true;
+ }
+#else
+ if (event.windowsKeyCode == ui::VKEY_BROWSER_BACK) {
+ Go(-1);
+ return true;
+ }
+
+ if (event.windowsKeyCode == ui::VKEY_BROWSER_FORWARD) {
+ Go(1);
+ return true;
+ }
+#endif
+
+ return false;
+}
+
WebViewGuest::PermissionResponseInfo::PermissionResponseInfo()
: permission_type(BROWSER_PLUGIN_PERMISSION_TYPE_UNKNOWN),
allowed_by_default(false) {
« no previous file with comments | « chrome/browser/guest_view/web_view/web_view_guest.h ('k') | content/browser/browser_plugin/browser_plugin_embedder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698