| 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 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 272 current_collapsed_sessions->DeepCopy()); | 272 current_collapsed_sessions->DeepCopy()); |
| 273 current_collapsed_sessions->Clear(); | 273 current_collapsed_sessions->Clear(); |
| 274 | 274 |
| 275 // Note: we don't own the SyncedSessions themselves. | 275 // Note: we don't own the SyncedSessions themselves. |
| 276 for (size_t i = 0; i < sessions.size() && i < kMaxSessionsToShow; ++i) { | 276 for (size_t i = 0; i < sessions.size() && i < kMaxSessionsToShow; ++i) { |
| 277 const sync_driver::SyncedSession* session = sessions[i]; | 277 const sync_driver::SyncedSession* session = sessions[i]; |
| 278 const std::string& session_tag = session->session_tag; | 278 const std::string& session_tag = session->session_tag; |
| 279 scoped_ptr<base::DictionaryValue> session_data( | 279 scoped_ptr<base::DictionaryValue> session_data( |
| 280 new base::DictionaryValue()); | 280 new base::DictionaryValue()); |
| 281 // The items which are to be written into |session_data| are also | 281 // The items which are to be written into |session_data| are also |
| 282 // described in chrome/browser/resources/ntp4/other_sessions.js in | 282 // described in chrome/browser/resources/history/externs.js |
| 283 // @typedef for SessionData. Please update it whenever you add or remove | 283 // @typedef for ForeignSession. Please update it whenever you add or |
| 284 // any keys here. | 284 // remove any keys here. |
| 285 session_data->SetString("tag", session_tag); | 285 session_data->SetString("tag", session_tag); |
| 286 session_data->SetString("name", session->session_name); | 286 session_data->SetString("name", session->session_name); |
| 287 session_data->SetString("deviceType", session->DeviceTypeAsString()); | 287 session_data->SetString("deviceType", session->DeviceTypeAsString()); |
| 288 session_data->SetString("modifiedTime", | 288 session_data->SetString("modifiedTime", |
| 289 FormatSessionTime(session->modified_time)); | 289 FormatSessionTime(session->modified_time)); |
| 290 session_data->SetDouble("timestamp", session->modified_time.ToJsTime()); |
| 290 | 291 |
| 291 bool is_collapsed = collapsed_sessions->HasKey(session_tag); | 292 bool is_collapsed = collapsed_sessions->HasKey(session_tag); |
| 292 session_data->SetBoolean("collapsed", is_collapsed); | 293 session_data->SetBoolean("collapsed", is_collapsed); |
| 293 if (is_collapsed) | 294 if (is_collapsed) |
| 294 current_collapsed_sessions->SetBoolean(session_tag, true); | 295 current_collapsed_sessions->SetBoolean(session_tag, true); |
| 295 | 296 |
| 296 scoped_ptr<base::ListValue> window_list(new base::ListValue()); | 297 scoped_ptr<base::ListValue> window_list(new base::ListValue()); |
| 297 const std::string group_name = | 298 const std::string group_name = |
| 298 base::FieldTrialList::FindFullName("TabSyncByRecency"); | 299 base::FieldTrialList::FindFullName("TabSyncByRecency"); |
| 299 if (group_name != "Enabled") { | 300 if (group_name != "Enabled") { |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 426 // collapsed state persists. | 427 // collapsed state persists. |
| 427 PrefService* prefs = Profile::FromWebUI(web_ui())->GetPrefs(); | 428 PrefService* prefs = Profile::FromWebUI(web_ui())->GetPrefs(); |
| 428 DictionaryPrefUpdate update(prefs, prefs::kNtpCollapsedForeignSessions); | 429 DictionaryPrefUpdate update(prefs, prefs::kNtpCollapsedForeignSessions); |
| 429 if (is_collapsed) | 430 if (is_collapsed) |
| 430 update.Get()->SetBoolean(session_tag, true); | 431 update.Get()->SetBoolean(session_tag, true); |
| 431 else | 432 else |
| 432 update.Get()->Remove(session_tag, NULL); | 433 update.Get()->Remove(session_tag, NULL); |
| 433 } | 434 } |
| 434 | 435 |
| 435 } // namespace browser_sync | 436 } // namespace browser_sync |
| OLD | NEW |