OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/bind.h" | 9 #include "base/bind.h" |
10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
11 #include "base/stl_util.h" | 11 #include "base/stl_util.h" |
12 #include "base/string_number_conversions.h" | 12 #include "base/string_number_conversions.h" |
13 #include "base/utf_string_conversions.h" | 13 #include "base/utf_string_conversions.h" |
14 #include "chrome/browser/history/top_sites.h" | 14 #include "chrome/browser/history/top_sites.h" |
15 #include "chrome/browser/profiles/profile.h" | 15 #include "chrome/browser/profiles/profile.h" |
16 #include "chrome/browser/sessions/tab_restore_service.h" | 16 #include "chrome/browser/sessions/tab_restore_service.h" |
17 #include "chrome/browser/sessions/tab_restore_service_factory.h" | 17 #include "chrome/browser/sessions/tab_restore_service_factory.h" |
18 #include "chrome/browser/themes/theme_service_factory.h" | 18 #include "chrome/browser/themes/theme_service_factory.h" |
19 #include "chrome/browser/ui/browser.h" | 19 #include "chrome/browser/ui/browser.h" |
20 #include "chrome/browser/ui/browser_tab_restore_service_delegate.h" | 20 #include "chrome/browser/ui/browser_tab_restore_service_delegate.h" |
| 21 #include "chrome/browser/ui/gtk/event_utils.h" |
21 #include "chrome/browser/ui/gtk/global_menu_bar.h" | 22 #include "chrome/browser/ui/gtk/global_menu_bar.h" |
22 #include "chrome/browser/ui/gtk/gtk_theme_service.h" | 23 #include "chrome/browser/ui/gtk/gtk_theme_service.h" |
23 #include "chrome/browser/ui/gtk/gtk_util.h" | 24 #include "chrome/browser/ui/gtk/gtk_util.h" |
24 #include "chrome/common/chrome_notification_types.h" | 25 #include "chrome/common/chrome_notification_types.h" |
25 #include "chrome/common/url_constants.h" | 26 #include "chrome/common/url_constants.h" |
26 #include "content/public/browser/notification_source.h" | 27 #include "content/public/browser/notification_source.h" |
27 #include "grit/generated_resources.h" | 28 #include "grit/generated_resources.h" |
28 #include "ui/base/gtk/owned_widget_gtk.h" | 29 #include "ui/base/gtk/owned_widget_gtk.h" |
29 #include "ui/base/l10n/l10n_util.h" | 30 #include "ui/base/l10n/l10n_util.h" |
30 #include "ui/base/text/text_elider.h" | 31 #include "ui/base/text/text_elider.h" |
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
368 } | 369 } |
369 } | 370 } |
370 | 371 |
371 void GlobalHistoryMenu::TabRestoreServiceDestroyed( | 372 void GlobalHistoryMenu::TabRestoreServiceDestroyed( |
372 TabRestoreService* service) { | 373 TabRestoreService* service) { |
373 tab_restore_service_ = NULL; | 374 tab_restore_service_ = NULL; |
374 } | 375 } |
375 | 376 |
376 void GlobalHistoryMenu::OnRecentlyClosedItemActivated(GtkWidget* sender) { | 377 void GlobalHistoryMenu::OnRecentlyClosedItemActivated(GtkWidget* sender) { |
377 WindowOpenDisposition disposition = | 378 WindowOpenDisposition disposition = |
378 gtk_util::DispositionForCurrentButtonPressEvent(); | 379 event_utils::DispositionForCurrentButtonPressEvent(); |
379 HistoryItem* item = HistoryItemForMenuItem(sender); | 380 HistoryItem* item = HistoryItemForMenuItem(sender); |
380 | 381 |
381 // If this item can be restored using TabRestoreService, do so. Otherwise, | 382 // If this item can be restored using TabRestoreService, do so. Otherwise, |
382 // just load the URL. | 383 // just load the URL. |
383 TabRestoreService* service = | 384 TabRestoreService* service = |
384 TabRestoreServiceFactory::GetForProfile(browser_->profile()); | 385 TabRestoreServiceFactory::GetForProfile(browser_->profile()); |
385 if (item->session_id && service) { | 386 if (item->session_id && service) { |
386 service->RestoreEntryById(browser_->tab_restore_service_delegate(), | 387 service->RestoreEntryById(browser_->tab_restore_service_delegate(), |
387 item->session_id, UNKNOWN); | 388 item->session_id, UNKNOWN); |
388 } else { | 389 } else { |
(...skipping 10 matching lines...) Expand all Loading... |
399 tab_restore_service_->LoadTabsFromLastSession(); | 400 tab_restore_service_->LoadTabsFromLastSession(); |
400 tab_restore_service_->AddObserver(this); | 401 tab_restore_service_->AddObserver(this); |
401 | 402 |
402 // If LoadTabsFromLastSession doesn't load tabs, it won't call | 403 // If LoadTabsFromLastSession doesn't load tabs, it won't call |
403 // TabRestoreServiceChanged(). This ensures that all new windows after | 404 // TabRestoreServiceChanged(). This ensures that all new windows after |
404 // the first one will have their menus populated correctly. | 405 // the first one will have their menus populated correctly. |
405 TabRestoreServiceChanged(tab_restore_service_); | 406 TabRestoreServiceChanged(tab_restore_service_); |
406 } | 407 } |
407 } | 408 } |
408 } | 409 } |
OLD | NEW |