OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/gtk/reload_button_gtk.h" | 5 #include "chrome/browser/gtk/reload_button_gtk.h" |
6 | 6 |
7 #include "app/l10n_util.h" | 7 #include "app/l10n_util.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "chrome/app/chrome_dll_resource.h" | 9 #include "chrome/app/chrome_dll_resource.h" |
10 #include "chrome/browser/browser.h" | 10 #include "chrome/browser/browser.h" |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 DCHECK(NotificationType::BROWSER_THEME_CHANGED == type); | 88 DCHECK(NotificationType::BROWSER_THEME_CHANGED == type); |
89 | 89 |
90 GtkThemeProvider* provider = static_cast<GtkThemeProvider*>( | 90 GtkThemeProvider* provider = static_cast<GtkThemeProvider*>( |
91 Source<GtkThemeProvider>(source).ptr()); | 91 Source<GtkThemeProvider>(source).ptr()); |
92 DCHECK_EQ(provider, theme_provider_); | 92 DCHECK_EQ(provider, theme_provider_); |
93 GtkButtonWidth = 0; | 93 GtkButtonWidth = 0; |
94 UpdateThemeButtons(); | 94 UpdateThemeButtons(); |
95 } | 95 } |
96 | 96 |
97 void ReloadButtonGtk::OnButtonTimer() { | 97 void ReloadButtonGtk::OnButtonTimer() { |
98 ChangeMode(intended_mode_, true); | 98 ChangeMode(intended_mode_, false); |
99 } | 99 } |
100 | 100 |
101 void ReloadButtonGtk::OnClicked(GtkWidget* sender) { | 101 void ReloadButtonGtk::OnClicked(GtkWidget* sender) { |
102 if (visible_mode_ == MODE_STOP) { | 102 if (visible_mode_ == MODE_STOP) { |
103 if (browser_) | 103 if (browser_) |
104 browser_->Stop(); | 104 browser_->Stop(); |
105 | 105 |
106 // The user has clicked, so we can feel free to update the button, | 106 // The user has clicked, so we can feel free to update the button, |
107 // even if the mouse is still hovering. | 107 // even if the mouse is still hovering. |
108 ChangeMode(MODE_RELOAD, true); | 108 ChangeMode(MODE_RELOAD, true); |
(...skipping 14 matching lines...) Expand all Loading... |
123 | 123 |
124 WindowOpenDisposition disposition = | 124 WindowOpenDisposition disposition = |
125 event_utils::DispositionFromEventFlags(modifier_state_uint); | 125 event_utils::DispositionFromEventFlags(modifier_state_uint); |
126 if (disposition == CURRENT_TAB) { | 126 if (disposition == CURRENT_TAB) { |
127 // Forcibly reset the location bar, since otherwise it won't discard any | 127 // Forcibly reset the location bar, since otherwise it won't discard any |
128 // ongoing user edits, since it doesn't realize this is a user-initiated | 128 // ongoing user edits, since it doesn't realize this is a user-initiated |
129 // action. | 129 // action. |
130 location_bar_->Revert(); | 130 location_bar_->Revert(); |
131 } | 131 } |
132 | 132 |
133 if (browser_) | |
134 browser_->ExecuteCommandWithDisposition(command, disposition); | |
135 | |
136 // Figure out the system double-click time. | 133 // Figure out the system double-click time. |
137 if (button_delay_ == 0) { | 134 if (button_delay_ == 0) { |
138 GtkSettings* settings = gtk_settings_get_default(); | 135 GtkSettings* settings = gtk_settings_get_default(); |
139 g_object_get(G_OBJECT(settings), "gtk-double-click-time", &button_delay_, | 136 g_object_get(G_OBJECT(settings), "gtk-double-click-time", &button_delay_, |
140 NULL); | 137 NULL); |
141 } | 138 } |
142 | 139 |
143 // Start a timer - while this timer is running, the reload button cannot be | 140 // Start a timer - while this timer is running, the reload button cannot be |
144 // changed to a stop button. We do not set |intended_mode_| to MODE_STOP | 141 // changed to a stop button. We do not set |intended_mode_| to MODE_STOP |
145 // here as we want to wait for the browser to tell us that it has started | 142 // here as the browser will do that when it actually starts loading (which |
146 // loading (and this may occur only after some delay). | 143 // may happen synchronously, thus the need to do this before telling the |
| 144 // browser to execute the reload command). |
147 timer_.Stop(); | 145 timer_.Stop(); |
148 timer_.Start(base::TimeDelta::FromMilliseconds(button_delay_), this, | 146 timer_.Start(base::TimeDelta::FromMilliseconds(button_delay_), this, |
149 &ReloadButtonGtk::OnButtonTimer); | 147 &ReloadButtonGtk::OnButtonTimer); |
| 148 |
| 149 if (browser_) |
| 150 browser_->ExecuteCommandWithDisposition(command, disposition); |
150 } | 151 } |
151 } | 152 } |
152 | 153 |
153 gboolean ReloadButtonGtk::OnExpose(GtkWidget* widget, | 154 gboolean ReloadButtonGtk::OnExpose(GtkWidget* widget, |
154 GdkEventExpose* e) { | 155 GdkEventExpose* e) { |
155 if (theme_provider_ && theme_provider_->UseGtkTheme()) | 156 if (theme_provider_ && theme_provider_->UseGtkTheme()) |
156 return FALSE; | 157 return FALSE; |
157 return ((visible_mode_ == MODE_RELOAD) ? reload_ : stop_).OnExpose( | 158 return ((visible_mode_ == MODE_RELOAD) ? reload_ : stop_).OnExpose( |
158 widget, e, hover_controller_.GetCurrentValue()); | 159 widget, e, hover_controller_.GetCurrentValue()); |
159 } | 160 } |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
206 reload_.Height()); | 207 reload_.Height()); |
207 | 208 |
208 gtk_widget_set_app_paintable(widget_.get(), TRUE); | 209 gtk_widget_set_app_paintable(widget_.get(), TRUE); |
209 // We effectively double-buffer by virtue of having only one image... | 210 // We effectively double-buffer by virtue of having only one image... |
210 gtk_widget_set_double_buffered(widget_.get(), FALSE); | 211 gtk_widget_set_double_buffered(widget_.get(), FALSE); |
211 } | 212 } |
212 | 213 |
213 gtk_chrome_button_set_use_gtk_rendering( | 214 gtk_chrome_button_set_use_gtk_rendering( |
214 GTK_CHROME_BUTTON(widget_.get()), use_gtk); | 215 GTK_CHROME_BUTTON(widget_.get()), use_gtk); |
215 } | 216 } |
OLD | NEW |