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

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

Issue 42571: Reverting r12383, caused a build breakage on all platforms. (Closed) Base URL: svn://chrome-svn/chrome/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/browser.h" 8 #include "chrome/browser/command_updater.h"
9 #include "chrome/browser/views/event_utils.h"
10 #include "chrome/browser/views/location_bar_view.h" 9 #include "chrome/browser/views/location_bar_view.h"
11 #include "chrome/common/l10n_util.h" 10 #include "chrome/common/l10n_util.h"
12 #include "grit/generated_resources.h" 11 #include "grit/generated_resources.h"
13 12
14 //////////////////////////////////////////////////////////////////////////////// 13 ////////////////////////////////////////////////////////////////////////////////
15 // GoButton, public: 14 // GoButton, public:
16 15
17 GoButton::GoButton(LocationBarView* location_bar, Browser* browser) 16 GoButton::GoButton(LocationBarView* location_bar,
17 CommandUpdater* command_updater)
18 : ToggleImageButton(this), 18 : ToggleImageButton(this),
19 location_bar_(location_bar), 19 location_bar_(location_bar),
20 browser_(browser), 20 command_updater_(command_updater),
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);
28 } 26 }
29 27
30 GoButton::~GoButton() { 28 GoButton::~GoButton() {
31 stop_timer_.RevokeAll(); 29 stop_timer_.RevokeAll();
32 } 30 }
33 31
34 void GoButton::ChangeMode(Mode mode) { 32 void GoButton::ChangeMode(Mode mode) {
35 stop_timer_.RevokeAll(); 33 stop_timer_.RevokeAll();
36 34
37 SetToggled(mode == MODE_STOP); 35 SetToggled(mode == MODE_STOP);
(...skipping 21 matching lines...) Expand all
59 ChangeMode(MODE_GO); 57 ChangeMode(MODE_GO);
60 } 58 }
61 } 59 }
62 } 60 }
63 61
64 //////////////////////////////////////////////////////////////////////////////// 62 ////////////////////////////////////////////////////////////////////////////////
65 // GoButton, views::ButtonListener implementation: 63 // GoButton, views::ButtonListener implementation:
66 64
67 void GoButton::ButtonPressed(views::Button* button) { 65 void GoButton::ButtonPressed(views::Button* button) {
68 if (visible_mode_ == MODE_STOP) { 66 if (visible_mode_ == MODE_STOP) {
69 browser_->Stop(); 67 command_updater_->ExecuteCommand(IDC_STOP);
70 68
71 // The user has clicked, so we can feel free to update the button, 69 // The user has clicked, so we can feel free to update the button,
72 // even if the mouse is still hovering. 70 // even if the mouse is still hovering.
73 ChangeMode(MODE_GO); 71 ChangeMode(MODE_GO);
74 } else if (visible_mode_ == MODE_GO && stop_timer_.empty()) { 72 } else if (visible_mode_ == MODE_GO && stop_timer_.empty()) {
75 // If the go button is visible and not within the double click timer, go. 73 // If the go button is visible and not within the double click timer, go.
76 browser_->Go(event_utils::DispositionFromEventFlags(mouse_event_flags())); 74 command_updater_->ExecuteCommand(IDC_GO);
77 75
78 // Figure out the system double-click time. 76 // Figure out the system double-click time.
79 if (button_delay_ == NULL) 77 if (button_delay_ == NULL)
80 button_delay_ = GetDoubleClickTime(); 78 button_delay_ = GetDoubleClickTime();
81 79
82 // Stop any existing timers. 80 // Stop any existing timers.
83 stop_timer_.RevokeAll(); 81 stop_timer_.RevokeAll();
84 82
85 // Start a timer - while this timer is running, the go button 83 // Start a timer - while this timer is running, the go button
86 // cannot be changed to a stop button. We do not set intended_mode_ 84 // 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
139 137
140 //////////////////////////////////////////////////////////////////////////////// 138 ////////////////////////////////////////////////////////////////////////////////
141 // GoButton, private: 139 // GoButton, private:
142 140
143 void GoButton::OnButtonTimer() { 141 void GoButton::OnButtonTimer() {
144 if (intended_mode_ != visible_mode_) 142 if (intended_mode_ != visible_mode_)
145 ChangeMode(intended_mode_); 143 ChangeMode(intended_mode_);
146 144
147 stop_timer_.RevokeAll(); 145 stop_timer_.RevokeAll();
148 } 146 }
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