Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(328)

Side by Side Diff: chrome/browser/gtk/browser_actions_toolbar_gtk.cc

Issue 337035: Replace ExtensionAction with ExtensionAction2. (Closed)
Patch Set: Remove todo Created 11 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/browser/tab_contents/tab_contents.h" 20 #include "chrome/browser/tab_contents/tab_contents.h"
21 #include "chrome/common/extensions/extension.h" 21 #include "chrome/common/extensions/extension.h"
22 #include "chrome/common/extensions/extension_action2.h" 22 #include "chrome/common/extensions/extension_action.h"
23 #include "chrome/common/gtk_util.h" 23 #include "chrome/common/gtk_util.h"
24 #include "chrome/common/notification_details.h" 24 #include "chrome/common/notification_details.h"
25 #include "chrome/common/notification_service.h" 25 #include "chrome/common/notification_service.h"
26 #include "chrome/common/notification_source.h" 26 #include "chrome/common/notification_source.h"
27 #include "chrome/common/notification_type.h" 27 #include "chrome/common/notification_type.h"
28 28
29 // The size of each button on the toolbar. 29 // The size of each button on the toolbar.
30 static const int kButtonSize = 29; 30 static const int kButtonSize = 29;
31 31
32 // The padding between browser action buttons. Visually, the actual number of 32 // The padding between browser action buttons. Visually, the actual number of
(...skipping 28 matching lines...) Expand all
61 Extension::kBrowserActionIconMaxSize)); 61 Extension::kBrowserActionIconMaxSize));
62 } 62 }
63 63
64 // We need to hook up extension popups here. http://crbug.com/23897 64 // We need to hook up extension popups here. http://crbug.com/23897
65 g_signal_connect(button_.get(), "clicked", 65 g_signal_connect(button_.get(), "clicked",
66 G_CALLBACK(OnButtonClicked), this); 66 G_CALLBACK(OnButtonClicked), this);
67 g_signal_connect_after(button_.get(), "expose-event", 67 g_signal_connect_after(button_.get(), "expose-event",
68 G_CALLBACK(OnExposeEvent), this); 68 G_CALLBACK(OnExposeEvent), this);
69 69
70 registrar_.Add(this, NotificationType::EXTENSION_BROWSER_ACTION_UPDATED, 70 registrar_.Add(this, NotificationType::EXTENSION_BROWSER_ACTION_UPDATED,
71 Source<ExtensionAction2>(extension->browser_action())); 71 Source<ExtensionAction>(extension->browser_action()));
72 registrar_.Add(this, NotificationType::BROWSER_THEME_CHANGED, 72 registrar_.Add(this, NotificationType::BROWSER_THEME_CHANGED,
73 NotificationService::AllSources()); 73 NotificationService::AllSources());
74 74
75 OnThemeChanged(); 75 OnThemeChanged();
76 } 76 }
77 77
78 ~BrowserActionButton() { 78 ~BrowserActionButton() {
79 if (tab_specific_icon_) 79 if (tab_specific_icon_)
80 g_object_unref(tab_specific_icon_); 80 g_object_unref(tab_specific_icon_);
81 81
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 } 155 }
156 } 156 }
157 157
158 static gboolean OnExposeEvent(GtkWidget* widget, 158 static gboolean OnExposeEvent(GtkWidget* widget,
159 GdkEventExpose* event, 159 GdkEventExpose* event,
160 BrowserActionButton* button) { 160 BrowserActionButton* button) {
161 int tab_id = button->toolbar_->GetCurrentTabId(); 161 int tab_id = button->toolbar_->GetCurrentTabId();
162 if (tab_id < 0) 162 if (tab_id < 0)
163 return FALSE; 163 return FALSE;
164 164
165 ExtensionAction2* action = button->extension_->browser_action(); 165 ExtensionAction* action = button->extension_->browser_action();
166 if (action->GetBadgeText(tab_id).empty()) 166 if (action->GetBadgeText(tab_id).empty())
167 return FALSE; 167 return FALSE;
168 168
169 gfx::CanvasPaint canvas(event, false); 169 gfx::CanvasPaint canvas(event, false);
170 gfx::Rect bounding_rect(widget->allocation); 170 gfx::Rect bounding_rect(widget->allocation);
171 action->PaintBadge(&canvas, bounding_rect, tab_id); 171 action->PaintBadge(&canvas, bounding_rect, tab_id);
172 return FALSE; 172 return FALSE;
173 } 173 }
174 174
175 // The toolbar containing this button. 175 // The toolbar containing this button.
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 if (extension_button_map_.erase(extension->id())) 273 if (extension_button_map_.erase(extension->id()))
274 UpdateVisibility(); 274 UpdateVisibility();
275 } 275 }
276 276
277 void BrowserActionsToolbarGtk::UpdateVisibility() { 277 void BrowserActionsToolbarGtk::UpdateVisibility() {
278 if (button_count() == 0) 278 if (button_count() == 0)
279 gtk_widget_hide(widget()); 279 gtk_widget_hide(widget());
280 else 280 else
281 gtk_widget_show(widget()); 281 gtk_widget_show(widget());
282 } 282 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/page_action_apitest.cc ('k') | chrome/browser/gtk/location_bar_view_gtk.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698