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_ui.h" | 18 #include "content/public/browser/web_ui.h" |
18 #include "ui/webui/web_ui_util.h" | 19 #include "ui/webui/web_ui_util.h" |
19 | 20 |
20 #if defined(OS_ANDROID) | 21 #if defined(OS_ANDROID) |
21 #include "chrome/browser/sessions/session_restore.h" | 22 #include "chrome/browser/sessions/session_restore.h" |
22 #endif | 23 #endif |
23 | 24 |
24 namespace { | 25 namespace { |
25 | 26 |
26 void TabToValue(const TabRestoreService::Tab& tab, | 27 void TabToValue(const TabRestoreService::Tab& tab, |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 UMA_HISTOGRAM_ENUMERATION("NewTabPage.SessionRestore", | 100 UMA_HISTOGRAM_ENUMERATION("NewTabPage.SessionRestore", |
100 static_cast<int>(index), 20); | 101 static_cast<int>(index), 20); |
101 | 102 |
102 TabRestoreServiceDelegate* delegate = | 103 TabRestoreServiceDelegate* delegate = |
103 TabRestoreServiceDelegate::FindDelegateForWebContents( | 104 TabRestoreServiceDelegate::FindDelegateForWebContents( |
104 web_ui()->GetWebContents()); | 105 web_ui()->GetWebContents()); |
105 if (!delegate) | 106 if (!delegate) |
106 return; | 107 return; |
107 chrome::HostDesktopType host_desktop_type = | 108 chrome::HostDesktopType host_desktop_type = |
108 chrome::GetHostDesktopTypeForNativeView( | 109 chrome::GetHostDesktopTypeForNativeView( |
109 web_ui()->GetWebContents()->GetNativeView()); | 110 web_ui()->GetWebContents()->GetView()->GetNativeView()); |
110 WindowOpenDisposition disposition = webui::GetDispositionFromClick(args, 2); | 111 WindowOpenDisposition disposition = webui::GetDispositionFromClick(args, 2); |
111 tab_restore_service_->RestoreEntryById(delegate, | 112 tab_restore_service_->RestoreEntryById(delegate, |
112 static_cast<int>(session_to_restore), | 113 static_cast<int>(session_to_restore), |
113 host_desktop_type, | 114 host_desktop_type, |
114 disposition); | 115 disposition); |
115 // The current tab has been nuked at this point; don't touch any member | 116 // The current tab has been nuked at this point; don't touch any member |
116 // variables. | 117 // variables. |
117 #endif | 118 #endif |
118 } | 119 } |
119 | 120 |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
181 | 182 |
182 // TabRestoreServiceFactory::GetForProfile() can return NULL (i.e., when in | 183 // TabRestoreServiceFactory::GetForProfile() can return NULL (i.e., when in |
183 // Off the Record mode) | 184 // Off the Record mode) |
184 if (tab_restore_service_) { | 185 if (tab_restore_service_) { |
185 // 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 |
186 // shouldn't be loaded. | 187 // shouldn't be loaded. |
187 tab_restore_service_->LoadTabsFromLastSession(); | 188 tab_restore_service_->LoadTabsFromLastSession(); |
188 tab_restore_service_->AddObserver(this); | 189 tab_restore_service_->AddObserver(this); |
189 } | 190 } |
190 } | 191 } |
OLD | NEW |