| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/browser_actions_toolbar_gtk.h" | 5 #include "chrome/browser/gtk/browser_actions_toolbar_gtk.h" |
| 6 | 6 |
| 7 #include <gtk/gtk.h> | 7 #include <gtk/gtk.h> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "app/gfx/canvas_paint.h" | 10 #include "app/gfx/canvas_paint.h" |
| 11 #include "app/gfx/gtk_util.h" | 11 #include "app/gfx/gtk_util.h" |
| 12 #include "chrome/browser/browser.h" | 12 #include "chrome/browser/browser.h" |
| 13 #include "chrome/browser/extensions/extension_browser_event_router.h" | 13 #include "chrome/browser/extensions/extension_browser_event_router.h" |
| 14 #include "chrome/browser/extensions/extensions_service.h" | 14 #include "chrome/browser/extensions/extensions_service.h" |
| 15 #include "chrome/browser/extensions/image_loading_tracker.h" | 15 #include "chrome/browser/extensions/image_loading_tracker.h" |
| 16 #include "chrome/browser/gtk/extension_popup_gtk.h" | 16 #include "chrome/browser/gtk/extension_popup_gtk.h" |
| 17 #include "chrome/browser/gtk/gtk_chrome_button.h" | 17 #include "chrome/browser/gtk/gtk_chrome_button.h" |
| 18 #include "chrome/browser/gtk/gtk_theme_provider.h" | 18 #include "chrome/browser/gtk/gtk_theme_provider.h" |
| 19 #include "chrome/browser/profile.h" | 19 #include "chrome/browser/profile.h" |
| 20 #include "chrome/common/extensions/extension.h" | 20 #include "chrome/common/extensions/extension.h" |
| 21 #include "chrome/common/gtk_util.h" |
| 21 #include "chrome/common/notification_details.h" | 22 #include "chrome/common/notification_details.h" |
| 22 #include "chrome/common/notification_service.h" | 23 #include "chrome/common/notification_service.h" |
| 23 #include "chrome/common/notification_source.h" | 24 #include "chrome/common/notification_source.h" |
| 24 #include "chrome/common/notification_type.h" | 25 #include "chrome/common/notification_type.h" |
| 25 | 26 |
| 26 // The size of each button on the toolbar. | 27 // The size of each button on the toolbar. |
| 27 static const int kButtonSize = 29; | 28 static const int kButtonSize = 29; |
| 28 | 29 |
| 29 class BrowserActionButton : public NotificationObserver, | 30 class BrowserActionButton : public NotificationObserver, |
| 30 public ImageLoadingTracker::Observer { | 31 public ImageLoadingTracker::Observer { |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 } | 121 } |
| 121 } | 122 } |
| 122 | 123 |
| 123 void OnThemeChanged() { | 124 void OnThemeChanged() { |
| 124 gtk_chrome_button_set_use_gtk_rendering(GTK_CHROME_BUTTON(button_.get()), | 125 gtk_chrome_button_set_use_gtk_rendering(GTK_CHROME_BUTTON(button_.get()), |
| 125 GtkThemeProvider::GetFrom(browser_->profile())->UseGtkTheme()); | 126 GtkThemeProvider::GetFrom(browser_->profile())->UseGtkTheme()); |
| 126 } | 127 } |
| 127 | 128 |
| 128 static void OnButtonClicked(GtkWidget* widget, BrowserActionButton* action) { | 129 static void OnButtonClicked(GtkWidget* widget, BrowserActionButton* action) { |
| 129 if (action->extension_->browser_action()->is_popup()) { | 130 if (action->extension_->browser_action()->is_popup()) { |
| 130 ExtensionPopupGtk::Show(action->extension_->browser_action()->popup_url(), | 131 ExtensionPopupGtk::Show( |
| 131 action->browser_, gfx::Rect(widget->allocation)); | 132 action->extension_->browser_action()->popup_url(), |
| 132 | 133 action->browser_, |
| 134 gtk_util::GetWidgetRectRelativeToToplevel(widget)); |
| 133 } else { | 135 } else { |
| 134 ExtensionBrowserEventRouter::GetInstance()->BrowserActionExecuted( | 136 ExtensionBrowserEventRouter::GetInstance()->BrowserActionExecuted( |
| 135 action->browser_->profile(), action->extension_->id(), | 137 action->browser_->profile(), action->extension_->id(), |
| 136 action->browser_); | 138 action->browser_); |
| 137 } | 139 } |
| 138 } | 140 } |
| 139 | 141 |
| 140 static gboolean OnExposeEvent(GtkWidget* widget, | 142 static gboolean OnExposeEvent(GtkWidget* widget, |
| 141 GdkEventExpose* event, | 143 GdkEventExpose* event, |
| 142 BrowserActionButton* action) { | 144 BrowserActionButton* action) { |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 244 if (extension_button_map_.erase(extension->id())) | 246 if (extension_button_map_.erase(extension->id())) |
| 245 UpdateVisibility(); | 247 UpdateVisibility(); |
| 246 } | 248 } |
| 247 | 249 |
| 248 void BrowserActionsToolbarGtk::UpdateVisibility() { | 250 void BrowserActionsToolbarGtk::UpdateVisibility() { |
| 249 if (button_count() == 0) | 251 if (button_count() == 0) |
| 250 gtk_widget_hide(widget()); | 252 gtk_widget_hide(widget()); |
| 251 else | 253 else |
| 252 gtk_widget_show(widget()); | 254 gtk_widget_show(widget()); |
| 253 } | 255 } |
| OLD | NEW |