Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(118)

Side by Side Diff: chrome/browser/ui/webui/foreign_session_handler.cc

Issue 2499023004: [Sync] Introduce SyncedSessionWindow type. (Closed)
Patch Set: Address comments Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <memory> 10 #include <memory>
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after
294 if (is_collapsed) 294 if (is_collapsed)
295 current_collapsed_sessions->SetBoolean(session_tag, true); 295 current_collapsed_sessions->SetBoolean(session_tag, true);
296 296
297 std::unique_ptr<base::ListValue> window_list(new base::ListValue()); 297 std::unique_ptr<base::ListValue> window_list(new base::ListValue());
298 const std::string group_name = 298 const std::string group_name =
299 base::FieldTrialList::FindFullName("TabSyncByRecency"); 299 base::FieldTrialList::FindFullName("TabSyncByRecency");
300 if (group_name != "Enabled") { 300 if (group_name != "Enabled") {
301 // Order tabs by visual order within window. 301 // Order tabs by visual order within window.
302 for (const auto& window_pair : session->windows) { 302 for (const auto& window_pair : session->windows) {
303 std::unique_ptr<base::DictionaryValue> window_data( 303 std::unique_ptr<base::DictionaryValue> window_data(
304 SessionWindowToValue(*window_pair.second.get())); 304 SessionWindowToValue(window_pair.second->wrapped_window));
305 if (window_data.get()) 305 if (window_data.get())
306 window_list->Append(std::move(window_data)); 306 window_list->Append(std::move(window_data));
307 } 307 }
308 } else { 308 } else {
309 // Order tabs by recency. This involves creating a synthetic singleton 309 // Order tabs by recency. This involves creating a synthetic singleton
310 // window that contains all the tabs of the session. 310 // window that contains all the tabs of the session.
311 base::Time modification_time; 311 base::Time modification_time;
312 std::vector<const ::sessions::SessionTab*> tabs; 312 std::vector<const ::sessions::SessionTab*> tabs;
313 open_tabs->GetForeignSessionTabs(session_tag, &tabs); 313 open_tabs->GetForeignSessionTabs(session_tag, &tabs);
314 std::unique_ptr<base::ListValue> tab_values(new base::ListValue()); 314 std::unique_ptr<base::ListValue> tab_values(new base::ListValue());
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
427 // collapsed state persists. 427 // collapsed state persists.
428 PrefService* prefs = Profile::FromWebUI(web_ui())->GetPrefs(); 428 PrefService* prefs = Profile::FromWebUI(web_ui())->GetPrefs();
429 DictionaryPrefUpdate update(prefs, prefs::kNtpCollapsedForeignSessions); 429 DictionaryPrefUpdate update(prefs, prefs::kNtpCollapsedForeignSessions);
430 if (is_collapsed) 430 if (is_collapsed)
431 update.Get()->SetBoolean(session_tag, true); 431 update.Get()->SetBoolean(session_tag, true);
432 else 432 else
433 update.Get()->Remove(session_tag, NULL); 433 update.Get()->Remove(session_tag, NULL);
434 } 434 }
435 435
436 } // namespace browser_sync 436 } // namespace browser_sync
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698