| 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 <algorithm> | 7 #include <algorithm> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 #include "chrome/common/extensions/extension_action.h" | 32 #include "chrome/common/extensions/extension_action.h" |
| 33 #include "chrome/common/extensions/extension_resource.h" | 33 #include "chrome/common/extensions/extension_resource.h" |
| 34 #include "content/public/browser/notification_details.h" | 34 #include "content/public/browser/notification_details.h" |
| 35 #include "content/public/browser/notification_source.h" | 35 #include "content/public/browser/notification_source.h" |
| 36 #include "grit/theme_resources.h" | 36 #include "grit/theme_resources.h" |
| 37 #include "grit/theme_resources_standard.h" | 37 #include "grit/theme_resources_standard.h" |
| 38 #include "grit/ui_resources.h" | 38 #include "grit/ui_resources.h" |
| 39 #include "ui/base/gtk/gtk_compat.h" | 39 #include "ui/base/gtk/gtk_compat.h" |
| 40 #include "ui/gfx/canvas_skia_paint.h" | 40 #include "ui/gfx/canvas_skia_paint.h" |
| 41 #include "ui/gfx/gtk_util.h" | 41 #include "ui/gfx/gtk_util.h" |
| 42 #include "ui/gfx/image/image.h" |
| 42 | 43 |
| 43 namespace { | 44 namespace { |
| 44 | 45 |
| 45 // The width of the browser action buttons. | 46 // The width of the browser action buttons. |
| 46 const int kButtonWidth = 27; | 47 const int kButtonWidth = 27; |
| 47 | 48 |
| 48 // The padding between browser action buttons. | 49 // The padding between browser action buttons. |
| 49 const int kButtonPadding = 4; | 50 const int kButtonPadding = 4; |
| 50 | 51 |
| 51 // The padding to the right of the browser action buttons (between the buttons | 52 // The padding to the right of the browser action buttons (between the buttons |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 void Observe(int type, | 154 void Observe(int type, |
| 154 const content::NotificationSource& source, | 155 const content::NotificationSource& source, |
| 155 const content::NotificationDetails& details) { | 156 const content::NotificationDetails& details) { |
| 156 if (type == chrome::NOTIFICATION_EXTENSION_BROWSER_ACTION_UPDATED) | 157 if (type == chrome::NOTIFICATION_EXTENSION_BROWSER_ACTION_UPDATED) |
| 157 UpdateState(); | 158 UpdateState(); |
| 158 else | 159 else |
| 159 NOTREACHED(); | 160 NOTREACHED(); |
| 160 } | 161 } |
| 161 | 162 |
| 162 // ImageLoadingTracker::Observer implementation. | 163 // ImageLoadingTracker::Observer implementation. |
| 163 void OnImageLoaded(SkBitmap* image, const ExtensionResource& resource, | 164 void OnImageLoaded(const gfx::Image& image, |
| 164 int index) { | 165 const std::string& extension_id, |
| 165 if (image) { | 166 int index) OVERRIDE { |
| 166 default_skbitmap_ = *image; | 167 if (!image.IsEmpty()) { |
| 167 default_icon_ = gfx::GdkPixbufFromSkBitmap(image); | 168 default_skbitmap_ = *image.ToSkBitmap(); |
| 169 default_icon_ = image.ToGdkPixbuf(); |
| 168 } | 170 } |
| 169 UpdateState(); | 171 UpdateState(); |
| 170 } | 172 } |
| 171 | 173 |
| 172 // Updates the button based on the latest state from the associated | 174 // Updates the button based on the latest state from the associated |
| 173 // browser action. | 175 // browser action. |
| 174 void UpdateState() { | 176 void UpdateState() { |
| 175 int tab_id = toolbar_->GetCurrentTabId(); | 177 int tab_id = toolbar_->GetCurrentTabId(); |
| 176 if (tab_id < 0) | 178 if (tab_id < 0) |
| 177 return; | 179 return; |
| (...skipping 795 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 973 | 975 |
| 974 menu->PopupAsContext(gfx::Point(event->x_root, event->y_root), | 976 menu->PopupAsContext(gfx::Point(event->x_root, event->y_root), |
| 975 event->time); | 977 event->time); |
| 976 return TRUE; | 978 return TRUE; |
| 977 } | 979 } |
| 978 | 980 |
| 979 void BrowserActionsToolbarGtk::OnButtonShowOrHide(GtkWidget* sender) { | 981 void BrowserActionsToolbarGtk::OnButtonShowOrHide(GtkWidget* sender) { |
| 980 if (!resize_animation_.is_animating()) | 982 if (!resize_animation_.is_animating()) |
| 981 UpdateChevronVisibility(); | 983 UpdateChevronVisibility(); |
| 982 } | 984 } |
| OLD | NEW |