| 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/foreign_session_handler.h" | 5 #include "chrome/browser/ui/webui/foreign_session_handler.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 176 LOG(ERROR) << "ForeignSessionHandler failed to get session data from" | 176 LOG(ERROR) << "ForeignSessionHandler failed to get session data from" |
| 177 "OpenTabsUIDelegate."; | 177 "OpenTabsUIDelegate."; |
| 178 return; | 178 return; |
| 179 } | 179 } |
| 180 std::vector<const ::sessions::SessionWindow*>::const_iterator iter_begin = | 180 std::vector<const ::sessions::SessionWindow*>::const_iterator iter_begin = |
| 181 windows.begin() + (window_num == kInvalidId ? 0 : window_num); | 181 windows.begin() + (window_num == kInvalidId ? 0 : window_num); |
| 182 std::vector<const ::sessions::SessionWindow*>::const_iterator iter_end = | 182 std::vector<const ::sessions::SessionWindow*>::const_iterator iter_end = |
| 183 window_num == kInvalidId ? | 183 window_num == kInvalidId ? |
| 184 std::vector<const ::sessions::SessionWindow*>::const_iterator( | 184 std::vector<const ::sessions::SessionWindow*>::const_iterator( |
| 185 windows.end()) : iter_begin + 1; | 185 windows.end()) : iter_begin + 1; |
| 186 chrome::HostDesktopType host_desktop_type = | 186 SessionRestore::RestoreForeignSessionWindows(Profile::FromWebUI(web_ui), |
| 187 chrome::GetHostDesktopTypeForNativeView( | 187 iter_begin, iter_end); |
| 188 web_ui->GetWebContents()->GetNativeView()); | |
| 189 SessionRestore::RestoreForeignSessionWindows( | |
| 190 Profile::FromWebUI(web_ui), host_desktop_type, iter_begin, iter_end); | |
| 191 } | 188 } |
| 192 | 189 |
| 193 // static | 190 // static |
| 194 sync_driver::OpenTabsUIDelegate* ForeignSessionHandler::GetOpenTabsUIDelegate( | 191 sync_driver::OpenTabsUIDelegate* ForeignSessionHandler::GetOpenTabsUIDelegate( |
| 195 content::WebUI* web_ui) { | 192 content::WebUI* web_ui) { |
| 196 Profile* profile = Profile::FromWebUI(web_ui); | 193 Profile* profile = Profile::FromWebUI(web_ui); |
| 197 ProfileSyncService* service = | 194 ProfileSyncService* service = |
| 198 ProfileSyncServiceFactory::GetInstance()->GetForProfile(profile); | 195 ProfileSyncServiceFactory::GetInstance()->GetForProfile(profile); |
| 199 | 196 |
| 200 // Only return the delegate if it exists and it is done syncing sessions. | 197 // Only return the delegate if it exists and it is done syncing sessions. |
| (...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 430 // collapsed state persists. | 427 // collapsed state persists. |
| 431 PrefService* prefs = Profile::FromWebUI(web_ui())->GetPrefs(); | 428 PrefService* prefs = Profile::FromWebUI(web_ui())->GetPrefs(); |
| 432 DictionaryPrefUpdate update(prefs, prefs::kNtpCollapsedForeignSessions); | 429 DictionaryPrefUpdate update(prefs, prefs::kNtpCollapsedForeignSessions); |
| 433 if (is_collapsed) | 430 if (is_collapsed) |
| 434 update.Get()->SetBoolean(session_tag, true); | 431 update.Get()->SetBoolean(session_tag, true); |
| 435 else | 432 else |
| 436 update.Get()->Remove(session_tag, NULL); | 433 update.Get()->Remove(session_tag, NULL); |
| 437 } | 434 } |
| 438 | 435 |
| 439 } // namespace browser_sync | 436 } // namespace browser_sync |
| OLD | NEW |