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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/gtk/browser_toolbar_gtk.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/views/toolbar_view.h" 5 #include "chrome/browser/views/toolbar_view.h"
6 6
7 #include "app/l10n_util.h" 7 #include "app/l10n_util.h"
8 #include "app/resource_bundle.h" 8 #include "app/resource_bundle.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "chrome/app/chrome_dll_resource.h" 10 #include "chrome/app/chrome_dll_resource.h"
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 bookmark_menu_(NULL), 80 bookmark_menu_(NULL),
81 profile_(NULL), 81 profile_(NULL),
82 browser_(browser), 82 browser_(browser),
83 profiles_menu_contents_(NULL), 83 profiles_menu_contents_(NULL),
84 last_focused_view_storage_id_(-1), 84 last_focused_view_storage_id_(-1),
85 menu_bar_emulation_mode_(false), 85 menu_bar_emulation_mode_(false),
86 ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)), 86 ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)),
87 destroyed_flag_(NULL), 87 destroyed_flag_(NULL),
88 collapsed_(false) { 88 collapsed_(false) {
89 SetID(VIEW_ID_TOOLBAR); 89 SetID(VIEW_ID_TOOLBAR);
90
90 browser_->command_updater()->AddCommandObserver(IDC_BACK, this); 91 browser_->command_updater()->AddCommandObserver(IDC_BACK, this);
91 browser_->command_updater()->AddCommandObserver(IDC_FORWARD, this); 92 browser_->command_updater()->AddCommandObserver(IDC_FORWARD, this);
92 browser_->command_updater()->AddCommandObserver(IDC_HOME, this); 93 browser_->command_updater()->AddCommandObserver(IDC_HOME, this);
93 browser_->command_updater()->AddCommandObserver(IDC_RELOAD, this); 94 browser_->command_updater()->AddCommandObserver(IDC_RELOAD, this);
94 95
95 display_mode_ = browser->SupportsWindowFeature(Browser::FEATURE_TABSTRIP) ? 96 display_mode_ = browser->SupportsWindowFeature(Browser::FEATURE_TABSTRIP) ?
96 DISPLAYMODE_NORMAL : DISPLAYMODE_LOCATION; 97 DISPLAYMODE_NORMAL : DISPLAYMODE_LOCATION;
97 98
98 if (!kPopupBackgroundEdge) { 99 if (!kPopupBackgroundEdge) {
99 kPopupBackgroundEdge = ResourceBundle::GetSharedInstance().GetBitmapNamed( 100 kPopupBackgroundEdge = ResourceBundle::GetSharedInstance().GetBitmapNamed(
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 147
147 home_ = new views::ImageButton(this); 148 home_ = new views::ImageButton(this);
148 home_->set_triggerable_event_flags(views::Event::EF_LEFT_BUTTON_DOWN | 149 home_->set_triggerable_event_flags(views::Event::EF_LEFT_BUTTON_DOWN |
149 views::Event::EF_MIDDLE_BUTTON_DOWN); 150 views::Event::EF_MIDDLE_BUTTON_DOWN);
150 home_->set_tag(IDC_HOME); 151 home_->set_tag(IDC_HOME);
151 home_->SetTooltipText(l10n_util::GetString(IDS_TOOLTIP_HOME)); 152 home_->SetTooltipText(l10n_util::GetString(IDS_TOOLTIP_HOME));
152 home_->SetAccessibleName(l10n_util::GetString(IDS_ACCNAME_HOME)); 153 home_->SetAccessibleName(l10n_util::GetString(IDS_ACCNAME_HOME));
153 home_->SetID(VIEW_ID_HOME_BUTTON); 154 home_->SetID(VIEW_ID_HOME_BUTTON);
154 155
155 reload_ = new views::ImageButton(this); 156 reload_ = new views::ImageButton(this);
157 reload_->set_triggerable_event_flags(views::Event::EF_LEFT_BUTTON_DOWN |
158 views::Event::EF_MIDDLE_BUTTON_DOWN);
156 reload_->set_tag(IDC_RELOAD); 159 reload_->set_tag(IDC_RELOAD);
157 reload_->SetTooltipText(l10n_util::GetString(IDS_TOOLTIP_RELOAD)); 160 reload_->SetTooltipText(l10n_util::GetString(IDS_TOOLTIP_RELOAD));
158 reload_->SetAccessibleName(l10n_util::GetString(IDS_ACCNAME_RELOAD)); 161 reload_->SetAccessibleName(l10n_util::GetString(IDS_ACCNAME_RELOAD));
159 reload_->SetID(VIEW_ID_RELOAD_BUTTON); 162 reload_->SetID(VIEW_ID_RELOAD_BUTTON);
160 163
161 location_bar_ = new LocationBarView(profile, browser_->command_updater(), 164 location_bar_ = new LocationBarView(profile, browser_->command_updater(),
162 model_, this, (display_mode_ == DISPLAYMODE_LOCATION) ? 165 model_, this, (display_mode_ == DISPLAYMODE_LOCATION) ?
163 LocationBarView::POPUP : LocationBarView::NORMAL); 166 LocationBarView::POPUP : LocationBarView::NORMAL);
164 location_bar_->SetAccessibleName(l10n_util::GetString(IDS_ACCNAME_LOCATION)); 167 location_bar_->SetAccessibleName(l10n_util::GetString(IDS_ACCNAME_LOCATION));
165 168
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
396 } 399 }
397 if (button) 400 if (button)
398 button->SetEnabled(enabled); 401 button->SetEnabled(enabled);
399 } 402 }
400 403
401 //////////////////////////////////////////////////////////////////////////////// 404 ////////////////////////////////////////////////////////////////////////////////
402 // ToolbarView, views::Button::ButtonListener implementation: 405 // ToolbarView, views::Button::ButtonListener implementation:
403 406
404 void ToolbarView::ButtonPressed(views::Button* sender, 407 void ToolbarView::ButtonPressed(views::Button* sender,
405 const views::Event& event) { 408 const views::Event& event) {
406 int id = sender->tag(); 409 int command = sender->tag();
407 switch (id) { 410 int flags = sender->mouse_event_flags();
411 // Shift-clicking or Ctrl-clicking the reload button means we should ignore
412 // any cached content.
413 // TODO(avayvod): eliminate duplication of this logic in
414 // CompactLocationBarView.
415 if ((command == IDC_RELOAD) &&
416 (event.IsShiftDown() || event.IsControlDown())) {
417 command = IDC_RELOAD_IGNORING_CACHE;
418 // Mask off shift/ctrl so they aren't interpreted as affecting the
419 // disposition below.
420 flags &= ~(views::Event::EF_SHIFT_DOWN | views::Event::EF_CONTROL_DOWN);
421 }
422 WindowOpenDisposition disposition =
423 event_utils::DispositionFromEventFlags(flags);
424 switch (command) {
408 case IDC_BACK: 425 case IDC_BACK:
409 case IDC_FORWARD: 426 case IDC_FORWARD:
410 case IDC_RELOAD: 427 case IDC_RELOAD:
411 // Forcibly reset the location bar, since otherwise it won't discard any 428 case IDC_RELOAD_IGNORING_CACHE:
412 // ongoing user edits, since it doesn't realize this is a user-initiated 429 if (disposition == CURRENT_TAB) {
413 // action. 430 // Forcibly reset the location bar, since otherwise it won't discard any
414 location_bar_->Revert(); 431 // ongoing user edits, since it doesn't realize this is a user-initiated
415 // Shift-clicking or Ctrl-clicking the reload button means we should 432 // action.
416 // ignore any cached content. 433 location_bar_->Revert();
417 // TODO(avayvod): eliminate duplication of this logic in 434 }
418 // CompactLocationBarView.
419 if (id == IDC_RELOAD && (event.IsShiftDown() || event.IsControlDown()))
420 id = IDC_RELOAD_IGNORING_CACHE;
421 break;
422 } 435 }
423 browser_->ExecuteCommandWithDisposition( 436 browser_->ExecuteCommandWithDisposition(command, disposition);
424 id, event_utils::DispositionFromEventFlags(sender->mouse_event_flags()));
425 } 437 }
426 438
427 //////////////////////////////////////////////////////////////////////////////// 439 ////////////////////////////////////////////////////////////////////////////////
428 // ToolbarView, NotificationObserver implementation: 440 // ToolbarView, NotificationObserver implementation:
429 441
430 void ToolbarView::Observe(NotificationType type, 442 void ToolbarView::Observe(NotificationType type,
431 const NotificationSource& source, 443 const NotificationSource& source,
432 const NotificationDetails& details) { 444 const NotificationDetails& details) {
433 if (type == NotificationType::PREF_CHANGED) { 445 if (type == NotificationType::PREF_CHANGED) {
434 std::wstring* pref_name = Details<std::wstring>(details).ptr(); 446 std::wstring* pref_name = Details<std::wstring>(details).ptr();
(...skipping 470 matching lines...) Expand 10 before | Expand all | Expand 10 after
905 last_focused_view->RequestFocus(); 917 last_focused_view->RequestFocus();
906 } else { 918 } else {
907 // Focus the location bar 919 // Focus the location bar
908 views::View* view = GetAncestorWithClassName(BrowserView::kViewClassName); 920 views::View* view = GetAncestorWithClassName(BrowserView::kViewClassName);
909 if (view) { 921 if (view) {
910 BrowserView* browser_view = static_cast<BrowserView*>(view); 922 BrowserView* browser_view = static_cast<BrowserView*>(view);
911 browser_view->SetFocusToLocationBar(false); 923 browser_view->SetFocusToLocationBar(false);
912 } 924 }
913 } 925 }
914 } 926 }
OLDNEW
« 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