summaryrefslogtreecommitdiffstats
path: root/chrome/browser/views
diff options
context:
space:
mode:
authorjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-02 01:25:41 +0000
committerjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-02 01:25:41 +0000
commit97df4b330f4a2b1a34adb1eb8e5f5e7f60d716ff (patch)
tree46cd48cb3b533fb88bb6e6975427e7741578cb5c /chrome/browser/views
parent7a0f5a3abf37e21eb15f4fe4058e917426e2e105 (diff)
downloadchromium_src-97df4b330f4a2b1a34adb1eb8e5f5e7f60d716ff.zip
chromium_src-97df4b330f4a2b1a34adb1eb8e5f5e7f60d716ff.tar.gz
chromium_src-97df4b330f4a2b1a34adb1eb8e5f5e7f60d716ff.tar.bz2
Don't send tab switching/killing/creating keyboard accelerators to pages. This avoids tabs maliciously preventing closing using ctrl+f4/ctrl+w/alt+f4, and also hung/slow renderers from making tab cycling sluggish.
BUG=5496 TEST=added ui test Review URL: http://codereview.chromium.org/224023 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@27814 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/views')
-rw-r--r--chrome/browser/views/frame/browser_view.cc20
-rw-r--r--chrome/browser/views/frame/browser_view.h1
2 files changed, 21 insertions, 0 deletions
diff --git a/chrome/browser/views/frame/browser_view.cc b/chrome/browser/views/frame/browser_view.cc
index 50fd3bd..a9fea14 100644
--- a/chrome/browser/views/frame/browser_view.cc
+++ b/chrome/browser/views/frame/browser_view.cc
@@ -12,6 +12,7 @@
#include "base/command_line.h"
#include "base/keyboard_codes.h"
#include "base/time.h"
+#include "base/win_util.h"
#include "build/build_config.h"
#include "chrome/app/chrome_dll_resource.h"
#include "chrome/browser/app_modal_dialog_queue.h"
@@ -48,6 +49,7 @@
#include "chrome/browser/tab_contents/tab_contents_view.h"
#include "chrome/browser/window_sizer.h"
#include "chrome/common/chrome_switches.h"
+#include "chrome/common/native_web_keyboard_event.h"
#include "chrome/common/native_window_notification_source.h"
#include "chrome/common/notification_service.h"
#include "chrome/common/pref_names.h"
@@ -1127,6 +1129,24 @@ void BrowserView::ShowAppMenu() {
toolbar_->app_menu()->Activate();
}
+int BrowserView::GetCommandId(const NativeWebKeyboardEvent& event) {
+ views::Accelerator accelerator(
+ win_util::WinToKeyboardCode(event.windowsKeyCode),
+ (event.modifiers & NativeWebKeyboardEvent::ShiftKey) ==
+ NativeWebKeyboardEvent::ShiftKey,
+ (event.modifiers & NativeWebKeyboardEvent::ControlKey) ==
+ NativeWebKeyboardEvent::ControlKey,
+ (event.modifiers & NativeWebKeyboardEvent::AltKey) ==
+ NativeWebKeyboardEvent::AltKey);
+
+ std::map<views::Accelerator, int>::const_iterator iter =
+ accelerator_table_.find(accelerator);
+ if (iter == accelerator_table_.end())
+ return -1;
+
+ return iter->second;
+}
+
///////////////////////////////////////////////////////////////////////////////
// BrowserView, BrowserWindowTesting implementation:
diff --git a/chrome/browser/views/frame/browser_view.h b/chrome/browser/views/frame/browser_view.h
index f910e29..f4f2c2e 100644
--- a/chrome/browser/views/frame/browser_view.h
+++ b/chrome/browser/views/frame/browser_view.h
@@ -261,6 +261,7 @@ class BrowserView : public BrowserWindow,
bool show_history);
virtual void ShowAppMenu();
virtual void ShowPageMenu();
+ virtual int GetCommandId(const NativeWebKeyboardEvent& event);
// Overridden from BrowserWindowTesting:
virtual BookmarkBarView* GetBookmarkBarView() const;