| Index: ios/web/navigation/wk_based_navigation_manager_impl.h
|
| diff --git a/ios/web/navigation/wk_based_navigation_manager_impl.h b/ios/web/navigation/wk_based_navigation_manager_impl.h
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..a67c8ac5cb89e52768ac0bb13c186eb8d4d4f445
|
| --- /dev/null
|
| +++ b/ios/web/navigation/wk_based_navigation_manager_impl.h
|
| @@ -0,0 +1,131 @@
|
| +// Copyright 2017 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#ifndef IOS_WEB_NAVIGATION_WK_BASED_NAVIGATION_MANAGER_IMPL_H_
|
| +#define IOS_WEB_NAVIGATION_WK_BASED_NAVIGATION_MANAGER_IMPL_H_
|
| +
|
| +#include <stddef.h>
|
| +
|
| +#include <memory>
|
| +#include <vector>
|
| +
|
| +#import "base/mac/scoped_nsobject.h"
|
| +#include "base/macros.h"
|
| +#import "ios/web/navigation/navigation_item_impl.h"
|
| +#import "ios/web/navigation/navigation_manager_impl.h"
|
| +#include "ios/web/public/reload_type.h"
|
| +#include "ui/base/page_transition_types.h"
|
| +#include "url/gurl.h"
|
| +
|
| +namespace web {
|
| +class BrowserState;
|
| +class NavigationItem;
|
| +struct Referrer;
|
| +class NavigationManagerDelegate;
|
| +class SessionStorageBuilder;
|
| +
|
| +// WKBackForwardList based implementation of NavigationManagerImpl.
|
| +class WKBasedNavigationManagerImpl : public NavigationManagerImpl {
|
| + public:
|
| + WKBasedNavigationManagerImpl();
|
| + ~WKBasedNavigationManagerImpl() override;
|
| +
|
| + // NavigationManagerImpl:
|
| + void SetDelegate(NavigationManagerDelegate* delegate) override;
|
| + void SetBrowserState(BrowserState* browser_state) override;
|
| + void SetSessionController(CRWSessionController* session_controller) override;
|
| + void InitializeSession() override;
|
| + void ReplaceSessionHistory(std::vector<std::unique_ptr<NavigationItem>> items,
|
| + int current_index) override;
|
| + void OnNavigationItemsPruned(size_t pruned_item_count) override;
|
| + void OnNavigationItemChanged() override;
|
| + void OnNavigationItemCommitted() override;
|
| + CRWSessionController* GetSessionController() const override;
|
| + void AddTransientItem(const GURL& url) override;
|
| + void AddPendingItem(
|
| + const GURL& url,
|
| + const web::Referrer& referrer,
|
| + ui::PageTransition navigation_type,
|
| + NavigationInitiationType initiation_type,
|
| + UserAgentOverrideOption user_agent_override_option) override;
|
| + void CommitPendingItem() override;
|
| + std::unique_ptr<std::vector<BrowserURLRewriter::URLRewriter>>
|
| + GetTransientURLRewriters() override;
|
| + void RemoveTransientURLRewriters() override;
|
| + int GetIndexForOffset(int offset) const override;
|
| + int GetPreviousItemIndex() const override;
|
| +
|
| + // NavigationManager:
|
| + BrowserState* GetBrowserState() const override;
|
| + WebState* GetWebState() const override;
|
| + NavigationItem* GetVisibleItem() const override;
|
| + NavigationItem* GetLastCommittedItem() const override;
|
| + NavigationItem* GetPendingItem() const override;
|
| + NavigationItem* GetTransientItem() const override;
|
| + void DiscardNonCommittedItems() override;
|
| + void LoadURLWithParams(const NavigationManager::WebLoadParams&) override;
|
| + void AddTransientURLRewriter(
|
| + BrowserURLRewriter::URLRewriter rewriter) override;
|
| + int GetItemCount() const override;
|
| + NavigationItem* GetItemAtIndex(size_t index) const override;
|
| + int GetIndexOfItem(const NavigationItem* item) const override;
|
| + int GetPendingItemIndex() const override;
|
| + int GetLastCommittedItemIndex() const override;
|
| + bool RemoveItemAtIndex(int index) override;
|
| + bool CanGoBack() const override;
|
| + bool CanGoForward() const override;
|
| + bool CanGoToOffset(int offset) const override;
|
| + void GoBack() override;
|
| + void GoForward() override;
|
| + void GoToIndex(int index) override;
|
| + void Reload(ReloadType reload_type, bool check_for_reposts) override;
|
| + NavigationItemList GetBackwardItems() const override;
|
| + NavigationItemList GetForwardItems() const override;
|
| + void CopyStateFromAndPrune(const NavigationManager* source) override;
|
| + bool CanPruneAllButLastCommittedItem() const override;
|
| +
|
| + private:
|
| + // The SessionStorageBuilder functions require access to private variables of
|
| + // NavigationManagerImpl.
|
| + friend SessionStorageBuilder;
|
| +
|
| + // NavigationManagerImpl methods used by SessionStorageBuilder.
|
| + NavigationItemImpl* GetNavigationItemImplAtIndex(size_t index) const override;
|
| +
|
| + // Current item is the anchor of the navigation history.
|
| + // int GetCurrentItemIndex() const;
|
| + // NavigationItem* GetCurrentItem() const;
|
| +
|
| + // Sync navigation_items_ to WKBackForwardList. This should be no-op in most
|
| + // cases, but will do real work after a renderer-initiated navigation.
|
| + // This method guarantees the navigation_items_ invariant.
|
| + // Returns true if committed_navigation_items_ were updated; false if no-op.
|
| + bool SyncNavigationItems() const;
|
| +
|
| + // The primary delegate for this manager.
|
| + NavigationManagerDelegate* delegate_;
|
| +
|
| + // The BrowserState that is associated with this instance.
|
| + BrowserState* browser_state_;
|
| +
|
| + // List of transient url rewriters added by |AddTransientURLRewriter()|.
|
| + std::unique_ptr<std::vector<BrowserURLRewriter::URLRewriter>>
|
| + transient_url_rewriters_;
|
| +
|
| + // NavigationItemImpl objects associated with the back/forward history.
|
| + // Invariant:
|
| + // navigation_items_.size() == GetItemCount() == backList.count +
|
| + // forwardList.count + currentItem ? 1 : 0.
|
| + mutable std::vector<std::unique_ptr<NavigationItemImpl>>
|
| + committed_navigation_items_;
|
| +
|
| + std::unique_ptr<NavigationItemImpl> pending_item_;
|
| + std::unique_ptr<NavigationItemImpl> transient_item_;
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(WKBasedNavigationManagerImpl);
|
| +};
|
| +
|
| +} // namespace web
|
| +
|
| +#endif // IOS_WEB_NAVIGATION_WK_BASED_NAVIGATION_MANAGER_IMPL_H_
|
|
|