OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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 "components/sessions/core/session_types.h" | 5 #include "components/sessions/core/session_types.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include "components/sessions/core/session_command.h" | 9 #include "components/sessions/core/session_command.h" |
10 | 10 |
(...skipping 21 matching lines...) Expand all Loading... |
32 pinned = sync_data.pinned(); | 32 pinned = sync_data.pinned(); |
33 extension_app_id = sync_data.extension_app_id(); | 33 extension_app_id = sync_data.extension_app_id(); |
34 user_agent_override.clear(); | 34 user_agent_override.clear(); |
35 this->timestamp = timestamp; | 35 this->timestamp = timestamp; |
36 navigations.clear(); | 36 navigations.clear(); |
37 for (int i = 0; i < sync_data.navigation_size(); ++i) { | 37 for (int i = 0; i < sync_data.navigation_size(); ++i) { |
38 navigations.push_back( | 38 navigations.push_back( |
39 SerializedNavigationEntry::FromSyncData(i, sync_data.navigation(i))); | 39 SerializedNavigationEntry::FromSyncData(i, sync_data.navigation(i))); |
40 } | 40 } |
41 session_storage_persistent_id.clear(); | 41 session_storage_persistent_id.clear(); |
42 variation_ids.clear(); | |
43 for (int i = 0; i < sync_data.variation_id_size(); ++i) | |
44 variation_ids.push_back(sync_data.variation_id(i)); | |
45 } | 42 } |
46 | 43 |
47 sync_pb::SessionTab SessionTab::ToSyncData() const { | 44 sync_pb::SessionTab SessionTab::ToSyncData() const { |
48 sync_pb::SessionTab sync_data; | 45 sync_pb::SessionTab sync_data; |
49 sync_data.set_tab_id(tab_id.id()); | 46 sync_data.set_tab_id(tab_id.id()); |
50 sync_data.set_window_id(window_id.id()); | 47 sync_data.set_window_id(window_id.id()); |
51 sync_data.set_tab_visual_index(tab_visual_index); | 48 sync_data.set_tab_visual_index(tab_visual_index); |
52 sync_data.set_current_navigation_index(current_navigation_index); | 49 sync_data.set_current_navigation_index(current_navigation_index); |
53 sync_data.set_pinned(pinned); | 50 sync_data.set_pinned(pinned); |
54 sync_data.set_extension_app_id(extension_app_id); | 51 sync_data.set_extension_app_id(extension_app_id); |
55 for (const SerializedNavigationEntry& navigation : navigations) { | 52 for (const SerializedNavigationEntry& navigation : navigations) { |
56 *sync_data.add_navigation() = navigation.ToSyncData(); | 53 *sync_data.add_navigation() = navigation.ToSyncData(); |
57 } | 54 } |
58 for (const variations::VariationID variation_id : variation_ids) { | |
59 sync_data.add_variation_id(variation_id); | |
60 } | |
61 return sync_data; | 55 return sync_data; |
62 } | 56 } |
63 | 57 |
64 // SessionWindow --------------------------------------------------------------- | 58 // SessionWindow --------------------------------------------------------------- |
65 | 59 |
66 SessionWindow::SessionWindow() | 60 SessionWindow::SessionWindow() |
67 : selected_tab_index(-1), | 61 : selected_tab_index(-1), |
68 type(TYPE_TABBED), | 62 type(TYPE_TABBED), |
69 is_constrained(true), | 63 is_constrained(true), |
70 show_state(ui::SHOW_STATE_DEFAULT) {} | 64 show_state(ui::SHOW_STATE_DEFAULT) {} |
71 | 65 |
72 SessionWindow::~SessionWindow() {} | 66 SessionWindow::~SessionWindow() {} |
73 | 67 |
74 sync_pb::SessionWindow SessionWindow::ToSyncData() const { | |
75 sync_pb::SessionWindow sync_data; | |
76 sync_data.set_window_id(window_id.id()); | |
77 sync_data.set_selected_tab_index(selected_tab_index); | |
78 switch (type) { | |
79 case SessionWindow::TYPE_TABBED: | |
80 sync_data.set_browser_type( | |
81 sync_pb::SessionWindow_BrowserType_TYPE_TABBED); | |
82 break; | |
83 case SessionWindow::TYPE_POPUP: | |
84 sync_data.set_browser_type( | |
85 sync_pb::SessionWindow_BrowserType_TYPE_POPUP); | |
86 break; | |
87 default: | |
88 NOTREACHED() << "Unhandled browser type."; | |
89 } | |
90 | |
91 for (const auto& tab : tabs) | |
92 sync_data.add_tab(tab->tab_id.id()); | |
93 | |
94 return sync_data; | |
95 } | |
96 | |
97 } // namespace sessions | 68 } // namespace sessions |
OLD | NEW |