ios_webstate_live_tab.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. // Copyright 2015 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_WEBSTATE_LIVE_TAB_H_
  5. #define COMPONENTS_SESSIONS_IOS_IOS_WEBSTATE_LIVE_TAB_H_
  6. #include "base/supports_user_data.h"
  7. #include "components/sessions/ios/ios_live_tab.h"
  8. #include "components/sessions/ios/ios_serialized_navigation_builder.h"
  9. #import "ios/web/public/web_state.h"
  10. namespace web {
  11. class NavigationManager;
  12. }
  13. namespace sessions {
  14. // An implementation of LiveTab that is backed by web::WebState for use
  15. // on //ios/web-based platforms.
  16. class SESSIONS_EXPORT IOSWebStateLiveTab : public IOSLiveTab,
  17. public base::SupportsUserData::Data {
  18. public:
  19. IOSWebStateLiveTab(const IOSWebStateLiveTab&) = delete;
  20. IOSWebStateLiveTab& operator=(const IOSWebStateLiveTab&) = delete;
  21. ~IOSWebStateLiveTab() override;
  22. // Returns the IOSLiveTab associated with |web_state|, creating it if
  23. // it has not already been created.
  24. static IOSWebStateLiveTab* GetForWebState(web::WebState* web_state);
  25. // LiveTab:
  26. bool IsInitialBlankNavigation() override;
  27. int GetCurrentEntryIndex() override;
  28. int GetPendingEntryIndex() override;
  29. sessions::SerializedNavigationEntry GetEntryAtIndex(int index) override;
  30. sessions::SerializedNavigationEntry GetPendingEntry() override;
  31. int GetEntryCount() override;
  32. sessions::SerializedUserAgentOverride GetUserAgentOverride() override;
  33. const web::WebState* GetWebState() const override;
  34. private:
  35. friend class base::SupportsUserData;
  36. explicit IOSWebStateLiveTab(web::WebState* web_state);
  37. web::NavigationManager* navigation_manager() {
  38. return web_state_->GetNavigationManager();
  39. }
  40. web::WebState* web_state_;
  41. };
  42. } // namespace sessions
  43. #endif // COMPONENTS_SESSIONS_IOS_IOS_WEBSTATE_LIVE_TAB_H_