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