Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef IOS_WEB_NAVIGATION_NAVIGATION_MANAGER_IMPL_H_ | 5 #ifndef IOS_WEB_NAVIGATION_NAVIGATION_MANAGER_IMPL_H_ |
| 6 #define IOS_WEB_NAVIGATION_NAVIGATION_MANAGER_IMPL_H_ | 6 #define IOS_WEB_NAVIGATION_NAVIGATION_MANAGER_IMPL_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| 11 #include <vector> | 11 #include <vector> |
| 12 | 12 |
| 13 #import "base/mac/scoped_nsobject.h" | 13 #import "base/mac/scoped_nsobject.h" |
| 14 #include "base/macros.h" | 14 #include "base/macros.h" |
| 15 #import "ios/web/public/navigation_manager.h" | 15 #import "ios/web/public/navigation_manager.h" |
| 16 #include "ui/base/page_transition_types.h" | 16 #include "ui/base/page_transition_types.h" |
| 17 #include "url/gurl.h" | 17 #include "url/gurl.h" |
| 18 | 18 |
| 19 @class CRWSessionController; | 19 @class CRWSessionController; |
| 20 | 20 |
| 21 namespace web { | 21 namespace web { |
| 22 class BrowserState; | 22 class BrowserState; |
| 23 class NavigationItem; | 23 class NavigationItem; |
| 24 struct Referrer; | 24 struct Referrer; |
| 25 class NavigationManagerDelegate; | 25 class NavigationManagerDelegate; |
| 26 class NavigationManagerFacadeDelegate; | 26 class NavigationManagerFacadeDelegate; |
| 27 class SessionStorageBuilder; | 27 class SessionStorageBuilder; |
| 28 | 28 |
| 29 // |USER_INITIATED| represents pending item that is initiated by actual user | |
|
Eugene But (OOO till 7-30)
2017/02/17 00:00:23
Please move comment for enum values and place them
liaoyuke
2017/02/17 01:16:51
Thank you for the detailed explanation!
Eugene But (OOO till 7-30)
2017/02/17 01:21:11
Per my previous comment, please add comments for e
liaoyuke
2017/02/17 01:32:59
Done.
| |
| 30 // actions, while |RENDERER_INITIATED| stands for pending item that is initiated | |
| 31 // by Url redirect from another navigation item. | |
| 32 enum class ItemInitiationType { | |
| 33 USER_INITIATED = 1, | |
| 34 RENDERER_INITIATED = 2, | |
| 35 }; | |
| 36 | |
| 29 // Implementation of NavigationManager. | 37 // Implementation of NavigationManager. |
| 30 // Generally mirrors upstream's NavigationController. | 38 // Generally mirrors upstream's NavigationController. |
| 31 class NavigationManagerImpl : public NavigationManager { | 39 class NavigationManagerImpl : public NavigationManager { |
| 32 public: | 40 public: |
| 33 NavigationManagerImpl(); | 41 NavigationManagerImpl(); |
| 34 ~NavigationManagerImpl() override; | 42 ~NavigationManagerImpl() override; |
| 35 | 43 |
| 36 // Setters for NavigationManagerDelegate and BrowserState. | 44 // Setters for NavigationManagerDelegate and BrowserState. |
| 37 void SetDelegate(NavigationManagerDelegate* delegate); | 45 void SetDelegate(NavigationManagerDelegate* delegate); |
| 38 void SetBrowserState(BrowserState* browser_state); | 46 void SetBrowserState(BrowserState* browser_state); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 75 void OnNavigationItemCommitted(); | 83 void OnNavigationItemCommitted(); |
| 76 | 84 |
| 77 // Temporary accessors and content/ class pass-throughs. | 85 // Temporary accessors and content/ class pass-throughs. |
| 78 // TODO(stuartmorgan): Re-evaluate this list once the refactorings have | 86 // TODO(stuartmorgan): Re-evaluate this list once the refactorings have |
| 79 // settled down. | 87 // settled down. |
| 80 CRWSessionController* GetSessionController(); | 88 CRWSessionController* GetSessionController(); |
| 81 void LoadURL(const GURL& url, | 89 void LoadURL(const GURL& url, |
| 82 const Referrer& referrer, | 90 const Referrer& referrer, |
| 83 ui::PageTransition type); | 91 ui::PageTransition type); |
| 84 | 92 |
| 93 // Adds a new item with the given url, referrer, navigation type, pending item | |
| 94 // type, making it the current item. If pending item is the same as the | |
|
Eugene But (OOO till 7-30)
2017/02/17 00:00:23
s/current/pending
liaoyuke
2017/02/17 01:16:51
Done.
| |
| 95 // current item, this does nothing. |referrer| may be nil if there isn't one. | |
| 96 // The item starts out as pending, and will be lost unless | |
| 97 // |-commitPendingItem| is called. | |
| 98 void AddPendingItem(const GURL& url, | |
| 99 const web::Referrer& referrer, | |
| 100 ui::PageTransition navigation_type, | |
| 101 ItemInitiationType initiation_type); | |
| 102 | |
| 85 // Convenience accessors to get the underlying NavigationItems from the | 103 // Convenience accessors to get the underlying NavigationItems from the |
| 86 // SessionEntries returned from |session_controller_|'s -lastUserEntry and | 104 // SessionEntries returned from |session_controller_|'s -lastUserEntry and |
| 87 // -previousEntry methods. | 105 // -previousEntry methods. |
| 88 // TODO(crbug.com/546365): Remove these methods. | 106 // TODO(crbug.com/546365): Remove these methods. |
| 89 NavigationItem* GetLastUserItem() const; | 107 NavigationItem* GetLastUserItem() const; |
| 90 NavigationItem* GetPreviousItem() const; | 108 NavigationItem* GetPreviousItem() const; |
| 91 | 109 |
| 92 // Temporary method. Returns a vector of NavigationItems corresponding to | 110 // Temporary method. Returns a vector of NavigationItems corresponding to |
| 93 // the SessionEntries of the uderlying CRWSessionController. | 111 // the SessionEntries of the uderlying CRWSessionController. |
| 94 // TODO(crbug.com/546365): Remove this method. | 112 // TODO(crbug.com/546365): Remove this method. |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 112 int GetPendingItemIndex() const override; | 130 int GetPendingItemIndex() const override; |
| 113 int GetLastCommittedItemIndex() const override; | 131 int GetLastCommittedItemIndex() const override; |
| 114 bool RemoveItemAtIndex(int index) override; | 132 bool RemoveItemAtIndex(int index) override; |
| 115 bool CanGoBack() const override; | 133 bool CanGoBack() const override; |
| 116 bool CanGoForward() const override; | 134 bool CanGoForward() const override; |
| 117 bool CanGoToOffset(int offset) const override; | 135 bool CanGoToOffset(int offset) const override; |
| 118 void GoBack() override; | 136 void GoBack() override; |
| 119 void GoForward() override; | 137 void GoForward() override; |
| 120 void GoToIndex(int index) override; | 138 void GoToIndex(int index) override; |
| 121 void Reload(bool check_for_reposts) override; | 139 void Reload(bool check_for_reposts) override; |
| 140 void OverrideDesktopUserAgentForNextPendingItem() override; | |
| 122 | 141 |
| 123 // Returns the current list of transient url rewriters, passing ownership to | 142 // Returns the current list of transient url rewriters, passing ownership to |
| 124 // the caller. | 143 // the caller. |
| 125 // TODO(crbug.com/546197): remove once NavigationItem creation occurs in this | 144 // TODO(crbug.com/546197): remove once NavigationItem creation occurs in this |
| 126 // class. | 145 // class. |
| 127 std::unique_ptr<std::vector<BrowserURLRewriter::URLRewriter>> | 146 std::unique_ptr<std::vector<BrowserURLRewriter::URLRewriter>> |
| 128 GetTransientURLRewriters(); | 147 GetTransientURLRewriters(); |
| 129 | 148 |
| 130 // Called to reset the transient url rewriter list. | 149 // Called to reset the transient url rewriter list. |
| 131 void RemoveTransientURLRewriters(); | 150 void RemoveTransientURLRewriters(); |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 143 | 162 |
| 144 private: | 163 private: |
| 145 // The SessionStorageBuilder functions require access to private variables of | 164 // The SessionStorageBuilder functions require access to private variables of |
| 146 // NavigationManagerImpl. | 165 // NavigationManagerImpl. |
| 147 friend SessionStorageBuilder; | 166 friend SessionStorageBuilder; |
| 148 | 167 |
| 149 // Returns true if the PageTransition for the underlying navigation item at | 168 // Returns true if the PageTransition for the underlying navigation item at |
| 150 // |index| has ui::PAGE_TRANSITION_IS_REDIRECT_MASK. | 169 // |index| has ui::PAGE_TRANSITION_IS_REDIRECT_MASK. |
| 151 bool IsRedirectItemAtIndex(int index) const; | 170 bool IsRedirectItemAtIndex(int index) const; |
| 152 | 171 |
| 172 // If true, override navigation item's useDesktopUserAgent flag and always | |
| 173 // create the pending entry using the desktop user agent. | |
| 174 // TODO(crbug.com/692303): Remove this when overriding the user agent doesn't | |
| 175 // create a new NavigationItem. | |
| 176 bool override_desktop_user_agent_for_next_pending_item_; | |
| 177 | |
| 153 // The primary delegate for this manager. | 178 // The primary delegate for this manager. |
| 154 NavigationManagerDelegate* delegate_; | 179 NavigationManagerDelegate* delegate_; |
| 155 | 180 |
| 156 // The BrowserState that is associated with this instance. | 181 // The BrowserState that is associated with this instance. |
| 157 BrowserState* browser_state_; | 182 BrowserState* browser_state_; |
| 158 | 183 |
| 159 // CRWSessionController that backs this instance. | 184 // CRWSessionController that backs this instance. |
| 160 // TODO(stuartmorgan): Fold CRWSessionController into this class. | 185 // TODO(stuartmorgan): Fold CRWSessionController into this class. |
| 161 base::scoped_nsobject<CRWSessionController> session_controller_; | 186 base::scoped_nsobject<CRWSessionController> session_controller_; |
| 162 | 187 |
| 163 // Weak pointer to the facade delegate. | 188 // Weak pointer to the facade delegate. |
| 164 NavigationManagerFacadeDelegate* facade_delegate_; | 189 NavigationManagerFacadeDelegate* facade_delegate_; |
| 165 | 190 |
| 166 // List of transient url rewriters added by |AddTransientURLRewriter()|. | 191 // List of transient url rewriters added by |AddTransientURLRewriter()|. |
| 167 std::unique_ptr<std::vector<BrowserURLRewriter::URLRewriter>> | 192 std::unique_ptr<std::vector<BrowserURLRewriter::URLRewriter>> |
| 168 transient_url_rewriters_; | 193 transient_url_rewriters_; |
| 169 | 194 |
| 170 DISALLOW_COPY_AND_ASSIGN(NavigationManagerImpl); | 195 DISALLOW_COPY_AND_ASSIGN(NavigationManagerImpl); |
| 171 }; | 196 }; |
| 172 | 197 |
| 173 } // namespace web | 198 } // namespace web |
| 174 | 199 |
| 175 #endif // IOS_WEB_NAVIGATION_NAVIGATION_MANAGER_IMPL_H_ | 200 #endif // IOS_WEB_NAVIGATION_NAVIGATION_MANAGER_IMPL_H_ |
| OLD | NEW |