content_serialized_navigation_builder.h 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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_CONTENT_CONTENT_SERIALIZED_NAVIGATION_BUILDER_H_
  5. #define COMPONENTS_SESSIONS_CONTENT_CONTENT_SERIALIZED_NAVIGATION_BUILDER_H_
  6. #include <memory>
  7. #include <vector>
  8. #include "components/sessions/core/sessions_export.h"
  9. namespace content {
  10. class BrowserContext;
  11. class NavigationEntry;
  12. class NavigationEntryRestoreContext;
  13. }
  14. namespace sessions {
  15. class SerializedNavigationEntry;
  16. // Provides methods to convert between SerializedNavigationEntry and content
  17. // classes.
  18. class SESSIONS_EXPORT ContentSerializedNavigationBuilder {
  19. public:
  20. // Set of options for serializing a navigation. Multiple options can be
  21. // combined by bit masking.
  22. enum SerializationOptions {
  23. // Serialized all available navigation data.
  24. DEFAULT = 0x0,
  25. // Exclude page state data. Serializing page state data can involve heavy
  26. // processing on pages with deep iframe trees, so should be avoided if not
  27. // necessary.
  28. EXCLUDE_PAGE_STATE = 0x1,
  29. };
  30. // Construct a SerializedNavigationEntry for a particular index from the given
  31. // NavigationEntry.
  32. static SerializedNavigationEntry FromNavigationEntry(
  33. int index,
  34. content::NavigationEntry* entry,
  35. SerializationOptions serialization_options =
  36. SerializationOptions::DEFAULT);
  37. // Convert the given SerializedNavigationEntry into a NavigationEntry with the
  38. // given context. The NavigationEntry will have a transition type of
  39. // PAGE_TRANSITION_RELOAD and a new unique ID.
  40. // If a |restore_context| is passed to multiple invocations of this function,
  41. // it will detect equivalent per-frame state across different
  42. // SerializedNavigationEntries and de-duplicate the resulting per-frame
  43. // session history state.
  44. static std::unique_ptr<content::NavigationEntry> ToNavigationEntry(
  45. const SerializedNavigationEntry* navigation,
  46. content::BrowserContext* browser_context,
  47. content::NavigationEntryRestoreContext* restore_context);
  48. // Converts a set of SerializedNavigationEntrys into a list of
  49. // NavigationEntrys with the given context.
  50. static std::vector<std::unique_ptr<content::NavigationEntry>>
  51. ToNavigationEntries(const std::vector<SerializedNavigationEntry>& navigations,
  52. content::BrowserContext* browser_context);
  53. };
  54. } // namespace sessions
  55. #endif // COMPONENTS_SESSIONS_CONTENT_CONTENT_SERIALIZED_NAVIGATION_BUILDER_H_