OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #ifndef COMPONENTS_SESSIONS_IOS_IOS_SERIALIZED_NAVIGATION_BUILDER_H_ | 5 #ifndef COMPONENTS_SESSIONS_IOS_IOS_SERIALIZED_NAVIGATION_BUILDER_H_ |
6 #define COMPONENTS_SESSIONS_IOS_IOS_SERIALIZED_NAVIGATION_BUILDER_H_ | 6 #define COMPONENTS_SESSIONS_IOS_IOS_SERIALIZED_NAVIGATION_BUILDER_H_ |
7 | 7 |
| 8 #include <memory> |
8 #include <vector> | 9 #include <vector> |
9 | 10 |
10 #include "base/memory/scoped_ptr.h" | |
11 #include "base/memory/scoped_vector.h" | 11 #include "base/memory/scoped_vector.h" |
12 | 12 |
13 namespace web { | 13 namespace web { |
14 class NavigationItem; | 14 class NavigationItem; |
15 } | 15 } |
16 | 16 |
17 namespace sessions { | 17 namespace sessions { |
18 class SerializedNavigationEntry; | 18 class SerializedNavigationEntry; |
19 | 19 |
20 // Provides methods to convert between SerializedNavigationEntry and //ios/web | 20 // Provides methods to convert between SerializedNavigationEntry and //ios/web |
21 // classes. | 21 // classes. |
22 class IOSSerializedNavigationBuilder { | 22 class IOSSerializedNavigationBuilder { |
23 public: | 23 public: |
24 // Construct a SerializedNavigationEntry for a particular index from the given | 24 // Construct a SerializedNavigationEntry for a particular index from the given |
25 // NavigationItem. | 25 // NavigationItem. |
26 static SerializedNavigationEntry FromNavigationItem( | 26 static SerializedNavigationEntry FromNavigationItem( |
27 int index, const web::NavigationItem& item); | 27 int index, const web::NavigationItem& item); |
28 | 28 |
29 // Convert the given SerializedNavigationEntry into a NavigationItem with the | 29 // Convert the given SerializedNavigationEntry into a NavigationItem with the |
30 // given page ID. The NavigationItem will have a transition type of | 30 // given page ID. The NavigationItem will have a transition type of |
31 // PAGE_TRANSITION_RELOAD and a new unique ID. | 31 // PAGE_TRANSITION_RELOAD and a new unique ID. |
32 static scoped_ptr<web::NavigationItem> ToNavigationItem( | 32 static std::unique_ptr<web::NavigationItem> ToNavigationItem( |
33 const SerializedNavigationEntry* navigation); | 33 const SerializedNavigationEntry* navigation); |
34 | 34 |
35 // Converts a set of SerializedNavigationEntrys into a list of | 35 // Converts a set of SerializedNavigationEntrys into a list of |
36 // NavigationItems with sequential page IDs. | 36 // NavigationItems with sequential page IDs. |
37 // TODO(crbug.com/561329): Change this API to return a | 37 // TODO(crbug.com/561329): Change this API to return a |
38 // std::vector<scoped_ptr> in coordination with changing downstream clients. | 38 // std::vector<scoped_ptr> in coordination with changing downstream clients. |
39 static ScopedVector<web::NavigationItem> ToNavigationItems( | 39 static ScopedVector<web::NavigationItem> ToNavigationItems( |
40 const std::vector<SerializedNavigationEntry>& navigations); | 40 const std::vector<SerializedNavigationEntry>& navigations); |
41 }; | 41 }; |
42 | 42 |
43 } // namespace sessions | 43 } // namespace sessions |
44 | 44 |
45 #endif // COMPONENTS_SESSIONS_IOS_IOS_SERIALIZED_NAVIGATION_BUILDER_H_ | 45 #endif // COMPONENTS_SESSIONS_IOS_IOS_SERIALIZED_NAVIGATION_BUILDER_H_ |
OLD | NEW |