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/gtk/reload_button_gtk.h" | 5 #include "chrome/browser/ui/gtk/reload_button_gtk.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "chrome/app/chrome_command_ids.h" | 10 #include "chrome/app/chrome_command_ids.h" |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 gtk_chrome_button_set_paint_state(GTK_CHROME_BUTTON(widget_.get()), | 112 gtk_chrome_button_set_paint_state(GTK_CHROME_BUTTON(widget_.get()), |
113 GTK_STATE_INSENSITIVE); | 113 GTK_STATE_INSENSITIVE); |
114 | 114 |
115 // If we're in GTK theme mode, we need to also render the correct icon for | 115 // If we're in GTK theme mode, we need to also render the correct icon for |
116 // the stop/insensitive since we won't be using |stop_| to render the icon. | 116 // the stop/insensitive since we won't be using |stop_| to render the icon. |
117 UpdateThemeButtons(); | 117 UpdateThemeButtons(); |
118 | 118 |
119 // Go ahead and change to reload after a bit, which allows repeated reloads | 119 // Go ahead and change to reload after a bit, which allows repeated reloads |
120 // without moving the mouse. | 120 // without moving the mouse. |
121 if (!stop_to_reload_timer_.IsRunning()) { | 121 if (!stop_to_reload_timer_.IsRunning()) { |
122 stop_to_reload_timer_.Start(FROM_HERE, stop_to_reload_timer_delay_, this, | 122 stop_to_reload_timer_.Start(stop_to_reload_timer_delay_, this, |
123 &ReloadButtonGtk::OnStopToReloadTimer); | 123 &ReloadButtonGtk::OnStopToReloadTimer); |
124 } | 124 } |
125 } | 125 } |
126 } | 126 } |
127 | 127 |
128 //////////////////////////////////////////////////////////////////////////////// | 128 //////////////////////////////////////////////////////////////////////////////// |
129 // ReloadButtonGtk, NotificationObserver implementation: | 129 // ReloadButtonGtk, NotificationObserver implementation: |
130 | 130 |
131 void ReloadButtonGtk::Observe(int type, | 131 void ReloadButtonGtk::Observe(int type, |
132 const NotificationSource& source, | 132 const NotificationSource& source, |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 // ongoing user edits, since it doesn't realize this is a user-initiated | 178 // ongoing user edits, since it doesn't realize this is a user-initiated |
179 // action. | 179 // action. |
180 location_bar_->Revert(); | 180 location_bar_->Revert(); |
181 } | 181 } |
182 | 182 |
183 // Start a timer - while this timer is running, the reload button cannot be | 183 // Start a timer - while this timer is running, the reload button cannot be |
184 // changed to a stop button. We do not set |intended_mode_| to MODE_STOP | 184 // changed to a stop button. We do not set |intended_mode_| to MODE_STOP |
185 // here as the browser will do that when it actually starts loading (which | 185 // here as the browser will do that when it actually starts loading (which |
186 // may happen synchronously, thus the need to do this before telling the | 186 // may happen synchronously, thus the need to do this before telling the |
187 // browser to execute the reload command). | 187 // browser to execute the reload command). |
188 double_click_timer_.Start(FROM_HERE, double_click_timer_delay_, this, | 188 double_click_timer_.Start(double_click_timer_delay_, this, |
189 &ReloadButtonGtk::OnDoubleClickTimer); | 189 &ReloadButtonGtk::OnDoubleClickTimer); |
190 | 190 |
191 if (browser_) | 191 if (browser_) |
192 browser_->ExecuteCommandWithDisposition(command, disposition); | 192 browser_->ExecuteCommandWithDisposition(command, disposition); |
193 ++testing_reload_count_; | 193 ++testing_reload_count_; |
194 } | 194 } |
195 } | 195 } |
196 | 196 |
197 gboolean ReloadButtonGtk::OnExpose(GtkWidget* widget, | 197 gboolean ReloadButtonGtk::OnExpose(GtkWidget* widget, |
198 GdkEventExpose* e) { | 198 GdkEventExpose* e) { |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
271 gtk_chrome_button_set_use_gtk_rendering(GTK_CHROME_BUTTON(widget()), use_gtk); | 271 gtk_chrome_button_set_use_gtk_rendering(GTK_CHROME_BUTTON(widget()), use_gtk); |
272 } | 272 } |
273 | 273 |
274 void ReloadButtonGtk::OnDoubleClickTimer() { | 274 void ReloadButtonGtk::OnDoubleClickTimer() { |
275 ChangeMode(intended_mode_, false); | 275 ChangeMode(intended_mode_, false); |
276 } | 276 } |
277 | 277 |
278 void ReloadButtonGtk::OnStopToReloadTimer() { | 278 void ReloadButtonGtk::OnStopToReloadTimer() { |
279 ChangeMode(intended_mode_, true); | 279 ChangeMode(intended_mode_, true); |
280 } | 280 } |
OLD | NEW |