| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
| 10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
| 11 #include "chrome/browser/sessions/tab_restore_service_delegate.h" | 11 #include "chrome/browser/sessions/tab_restore_service_delegate.h" |
| 12 #include "chrome/browser/sessions/tab_restore_service_factory.h" | 12 #include "chrome/browser/sessions/tab_restore_service_factory.h" |
| 13 #include "chrome/browser/ui/host_desktop.h" | 13 #include "chrome/browser/ui/host_desktop.h" |
| 14 #include "chrome/browser/ui/webui/ntp/new_tab_ui.h" | 14 #include "chrome/browser/ui/webui/ntp/new_tab_ui.h" |
| 15 #include "chrome/common/url_constants.h" | 15 #include "chrome/common/url_constants.h" |
| 16 #include "content/public/browser/web_contents.h" | 16 #include "content/public/browser/web_contents.h" |
| 17 #include "content/public/browser/web_contents_view.h" | 17 #include "content/public/browser/web_contents_view.h" |
| 18 #include "content/public/browser/web_ui.h" | 18 #include "content/public/browser/web_ui.h" |
| 19 #include "ui/webui/web_ui_util.h" | 19 #include "ui/webui/web_ui_util.h" |
| 20 | 20 |
| 21 #if defined(OS_ANDROID) | 21 #if defined(OS_ANDROID) |
| 22 #include "chrome/browser/sessions/session_restore.h" | 22 #include "chrome/browser/sessions/session_restore.h" |
| 23 #endif | 23 #endif |
| 24 | 24 |
| 25 namespace { | 25 namespace { |
| 26 | 26 |
| 27 void TabToValue(const TabRestoreService::Tab& tab, | 27 void TabToValue(const TabRestoreService::Tab& tab, |
| 28 DictionaryValue* dictionary) { | 28 DictionaryValue* dictionary) { |
| 29 const TabNavigation& current_navigation = | 29 const sessions::SerializedNavigationEntry& current_navigation = |
| 30 tab.navigations.at(tab.current_navigation_index); | 30 tab.navigations.at(tab.current_navigation_index); |
| 31 NewTabUI::SetUrlTitleAndDirection(dictionary, current_navigation.title(), | 31 NewTabUI::SetUrlTitleAndDirection(dictionary, current_navigation.title(), |
| 32 current_navigation.virtual_url()); | 32 current_navigation.virtual_url()); |
| 33 dictionary->SetString("type", "tab"); | 33 dictionary->SetString("type", "tab"); |
| 34 dictionary->SetDouble("timestamp", tab.timestamp.ToDoubleT()); | 34 dictionary->SetDouble("timestamp", tab.timestamp.ToDoubleT()); |
| 35 } | 35 } |
| 36 | 36 |
| 37 void WindowToValue(const TabRestoreService::Window& window, | 37 void WindowToValue(const TabRestoreService::Window& window, |
| 38 DictionaryValue* dictionary) { | 38 DictionaryValue* dictionary) { |
| 39 DCHECK(!window.tabs.empty()); | 39 DCHECK(!window.tabs.empty()); |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 182 | 182 |
| 183 // TabRestoreServiceFactory::GetForProfile() can return NULL (i.e., when in | 183 // TabRestoreServiceFactory::GetForProfile() can return NULL (i.e., when in |
| 184 // Off the Record mode) | 184 // Off the Record mode) |
| 185 if (tab_restore_service_) { | 185 if (tab_restore_service_) { |
| 186 // This does nothing if the tabs have already been loaded or they | 186 // This does nothing if the tabs have already been loaded or they |
| 187 // shouldn't be loaded. | 187 // shouldn't be loaded. |
| 188 tab_restore_service_->LoadTabsFromLastSession(); | 188 tab_restore_service_->LoadTabsFromLastSession(); |
| 189 tab_restore_service_->AddObserver(this); | 189 tab_restore_service_->AddObserver(this); |
| 190 } | 190 } |
| 191 } | 191 } |
| OLD | NEW |