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

Side by Side Diff: chrome/browser/ui/webui/new_tab_ui.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, 7 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
« no previous file with comments | « chrome/browser/ui/views/frame/browser_view.cc ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "build/build_config.h" 5 #include "build/build_config.h"
6 6
7 #include "chrome/browser/ui/webui/new_tab_ui.h" 7 #include "chrome/browser/ui/webui/new_tab_ui.h"
8 8
9 #include <set> 9 #include <set>
10 10
11 #include "base/callback.h" 11 #include "base/callback.h"
12 #include "base/command_line.h" 12 #include "base/command_line.h"
13 #include "base/i18n/rtl.h" 13 #include "base/i18n/rtl.h"
14 #include "base/memory/singleton.h" 14 #include "base/memory/singleton.h"
15 #include "base/metrics/histogram.h" 15 #include "base/metrics/histogram.h"
16 #include "base/string_number_conversions.h" 16 #include "base/string_number_conversions.h"
17 #include "base/threading/thread.h" 17 #include "base/threading/thread.h"
18 #include "base/utf_string_conversions.h" 18 #include "base/utf_string_conversions.h"
19 #include "chrome/browser/prefs/pref_service.h" 19 #include "chrome/browser/prefs/pref_service.h"
20 #include "chrome/browser/profiles/profile.h" 20 #include "chrome/browser/profiles/profile.h"
21 #include "chrome/browser/sessions/session_types.h" 21 #include "chrome/browser/sessions/session_types.h"
22 #include "chrome/browser/sessions/tab_restore_service.h" 22 #include "chrome/browser/sessions/tab_restore_service.h"
23 #include "chrome/browser/sessions/tab_restore_service_delegate.h" 23 #include "chrome/browser/sessions/tab_restore_service_delegate.h"
24 #include "chrome/browser/sessions/tab_restore_service_factory.h"
24 #include "chrome/browser/sessions/tab_restore_service_observer.h" 25 #include "chrome/browser/sessions/tab_restore_service_observer.h"
25 #include "chrome/browser/sync/profile_sync_service.h" 26 #include "chrome/browser/sync/profile_sync_service.h"
26 #include "chrome/browser/themes/theme_service.h" 27 #include "chrome/browser/themes/theme_service.h"
27 #include "chrome/browser/themes/theme_service_factory.h" 28 #include "chrome/browser/themes/theme_service_factory.h"
28 #include "chrome/browser/ui/browser.h" 29 #include "chrome/browser/ui/browser.h"
29 #include "chrome/browser/ui/webui/app_launcher_handler.h" 30 #include "chrome/browser/ui/webui/app_launcher_handler.h"
30 #include "chrome/browser/ui/webui/foreign_session_handler.h" 31 #include "chrome/browser/ui/webui/foreign_session_handler.h"
31 #include "chrome/browser/ui/webui/most_visited_handler.h" 32 #include "chrome/browser/ui/webui/most_visited_handler.h"
32 #include "chrome/browser/ui/webui/new_tab_page_sync_handler.h" 33 #include "chrome/browser/ui/webui/new_tab_page_sync_handler.h"
33 #include "chrome/browser/ui/webui/ntp_login_handler.h" 34 #include "chrome/browser/ui/webui/ntp_login_handler.h"
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 int session_to_restore; 125 int session_to_restore;
125 if (ExtractIntegerValue(args, &session_to_restore)) 126 if (ExtractIntegerValue(args, &session_to_restore))
126 tab_restore_service_->RestoreEntryById(delegate, session_to_restore, true); 127 tab_restore_service_->RestoreEntryById(delegate, session_to_restore, true);
127 // The current tab has been nuked at this point; don't touch any member 128 // The current tab has been nuked at this point; don't touch any member
128 // variables. 129 // variables.
129 } 130 }
130 131
131 void RecentlyClosedTabsHandler::HandleGetRecentlyClosedTabs( 132 void RecentlyClosedTabsHandler::HandleGetRecentlyClosedTabs(
132 const ListValue* args) { 133 const ListValue* args) {
133 if (!tab_restore_service_) { 134 if (!tab_restore_service_) {
134 tab_restore_service_ = web_ui_->GetProfile()->GetTabRestoreService(); 135 tab_restore_service_ =
136 TabRestoreServiceFactory::GetForProfile(web_ui_->GetProfile());
135 137
136 // GetTabRestoreService() can return NULL (i.e., when in Off the 138 // TabRestoreServiceFactory::GetForProfile() can return NULL (i.e., when in
137 // Record mode) 139 // Off the Record mode)
138 if (tab_restore_service_) { 140 if (tab_restore_service_) {
139 // This does nothing if the tabs have already been loaded or they 141 // This does nothing if the tabs have already been loaded or they
140 // shouldn't be loaded. 142 // shouldn't be loaded.
141 tab_restore_service_->LoadTabsFromLastSession(); 143 tab_restore_service_->LoadTabsFromLastSession();
142 144
143 tab_restore_service_->AddObserver(this); 145 tab_restore_service_->AddObserver(this);
144 } 146 }
145 } 147 }
146 148
147 if (tab_restore_service_) 149 if (tab_restore_service_)
(...skipping 448 matching lines...) Expand 10 before | Expand all | Expand 10 after
596 SendResponse(request_id, html_bytes); 598 SendResponse(request_id, html_bytes);
597 } 599 }
598 600
599 std::string NewTabUI::NewTabHTMLSource::GetMimeType(const std::string&) const { 601 std::string NewTabUI::NewTabHTMLSource::GetMimeType(const std::string&) const {
600 return "text/html"; 602 return "text/html";
601 } 603 }
602 604
603 bool NewTabUI::NewTabHTMLSource::ShouldReplaceExistingSource() const { 605 bool NewTabUI::NewTabHTMLSource::ShouldReplaceExistingSource() const {
604 return false; 606 return false;
605 } 607 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/frame/browser_view.cc ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698