OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/dom_ui/foreign_session_handler.h" | 5 #include "chrome/browser/dom_ui/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/scoped_vector.h" | 10 #include "base/scoped_vector.h" |
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
203 0, | 203 0, |
204 std::min(selected_index, | 204 std::min(selected_index, |
205 static_cast<int>(tab.navigations.size() - 1))); | 205 static_cast<int>(tab.navigations.size() - 1))); |
206 const TabNavigation& current_navigation = | 206 const TabNavigation& current_navigation = |
207 tab.navigations.at(selected_index); | 207 tab.navigations.at(selected_index); |
208 if (current_navigation.virtual_url() == GURL(chrome::kChromeUINewTabURL)) | 208 if (current_navigation.virtual_url() == GURL(chrome::kChromeUINewTabURL)) |
209 return false; | 209 return false; |
210 NewTabUI::SetURLTitleAndDirection(dictionary, current_navigation.title(), | 210 NewTabUI::SetURLTitleAndDirection(dictionary, current_navigation.title(), |
211 current_navigation.virtual_url()); | 211 current_navigation.virtual_url()); |
212 dictionary->SetString("type", "tab"); | 212 dictionary->SetString("type", "tab"); |
213 dictionary->SetReal("timestamp", | 213 dictionary->SetDouble("timestamp", |
214 static_cast<double>(tab.timestamp.ToInternalValue())); | 214 static_cast<double>(tab.timestamp.ToInternalValue())); |
215 dictionary->SetInteger("sessionId", tab.tab_id.id()); | 215 dictionary->SetInteger("sessionId", tab.tab_id.id()); |
216 return true; | 216 return true; |
217 } | 217 } |
218 | 218 |
219 bool ForeignSessionHandler::SessionWindowToValue( | 219 bool ForeignSessionHandler::SessionWindowToValue( |
220 const SessionWindow& window, | 220 const SessionWindow& window, |
221 DictionaryValue* dictionary) { | 221 DictionaryValue* dictionary) { |
222 if (window.tabs.empty()) { | 222 if (window.tabs.empty()) { |
223 NOTREACHED(); | 223 NOTREACHED(); |
224 return false; | 224 return false; |
225 } | 225 } |
226 scoped_ptr<ListValue> tab_values(new ListValue()); | 226 scoped_ptr<ListValue> tab_values(new ListValue()); |
227 for (size_t i = 0; i < window.tabs.size(); ++i) { | 227 for (size_t i = 0; i < window.tabs.size(); ++i) { |
228 scoped_ptr<DictionaryValue> tab_value(new DictionaryValue()); | 228 scoped_ptr<DictionaryValue> tab_value(new DictionaryValue()); |
229 if (SessionTabToValue(*window.tabs[i], tab_value.get())) | 229 if (SessionTabToValue(*window.tabs[i], tab_value.get())) |
230 tab_values->Append(tab_value.release()); | 230 tab_values->Append(tab_value.release()); |
231 } | 231 } |
232 if (tab_values->GetSize() == 0) | 232 if (tab_values->GetSize() == 0) |
233 return false; | 233 return false; |
234 dictionary->SetString("type", "window"); | 234 dictionary->SetString("type", "window"); |
235 dictionary->SetReal("timestamp", | 235 dictionary->SetDouble("timestamp", |
236 static_cast<double>(window.timestamp.ToInternalValue())); | 236 static_cast<double>(window.timestamp.ToInternalValue())); |
237 dictionary->SetInteger("sessionId", window.window_id.id()); | 237 dictionary->SetInteger("sessionId", window.window_id.id()); |
238 dictionary->Set("tabs", tab_values.release()); | 238 dictionary->Set("tabs", tab_values.release()); |
239 return true; | 239 return true; |
240 } | 240 } |
241 | 241 |
242 } // namespace browser_sync | 242 } // namespace browser_sync |
OLD | NEW |