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

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

Issue 7327007: Moving notification types which are chrome specific to a new header file chrome_notification_type... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 5 months 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/i18n/rtl.h" 10 #include "base/i18n/rtl.h"
11 #include "base/utf_string_conversions.h" 11 #include "base/utf_string_conversions.h"
12 #include "chrome/browser/extensions/extension_browser_event_router.h" 12 #include "chrome/browser/extensions/extension_browser_event_router.h"
13 #include "chrome/browser/extensions/extension_context_menu_model.h" 13 #include "chrome/browser/extensions/extension_context_menu_model.h"
14 #include "chrome/browser/extensions/extension_service.h" 14 #include "chrome/browser/extensions/extension_service.h"
15 #include "chrome/browser/extensions/image_loading_tracker.h" 15 #include "chrome/browser/extensions/image_loading_tracker.h"
16 #include "chrome/browser/profiles/profile.h" 16 #include "chrome/browser/profiles/profile.h"
17 #include "chrome/browser/sessions/restore_tab_helper.h" 17 #include "chrome/browser/sessions/restore_tab_helper.h"
18 #include "chrome/browser/ui/browser.h" 18 #include "chrome/browser/ui/browser.h"
19 #include "chrome/browser/ui/gtk/cairo_cached_surface.h" 19 #include "chrome/browser/ui/gtk/cairo_cached_surface.h"
20 #include "chrome/browser/ui/gtk/extensions/extension_popup_gtk.h" 20 #include "chrome/browser/ui/gtk/extensions/extension_popup_gtk.h"
21 #include "chrome/browser/ui/gtk/gtk_chrome_button.h" 21 #include "chrome/browser/ui/gtk/gtk_chrome_button.h"
22 #include "chrome/browser/ui/gtk/gtk_chrome_shrinkable_hbox.h" 22 #include "chrome/browser/ui/gtk/gtk_chrome_shrinkable_hbox.h"
23 #include "chrome/browser/ui/gtk/gtk_theme_service.h" 23 #include "chrome/browser/ui/gtk/gtk_theme_service.h"
24 #include "chrome/browser/ui/gtk/gtk_util.h" 24 #include "chrome/browser/ui/gtk/gtk_util.h"
25 #include "chrome/browser/ui/gtk/hover_controller_gtk.h" 25 #include "chrome/browser/ui/gtk/hover_controller_gtk.h"
26 #include "chrome/browser/ui/gtk/menu_gtk.h" 26 #include "chrome/browser/ui/gtk/menu_gtk.h"
27 #include "chrome/browser/ui/gtk/view_id_util.h" 27 #include "chrome/browser/ui/gtk/view_id_util.h"
28 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" 28 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
29 #include "chrome/common/chrome_notification_types.h"
29 #include "chrome/common/extensions/extension.h" 30 #include "chrome/common/extensions/extension.h"
30 #include "chrome/common/extensions/extension_action.h" 31 #include "chrome/common/extensions/extension_action.h"
31 #include "chrome/common/extensions/extension_resource.h" 32 #include "chrome/common/extensions/extension_resource.h"
32 #include "content/browser/tab_contents/tab_contents.h" 33 #include "content/browser/tab_contents/tab_contents.h"
33 #include "content/common/notification_details.h" 34 #include "content/common/notification_details.h"
34 #include "content/common/notification_service.h" 35 #include "content/common/notification_service.h"
35 #include "content/common/notification_source.h" 36 #include "content/common/notification_source.h"
36 #include "content/common/notification_type.h"
37 #include "grit/theme_resources.h" 37 #include "grit/theme_resources.h"
38 #include "grit/theme_resources_standard.h" 38 #include "grit/theme_resources_standard.h"
39 #include "grit/ui_resources.h" 39 #include "grit/ui_resources.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 42
43 namespace { 43 namespace {
44 44
45 // The width of the browser action buttons. 45 // The width of the browser action buttons.
46 const int kButtonWidth = 27; 46 const int kButtonWidth = 27;
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 122
123 signals_.Connect(button(), "button-press-event", 123 signals_.Connect(button(), "button-press-event",
124 G_CALLBACK(OnButtonPress), this); 124 G_CALLBACK(OnButtonPress), this);
125 signals_.Connect(button(), "clicked", 125 signals_.Connect(button(), "clicked",
126 G_CALLBACK(OnClicked), this); 126 G_CALLBACK(OnClicked), this);
127 signals_.Connect(button(), "drag-begin", 127 signals_.Connect(button(), "drag-begin",
128 G_CALLBACK(&OnDragBegin), this); 128 G_CALLBACK(&OnDragBegin), this);
129 signals_.ConnectAfter(widget(), "expose-event", 129 signals_.ConnectAfter(widget(), "expose-event",
130 G_CALLBACK(OnExposeEvent), this); 130 G_CALLBACK(OnExposeEvent), this);
131 131
132 registrar_.Add(this, NotificationType::EXTENSION_BROWSER_ACTION_UPDATED, 132 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_BROWSER_ACTION_UPDATED,
133 Source<ExtensionAction>(extension->browser_action())); 133 Source<ExtensionAction>(extension->browser_action()));
134 } 134 }
135 135
136 ~BrowserActionButton() { 136 ~BrowserActionButton() {
137 if (tab_specific_icon_) 137 if (tab_specific_icon_)
138 g_object_unref(tab_specific_icon_); 138 g_object_unref(tab_specific_icon_);
139 139
140 if (default_icon_) 140 if (default_icon_)
141 g_object_unref(default_icon_); 141 g_object_unref(default_icon_);
142 142
143 alignment_.Destroy(); 143 alignment_.Destroy();
144 } 144 }
145 145
146 GtkWidget* button() { return button_->widget(); } 146 GtkWidget* button() { return button_->widget(); }
147 147
148 GtkWidget* widget() { return alignment_.get(); } 148 GtkWidget* widget() { return alignment_.get(); }
149 149
150 const Extension* extension() { return extension_; } 150 const Extension* extension() { return extension_; }
151 151
152 // NotificationObserver implementation. 152 // NotificationObserver implementation.
153 void Observe(NotificationType type, 153 void Observe(int type,
154 const NotificationSource& source, 154 const NotificationSource& source,
155 const NotificationDetails& details) { 155 const NotificationDetails& details) {
156 if (type == NotificationType::EXTENSION_BROWSER_ACTION_UPDATED) 156 if (type == chrome::NOTIFICATION_EXTENSION_BROWSER_ACTION_UPDATED)
157 UpdateState(); 157 UpdateState();
158 else 158 else
159 NOTREACHED(); 159 NOTREACHED();
160 } 160 }
161 161
162 // ImageLoadingTracker::Observer implementation. 162 // ImageLoadingTracker::Observer implementation.
163 void OnImageLoaded(SkBitmap* image, const ExtensionResource& resource, 163 void OnImageLoaded(SkBitmap* image, const ExtensionResource& resource,
164 int index) { 164 int index) {
165 if (image) { 165 if (image) {
166 default_skbitmap_ = *image; 166 default_skbitmap_ = *image;
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after
442 } 442 }
443 443
444 // We want to connect to "set-focus" on the toplevel window; we have to wait 444 // We want to connect to "set-focus" on the toplevel window; we have to wait
445 // until we are added to a toplevel window to do so. 445 // until we are added to a toplevel window to do so.
446 signals_.Connect(widget(), "hierarchy-changed", 446 signals_.Connect(widget(), "hierarchy-changed",
447 G_CALLBACK(OnHierarchyChangedThunk), this); 447 G_CALLBACK(OnHierarchyChangedThunk), this);
448 448
449 ViewIDUtil::SetID(button_hbox_.get(), VIEW_ID_BROWSER_ACTION_TOOLBAR); 449 ViewIDUtil::SetID(button_hbox_.get(), VIEW_ID_BROWSER_ACTION_TOOLBAR);
450 450
451 registrar_.Add(this, 451 registrar_.Add(this,
452 NotificationType::BROWSER_THEME_CHANGED, 452 chrome::NOTIFICATION_BROWSER_THEME_CHANGED,
453 NotificationService::AllSources()); 453 NotificationService::AllSources());
454 theme_service_->InitThemesFor(this); 454 theme_service_->InitThemesFor(this);
455 } 455 }
456 456
457 BrowserActionsToolbarGtk::~BrowserActionsToolbarGtk() { 457 BrowserActionsToolbarGtk::~BrowserActionsToolbarGtk() {
458 if (model_) 458 if (model_)
459 model_->RemoveObserver(this); 459 model_->RemoveObserver(this);
460 button_hbox_.Destroy(); 460 button_hbox_.Destroy();
461 hbox_.Destroy(); 461 hbox_.Destroy();
462 } 462 }
463 463
464 int BrowserActionsToolbarGtk::GetCurrentTabId() { 464 int BrowserActionsToolbarGtk::GetCurrentTabId() {
465 TabContentsWrapper* selected_tab = browser_->GetSelectedTabContentsWrapper(); 465 TabContentsWrapper* selected_tab = browser_->GetSelectedTabContentsWrapper();
466 if (!selected_tab) 466 if (!selected_tab)
467 return -1; 467 return -1;
468 468
469 return selected_tab->restore_tab_helper()->session_id().id(); 469 return selected_tab->restore_tab_helper()->session_id().id();
470 } 470 }
471 471
472 void BrowserActionsToolbarGtk::Update() { 472 void BrowserActionsToolbarGtk::Update() {
473 for (ExtensionButtonMap::iterator iter = extension_button_map_.begin(); 473 for (ExtensionButtonMap::iterator iter = extension_button_map_.begin();
474 iter != extension_button_map_.end(); ++iter) { 474 iter != extension_button_map_.end(); ++iter) {
475 iter->second->UpdateState(); 475 iter->second->UpdateState();
476 } 476 }
477 } 477 }
478 478
479 void BrowserActionsToolbarGtk::Observe(NotificationType type, 479 void BrowserActionsToolbarGtk::Observe(int type,
480 const NotificationSource& source, 480 const NotificationSource& source,
481 const NotificationDetails& details) { 481 const NotificationDetails& details) {
482 DCHECK(NotificationType::BROWSER_THEME_CHANGED == type); 482 DCHECK(chrome::NOTIFICATION_BROWSER_THEME_CHANGED == type);
483 gtk_widget_set_visible(separator_, theme_service_->UsingNativeTheme()); 483 gtk_widget_set_visible(separator_, theme_service_->UsingNativeTheme());
484 } 484 }
485 485
486 void BrowserActionsToolbarGtk::SetupDrags() { 486 void BrowserActionsToolbarGtk::SetupDrags() {
487 GtkTargetEntry drag_target = GetDragTargetEntry(); 487 GtkTargetEntry drag_target = GetDragTargetEntry();
488 gtk_drag_dest_set(button_hbox_.get(), GTK_DEST_DEFAULT_DROP, &drag_target, 1, 488 gtk_drag_dest_set(button_hbox_.get(), GTK_DEST_DEFAULT_DROP, &drag_target, 1,
489 GDK_ACTION_MOVE); 489 GDK_ACTION_MOVE);
490 490
491 signals_.Connect(button_hbox_.get(), "drag-motion", 491 signals_.Connect(button_hbox_.get(), "drag-motion",
492 G_CALLBACK(OnDragMotionThunk), this); 492 G_CALLBACK(OnDragMotionThunk), this);
(...skipping 457 matching lines...) Expand 10 before | Expand all | Expand 10 after
950 950
951 menu->PopupAsContext(gfx::Point(event->x_root, event->y_root), 951 menu->PopupAsContext(gfx::Point(event->x_root, event->y_root),
952 event->time); 952 event->time);
953 return TRUE; 953 return TRUE;
954 } 954 }
955 955
956 void BrowserActionsToolbarGtk::OnButtonShowOrHide(GtkWidget* sender) { 956 void BrowserActionsToolbarGtk::OnButtonShowOrHide(GtkWidget* sender) {
957 if (!resize_animation_.is_animating()) 957 if (!resize_animation_.is_animating())
958 UpdateChevronVisibility(); 958 UpdateChevronVisibility();
959 } 959 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/gtk/browser_actions_toolbar_gtk.h ('k') | chrome/browser/ui/gtk/browser_titlebar.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698