OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/browser_actions_toolbar_gtk.h" | 5 #include "chrome/browser/ui/gtk/browser_actions_toolbar_gtk.h" |
6 | 6 |
7 #include <gtk/gtk.h> | 7 #include <gtk/gtk.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <vector> | 10 #include <vector> |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
216 NOTREACHED(); | 216 NOTREACHED(); |
217 break; | 217 break; |
218 } | 218 } |
219 } | 219 } |
220 | 220 |
221 // ImageLoadingTracker::Observer implementation. | 221 // ImageLoadingTracker::Observer implementation. |
222 void OnImageLoaded(const gfx::Image& image, | 222 void OnImageLoaded(const gfx::Image& image, |
223 const std::string& extension_id, | 223 const std::string& extension_id, |
224 int index) OVERRIDE { | 224 int index) OVERRIDE { |
225 extension_->browser_action()->CacheIcon( | 225 extension_->browser_action()->CacheIcon( |
226 extension_->browser_action()->default_icon_path(), image); | 226 extension_->browser_action()->default_icon_path(), |
| 227 *image.ToImageSkia()); |
227 UpdateState(); | 228 UpdateState(); |
228 } | 229 } |
229 | 230 |
230 // Updates the button based on the latest state from the associated | 231 // Updates the button based on the latest state from the associated |
231 // browser action. | 232 // browser action. |
232 void UpdateState() { | 233 void UpdateState() { |
233 int tab_id = toolbar_->GetCurrentTabId(); | 234 int tab_id = toolbar_->GetCurrentTabId(); |
234 if (tab_id < 0) | 235 if (tab_id < 0) |
235 return; | 236 return; |
236 | 237 |
237 std::string tooltip = extension_->browser_action()->GetTitle(tab_id); | 238 std::string tooltip = extension_->browser_action()->GetTitle(tab_id); |
238 if (tooltip.empty()) | 239 if (tooltip.empty()) |
239 gtk_widget_set_has_tooltip(button(), FALSE); | 240 gtk_widget_set_has_tooltip(button(), FALSE); |
240 else | 241 else |
241 gtk_widget_set_tooltip_text(button(), tooltip.c_str()); | 242 gtk_widget_set_tooltip_text(button(), tooltip.c_str()); |
242 | 243 |
243 gfx::Image image = extension_->browser_action()->GetIcon(tab_id); | 244 gfx::ImageSkia image = extension_->browser_action()->GetIcon(tab_id); |
244 if (!image.IsEmpty()) | 245 if (!image.empty()) |
245 SetImage(image.ToGdkPixbuf()); | 246 SetImage(gfx::GdkPixbufFromSkBitmap(*image.bitmap())); |
246 bool enabled = extension_->browser_action()->GetIsVisible(tab_id); | 247 bool enabled = extension_->browser_action()->GetIsVisible(tab_id); |
247 gtk_widget_set_sensitive(button(), enabled); | 248 gtk_widget_set_sensitive(button(), enabled); |
248 | 249 |
249 gtk_widget_queue_draw(button()); | 250 gtk_widget_queue_draw(button()); |
250 } | 251 } |
251 | 252 |
252 SkBitmap GetIcon() { | 253 gfx::ImageSkia GetIcon() { |
253 return *extension_->browser_action()->GetIcon( | 254 return extension_->browser_action()->GetIcon(toolbar_->GetCurrentTabId()); |
254 toolbar_->GetCurrentTabId()).ToSkBitmap(); | |
255 } | 255 } |
256 | 256 |
257 MenuGtk* GetContextMenu() { | 257 MenuGtk* GetContextMenu() { |
258 if (!extension_->ShowConfigureContextMenus()) | 258 if (!extension_->ShowConfigureContextMenus()) |
259 return NULL; | 259 return NULL; |
260 | 260 |
261 context_menu_model_ = | 261 context_menu_model_ = |
262 new ExtensionContextMenuModel(extension_, toolbar_->browser(), this); | 262 new ExtensionContextMenuModel(extension_, toolbar_->browser(), this); |
263 context_menu_.reset( | 263 context_menu_.reset( |
264 new MenuGtk(this, context_menu_model_.get())); | 264 new MenuGtk(this, context_menu_model_.get())); |
(...skipping 828 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1093 | 1093 |
1094 menu->PopupAsContext(gfx::Point(event->x_root, event->y_root), | 1094 menu->PopupAsContext(gfx::Point(event->x_root, event->y_root), |
1095 event->time); | 1095 event->time); |
1096 return TRUE; | 1096 return TRUE; |
1097 } | 1097 } |
1098 | 1098 |
1099 void BrowserActionsToolbarGtk::OnButtonShowOrHide(GtkWidget* sender) { | 1099 void BrowserActionsToolbarGtk::OnButtonShowOrHide(GtkWidget* sender) { |
1100 if (!resize_animation_.is_animating()) | 1100 if (!resize_animation_.is_animating()) |
1101 UpdateChevronVisibility(); | 1101 UpdateChevronVisibility(); |
1102 } | 1102 } |
OLD | NEW |