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/value_helper.h" | 5 #include "chrome/browser/dom_ui/value_helper.h" |
6 | 6 |
7 #include "chrome/browser/dom_ui/new_tab_ui.h" | 7 #include "chrome/browser/dom_ui/new_tab_ui.h" |
8 #include "chrome/common/url_constants.h" | 8 #include "chrome/common/url_constants.h" |
9 | 9 |
10 bool ValueHelper::TabToValue( | 10 bool ValueHelper::TabToValue( |
11 const TabRestoreService::Tab& tab, | 11 const TabRestoreService::Tab& tab, |
12 DictionaryValue* dictionary) { | 12 DictionaryValue* dictionary) { |
13 if (tab.navigations.empty()) | 13 if (tab.navigations.empty()) |
14 return false; | 14 return false; |
15 | 15 |
16 const TabNavigation& current_navigation = | 16 const TabNavigation& current_navigation = |
17 tab.navigations.at(tab.current_navigation_index); | 17 tab.navigations.at(tab.current_navigation_index); |
18 if (current_navigation.virtual_url() == GURL(chrome::kChromeUINewTabURL)) | 18 if (current_navigation.virtual_url() == GURL(chrome::kChromeUINewTabURL)) |
19 return false; | 19 return false; |
20 NewTabUI::SetURLTitleAndDirection(dictionary, current_navigation.title(), | 20 NewTabUI::SetURLTitleAndDirection(dictionary, current_navigation.title(), |
21 current_navigation.virtual_url()); | 21 current_navigation.virtual_url()); |
22 dictionary->SetString("type", "tab"); | 22 dictionary->SetString("type", "tab"); |
23 dictionary->SetReal("timestamp", tab.timestamp.ToDoubleT()); | 23 dictionary->SetDouble("timestamp", tab.timestamp.ToDoubleT()); |
24 return true; | 24 return true; |
25 } | 25 } |
26 | 26 |
27 bool ValueHelper::WindowToValue( | 27 bool ValueHelper::WindowToValue( |
28 const TabRestoreService::Window& window, | 28 const TabRestoreService::Window& window, |
29 DictionaryValue* dictionary) { | 29 DictionaryValue* dictionary) { |
30 if (window.tabs.empty()) { | 30 if (window.tabs.empty()) { |
31 NOTREACHED(); | 31 NOTREACHED(); |
32 return false; | 32 return false; |
33 } | 33 } |
34 scoped_ptr<ListValue> tab_values(new ListValue()); | 34 scoped_ptr<ListValue> tab_values(new ListValue()); |
35 for (size_t i = 0; i < window.tabs.size(); ++i) { | 35 for (size_t i = 0; i < window.tabs.size(); ++i) { |
36 scoped_ptr<DictionaryValue> tab_value(new DictionaryValue()); | 36 scoped_ptr<DictionaryValue> tab_value(new DictionaryValue()); |
37 if (TabToValue(window.tabs[i], tab_value.get())) | 37 if (TabToValue(window.tabs[i], tab_value.get())) |
38 tab_values->Append(tab_value.release()); | 38 tab_values->Append(tab_value.release()); |
39 } | 39 } |
40 if (tab_values->GetSize() == 0) | 40 if (tab_values->GetSize() == 0) |
41 return false; | 41 return false; |
42 dictionary->SetString("type", "window"); | 42 dictionary->SetString("type", "window"); |
43 dictionary->SetReal("timestamp", window.timestamp.ToDoubleT()); | 43 dictionary->SetDouble("timestamp", window.timestamp.ToDoubleT()); |
44 dictionary->Set("tabs", tab_values.release()); | 44 dictionary->Set("tabs", tab_values.release()); |
45 return true; | 45 return true; |
46 } | 46 } |
47 | 47 |
OLD | NEW |