| OLD | NEW |
| 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/global_bookmark_menu.h" | 5 #include "chrome/browser/ui/gtk/global_bookmark_menu.h" |
| 6 | 6 |
| 7 #include <dlfcn.h> | 7 #include <dlfcn.h> |
| 8 #include <gtk/gtk.h> | 8 #include <gtk/gtk.h> |
| 9 | 9 |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 | 53 |
| 54 GlobalBookmarkMenu::GlobalBookmarkMenu(Browser* browser) | 54 GlobalBookmarkMenu::GlobalBookmarkMenu(Browser* browser) |
| 55 : browser_(browser), | 55 : browser_(browser), |
| 56 profile_(browser->profile()), | 56 profile_(browser->profile()), |
| 57 default_favicon_(NULL), | 57 default_favicon_(NULL), |
| 58 ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)) { | 58 ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)) { |
| 59 DCHECK(profile_); | 59 DCHECK(profile_); |
| 60 | 60 |
| 61 default_favicon_ = GtkThemeService::GetDefaultFavicon(true); | 61 default_favicon_ = GtkThemeService::GetDefaultFavicon(true); |
| 62 default_folder_ = GtkThemeService::GetFolderIcon(true); | 62 default_folder_ = GtkThemeService::GetFolderIcon(true); |
| 63 registrar_.Add(this, NotificationType::BROWSER_THEME_CHANGED, | 63 registrar_.Add(this, chrome::NOTIFICATION_BROWSER_THEME_CHANGED, |
| 64 Source<ThemeService>( | 64 Source<ThemeService>( |
| 65 ThemeServiceFactory::GetForProfile(profile_))); | 65 ThemeServiceFactory::GetForProfile(profile_))); |
| 66 } | 66 } |
| 67 | 67 |
| 68 GlobalBookmarkMenu::~GlobalBookmarkMenu() { | 68 GlobalBookmarkMenu::~GlobalBookmarkMenu() { |
| 69 profile_->GetBookmarkModel()->RemoveObserver(this); | 69 profile_->GetBookmarkModel()->RemoveObserver(this); |
| 70 } | 70 } |
| 71 | 71 |
| 72 void GlobalBookmarkMenu::Init(GtkWidget* bookmark_menu, | 72 void GlobalBookmarkMenu::Init(GtkWidget* bookmark_menu, |
| 73 GtkWidget* bookmark_menu_item) { | 73 GtkWidget* bookmark_menu_item) { |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 218 } | 218 } |
| 219 | 219 |
| 220 // static | 220 // static |
| 221 void GlobalBookmarkMenu::ClearBookmarkItemCallback(GtkWidget* menu_item, | 221 void GlobalBookmarkMenu::ClearBookmarkItemCallback(GtkWidget* menu_item, |
| 222 void* unused) { | 222 void* unused) { |
| 223 int tag = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(menu_item), "type-tag")); | 223 int tag = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(menu_item), "type-tag")); |
| 224 if (tag == GlobalMenuBar::TAG_BOOKMARK_CLEARABLE) | 224 if (tag == GlobalMenuBar::TAG_BOOKMARK_CLEARABLE) |
| 225 gtk_widget_destroy(menu_item); | 225 gtk_widget_destroy(menu_item); |
| 226 } | 226 } |
| 227 | 227 |
| 228 void GlobalBookmarkMenu::Observe(NotificationType type, | 228 void GlobalBookmarkMenu::Observe(int type, |
| 229 const NotificationSource& source, | 229 const NotificationSource& source, |
| 230 const NotificationDetails& details) { | 230 const NotificationDetails& details) { |
| 231 DCHECK(type.value == NotificationType::BROWSER_THEME_CHANGED); | 231 DCHECK(type == chrome::NOTIFICATION_BROWSER_THEME_CHANGED); |
| 232 | 232 |
| 233 // Change the icon and invalidate the menu. | 233 // Change the icon and invalidate the menu. |
| 234 default_favicon_ = GtkThemeService::GetDefaultFavicon(true); | 234 default_favicon_ = GtkThemeService::GetDefaultFavicon(true); |
| 235 default_folder_ = GtkThemeService::GetFolderIcon(true); | 235 default_folder_ = GtkThemeService::GetFolderIcon(true); |
| 236 RebuildMenuInFuture(); | 236 RebuildMenuInFuture(); |
| 237 } | 237 } |
| 238 | 238 |
| 239 void GlobalBookmarkMenu::Loaded(BookmarkModel* model) { | 239 void GlobalBookmarkMenu::Loaded(BookmarkModel* model) { |
| 240 // If we have a Loaded() event, then we need to build the menu immediately | 240 // If we have a Loaded() event, then we need to build the menu immediately |
| 241 // for the first time. | 241 // for the first time. |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 294 void GlobalBookmarkMenu::OnBookmarkItemActivated(GtkWidget* menu_item) { | 294 void GlobalBookmarkMenu::OnBookmarkItemActivated(GtkWidget* menu_item) { |
| 295 // The actual mouse event that generated this activated event was in a | 295 // The actual mouse event that generated this activated event was in a |
| 296 // different process. Go with something default. | 296 // different process. Go with something default. |
| 297 const BookmarkNode* node = static_cast<const BookmarkNode*>( | 297 const BookmarkNode* node = static_cast<const BookmarkNode*>( |
| 298 g_object_get_data(G_OBJECT(menu_item), "bookmark-node")); | 298 g_object_get_data(G_OBJECT(menu_item), "bookmark-node")); |
| 299 | 299 |
| 300 browser_->OpenURL(node->GetURL(), GURL(), NEW_FOREGROUND_TAB, | 300 browser_->OpenURL(node->GetURL(), GURL(), NEW_FOREGROUND_TAB, |
| 301 PageTransition::AUTO_BOOKMARK); | 301 PageTransition::AUTO_BOOKMARK); |
| 302 } | 302 } |
| 303 | 303 |
| OLD | NEW |