OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/ui/views/reload_button.h" | 5 #include "chrome/browser/ui/views/reload_button.h" |
6 | 6 |
7 #include "base/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
8 #include "chrome/app/chrome_command_ids.h" | 8 #include "chrome/app/chrome_command_ids.h" |
9 #include "chrome/browser/ui/browser.h" | 9 #include "chrome/browser/ui/browser.h" |
10 #include "chrome/browser/ui/views/event_utils.h" | 10 #include "chrome/browser/ui/views/event_utils.h" |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 // We want to disable the button if we're preventing a change from stop to | 53 // We want to disable the button if we're preventing a change from stop to |
54 // reload due to hovering, but not if we're preventing a change from reload to | 54 // reload due to hovering, but not if we're preventing a change from reload to |
55 // stop due to the double-click timer running. (There is no disabled reload | 55 // stop due to the double-click timer running. (There is no disabled reload |
56 // state.) | 56 // state.) |
57 } else if (visible_mode_ != MODE_RELOAD) { | 57 } else if (visible_mode_ != MODE_RELOAD) { |
58 SetEnabled(false); | 58 SetEnabled(false); |
59 | 59 |
60 // Go ahead and change to reload after a bit, which allows repeated reloads | 60 // Go ahead and change to reload after a bit, which allows repeated reloads |
61 // without moving the mouse. | 61 // without moving the mouse. |
62 if (!stop_to_reload_timer_.IsRunning()) { | 62 if (!stop_to_reload_timer_.IsRunning()) { |
63 stop_to_reload_timer_.Start(FROM_HERE, stop_to_reload_timer_delay_, this, | 63 stop_to_reload_timer_.Start(stop_to_reload_timer_delay_, this, |
64 &ReloadButton::OnStopToReloadTimer); | 64 &ReloadButton::OnStopToReloadTimer); |
65 } | 65 } |
66 } | 66 } |
67 } | 67 } |
68 | 68 |
69 //////////////////////////////////////////////////////////////////////////////// | 69 //////////////////////////////////////////////////////////////////////////////// |
70 // ReloadButton, views::ButtonListener implementation: | 70 // ReloadButton, views::ButtonListener implementation: |
71 | 71 |
72 void ReloadButton::ButtonPressed(views::Button* /* button */, | 72 void ReloadButton::ButtonPressed(views::Button* /* button */, |
73 const views::Event& event) { | 73 const views::Event& event) { |
(...skipping 25 matching lines...) Expand all Loading... |
99 // ongoing user edits, since it doesn't realize this is a user-initiated | 99 // ongoing user edits, since it doesn't realize this is a user-initiated |
100 // action. | 100 // action. |
101 location_bar_->Revert(); | 101 location_bar_->Revert(); |
102 } | 102 } |
103 | 103 |
104 // Start a timer - while this timer is running, the reload button cannot be | 104 // Start a timer - while this timer is running, the reload button cannot be |
105 // changed to a stop button. We do not set |intended_mode_| to MODE_STOP | 105 // changed to a stop button. We do not set |intended_mode_| to MODE_STOP |
106 // here as the browser will do that when it actually starts loading (which | 106 // here as the browser will do that when it actually starts loading (which |
107 // may happen synchronously, thus the need to do this before telling the | 107 // may happen synchronously, thus the need to do this before telling the |
108 // browser to execute the reload command). | 108 // browser to execute the reload command). |
109 double_click_timer_.Start(FROM_HERE, double_click_timer_delay_, this, | 109 double_click_timer_.Start(double_click_timer_delay_, this, |
110 &ReloadButton::OnDoubleClickTimer); | 110 &ReloadButton::OnDoubleClickTimer); |
111 | 111 |
112 if (browser_) | 112 if (browser_) |
113 browser_->ExecuteCommandWithDisposition(command, disposition); | 113 browser_->ExecuteCommandWithDisposition(command, disposition); |
114 ++testing_reload_count_; | 114 ++testing_reload_count_; |
115 } | 115 } |
116 } | 116 } |
117 | 117 |
118 //////////////////////////////////////////////////////////////////////////////// | 118 //////////////////////////////////////////////////////////////////////////////// |
119 // ReloadButton, View overrides: | 119 // ReloadButton, View overrides: |
(...skipping 18 matching lines...) Expand all Loading... |
138 //////////////////////////////////////////////////////////////////////////////// | 138 //////////////////////////////////////////////////////////////////////////////// |
139 // ReloadButton, private: | 139 // ReloadButton, private: |
140 | 140 |
141 void ReloadButton::OnDoubleClickTimer() { | 141 void ReloadButton::OnDoubleClickTimer() { |
142 ChangeMode(intended_mode_, false); | 142 ChangeMode(intended_mode_, false); |
143 } | 143 } |
144 | 144 |
145 void ReloadButton::OnStopToReloadTimer() { | 145 void ReloadButton::OnStopToReloadTimer() { |
146 ChangeMode(intended_mode_, true); | 146 ChangeMode(intended_mode_, true); |
147 } | 147 } |
OLD | NEW |