diff options
Diffstat (limited to 'chrome/browser/extensions')
-rw-r--r-- | chrome/browser/extensions/extension_host.cc | 17 | ||||
-rw-r--r-- | chrome/browser/extensions/extension_host.h | 7 | ||||
-rw-r--r-- | chrome/browser/extensions/extension_host_mac.h | 4 | ||||
-rw-r--r-- | chrome/browser/extensions/extension_host_mac.mm | 17 |
4 files changed, 37 insertions, 8 deletions
diff --git a/chrome/browser/extensions/extension_host.cc b/chrome/browser/extensions/extension_host.cc index e9fb5c4..78d83da 100644 --- a/chrome/browser/extensions/extension_host.cc +++ b/chrome/browser/extensions/extension_host.cc @@ -570,6 +570,7 @@ void ExtensionHost::TakeFocus(bool reverse) { bool ExtensionHost::PreHandleKeyboardEvent(const NativeWebKeyboardEvent& event, bool* is_keyboard_shortcut) { if (extension_host_type_ == ViewType::EXTENSION_POPUP && + event.type == NativeWebKeyboardEvent::RawKeyDown && event.windowsKeyCode == base::VKEY_ESCAPE) { DCHECK(is_keyboard_shortcut != NULL); *is_keyboard_shortcut = true; @@ -578,13 +579,17 @@ bool ExtensionHost::PreHandleKeyboardEvent(const NativeWebKeyboardEvent& event, } void ExtensionHost::HandleKeyboardEvent(const NativeWebKeyboardEvent& event) { - if (extension_host_type_ == ViewType::EXTENSION_POPUP && - event.windowsKeyCode == base::VKEY_ESCAPE) { - NotificationService::current()->Notify( - NotificationType::EXTENSION_HOST_VIEW_SHOULD_CLOSE, - Source<Profile>(profile_), - Details<ExtensionHost>(this)); + if (extension_host_type_ == ViewType::EXTENSION_POPUP) { + if (event.type == NativeWebKeyboardEvent::RawKeyDown && + event.windowsKeyCode == base::VKEY_ESCAPE) { + NotificationService::current()->Notify( + NotificationType::EXTENSION_HOST_VIEW_SHOULD_CLOSE, + Source<Profile>(profile_), + Details<ExtensionHost>(this)); + return; + } } + UnhandledKeyboardEvent(event); } void ExtensionHost::HandleMouseEvent() { diff --git a/chrome/browser/extensions/extension_host.h b/chrome/browser/extensions/extension_host.h index 2bd7906..c5ea9b2 100644 --- a/chrome/browser/extensions/extension_host.h +++ b/chrome/browser/extensions/extension_host.h @@ -81,6 +81,8 @@ class ExtensionHost : public ExtensionPopupHost::PopupDelegate, } Profile* profile() const { return profile_; } + ViewType::Type extension_host_type() const { return extension_host_type_; } + // Sets the the ViewType of this host (e.g. mole, toolstrip). void SetRenderViewType(ViewType::Type type); @@ -199,6 +201,11 @@ class ExtensionHost : public ExtensionPopupHost::PopupDelegate, return view()->native_view(); } + // Handles keyboard events that were not handled by HandleKeyboardEvent(). + // Platform specific implementation may override this method to handle the + // event in platform specific way. + virtual void UnhandledKeyboardEvent(const NativeWebKeyboardEvent& event) {} + // Returns true if we're hosting a background page. // This isn't valid until CreateRenderView is called. bool is_background_page() const { return !view(); } diff --git a/chrome/browser/extensions/extension_host_mac.h b/chrome/browser/extensions/extension_host_mac.h index 0624826..8032fd9 100644 --- a/chrome/browser/extensions/extension_host_mac.h +++ b/chrome/browser/extensions/extension_host_mac.h @@ -1,4 +1,4 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Copyright (c) 2010 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -21,6 +21,8 @@ class ExtensionHostMac : public ExtensionHost { virtual void ShowCreatedWidgetInternal(RenderWidgetHostView* widget_host_view, const gfx::Rect& initial_pos); private: + virtual void UnhandledKeyboardEvent(const NativeWebKeyboardEvent& event); + DISALLOW_COPY_AND_ASSIGN(ExtensionHostMac); }; diff --git a/chrome/browser/extensions/extension_host_mac.mm b/chrome/browser/extensions/extension_host_mac.mm index d541deb..2dfc336 100644 --- a/chrome/browser/extensions/extension_host_mac.mm +++ b/chrome/browser/extensions/extension_host_mac.mm @@ -1,10 +1,12 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Copyright (c) 2010 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "chrome/browser/extensions/extension_host_mac.h" +#import "chrome/browser/cocoa/chrome_event_processing_window.h" #include "chrome/browser/renderer_host/render_widget_host_view_mac.h" +#include "chrome/common/native_web_keyboard_event.h" RenderWidgetHostView* ExtensionHostMac::CreateNewWidgetInternal( int route_id, @@ -35,3 +37,16 @@ void ExtensionHostMac::ShowCreatedWidgetInternal( static_cast<RenderWidgetHostViewMac*>(widget_host_view); [widget_view_mac->native_view() release]; } + +void ExtensionHostMac::UnhandledKeyboardEvent( + const NativeWebKeyboardEvent& event) { + if (event.skip_in_browser || event.type == NativeWebKeyboardEvent::Char || + extension_host_type() != ViewType::EXTENSION_POPUP) { + return; + } + + ChromeEventProcessingWindow* event_window = + static_cast<ChromeEventProcessingWindow*>([view()->native_view() window]); + DCHECK([event_window isKindOfClass:[ChromeEventProcessingWindow class]]); + [event_window redispatchKeyEvent:event.os_event]; +} |