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_LEGACY_NAVIGATION_MANAGER_IMPL_H_ |
| 6 #define IOS_WEB_NAVIGATION_LEGACY_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_manager_impl.h" |
| 16 #import "ios/web/public/navigation_item_list.h" |
| 17 #include "ios/web/public/reload_type.h" |
| 18 #include "ui/base/page_transition_types.h" |
| 19 #include "url/gurl.h" |
| 20 |
| 21 @class CRWSessionController; |
| 22 |
| 23 namespace web { |
| 24 class BrowserState; |
| 25 class NavigationItem; |
| 26 struct Referrer; |
| 27 class NavigationManagerDelegate; |
| 28 class SessionStorageBuilder; |
| 29 |
| 30 // Implementation of NavigationManagerImpl. |
| 31 class LegacyNavigationManagerImpl : public NavigationManagerImpl { |
| 32 public: |
| 33 LegacyNavigationManagerImpl(); |
| 34 ~LegacyNavigationManagerImpl() override; |
| 35 |
| 36 // NavigationManagerImpl: |
| 37 void SetDelegate(NavigationManagerDelegate* delegate) override; |
| 38 void SetBrowserState(BrowserState* browser_state) override; |
| 39 void SetSessionController(CRWSessionController* session_controller) override; |
| 40 void InitializeSession() override; |
| 41 void ReplaceSessionHistory(std::vector<std::unique_ptr<NavigationItem>> items, |
| 42 int current_index) override; |
| 43 void OnNavigationItemsPruned(size_t pruned_item_count) override; |
| 44 void OnNavigationItemChanged() override; |
| 45 void OnNavigationItemCommitted() override; |
| 46 CRWSessionController* GetSessionController() const override; |
| 47 void AddTransientItem(const GURL& url) override; |
| 48 void AddPendingItem( |
| 49 const GURL& url, |
| 50 const web::Referrer& referrer, |
| 51 ui::PageTransition navigation_type, |
| 52 NavigationInitiationType initiation_type, |
| 53 UserAgentOverrideOption user_agent_override_option) override; |
| 54 void CommitPendingItem() override; |
| 55 std::unique_ptr<std::vector<BrowserURLRewriter::URLRewriter>> |
| 56 GetTransientURLRewriters() override; |
| 57 void RemoveTransientURLRewriters() override; |
| 58 int GetIndexForOffset(int offset) const override; |
| 59 |
| 60 // NavigationManager: |
| 61 BrowserState* GetBrowserState() const override; |
| 62 WebState* GetWebState() const override; |
| 63 NavigationItem* GetVisibleItem() const override; |
| 64 NavigationItem* GetLastCommittedItem() const override; |
| 65 NavigationItem* GetPendingItem() const override; |
| 66 NavigationItem* GetTransientItem() const override; |
| 67 void DiscardNonCommittedItems() override; |
| 68 void LoadURLWithParams(const NavigationManager::WebLoadParams&) override; |
| 69 void AddTransientURLRewriter( |
| 70 BrowserURLRewriter::URLRewriter rewriter) override; |
| 71 int GetItemCount() const override; |
| 72 NavigationItem* GetItemAtIndex(size_t index) const override; |
| 73 int GetIndexOfItem(const NavigationItem* item) const override; |
| 74 int GetPendingItemIndex() const override; |
| 75 int GetLastCommittedItemIndex() const override; |
| 76 bool RemoveItemAtIndex(int index) override; |
| 77 bool CanGoBack() const override; |
| 78 bool CanGoForward() const override; |
| 79 bool CanGoToOffset(int offset) const override; |
| 80 void GoBack() override; |
| 81 void GoForward() override; |
| 82 void GoToIndex(int index) override; |
| 83 void Reload(ReloadType reload_type, bool check_for_reposts) override; |
| 84 NavigationItemList GetBackwardItems() const override; |
| 85 NavigationItemList GetForwardItems() const override; |
| 86 void CopyStateFromAndPrune(const NavigationManager* source) override; |
| 87 bool CanPruneAllButLastCommittedItem() const override; |
| 88 |
| 89 private: |
| 90 // The SessionStorageBuilder functions require access to private variables of |
| 91 // NavigationManagerImpl. |
| 92 friend SessionStorageBuilder; |
| 93 |
| 94 // NavigationManagerImpl methods used by SessionStorageBuilder. |
| 95 NavigationItemImpl* GetNavigationItemImplAtIndex(size_t index) const override; |
| 96 size_t GetPreviousItemIndex() const override; |
| 97 |
| 98 // Returns true if the PageTransition for the underlying navigation item at |
| 99 // |index| has ui::PAGE_TRANSITION_IS_REDIRECT_MASK. |
| 100 bool IsRedirectItemAtIndex(int index) const; |
| 101 |
| 102 // Returns the most recent NavigationItem that does not have an app-specific |
| 103 // URL. |
| 104 NavigationItem* GetLastCommittedNonAppSpecificItem() const; |
| 105 |
| 106 // The primary delegate for this manager. |
| 107 NavigationManagerDelegate* delegate_; |
| 108 |
| 109 // The BrowserState that is associated with this instance. |
| 110 BrowserState* browser_state_; |
| 111 |
| 112 // CRWSessionController that backs this instance. |
| 113 // TODO(stuartmorgan): Fold CRWSessionController into this class. |
| 114 base::scoped_nsobject<CRWSessionController> session_controller_; |
| 115 |
| 116 // List of transient url rewriters added by |AddTransientURLRewriter()|. |
| 117 std::unique_ptr<std::vector<BrowserURLRewriter::URLRewriter>> |
| 118 transient_url_rewriters_; |
| 119 |
| 120 DISALLOW_COPY_AND_ASSIGN(LegacyNavigationManagerImpl); |
| 121 }; |
| 122 |
| 123 } // namespace web |
| 124 |
| 125 #endif // IOS_WEB_NAVIGATION_LEGACY_NAVIGATION_MANAGER_IMPL_H_ |
OLD | NEW |