| 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_history_menu.h" | 5 #include "chrome/browser/ui/gtk/global_history_menu.h" |
| 6 | 6 |
| 7 #include <gtk/gtk.h> | 7 #include <gtk/gtk.h> |
| 8 | 8 |
| 9 #include "base/stl_util-inl.h" | 9 #include "base/stl_util-inl.h" |
| 10 #include "base/string_number_conversions.h" | 10 #include "base/string_number_conversions.h" |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 g_signal_connect(history_menu_item, "activate", | 111 g_signal_connect(history_menu_item, "activate", |
| 112 G_CALLBACK(OnMenuActivateThunk), this); | 112 G_CALLBACK(OnMenuActivateThunk), this); |
| 113 | 113 |
| 114 if (profile_) { | 114 if (profile_) { |
| 115 top_sites_ = profile_->GetTopSites(); | 115 top_sites_ = profile_->GetTopSites(); |
| 116 if (top_sites_) { | 116 if (top_sites_) { |
| 117 GetTopSitesData(); | 117 GetTopSitesData(); |
| 118 | 118 |
| 119 // Register for notification when TopSites changes so that we can update | 119 // Register for notification when TopSites changes so that we can update |
| 120 // ourself. | 120 // ourself. |
| 121 registrar_.Add(this, NotificationType::TOP_SITES_CHANGED, | 121 registrar_.Add(this, chrome::TOP_SITES_CHANGED, |
| 122 Source<history::TopSites>(top_sites_)); | 122 Source<history::TopSites>(top_sites_)); |
| 123 } | 123 } |
| 124 } | 124 } |
| 125 } | 125 } |
| 126 | 126 |
| 127 void GlobalHistoryMenu::GetTopSitesData() { | 127 void GlobalHistoryMenu::GetTopSitesData() { |
| 128 DCHECK(top_sites_); | 128 DCHECK(top_sites_); |
| 129 | 129 |
| 130 top_sites_->GetMostVisitedURLs( | 130 top_sites_->GetMostVisitedURLs( |
| 131 &top_sites_consumer_, | 131 &top_sites_consumer_, |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 271 } | 271 } |
| 272 | 272 |
| 273 GtkWidget* submenu = gtk_menu_item_get_submenu(GTK_MENU_ITEM(menu_item)); | 273 GtkWidget* submenu = gtk_menu_item_get_submenu(GTK_MENU_ITEM(menu_item)); |
| 274 if (submenu) | 274 if (submenu) |
| 275 closure->menu_bar->ClearMenuSection(submenu, closure->tag); | 275 closure->menu_bar->ClearMenuSection(submenu, closure->tag); |
| 276 | 276 |
| 277 gtk_container_remove(GTK_CONTAINER(closure->container), menu_item); | 277 gtk_container_remove(GTK_CONTAINER(closure->container), menu_item); |
| 278 } | 278 } |
| 279 } | 279 } |
| 280 | 280 |
| 281 void GlobalHistoryMenu::Observe(NotificationType type, | 281 void GlobalHistoryMenu::Observe(int type, |
| 282 const NotificationSource& source, | 282 const NotificationSource& source, |
| 283 const NotificationDetails& details) { | 283 const NotificationDetails& details) { |
| 284 if (type.value == NotificationType::TOP_SITES_CHANGED) { | 284 if (type == chrome::TOP_SITES_CHANGED) { |
| 285 if (Source<history::TopSites>(source).ptr() == top_sites_) | 285 if (Source<history::TopSites>(source).ptr() == top_sites_) |
| 286 GetTopSitesData(); | 286 GetTopSitesData(); |
| 287 } else { | 287 } else { |
| 288 NOTREACHED(); | 288 NOTREACHED(); |
| 289 } | 289 } |
| 290 } | 290 } |
| 291 | 291 |
| 292 void GlobalHistoryMenu::TabRestoreServiceChanged(TabRestoreService* service) { | 292 void GlobalHistoryMenu::TabRestoreServiceChanged(TabRestoreService* service) { |
| 293 const TabRestoreService::Entries& entries = service->entries(); | 293 const TabRestoreService::Entries& entries = service->entries(); |
| 294 | 294 |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 434 tab_restore_service_->LoadTabsFromLastSession(); | 434 tab_restore_service_->LoadTabsFromLastSession(); |
| 435 tab_restore_service_->AddObserver(this); | 435 tab_restore_service_->AddObserver(this); |
| 436 | 436 |
| 437 // If LoadTabsFromLastSession doesn't load tabs, it won't call | 437 // If LoadTabsFromLastSession doesn't load tabs, it won't call |
| 438 // TabRestoreServiceChanged(). This ensures that all new windows after | 438 // TabRestoreServiceChanged(). This ensures that all new windows after |
| 439 // the first one will have their menus populated correctly. | 439 // the first one will have their menus populated correctly. |
| 440 TabRestoreServiceChanged(tab_restore_service_); | 440 TabRestoreServiceChanged(tab_restore_service_); |
| 441 } | 441 } |
| 442 } | 442 } |
| 443 } | 443 } |
| OLD | NEW |