browser_persistence_common.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. // Copyright 2020 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 WEBLAYER_BROWSER_PERSISTENCE_BROWSER_PERSISTENCE_COMMON_H_
  5. #define WEBLAYER_BROWSER_PERSISTENCE_BROWSER_PERSISTENCE_COMMON_H_
  6. #include <memory>
  7. #include <vector>
  8. class SessionID;
  9. namespace sessions {
  10. class SessionCommand;
  11. }
  12. // Common functions used in persisting/restoring the state (tabs, navigations)
  13. // of a Browser.
  14. namespace weblayer {
  15. class BrowserImpl;
  16. class Tab;
  17. class TabImpl;
  18. // Restores browser state from |commands|. This ensures |browser| contains at
  19. // least one tab when done.
  20. void RestoreBrowserState(
  21. BrowserImpl* browser,
  22. std::vector<std::unique_ptr<sessions::SessionCommand>> commands);
  23. // Creates and returns the minimal set of SessionCommands to configure a tab.
  24. // This does not include any navigations.
  25. std::vector<std::unique_ptr<sessions::SessionCommand>>
  26. BuildCommandsForTabConfiguration(const SessionID& browser_session_id,
  27. TabImpl* tab,
  28. int index_in_browser);
  29. // Convenience to return the SessionID for a Tab.
  30. const SessionID& GetSessionIDForTab(Tab* tab);
  31. } // namespace weblayer
  32. #endif // WEBLAYER_BROWSER_PERSISTENCE_BROWSER_PERSISTENCE_COMMON_H_