diff options
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/browser/autocomplete/autocomplete_edit.h | 3 | ||||
-rw-r--r-- | chrome/browser/autocomplete/autocomplete_edit_view_gtk.cc | 1 | ||||
-rw-r--r-- | chrome/browser/chromeos/compact_navigation_bar.cc | 3 | ||||
-rw-r--r-- | chrome/browser/chromeos/compact_navigation_bar.h | 1 | ||||
-rw-r--r-- | chrome/browser/cocoa/location_bar_view_mac.h | 1 | ||||
-rw-r--r-- | chrome/browser/cocoa/location_bar_view_mac.mm | 3 | ||||
-rw-r--r-- | chrome/browser/gtk/location_bar_view_gtk.cc | 3 | ||||
-rw-r--r-- | chrome/browser/gtk/location_bar_view_gtk.h | 1 | ||||
-rw-r--r-- | chrome/browser/views/location_bar_view.cc | 17 | ||||
-rw-r--r-- | chrome/browser/views/location_bar_view.h | 1 | ||||
-rw-r--r-- | chrome/browser/views/tab_contents/tab_contents_view_gtk.cc | 30 |
11 files changed, 62 insertions, 2 deletions
diff --git a/chrome/browser/autocomplete/autocomplete_edit.h b/chrome/browser/autocomplete/autocomplete_edit.h index 4d6c4a7..1264a32 100644 --- a/chrome/browser/autocomplete/autocomplete_edit.h +++ b/chrome/browser/autocomplete/autocomplete_edit.h @@ -47,6 +47,9 @@ class AutocompleteEditController { // the edit is guaranteed to be showing the permanent text. virtual void OnInputInProgress(bool in_progress) = 0; + // Called whenever the autocomplete edit gets focused. + virtual void OnSetFocus() = 0; + // Returns the favicon of the current page. virtual SkBitmap GetFavIcon() const = 0; diff --git a/chrome/browser/autocomplete/autocomplete_edit_view_gtk.cc b/chrome/browser/autocomplete/autocomplete_edit_view_gtk.cc index 0d47780f..cbeb156 100644 --- a/chrome/browser/autocomplete/autocomplete_edit_view_gtk.cc +++ b/chrome/browser/autocomplete/autocomplete_edit_view_gtk.cc @@ -750,6 +750,7 @@ gboolean AutocompleteEditViewGtk::HandleViewFocusIn() { GdkModifierType modifiers; gdk_window_get_pointer(text_view_->window, NULL, NULL, &modifiers); model_->OnSetFocus((modifiers & GDK_CONTROL_MASK) != 0); + controller_->OnSetFocus(); // TODO(deanm): Some keyword hit business, etc here. return FALSE; // Continue propagation. diff --git a/chrome/browser/chromeos/compact_navigation_bar.cc b/chrome/browser/chromeos/compact_navigation_bar.cc index 415f763..b68ae41 100644 --- a/chrome/browser/chromeos/compact_navigation_bar.cc +++ b/chrome/browser/chromeos/compact_navigation_bar.cc @@ -188,6 +188,9 @@ void CompactNavigationBar::OnChanged() { void CompactNavigationBar::OnInputInProgress(bool in_progress) { } +void CompactNavigationBar::OnSetFocus() { +} + SkBitmap CompactNavigationBar::GetFavIcon() const { return SkBitmap(); } diff --git a/chrome/browser/chromeos/compact_navigation_bar.h b/chrome/browser/chromeos/compact_navigation_bar.h index f423996..ce3cd5f 100644 --- a/chrome/browser/chromeos/compact_navigation_bar.h +++ b/chrome/browser/chromeos/compact_navigation_bar.h @@ -51,6 +51,7 @@ class CompactNavigationBar : public views::View, const GURL& alternate_nav_url); virtual void OnChanged(); virtual void OnInputInProgress(bool in_progress); + virtual void OnSetFocus(); virtual SkBitmap GetFavIcon() const; virtual std::wstring GetTitle() const; diff --git a/chrome/browser/cocoa/location_bar_view_mac.h b/chrome/browser/cocoa/location_bar_view_mac.h index 6a4099d..e35b421 100644 --- a/chrome/browser/cocoa/location_bar_view_mac.h +++ b/chrome/browser/cocoa/location_bar_view_mac.h @@ -65,6 +65,7 @@ class LocationBarViewMac : public AutocompleteEditController, const GURL& alternate_nav_url); virtual void OnChanged(); virtual void OnInputInProgress(bool in_progress); + virtual void OnSetFocus(); virtual SkBitmap GetFavIcon() const; virtual std::wstring GetTitle() const; diff --git a/chrome/browser/cocoa/location_bar_view_mac.mm b/chrome/browser/cocoa/location_bar_view_mac.mm index de3f6ef..6410984 100644 --- a/chrome/browser/cocoa/location_bar_view_mac.mm +++ b/chrome/browser/cocoa/location_bar_view_mac.mm @@ -224,6 +224,9 @@ void LocationBarViewMac::OnInputInProgress(bool in_progress) { NOTIMPLEMENTED(); } +void LocationBarViewMac::OnSetFocus() { +} + SkBitmap LocationBarViewMac::GetFavIcon() const { NOTIMPLEMENTED(); return SkBitmap(); diff --git a/chrome/browser/gtk/location_bar_view_gtk.cc b/chrome/browser/gtk/location_bar_view_gtk.cc index d99b27a..8694c41 100644 --- a/chrome/browser/gtk/location_bar_view_gtk.cc +++ b/chrome/browser/gtk/location_bar_view_gtk.cc @@ -346,6 +346,9 @@ void LocationBarViewGtk::OnInputInProgress(bool in_progress) { Update(NULL); } +void LocationBarViewGtk::OnSetFocus() { +} + SkBitmap LocationBarViewGtk::GetFavIcon() const { NOTIMPLEMENTED(); return SkBitmap(); diff --git a/chrome/browser/gtk/location_bar_view_gtk.h b/chrome/browser/gtk/location_bar_view_gtk.h index ebf7035..87ffd7d 100644 --- a/chrome/browser/gtk/location_bar_view_gtk.h +++ b/chrome/browser/gtk/location_bar_view_gtk.h @@ -57,6 +57,7 @@ class LocationBarViewGtk : public AutocompleteEditController, PageTransition::Type transition, const GURL& alternate_nav_url); virtual void OnChanged(); + virtual void OnSetFocus(); virtual void OnInputInProgress(bool in_progress); virtual SkBitmap GetFavIcon() const; virtual std::wstring GetTitle() const; diff --git a/chrome/browser/views/location_bar_view.cc b/chrome/browser/views/location_bar_view.cc index eeef5b9..5dbcad8 100644 --- a/chrome/browser/views/location_bar_view.cc +++ b/chrome/browser/views/location_bar_view.cc @@ -15,6 +15,7 @@ #include "app/l10n_util.h" #include "app/resource_bundle.h" #include "base/file_util.h" +#include "base/keyboard_codes.h" #include "base/path_service.h" #include "base/string_util.h" #include "chrome/app/chrome_dll_resource.h" @@ -381,6 +382,15 @@ void LocationBarView::OnChanged() { DoLayout(false); } +void LocationBarView::OnSetFocus() { + views::FocusManager* focus_manager = GetFocusManager(); + if (!focus_manager) { + NOTREACHED(); + return; + } + focus_manager->SetFocusedView(this); +} + SkBitmap LocationBarView::GetFavIcon() const { DCHECK(delegate_); DCHECK(delegate_->GetTabContents()); @@ -945,6 +955,13 @@ bool LocationBarView::SkipDefaultKeyEventProcessing(const views::KeyEvent& e) { #if defined(OS_WIN) return location_entry_->SkipDefaultKeyEventProcessing(e); #else + // TODO(jcampan): We need to refactor the code of + // AutocompleteEditViewWin::SkipDefaultKeyEventProcessing into this class so + // it can be shared between Windows and Linux. + // For now, we just override back-space as it is the accelerator for back + // navigation. + if (e.GetCharacter() == base::VKEY_BACK) + return true; return false; #endif } diff --git a/chrome/browser/views/location_bar_view.h b/chrome/browser/views/location_bar_view.h index a127ab9..dcc00da 100644 --- a/chrome/browser/views/location_bar_view.h +++ b/chrome/browser/views/location_bar_view.h @@ -109,6 +109,7 @@ class LocationBarView : public LocationBar, virtual void OnInputInProgress(bool in_progress) { delegate_->OnInputInProgress(in_progress); } + virtual void OnSetFocus(); virtual SkBitmap GetFavIcon() const; virtual std::wstring GetTitle() const; 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) { |