| 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 "chrome/browser/ui/webui/ntp/recently_closed_tabs_handler.h" | 5 #include "chrome/browser/ui/webui/ntp/recently_closed_tabs_handler.h" |
| 6 | 6 |
| 7 #include "base/metrics/histogram.h" | 7 #include "base/metrics/histogram.h" |
| 8 #include "chrome/browser/profiles/profile.h" |
| 8 #include "chrome/browser/sessions/tab_restore_service_delegate.h" | 9 #include "chrome/browser/sessions/tab_restore_service_delegate.h" |
| 9 #include "chrome/browser/sessions/tab_restore_service_factory.h" | 10 #include "chrome/browser/sessions/tab_restore_service_factory.h" |
| 10 #include "chrome/browser/ui/webui/ntp/new_tab_ui.h" | 11 #include "chrome/browser/ui/webui/ntp/new_tab_ui.h" |
| 11 #include "chrome/common/url_constants.h" | 12 #include "chrome/common/url_constants.h" |
| 12 #include "content/browser/tab_contents/tab_contents.h" | 13 #include "content/browser/tab_contents/tab_contents.h" |
| 13 | 14 |
| 14 namespace { | 15 namespace { |
| 15 | 16 |
| 16 bool IsTabUnique(const DictionaryValue* tab, | 17 bool IsTabUnique(const DictionaryValue* tab, |
| 17 std::set<std::string>* unique_items) { | 18 std::set<std::string>* unique_items) { |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 | 106 |
| 106 tab_restore_service_->RestoreEntryById(delegate, session_to_restore, true); | 107 tab_restore_service_->RestoreEntryById(delegate, session_to_restore, true); |
| 107 // The current tab has been nuked at this point; don't touch any member | 108 // The current tab has been nuked at this point; don't touch any member |
| 108 // variables. | 109 // variables. |
| 109 } | 110 } |
| 110 | 111 |
| 111 void RecentlyClosedTabsHandler::HandleGetRecentlyClosedTabs( | 112 void RecentlyClosedTabsHandler::HandleGetRecentlyClosedTabs( |
| 112 const ListValue* args) { | 113 const ListValue* args) { |
| 113 if (!tab_restore_service_) { | 114 if (!tab_restore_service_) { |
| 114 tab_restore_service_ = | 115 tab_restore_service_ = |
| 115 TabRestoreServiceFactory::GetForProfile(web_ui_->GetProfile()); | 116 TabRestoreServiceFactory::GetForProfile(Profile::FromWebUI(web_ui_)); |
| 116 | 117 |
| 117 // TabRestoreServiceFactory::GetForProfile() can return NULL (i.e., when in | 118 // TabRestoreServiceFactory::GetForProfile() can return NULL (i.e., when in |
| 118 // Off the Record mode) | 119 // Off the Record mode) |
| 119 if (tab_restore_service_) { | 120 if (tab_restore_service_) { |
| 120 // This does nothing if the tabs have already been loaded or they | 121 // This does nothing if the tabs have already been loaded or they |
| 121 // shouldn't be loaded. | 122 // shouldn't be loaded. |
| 122 tab_restore_service_->LoadTabsFromLastSession(); | 123 tab_restore_service_->LoadTabsFromLastSession(); |
| 123 | 124 |
| 124 tab_restore_service_->AddObserver(this); | 125 tab_restore_service_->AddObserver(this); |
| 125 } | 126 } |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 163 (entry->type == TabRestoreService::WINDOW && | 164 (entry->type == TabRestoreService::WINDOW && |
| 164 WindowToValue( | 165 WindowToValue( |
| 165 *static_cast<TabRestoreService::Window*>(entry), | 166 *static_cast<TabRestoreService::Window*>(entry), |
| 166 entry_dict.get()))) { | 167 entry_dict.get()))) { |
| 167 entry_dict->SetInteger("sessionId", entry->id); | 168 entry_dict->SetInteger("sessionId", entry->id); |
| 168 entry_list_value->Append(entry_dict.release()); | 169 entry_list_value->Append(entry_dict.release()); |
| 169 added_count++; | 170 added_count++; |
| 170 } | 171 } |
| 171 } | 172 } |
| 172 } | 173 } |
| OLD | NEW |