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

Side by Side Diff: chrome/browser/ui/webui/new_tab_ui.cc

Issue 6660028: Decouple TabRestoreService from Browser (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Change new tab UI to use delegate interface Created 9 years, 9 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/browser_tab_restore_service_delegate.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/metrics/histogram.h" 14 #include "base/metrics/histogram.h"
15 #include "base/singleton.h" 15 #include "base/singleton.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/metrics/user_metrics.h" 19 #include "chrome/browser/metrics/user_metrics.h"
20 #include "chrome/browser/prefs/pref_service.h" 20 #include "chrome/browser/prefs/pref_service.h"
21 #include "chrome/browser/profiles/profile.h" 21 #include "chrome/browser/profiles/profile.h"
22 #include "chrome/browser/sessions/session_types.h" 22 #include "chrome/browser/sessions/session_types.h"
23 #include "chrome/browser/sessions/tab_restore_service.h" 23 #include "chrome/browser/sessions/tab_restore_service.h"
24 #include "chrome/browser/sessions/tab_restore_service_delegate.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/browser_theme_provider.h" 27 #include "chrome/browser/themes/browser_theme_provider.h"
27 #include "chrome/browser/ui/browser.h" 28 #include "chrome/browser/ui/browser.h"
29 #include "chrome/browser/ui/browser_tab_restore_service_delegate.h"
sky 2011/03/14 18:31:25 You shouldn't need this include, right?
28 #include "chrome/browser/ui/webui/app_launcher_handler.h" 30 #include "chrome/browser/ui/webui/app_launcher_handler.h"
29 #include "chrome/browser/ui/webui/foreign_session_handler.h" 31 #include "chrome/browser/ui/webui/foreign_session_handler.h"
30 #include "chrome/browser/ui/webui/most_visited_handler.h" 32 #include "chrome/browser/ui/webui/most_visited_handler.h"
31 #include "chrome/browser/ui/webui/new_tab_page_sync_handler.h" 33 #include "chrome/browser/ui/webui/new_tab_page_sync_handler.h"
32 #include "chrome/browser/ui/webui/ntp_login_handler.h" 34 #include "chrome/browser/ui/webui/ntp_login_handler.h"
33 #include "chrome/browser/ui/webui/ntp_resource_cache.h" 35 #include "chrome/browser/ui/webui/ntp_resource_cache.h"
34 #include "chrome/browser/ui/webui/shown_sections_handler.h" 36 #include "chrome/browser/ui/webui/shown_sections_handler.h"
35 #include "chrome/browser/ui/webui/theme_source.h" 37 #include "chrome/browser/ui/webui/theme_source.h"
36 #include "chrome/browser/ui/webui/tips_handler.h" 38 #include "chrome/browser/ui/webui/tips_handler.h"
37 #include "chrome/browser/ui/webui/value_helper.h" 39 #include "chrome/browser/ui/webui/value_helper.h"
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 web_ui_->RegisterMessageCallback("reopenTab", 109 web_ui_->RegisterMessageCallback("reopenTab",
108 NewCallback(this, &RecentlyClosedTabsHandler::HandleReopenTab)); 110 NewCallback(this, &RecentlyClosedTabsHandler::HandleReopenTab));
109 } 111 }
110 112
111 RecentlyClosedTabsHandler::~RecentlyClosedTabsHandler() { 113 RecentlyClosedTabsHandler::~RecentlyClosedTabsHandler() {
112 if (tab_restore_service_) 114 if (tab_restore_service_)
113 tab_restore_service_->RemoveObserver(this); 115 tab_restore_service_->RemoveObserver(this);
114 } 116 }
115 117
116 void RecentlyClosedTabsHandler::HandleReopenTab(const ListValue* args) { 118 void RecentlyClosedTabsHandler::HandleReopenTab(const ListValue* args) {
117 Browser* browser = Browser::GetBrowserForController( 119 TabRestoreServiceDelegate* delegate =
120 TabRestoreServiceDelegate::FindDelegateForController(
118 &web_ui_->tab_contents()->controller(), NULL); 121 &web_ui_->tab_contents()->controller(), NULL);
119 if (!browser) 122 if (!delegate)
120 return; 123 return;
121 124
122 int session_to_restore; 125 int session_to_restore;
123 if (ExtractIntegerValue(args, &session_to_restore)) 126 if (ExtractIntegerValue(args, &session_to_restore))
124 tab_restore_service_->RestoreEntryById(browser, session_to_restore, true); 127 tab_restore_service_->RestoreEntryById(delegate, session_to_restore, true);
125 // 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
126 // variables. 129 // variables.
127 } 130 }
128 131
129 void RecentlyClosedTabsHandler::HandleGetRecentlyClosedTabs( 132 void RecentlyClosedTabsHandler::HandleGetRecentlyClosedTabs(
130 const ListValue* args) { 133 const ListValue* args) {
131 if (!tab_restore_service_) { 134 if (!tab_restore_service_) {
132 tab_restore_service_ = web_ui_->GetProfile()->GetTabRestoreService(); 135 tab_restore_service_ = web_ui_->GetProfile()->GetTabRestoreService();
133 136
134 // GetTabRestoreService() can return NULL (i.e., when in Off the 137 // GetTabRestoreService() can return NULL (i.e., when in Off the
(...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after
595 SendResponse(request_id, html_bytes); 598 SendResponse(request_id, html_bytes);
596 } 599 }
597 600
598 std::string NewTabUI::NewTabHTMLSource::GetMimeType(const std::string&) const { 601 std::string NewTabUI::NewTabHTMLSource::GetMimeType(const std::string&) const {
599 return "text/html"; 602 return "text/html";
600 } 603 }
601 604
602 bool NewTabUI::NewTabHTMLSource::ShouldReplaceExistingSource() const { 605 bool NewTabUI::NewTabHTMLSource::ShouldReplaceExistingSource() const {
603 return false; 606 return false;
604 } 607 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/browser_tab_restore_service_delegate.cc ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698