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

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

Issue 6901031: Profile shouldn't own Session/TabRestore services. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase again and hope upload works this time Created 9 years, 8 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/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/utf_string_conversions.h" 10 #include "base/utf_string_conversions.h"
11 #include "base/string_number_conversions.h" 11 #include "base/string_number_conversions.h"
12 #include "chrome/browser/favicon_service.h" 12 #include "chrome/browser/favicon_service.h"
13 #include "chrome/browser/profiles/profile.h" 13 #include "chrome/browser/profiles/profile.h"
14 #include "chrome/browser/sessions/tab_restore_service.h"
15 #include "chrome/browser/sessions/tab_restore_service_factory.h"
14 #include "chrome/browser/ui/browser.h" 16 #include "chrome/browser/ui/browser.h"
15 #include "chrome/browser/ui/browser_tab_restore_service_delegate.h" 17 #include "chrome/browser/ui/browser_tab_restore_service_delegate.h"
16 #include "chrome/browser/ui/gtk/global_menu_bar.h" 18 #include "chrome/browser/ui/gtk/global_menu_bar.h"
17 #include "chrome/browser/ui/gtk/gtk_theme_service.h" 19 #include "chrome/browser/ui/gtk/gtk_theme_service.h"
18 #include "chrome/browser/ui/gtk/gtk_util.h" 20 #include "chrome/browser/ui/gtk/gtk_util.h"
19 #include "chrome/browser/ui/gtk/owned_widget_gtk.h" 21 #include "chrome/browser/ui/gtk/owned_widget_gtk.h"
20 #include "chrome/common/url_constants.h" 22 #include "chrome/common/url_constants.h"
21 #include "content/common/notification_service.h" 23 #include "content/common/notification_service.h"
22 #include "grit/generated_resources.h" 24 #include "grit/generated_resources.h"
23 #include "ui/base/l10n/l10n_util.h" 25 #include "ui/base/l10n/l10n_util.h"
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 menu_item_history_map_.end()); 107 menu_item_history_map_.end());
106 menu_item_history_map_.clear(); 108 menu_item_history_map_.clear();
107 } 109 }
108 110
109 void GlobalHistoryMenu::Init(GtkWidget* history_menu) { 111 void GlobalHistoryMenu::Init(GtkWidget* history_menu) {
110 history_menu_ = history_menu; 112 history_menu_ = history_menu;
111 113
112 default_favicon_ = GtkThemeService::GetDefaultFavicon(true); 114 default_favicon_ = GtkThemeService::GetDefaultFavicon(true);
113 115
114 if (profile_) { 116 if (profile_) {
115 tab_restore_service_ = profile_->GetTabRestoreService(); 117 tab_restore_service_ = TabRestoreServiceFactory::GetForProfile(profile_);
116 if (tab_restore_service_) { 118 if (tab_restore_service_) {
117 tab_restore_service_->LoadTabsFromLastSession(); 119 tab_restore_service_->LoadTabsFromLastSession();
118 tab_restore_service_->AddObserver(this); 120 tab_restore_service_->AddObserver(this);
119 121
120 // If LoadTabsFromLastSession doesn't load tabs, it won't call 122 // If LoadTabsFromLastSession doesn't load tabs, it won't call
121 // TabRestoreServiceChanged(). This ensures that all new windows after 123 // TabRestoreServiceChanged(). This ensures that all new windows after
122 // the first one will have their menus populated correctly. 124 // the first one will have their menus populated correctly.
123 TabRestoreServiceChanged(tab_restore_service_); 125 TabRestoreServiceChanged(tab_restore_service_);
124 } 126 }
125 127
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after
443 tab_restore_service_ = NULL; 445 tab_restore_service_ = NULL;
444 } 446 }
445 447
446 void GlobalHistoryMenu::OnRecentlyClosedItemActivated(GtkWidget* sender) { 448 void GlobalHistoryMenu::OnRecentlyClosedItemActivated(GtkWidget* sender) {
447 WindowOpenDisposition disposition = 449 WindowOpenDisposition disposition =
448 gtk_util::DispositionForCurrentButtonPressEvent(); 450 gtk_util::DispositionForCurrentButtonPressEvent();
449 HistoryItem* item = HistoryItemForMenuItem(sender); 451 HistoryItem* item = HistoryItemForMenuItem(sender);
450 452
451 // If this item can be restored using TabRestoreService, do so. Otherwise, 453 // If this item can be restored using TabRestoreService, do so. Otherwise,
452 // just load the URL. 454 // just load the URL.
453 TabRestoreService* service = browser_->profile()->GetTabRestoreService(); 455 TabRestoreService* service =
456 TabRestoreServiceFactory::GetForProfile(browser_->profile());
454 if (item->session_id && service) { 457 if (item->session_id && service) {
455 service->RestoreEntryById(browser_->tab_restore_service_delegate(), 458 service->RestoreEntryById(browser_->tab_restore_service_delegate(),
456 item->session_id, false); 459 item->session_id, false);
457 } else { 460 } else {
458 DCHECK(item->url.is_valid()); 461 DCHECK(item->url.is_valid());
459 browser_->OpenURL(item->url, GURL(), disposition, 462 browser_->OpenURL(item->url, GURL(), disposition,
460 PageTransition::AUTO_BOOKMARK); 463 PageTransition::AUTO_BOOKMARK);
461 } 464 }
462 } 465 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/cocoa/history_menu_cocoa_controller.mm ('k') | chrome/browser/ui/views/frame/browser_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698