ios_serialized_navigation_builder.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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
  3. // found in the LICENSE file.
  4. #ifndef COMPONENTS_SESSIONS_IOS_IOS_SERIALIZED_NAVIGATION_BUILDER_H_
  5. #define COMPONENTS_SESSIONS_IOS_IOS_SERIALIZED_NAVIGATION_BUILDER_H_
  6. #include <memory>
  7. #include <vector>
  8. namespace web {
  9. class NavigationItem;
  10. }
  11. @class CRWNavigationItemStorage;
  12. namespace sessions {
  13. class SerializedNavigationEntry;
  14. // Provides methods to convert between SerializedNavigationEntry and //ios/web
  15. // classes.
  16. class IOSSerializedNavigationBuilder {
  17. public:
  18. // Construct a SerializedNavigationEntry for a particular index from the given
  19. // NavigationItem.
  20. static SerializedNavigationEntry FromNavigationItem(
  21. int index, const web::NavigationItem& item);
  22. // Construct a SerializedNavigationEntry for a particular index from the given
  23. // CRWNavigationItemStorage.
  24. static SerializedNavigationEntry FromNavigationStorageItem(
  25. int index,
  26. CRWNavigationItemStorage* item);
  27. // Convert the given SerializedNavigationEntry into a NavigationItem. The
  28. // NavigationItem will have a transition type of
  29. // PAGE_TRANSITION_RELOAD and a new unique ID.
  30. static std::unique_ptr<web::NavigationItem> ToNavigationItem(
  31. const SerializedNavigationEntry* navigation);
  32. // Converts a set of SerializedNavigationEntrys into a list of
  33. // NavigationItems with sequential page IDs.
  34. static std::vector<std::unique_ptr<web::NavigationItem>> ToNavigationItems(
  35. const std::vector<SerializedNavigationEntry>& navigations);
  36. };
  37. } // namespace sessions
  38. #endif // COMPONENTS_SESSIONS_IOS_IOS_SERIALIZED_NAVIGATION_BUILDER_H_