Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1307)

Unified Diff: chrome/browser/browser.cc

Issue 400012: Refactor the keyboard events handling code related to RenderViewHostDelegate:... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 11 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/browser.h ('k') | chrome/browser/browser_keyevents_browsertest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/browser.cc
===================================================================
--- chrome/browser/browser.cc (revision 34219)
+++ chrome/browser/browser.cc (working copy)
@@ -140,7 +140,10 @@
is_attempting_to_close_browser_(false),
cancel_download_confirmation_state_(NOT_PROMPTED),
maximized_state_(MAXIMIZED_STATE_DEFAULT),
- method_factory_(this) {
+ method_factory_(this),
+ block_command_execution_(false),
+ last_blocked_command_id_(-1),
+ last_blocked_command_disposition_(CURRENT_TAB) {
tabstrip_model_.AddObserver(this);
registrar_.Add(this, NotificationType::SSL_VISIBLE_STATE_CHANGED,
@@ -1402,6 +1405,16 @@
DCHECK(command_updater_.IsCommandEnabled(id)) << "Invalid/disabled command";
+ // If command execution is blocked then just record the command and return.
+ if (block_command_execution_) {
+ // We actually only allow no more than one blocked command, otherwise some
+ // commands maybe lost.
+ DCHECK(last_blocked_command_id_ == -1);
+ last_blocked_command_id_ = id;
+ last_blocked_command_disposition_ = disposition;
+ return;
+ }
+
// The order of commands in this switch statement must match the function
// declaration order in browser.h!
switch (id) {
@@ -1563,6 +1576,33 @@
}
}
+bool Browser::IsReservedCommand(int command_id) {
+ return command_id == IDC_CLOSE_TAB ||
+ command_id == IDC_CLOSE_POPUPS ||
+ command_id == IDC_CLOSE_WINDOW ||
+ command_id == IDC_NEW_INCOGNITO_WINDOW ||
+ command_id == IDC_NEW_TAB ||
+ command_id == IDC_NEW_WINDOW ||
+ command_id == IDC_RESTORE_TAB ||
+ command_id == IDC_SELECT_NEXT_TAB ||
+ command_id == IDC_SELECT_PREVIOUS_TAB ||
+ command_id == IDC_EXIT;
+}
+
+void Browser::SetBlockCommandExecution(bool block) {
+ block_command_execution_ = block;
+ if (block) {
+ last_blocked_command_id_ = -1;
+ last_blocked_command_disposition_ = CURRENT_TAB;
+ }
+}
+
+int Browser::GetLastBlockedCommand(WindowOpenDisposition* disposition) {
+ if (disposition)
+ *disposition = last_blocked_command_disposition_;
+ return last_blocked_command_id_;
+}
+
///////////////////////////////////////////////////////////////////////////////
// Browser, CommandUpdater::CommandUpdaterDelegate implementation:
@@ -2197,25 +2237,13 @@
window()->ShowPageInfo(profile, url, ssl, show_history);
}
-bool Browser::IsReservedAccelerator(const NativeWebKeyboardEvent& event) {
- // Other platforms don't send close-app keyboard shortcuts to apps first.
-#if defined(OS_WIN)
- if ((event.modifiers & NativeWebKeyboardEvent::AltKey) &&
- event.windowsKeyCode == VK_F4) {
- return true;
- }
-#endif
+bool Browser::PreHandleKeyboardEvent(const NativeWebKeyboardEvent& event,
+ bool* is_keyboard_shortcut) {
+ return window()->PreHandleKeyboardEvent(event, is_keyboard_shortcut);
+}
- int command_id = window()->GetCommandId(event);
- return command_id == IDC_CLOSE_TAB ||
- command_id == IDC_CLOSE_POPUPS ||
- command_id == IDC_CLOSE_WINDOW ||
- command_id == IDC_NEW_INCOGNITO_WINDOW ||
- command_id == IDC_NEW_TAB ||
- command_id == IDC_NEW_WINDOW ||
- command_id == IDC_RESTORE_TAB ||
- command_id == IDC_SELECT_NEXT_TAB ||
- command_id == IDC_SELECT_PREVIOUS_TAB;
+void Browser::HandleKeyboardEvent(const NativeWebKeyboardEvent& event) {
+ window()->HandleKeyboardEvent(event);
}
void Browser::ShowRepostFormWarningDialog(TabContents *tab_contents) {
« no previous file with comments | « chrome/browser/browser.h ('k') | chrome/browser/browser_keyevents_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698