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

Unified Diff: chrome/browser/views/toolbar_view.cc

Issue 2779011: Make the reload button respond to middle-clicks like back/forward/home alread... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 6 months 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/gtk/browser_toolbar_gtk.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/views/toolbar_view.cc
===================================================================
--- chrome/browser/views/toolbar_view.cc (revision 49315)
+++ chrome/browser/views/toolbar_view.cc (working copy)
@@ -87,6 +87,7 @@
destroyed_flag_(NULL),
collapsed_(false) {
SetID(VIEW_ID_TOOLBAR);
+
browser_->command_updater()->AddCommandObserver(IDC_BACK, this);
browser_->command_updater()->AddCommandObserver(IDC_FORWARD, this);
browser_->command_updater()->AddCommandObserver(IDC_HOME, this);
@@ -153,6 +154,8 @@
home_->SetID(VIEW_ID_HOME_BUTTON);
reload_ = new views::ImageButton(this);
+ reload_->set_triggerable_event_flags(views::Event::EF_LEFT_BUTTON_DOWN |
+ views::Event::EF_MIDDLE_BUTTON_DOWN);
reload_->set_tag(IDC_RELOAD);
reload_->SetTooltipText(l10n_util::GetString(IDS_TOOLTIP_RELOAD));
reload_->SetAccessibleName(l10n_util::GetString(IDS_ACCNAME_RELOAD));
@@ -403,25 +406,34 @@
void ToolbarView::ButtonPressed(views::Button* sender,
const views::Event& event) {
- int id = sender->tag();
- switch (id) {
+ int command = sender->tag();
+ int flags = sender->mouse_event_flags();
+ // Shift-clicking or Ctrl-clicking the reload button means we should ignore
+ // any cached content.
+ // TODO(avayvod): eliminate duplication of this logic in
+ // CompactLocationBarView.
+ if ((command == IDC_RELOAD) &&
+ (event.IsShiftDown() || event.IsControlDown())) {
+ command = IDC_RELOAD_IGNORING_CACHE;
+ // Mask off shift/ctrl so they aren't interpreted as affecting the
+ // disposition below.
+ flags &= ~(views::Event::EF_SHIFT_DOWN | views::Event::EF_CONTROL_DOWN);
+ }
+ WindowOpenDisposition disposition =
+ event_utils::DispositionFromEventFlags(flags);
+ switch (command) {
case IDC_BACK:
case IDC_FORWARD:
case IDC_RELOAD:
- // Forcibly reset the location bar, since otherwise it won't discard any
- // ongoing user edits, since it doesn't realize this is a user-initiated
- // action.
- location_bar_->Revert();
- // Shift-clicking or Ctrl-clicking the reload button means we should
- // ignore any cached content.
- // TODO(avayvod): eliminate duplication of this logic in
- // CompactLocationBarView.
- if (id == IDC_RELOAD && (event.IsShiftDown() || event.IsControlDown()))
- id = IDC_RELOAD_IGNORING_CACHE;
- break;
+ case IDC_RELOAD_IGNORING_CACHE:
+ if (disposition == CURRENT_TAB) {
+ // Forcibly reset the location bar, since otherwise it won't discard any
+ // ongoing user edits, since it doesn't realize this is a user-initiated
+ // action.
+ location_bar_->Revert();
+ }
}
- browser_->ExecuteCommandWithDisposition(
- id, event_utils::DispositionFromEventFlags(sender->mouse_event_flags()));
+ browser_->ExecuteCommandWithDisposition(command, disposition);
}
////////////////////////////////////////////////////////////////////////////////
« no previous file with comments | « chrome/browser/gtk/browser_toolbar_gtk.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698