| 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 "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/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_delegate.h" |
| 25 #include "chrome/browser/sessions/tab_restore_service_factory.h" |
| 25 #include "chrome/browser/sessions/tab_restore_service_observer.h" | 26 #include "chrome/browser/sessions/tab_restore_service_observer.h" |
| 26 #include "chrome/browser/sync/profile_sync_service.h" | 27 #include "chrome/browser/sync/profile_sync_service.h" |
| 27 #include "chrome/browser/themes/theme_service.h" | 28 #include "chrome/browser/themes/theme_service.h" |
| 28 #include "chrome/browser/themes/theme_service_factory.h" | 29 #include "chrome/browser/themes/theme_service_factory.h" |
| 29 #include "chrome/browser/ui/browser.h" | 30 #include "chrome/browser/ui/browser.h" |
| 30 #include "chrome/browser/ui/webui/app_launcher_handler.h" | 31 #include "chrome/browser/ui/webui/app_launcher_handler.h" |
| 31 #include "chrome/browser/ui/webui/foreign_session_handler.h" | 32 #include "chrome/browser/ui/webui/foreign_session_handler.h" |
| 32 #include "chrome/browser/ui/webui/most_visited_handler.h" | 33 #include "chrome/browser/ui/webui/most_visited_handler.h" |
| 33 #include "chrome/browser/ui/webui/new_tab_page_sync_handler.h" | 34 #include "chrome/browser/ui/webui/new_tab_page_sync_handler.h" |
| 34 #include "chrome/browser/ui/webui/ntp_login_handler.h" | 35 #include "chrome/browser/ui/webui/ntp_login_handler.h" |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 Loading... |
| 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 } |
| OLD | NEW |