summaryrefslogtreecommitdiffstats
path: root/chrome/browser/views/tab_contents
diff options
context:
space:
mode:
authorjcampan@chromium.org <jcampan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-03 22:30:27 +0000
committerjcampan@chromium.org <jcampan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-03 22:30:27 +0000
commit5bc862f799bb4e8292c685a04a06fd0fa3ae72db (patch)
treea605ea0df0b1c08f8096dabf3b357849f317c9b9 /chrome/browser/views/tab_contents
parentbd7a9abd4090d3ace7c2f2a9b67d6a66a8b9e3d3 (diff)
downloadchromium_src-5bc862f799bb4e8292c685a04a06fd0fa3ae72db.zip
chromium_src-5bc862f799bb4e8292c685a04a06fd0fa3ae72db.tar.gz
chromium_src-5bc862f799bb4e8292c685a04a06fd0fa3ae72db.tar.bz2
Fixing focus in location bar and accelerators on Linux toolkit views.
BUG=None TEST=Focus the location bar, deactive/reactivate the browser window with Alt-Tab, the focus should still be on the location bar. Click few links on a page to have a history navigation. Focus the location bar, use backspace to delete some text. Focus a text area in a web page, make sure backspace works as expected (deletes text). Now click on a non text area, press backspace. You should trigger a navigate back. Review URL: http://codereview.chromium.org/185014 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@25389 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/views/tab_contents')
-rw-r--r--chrome/browser/views/tab_contents/tab_contents_view_gtk.cc30
1 files changed, 28 insertions, 2 deletions
diff --git a/chrome/browser/views/tab_contents/tab_contents_view_gtk.cc b/chrome/browser/views/tab_contents/tab_contents_view_gtk.cc
index 54f22b4..1d566a3 100644
--- a/chrome/browser/views/tab_contents/tab_contents_view_gtk.cc
+++ b/chrome/browser/views/tab_contents/tab_contents_view_gtk.cc
@@ -239,8 +239,34 @@ void TabContentsViewGtk::TakeFocus(bool reverse) {
void TabContentsViewGtk::HandleKeyboardEvent(
const NativeWebKeyboardEvent& event) {
- NOTIMPLEMENTED();
- // TODO(port): could be an accelerator, pass to parent.
+ // The renderer returned a keyboard event it did not process. This may be
+ // a keyboard shortcut that we have to process.
+ if (event.type != WebInputEvent::RawKeyDown)
+ return;
+
+ views::FocusManager* focus_manager =
+ views::FocusManager::GetFocusManagerForNativeView(GetNativeView());
+ // We may not have a focus_manager at this point (if the tab has been switched
+ // by the time this message returned).
+ if (!focus_manager)
+ return;
+
+ bool shift_pressed = (event.modifiers & WebInputEvent::ShiftKey) ==
+ WebInputEvent::ShiftKey;
+ bool ctrl_pressed = (event.modifiers & WebInputEvent::ControlKey) ==
+ WebInputEvent::ControlKey;
+ bool alt_pressed = (event.modifiers & WebInputEvent::AltKey) ==
+ WebInputEvent::AltKey;
+
+ focus_manager->ProcessAccelerator(views::Accelerator(event.os_event->keyval,
+ shift_pressed,
+ ctrl_pressed,
+ alt_pressed));
+ // DANGER: |this| could be deleted now!
+
+ // Note that we do not handle Gtk mnemonics/accelerators or binding set here
+ // (as it is done in BrowserWindowGtk::HandleKeyboardEvent), as we override
+ // Gtk behavior completely.
}
void TabContentsViewGtk::ShowContextMenu(const ContextMenuParams& params) {