| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/foreign_session_handler.h" | 5 #include "chrome/browser/ui/webui/ntp/foreign_session_handler.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 #include "base/memory/scoped_vector.h" | 10 #include "base/memory/scoped_vector.h" |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 "SessionModelAssociator."; | 101 "SessionModelAssociator."; |
| 102 return; | 102 return; |
| 103 } | 103 } |
| 104 int added_count = 0; | 104 int added_count = 0; |
| 105 ListValue session_list; | 105 ListValue session_list; |
| 106 for (std::vector<const SyncedSession*>::const_iterator i = | 106 for (std::vector<const SyncedSession*>::const_iterator i = |
| 107 sessions.begin(); i != sessions.end() && | 107 sessions.begin(); i != sessions.end() && |
| 108 added_count < kMaxSessionsToShow; ++i) { | 108 added_count < kMaxSessionsToShow; ++i) { |
| 109 const SyncedSession* foreign_session = *i; | 109 const SyncedSession* foreign_session = *i; |
| 110 scoped_ptr<ListValue> window_list(new ListValue()); | 110 scoped_ptr<ListValue> window_list(new ListValue()); |
| 111 for (std::vector<SessionWindow*>::const_iterator it = | 111 for (SyncedSession::SyncedWindowMap::const_iterator it = |
| 112 foreign_session->windows.begin(); it != foreign_session->windows.end(); | 112 foreign_session->windows.begin(); it != foreign_session->windows.end(); |
| 113 ++it) { | 113 ++it) { |
| 114 SessionWindow* window = *it; | 114 SessionWindow* window = it->second; |
| 115 scoped_ptr<DictionaryValue> window_data(new DictionaryValue()); | 115 scoped_ptr<DictionaryValue> window_data(new DictionaryValue()); |
| 116 if (SessionWindowToValue(*window, window_data.get())) { | 116 if (SessionWindowToValue(*window, window_data.get())) { |
| 117 window_data->SetString("sessionTag", foreign_session->session_tag); | 117 window_data->SetString("sessionTag", foreign_session->session_tag); |
| 118 | 118 |
| 119 // Give ownership to |list_value|. | 119 // Give ownership to |list_value|. |
| 120 window_list->Append(window_data.release()); | 120 window_list->Append(window_data.release()); |
| 121 } | 121 } |
| 122 } | 122 } |
| 123 added_count++; | 123 added_count++; |
| 124 | 124 |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 232 return false; | 232 return false; |
| 233 dictionary->SetString("type", "window"); | 233 dictionary->SetString("type", "window"); |
| 234 dictionary->SetDouble("timestamp", | 234 dictionary->SetDouble("timestamp", |
| 235 static_cast<double>(window.timestamp.ToInternalValue())); | 235 static_cast<double>(window.timestamp.ToInternalValue())); |
| 236 dictionary->SetInteger("sessionId", window.window_id.id()); | 236 dictionary->SetInteger("sessionId", window.window_id.id()); |
| 237 dictionary->Set("tabs", tab_values.release()); | 237 dictionary->Set("tabs", tab_values.release()); |
| 238 return true; | 238 return true; |
| 239 } | 239 } |
| 240 | 240 |
| 241 } // namespace browser_sync | 241 } // namespace browser_sync |
| OLD | NEW |