summaryrefslogtreecommitdiffstats
path: root/chrome/browser
diff options
context:
space:
mode:
authorananta@chromium.org <ananta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-14 03:42:55 +0000
committerananta@chromium.org <ananta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-14 03:42:55 +0000
commit334a105b240c34841c864e8dd50974d90e0105b1 (patch)
treeed3d36542e3bb7bf1719e0b7268e72ae14698cdb /chrome/browser
parentde23fff1310d85866e800103b50fb04851b6d1bc (diff)
downloadchromium_src-334a105b240c34841c864e8dd50974d90e0105b1.zip
chromium_src-334a105b240c34841c864e8dd50974d90e0105b1.tar.gz
chromium_src-334a105b240c34841c864e8dd50974d90e0105b1.tar.bz2
Allow TabContentsDelegates to process unhandled keyboard messages coming back from the renderer. This is required
for ExternalTabContainer to be able to pass unhandled keyboard accelerator messages back to the external host. This worked before as the focus manager would hand off these messages to keystroke listeners like the ExternalTabContainer. However with the ExternalTabContainer no longer using the focus manager this does not work anymore. Removed the keystroke listener code from the focus manager as the ExternalTabContainer was the only consumer and it does not use it anymore. This fixes bug http://b/issue?id=1975749 Bug=1975749 Review URL: http://codereview.chromium.org/149520 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@20600 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r--chrome/browser/external_tab_container.cc45
-rw-r--r--chrome/browser/external_tab_container.h14
-rw-r--r--chrome/browser/tab_contents/tab_contents_delegate.h8
-rw-r--r--chrome/browser/views/tab_contents/tab_contents_view_win.cc5
4 files changed, 47 insertions, 25 deletions
diff --git a/chrome/browser/external_tab_container.cc b/chrome/browser/external_tab_container.cc
index 732aead..a2d71b5 100644
--- a/chrome/browser/external_tab_container.cc
+++ b/chrome/browser/external_tab_container.cc
@@ -299,6 +299,14 @@ bool ExternalTabContainer::ExecuteContextMenuCommand(int command) {
return true;
}
+bool ExternalTabContainer::HandleKeyboardEvent(
+ const NativeWebKeyboardEvent& event) {
+ return ProcessUnhandledKeyStroke(event.os_event.hwnd,
+ event.os_event.message,
+ event.os_event.wParam,
+ event.os_event.lParam);
+}
+
////////////////////////////////////////////////////////////////////////////////
// ExternalTabContainer, NotificationObserver implementation:
@@ -392,10 +400,25 @@ void ExternalTabContainer::OnDestroy() {
}
////////////////////////////////////////////////////////////////////////////////
-// ExternalTabContainer, views::KeystrokeListener implementation:
+// ExternalTabContainer, private:
+
+void ExternalTabContainer::Uninitialize(HWND window) {
+ registrar_.RemoveAll();
+ if (tab_contents_) {
+ NotificationService::current()->Notify(
+ NotificationType::EXTERNAL_TAB_CLOSED,
+ Source<NavigationController>(&tab_contents_->controller()),
+ Details<ExternalTabContainer>(this));
+
+ delete tab_contents_;
+ tab_contents_ = NULL;
+ }
+}
-bool ExternalTabContainer::ProcessKeyStroke(HWND window, UINT message,
- WPARAM wparam, LPARAM lparam) {
+bool ExternalTabContainer::ProcessUnhandledKeyStroke(HWND window,
+ UINT message,
+ WPARAM wparam,
+ LPARAM lparam) {
if (!automation_) {
return false;
}
@@ -430,19 +453,3 @@ bool ExternalTabContainer::ProcessKeyStroke(HWND window, UINT message,
return false;
}
-
-////////////////////////////////////////////////////////////////////////////////
-// ExternalTabContainer, private:
-
-void ExternalTabContainer::Uninitialize(HWND window) {
- registrar_.RemoveAll();
- if (tab_contents_) {
- NotificationService::current()->Notify(
- NotificationType::EXTERNAL_TAB_CLOSED,
- Source<NavigationController>(&tab_contents_->controller()),
- Details<ExternalTabContainer>(this));
-
- delete tab_contents_;
- tab_contents_ = NULL;
- }
-}
diff --git a/chrome/browser/external_tab_container.h b/chrome/browser/external_tab_container.h
index e69283c..d40a0f4 100644
--- a/chrome/browser/external_tab_container.h
+++ b/chrome/browser/external_tab_container.h
@@ -25,8 +25,7 @@ class RenderViewContextMenuExternalWin;
// TODO(beng): Should override WidgetWin instead of Widget.
class ExternalTabContainer : public TabContentsDelegate,
public NotificationObserver,
- public views::WidgetWin,
- public views::KeystrokeListener {
+ public views::WidgetWin {
public:
ExternalTabContainer(AutomationProvider* automation,
AutomationResourceMessageFilter* filter);
@@ -89,6 +88,8 @@ class ExternalTabContainer : public TabContentsDelegate,
return true;
};
+ virtual bool HandleKeyboardEvent(const NativeWebKeyboardEvent& event);
+
virtual bool TakeFocus(bool reverse);
// Overridden from NotificationObserver:
@@ -96,10 +97,6 @@ class ExternalTabContainer : public TabContentsDelegate,
const NotificationSource& source,
const NotificationDetails& details);
- // Overridden from views::KeystrokeListener:
- virtual bool ProcessKeyStroke(HWND window, UINT message, WPARAM wparam,
- LPARAM lparam);
-
// Handles the context menu display operation. This allows external
// hosts to customize the menu.
virtual bool HandleContextMenu(const ContextMenuParams& params);
@@ -119,6 +116,11 @@ class ExternalTabContainer : public TabContentsDelegate,
// 2. In the destructor.
void Uninitialize(HWND window);
+ // Helper function for processing keystokes coming back from the renderer
+ // process.
+ bool ProcessUnhandledKeyStroke(HWND window, UINT message, WPARAM wparam,
+ LPARAM lparam);
+
TabContents* tab_contents_;
scoped_refptr<AutomationProvider> automation_;
diff --git a/chrome/browser/tab_contents/tab_contents_delegate.h b/chrome/browser/tab_contents/tab_contents_delegate.h
index b93de6e..b00f31f 100644
--- a/chrome/browser/tab_contents/tab_contents_delegate.h
+++ b/chrome/browser/tab_contents/tab_contents_delegate.h
@@ -8,6 +8,7 @@
#include "base/basictypes.h"
#include "base/gfx/native_widget_types.h"
#include "base/gfx/rect.h"
+#include "chrome/common/native_web_keyboard_event.h"
#include "chrome/common/page_transition_types.h"
#include "chrome/common/renderer_preferences.h"
#include "webkit/glue/context_menu.h"
@@ -205,6 +206,13 @@ class TabContentsDelegate {
Profile* profile) {
}
+ // Allows delegates to handle unhandled keyboard messages coming back from
+ // the renderer.
+ // Returns true if the keyboard message was handled.
+ virtual bool HandleKeyboardEvent(const NativeWebKeyboardEvent& event) {
+ return false;
+ }
+
protected:
~TabContentsDelegate() {}
RendererPreferences renderer_preferences_;
diff --git a/chrome/browser/views/tab_contents/tab_contents_view_win.cc b/chrome/browser/views/tab_contents/tab_contents_view_win.cc
index 7b6aabb..543cff4 100644
--- a/chrome/browser/views/tab_contents/tab_contents_view_win.cc
+++ b/chrome/browser/views/tab_contents/tab_contents_view_win.cc
@@ -421,6 +421,11 @@ void TabContentsViewWin::HandleKeyboardEvent(
}
}
+ if (tab_contents()->delegate() &&
+ tab_contents()->delegate()->HandleKeyboardEvent(event)) {
+ return;
+ }
+
// Any unhandled keyboard/character messages should be defproced.
// This allows stuff like Alt+F4, etc to work correctly.
DefWindowProc(event.os_event.hwnd,