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

Side by Side Diff: chrome/browser/views/go_button.cc

Issue 17428: Issue 358: Can't open a new tab by middle-clicking home button... (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: '' Created 11 years, 9 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/views/go_button.h ('k') | chrome/browser/views/location_bar_view.h » ('j') | 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) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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/go_button.h" 5 #include "chrome/browser/views/go_button.h"
6 6
7 #include "chrome/app/chrome_dll_resource.h" 7 #include "chrome/app/chrome_dll_resource.h"
8 #include "chrome/browser/command_updater.h" 8 #include "chrome/browser/browser.h"
9 #include "chrome/browser/views/event_utils.h"
9 #include "chrome/browser/views/location_bar_view.h" 10 #include "chrome/browser/views/location_bar_view.h"
10 #include "chrome/common/l10n_util.h" 11 #include "chrome/common/l10n_util.h"
11 #include "grit/generated_resources.h" 12 #include "grit/generated_resources.h"
12 13
13 //////////////////////////////////////////////////////////////////////////////// 14 ////////////////////////////////////////////////////////////////////////////////
14 // GoButton, public: 15 // GoButton, public:
15 16
16 GoButton::GoButton(LocationBarView* location_bar, 17 GoButton::GoButton(LocationBarView* location_bar, Browser* browser)
17 CommandUpdater* command_updater)
18 : ToggleImageButton(this), 18 : ToggleImageButton(this),
19 location_bar_(location_bar), 19 location_bar_(location_bar),
20 command_updater_(command_updater), 20 browser_(browser),
21 intended_mode_(MODE_GO), 21 intended_mode_(MODE_GO),
22 visible_mode_(MODE_GO), 22 visible_mode_(MODE_GO),
23 button_delay_(NULL), 23 button_delay_(NULL),
24 stop_timer_(this) { 24 stop_timer_(this) {
25 DCHECK(location_bar_); 25 DCHECK(location_bar_);
26 set_triggerable_event_flags(views::Event::EF_LEFT_BUTTON_DOWN |
27 views::Event::EF_MIDDLE_BUTTON_DOWN);
26 } 28 }
27 29
28 GoButton::~GoButton() { 30 GoButton::~GoButton() {
29 stop_timer_.RevokeAll(); 31 stop_timer_.RevokeAll();
30 } 32 }
31 33
32 void GoButton::ChangeMode(Mode mode) { 34 void GoButton::ChangeMode(Mode mode) {
33 stop_timer_.RevokeAll(); 35 stop_timer_.RevokeAll();
34 36
35 SetToggled(mode == MODE_STOP); 37 SetToggled(mode == MODE_STOP);
(...skipping 21 matching lines...) Expand all
57 ChangeMode(MODE_GO); 59 ChangeMode(MODE_GO);
58 } 60 }
59 } 61 }
60 } 62 }
61 63
62 //////////////////////////////////////////////////////////////////////////////// 64 ////////////////////////////////////////////////////////////////////////////////
63 // GoButton, views::ButtonListener implementation: 65 // GoButton, views::ButtonListener implementation:
64 66
65 void GoButton::ButtonPressed(views::Button* button) { 67 void GoButton::ButtonPressed(views::Button* button) {
66 if (visible_mode_ == MODE_STOP) { 68 if (visible_mode_ == MODE_STOP) {
67 command_updater_->ExecuteCommand(IDC_STOP); 69 browser_->Stop();
68 70
69 // The user has clicked, so we can feel free to update the button, 71 // The user has clicked, so we can feel free to update the button,
70 // even if the mouse is still hovering. 72 // even if the mouse is still hovering.
71 ChangeMode(MODE_GO); 73 ChangeMode(MODE_GO);
72 } else if (visible_mode_ == MODE_GO && stop_timer_.empty()) { 74 } else if (visible_mode_ == MODE_GO && stop_timer_.empty()) {
73 // If the go button is visible and not within the double click timer, go. 75 // If the go button is visible and not within the double click timer, go.
74 command_updater_->ExecuteCommand(IDC_GO); 76 browser_->Go(event_utils::DispositionFromEventFlags(mouse_event_flags()));
75 77
76 // Figure out the system double-click time. 78 // Figure out the system double-click time.
77 if (button_delay_ == NULL) 79 if (button_delay_ == NULL)
78 button_delay_ = GetDoubleClickTime(); 80 button_delay_ = GetDoubleClickTime();
79 81
80 // Stop any existing timers. 82 // Stop any existing timers.
81 stop_timer_.RevokeAll(); 83 stop_timer_.RevokeAll();
82 84
83 // Start a timer - while this timer is running, the go button 85 // Start a timer - while this timer is running, the go button
84 // cannot be changed to a stop button. We do not set intended_mode_ 86 // cannot be changed to a stop button. We do not set intended_mode_
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 139
138 //////////////////////////////////////////////////////////////////////////////// 140 ////////////////////////////////////////////////////////////////////////////////
139 // GoButton, private: 141 // GoButton, private:
140 142
141 void GoButton::OnButtonTimer() { 143 void GoButton::OnButtonTimer() {
142 if (intended_mode_ != visible_mode_) 144 if (intended_mode_ != visible_mode_)
143 ChangeMode(intended_mode_); 145 ChangeMode(intended_mode_);
144 146
145 stop_timer_.RevokeAll(); 147 stop_timer_.RevokeAll();
146 } 148 }
OLDNEW
« no previous file with comments | « chrome/browser/views/go_button.h ('k') | chrome/browser/views/location_bar_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698