| 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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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(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 FROM_HERE); |
| 65 } | 66 } |
| 66 } | 67 } |
| 67 } | 68 } |
| 68 | 69 |
| 69 //////////////////////////////////////////////////////////////////////////////// | 70 //////////////////////////////////////////////////////////////////////////////// |
| 70 // ReloadButton, views::ButtonListener implementation: | 71 // ReloadButton, views::ButtonListener implementation: |
| 71 | 72 |
| 72 void ReloadButton::ButtonPressed(views::Button* /* button */, | 73 void ReloadButton::ButtonPressed(views::Button* /* button */, |
| 73 const views::Event& event) { | 74 const views::Event& event) { |
| 74 if (visible_mode_ == MODE_STOP) { | 75 if (visible_mode_ == MODE_STOP) { |
| (...skipping 25 matching lines...) Expand all Loading... |
| 100 // action. | 101 // action. |
| 101 location_bar_->Revert(); | 102 location_bar_->Revert(); |
| 102 } | 103 } |
| 103 | 104 |
| 104 // Start a timer - while this timer is running, the reload button cannot be | 105 // 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 | 106 // 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 | 107 // 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 | 108 // may happen synchronously, thus the need to do this before telling the |
| 108 // browser to execute the reload command). | 109 // browser to execute the reload command). |
| 109 double_click_timer_.Start(double_click_timer_delay_, this, | 110 double_click_timer_.Start(double_click_timer_delay_, this, |
| 110 &ReloadButton::OnDoubleClickTimer); | 111 &ReloadButton::OnDoubleClickTimer, FROM_HERE); |
| 111 | 112 |
| 112 if (browser_) | 113 if (browser_) |
| 113 browser_->ExecuteCommandWithDisposition(command, disposition); | 114 browser_->ExecuteCommandWithDisposition(command, disposition); |
| 114 ++testing_reload_count_; | 115 ++testing_reload_count_; |
| 115 } | 116 } |
| 116 } | 117 } |
| 117 | 118 |
| 118 //////////////////////////////////////////////////////////////////////////////// | 119 //////////////////////////////////////////////////////////////////////////////// |
| 119 // ReloadButton, View overrides: | 120 // ReloadButton, View overrides: |
| 120 | 121 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 138 //////////////////////////////////////////////////////////////////////////////// | 139 //////////////////////////////////////////////////////////////////////////////// |
| 139 // ReloadButton, private: | 140 // ReloadButton, private: |
| 140 | 141 |
| 141 void ReloadButton::OnDoubleClickTimer() { | 142 void ReloadButton::OnDoubleClickTimer() { |
| 142 ChangeMode(intended_mode_, false); | 143 ChangeMode(intended_mode_, false); |
| 143 } | 144 } |
| 144 | 145 |
| 145 void ReloadButton::OnStopToReloadTimer() { | 146 void ReloadButton::OnStopToReloadTimer() { |
| 146 ChangeMode(intended_mode_, true); | 147 ChangeMode(intended_mode_, true); |
| 147 } | 148 } |
| OLD | NEW |