| OLD | NEW |
| (Empty) | |
| 1 // Copyright 2017 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 |
| 5 #ifndef IOS_WEB_NAVIGATION_WK_BASED_NAVIGATION_MANAGER_IMPL_H_ |
| 6 #define IOS_WEB_NAVIGATION_WK_BASED_NAVIGATION_MANAGER_IMPL_H_ |
| 7 |
| 8 #include <stddef.h> |
| 9 |
| 10 #include <memory> |
| 11 #include <vector> |
| 12 |
| 13 #import "base/mac/scoped_nsobject.h" |
| 14 #include "base/macros.h" |
| 15 #import "ios/web/navigation/navigation_item_impl.h" |
| 16 #import "ios/web/navigation/navigation_manager_impl.h" |
| 17 #include "ios/web/public/reload_type.h" |
| 18 #include "ui/base/page_transition_types.h" |
| 19 #include "url/gurl.h" |
| 20 |
| 21 namespace web { |
| 22 class BrowserState; |
| 23 class NavigationItem; |
| 24 struct Referrer; |
| 25 class NavigationManagerDelegate; |
| 26 class SessionStorageBuilder; |
| 27 |
| 28 // WKBackForwardList based implementation of NavigationManagerImpl. |
| 29 // This class relies on the following WKWebView APIs, defined by the |
| 30 // WebViewNavigationProxy protocol: |
| 31 // @property backForwardList |
| 32 // @property canGoBack |
| 33 // @property canGoForward |
| 34 // - goBack |
| 35 // - goForward |
| 36 // - goToBackForwardListItem: |
| 37 class WKBasedNavigationManagerImpl : public NavigationManagerImpl { |
| 38 public: |
| 39 WKBasedNavigationManagerImpl(); |
| 40 ~WKBasedNavigationManagerImpl() override; |
| 41 |
| 42 // NavigationManagerImpl: |
| 43 void SetDelegate(NavigationManagerDelegate* delegate) override; |
| 44 void SetBrowserState(BrowserState* browser_state) override; |
| 45 void SetSessionController(CRWSessionController* session_controller) override; |
| 46 void InitializeSession() override; |
| 47 void ReplaceSessionHistory(std::vector<std::unique_ptr<NavigationItem>> items, |
| 48 int current_index) override; |
| 49 void OnNavigationItemsPruned(size_t pruned_item_count) override; |
| 50 void OnNavigationItemChanged() override; |
| 51 void OnNavigationItemCommitted() override; |
| 52 CRWSessionController* GetSessionController() const override; |
| 53 void AddTransientItem(const GURL& url) override; |
| 54 void AddPendingItem( |
| 55 const GURL& url, |
| 56 const web::Referrer& referrer, |
| 57 ui::PageTransition navigation_type, |
| 58 NavigationInitiationType initiation_type, |
| 59 UserAgentOverrideOption user_agent_override_option) override; |
| 60 void CommitPendingItem() override; |
| 61 std::unique_ptr<std::vector<BrowserURLRewriter::URLRewriter>> |
| 62 GetTransientURLRewriters() override; |
| 63 void RemoveTransientURLRewriters() override; |
| 64 int GetIndexForOffset(int offset) const override; |
| 65 int GetPreviousItemIndex() const override; |
| 66 |
| 67 // NavigationManager: |
| 68 BrowserState* GetBrowserState() const override; |
| 69 WebState* GetWebState() const override; |
| 70 NavigationItem* GetVisibleItem() const override; |
| 71 NavigationItem* GetLastCommittedItem() const override; |
| 72 NavigationItem* GetPendingItem() const override; |
| 73 NavigationItem* GetTransientItem() const override; |
| 74 void DiscardNonCommittedItems() override; |
| 75 void LoadURLWithParams(const NavigationManager::WebLoadParams&) override; |
| 76 void AddTransientURLRewriter( |
| 77 BrowserURLRewriter::URLRewriter rewriter) override; |
| 78 int GetItemCount() const override; |
| 79 NavigationItem* GetItemAtIndex(size_t index) const override; |
| 80 int GetIndexOfItem(const NavigationItem* item) const override; |
| 81 int GetPendingItemIndex() const override; |
| 82 int GetLastCommittedItemIndex() const override; |
| 83 bool RemoveItemAtIndex(int index) override; |
| 84 bool CanGoBack() const override; |
| 85 bool CanGoForward() const override; |
| 86 bool CanGoToOffset(int offset) const override; |
| 87 void GoBack() override; |
| 88 void GoForward() override; |
| 89 void GoToIndex(int index) override; |
| 90 void Reload(ReloadType reload_type, bool check_for_reposts) override; |
| 91 NavigationItemList GetBackwardItems() const override; |
| 92 NavigationItemList GetForwardItems() const override; |
| 93 void CopyStateFromAndPrune(const NavigationManager* source) override; |
| 94 bool CanPruneAllButLastCommittedItem() const override; |
| 95 |
| 96 private: |
| 97 // The SessionStorageBuilder functions require access to private variables of |
| 98 // NavigationManagerImpl. |
| 99 friend SessionStorageBuilder; |
| 100 |
| 101 // NavigationManagerImpl methods used by SessionStorageBuilder. |
| 102 NavigationItemImpl* GetNavigationItemImplAtIndex(size_t index) const override; |
| 103 |
| 104 // The primary delegate for this manager. |
| 105 NavigationManagerDelegate* delegate_; |
| 106 |
| 107 // The BrowserState that is associated with this instance. |
| 108 BrowserState* browser_state_; |
| 109 |
| 110 // List of transient url rewriters added by |AddTransientURLRewriter()|. |
| 111 std::unique_ptr<std::vector<BrowserURLRewriter::URLRewriter>> |
| 112 transient_url_rewriters_; |
| 113 |
| 114 DISALLOW_COPY_AND_ASSIGN(WKBasedNavigationManagerImpl); |
| 115 }; |
| 116 |
| 117 } // namespace web |
| 118 |
| 119 #endif // IOS_WEB_NAVIGATION_WK_BASED_NAVIGATION_MANAGER_IMPL_H_ |
| OLD | NEW |