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

Side by Side Diff: chrome/browser/dom_ui/value_helper.cc

Issue 3133022: sync: take two for: "Added classes to enable session sync... (Closed)
Patch Set: Created 10 years, 4 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
« no previous file with comments | « chrome/browser/dom_ui/value_helper.h ('k') | chrome/browser/sessions/session_restore.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "chrome/browser/dom_ui/value_helper.h"
6
7 #include "chrome/browser/dom_ui/new_tab_ui.h"
8 #include "chrome/common/url_constants.h"
9
10 bool ValueHelper::TabToValue(
11 const TabRestoreService::Tab& tab,
12 DictionaryValue* dictionary) {
13 if (tab.navigations.empty())
14 return false;
15
16 const TabNavigation& current_navigation =
17 tab.navigations.at(tab.current_navigation_index);
18 if (current_navigation.virtual_url() == GURL(chrome::kChromeUINewTabURL))
19 return false;
20 NewTabUI::SetURLTitleAndDirection(dictionary, current_navigation.title(),
21 current_navigation.virtual_url());
22 dictionary->SetString("type", "tab");
23 dictionary->SetReal("timestamp", tab.timestamp.ToDoubleT());
24 return true;
25 }
26
27 bool ValueHelper::WindowToValue(
28 const TabRestoreService::Window& window,
29 DictionaryValue* dictionary) {
30 if (window.tabs.empty()) {
31 NOTREACHED();
32 return false;
33 }
34 scoped_ptr<ListValue> tab_values(new ListValue());
35 for (size_t i = 0; i < window.tabs.size(); ++i) {
36 scoped_ptr<DictionaryValue> tab_value(new DictionaryValue());
37 if (TabToValue(window.tabs[i], tab_value.get()))
38 tab_values->Append(tab_value.release());
39 }
40 if (tab_values->GetSize() == 0)
41 return false;
42 dictionary->SetString("type", "window");
43 dictionary->SetReal("timestamp", window.timestamp.ToDoubleT());
44 dictionary->Set("tabs", tab_values.release());
45 return true;
46 }
47
OLDNEW
« no previous file with comments | « chrome/browser/dom_ui/value_helper.h ('k') | chrome/browser/sessions/session_restore.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698