Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3)

Side by Side Diff: ios/web/navigation/navigation_manager_impl.h

Issue 2698773002: [iOS] Refactoring web CRWSessionController user agent code. (Closed)
Patch Set: Fix unit tests and rebase Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 // Defines the ways how a pending navigation can be initiated.
30 enum class NavigationInitiationType {
31 // Navigation was initiated by actual user action.
32 USER_INITIATED = 1,
33
34 // Navigation was initiated by renderer. Examples of renderer-initiated
35 // navigations include:
36 // * <a> link click
37 // * changing window.location.href
38 // * redirect via the <meta http-equiv="refresh"> tag
39 // * using window.history.pushState
40 RENDERER_INITIATED,
41 };
42
29 // Implementation of NavigationManager. 43 // Implementation of NavigationManager.
30 // Generally mirrors upstream's NavigationController. 44 // Generally mirrors upstream's NavigationController.
31 class NavigationManagerImpl : public NavigationManager { 45 class NavigationManagerImpl : public NavigationManager {
32 public: 46 public:
33 NavigationManagerImpl(); 47 NavigationManagerImpl();
34 ~NavigationManagerImpl() override; 48 ~NavigationManagerImpl() override;
35 49
36 // Setters for NavigationManagerDelegate and BrowserState. 50 // Setters for NavigationManagerDelegate and BrowserState.
37 void SetDelegate(NavigationManagerDelegate* delegate); 51 void SetDelegate(NavigationManagerDelegate* delegate);
38 void SetBrowserState(BrowserState* browser_state); 52 void SetBrowserState(BrowserState* browser_state);
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 void OnNavigationItemCommitted(); 89 void OnNavigationItemCommitted();
76 90
77 // Temporary accessors and content/ class pass-throughs. 91 // Temporary accessors and content/ class pass-throughs.
78 // TODO(stuartmorgan): Re-evaluate this list once the refactorings have 92 // TODO(stuartmorgan): Re-evaluate this list once the refactorings have
79 // settled down. 93 // settled down.
80 CRWSessionController* GetSessionController(); 94 CRWSessionController* GetSessionController();
81 void LoadURL(const GURL& url, 95 void LoadURL(const GURL& url,
82 const Referrer& referrer, 96 const Referrer& referrer,
83 ui::PageTransition type); 97 ui::PageTransition type);
84 98
99 // Adds a new item with the given url, referrer, navigation type, and
100 // initiation type, making it the pending item. If pending item is the same as
101 // the current item, this does nothing. |referrer| may be nil if there isn't
102 // one. The item starts out as pending, and will be lost unless
103 // |-commitPendingItem| is called.
104 void AddPendingItem(const GURL& url,
105 const web::Referrer& referrer,
106 ui::PageTransition navigation_type,
107 NavigationInitiationType initiation_type);
108
85 // Convenience accessors to get the underlying NavigationItems from the 109 // Convenience accessors to get the underlying NavigationItems from the
86 // SessionEntries returned from |session_controller_|'s -lastUserEntry and 110 // SessionEntries returned from |session_controller_|'s -lastUserEntry and
87 // -previousEntry methods. 111 // -previousEntry methods.
88 // TODO(crbug.com/546365): Remove these methods. 112 // TODO(crbug.com/546365): Remove these methods.
89 NavigationItem* GetLastUserItem() const; 113 NavigationItem* GetLastUserItem() const;
90 NavigationItem* GetPreviousItem() const; 114 NavigationItem* GetPreviousItem() const;
91 115
92 // Temporary method. Returns a vector of NavigationItems corresponding to 116 // Temporary method. Returns a vector of NavigationItems corresponding to
93 // the SessionEntries of the uderlying CRWSessionController. 117 // the SessionEntries of the uderlying CRWSessionController.
94 // TODO(crbug.com/546365): Remove this method. 118 // TODO(crbug.com/546365): Remove this method.
(...skipping 17 matching lines...) Expand all
112 int GetPendingItemIndex() const override; 136 int GetPendingItemIndex() const override;
113 int GetLastCommittedItemIndex() const override; 137 int GetLastCommittedItemIndex() const override;
114 bool RemoveItemAtIndex(int index) override; 138 bool RemoveItemAtIndex(int index) override;
115 bool CanGoBack() const override; 139 bool CanGoBack() const override;
116 bool CanGoForward() const override; 140 bool CanGoForward() const override;
117 bool CanGoToOffset(int offset) const override; 141 bool CanGoToOffset(int offset) const override;
118 void GoBack() override; 142 void GoBack() override;
119 void GoForward() override; 143 void GoForward() override;
120 void GoToIndex(int index) override; 144 void GoToIndex(int index) override;
121 void Reload(bool check_for_reposts) override; 145 void Reload(bool check_for_reposts) override;
146 void OverrideDesktopUserAgentForNextPendingItem() override;
122 147
123 // Returns the current list of transient url rewriters, passing ownership to 148 // Returns the current list of transient url rewriters, passing ownership to
124 // the caller. 149 // the caller.
125 // TODO(crbug.com/546197): remove once NavigationItem creation occurs in this 150 // TODO(crbug.com/546197): remove once NavigationItem creation occurs in this
126 // class. 151 // class.
127 std::unique_ptr<std::vector<BrowserURLRewriter::URLRewriter>> 152 std::unique_ptr<std::vector<BrowserURLRewriter::URLRewriter>>
128 GetTransientURLRewriters(); 153 GetTransientURLRewriters();
129 154
130 // Called to reset the transient url rewriter list. 155 // Called to reset the transient url rewriter list.
131 void RemoveTransientURLRewriters(); 156 void RemoveTransientURLRewriters();
(...skipping 11 matching lines...) Expand all
143 168
144 private: 169 private:
145 // The SessionStorageBuilder functions require access to private variables of 170 // The SessionStorageBuilder functions require access to private variables of
146 // NavigationManagerImpl. 171 // NavigationManagerImpl.
147 friend SessionStorageBuilder; 172 friend SessionStorageBuilder;
148 173
149 // Returns true if the PageTransition for the underlying navigation item at 174 // Returns true if the PageTransition for the underlying navigation item at
150 // |index| has ui::PAGE_TRANSITION_IS_REDIRECT_MASK. 175 // |index| has ui::PAGE_TRANSITION_IS_REDIRECT_MASK.
151 bool IsRedirectItemAtIndex(int index) const; 176 bool IsRedirectItemAtIndex(int index) const;
152 177
178 // If true, override navigation item's useDesktopUserAgent flag and always
179 // create the pending entry using the desktop user agent.
180 // TODO(crbug.com/692303): Remove this when overriding the user agent doesn't
181 // create a new NavigationItem.
182 bool override_desktop_user_agent_for_next_pending_item_;
183
153 // The primary delegate for this manager. 184 // The primary delegate for this manager.
154 NavigationManagerDelegate* delegate_; 185 NavigationManagerDelegate* delegate_;
155 186
156 // The BrowserState that is associated with this instance. 187 // The BrowserState that is associated with this instance.
157 BrowserState* browser_state_; 188 BrowserState* browser_state_;
158 189
159 // CRWSessionController that backs this instance. 190 // CRWSessionController that backs this instance.
160 // TODO(stuartmorgan): Fold CRWSessionController into this class. 191 // TODO(stuartmorgan): Fold CRWSessionController into this class.
161 base::scoped_nsobject<CRWSessionController> session_controller_; 192 base::scoped_nsobject<CRWSessionController> session_controller_;
162 193
163 // Weak pointer to the facade delegate. 194 // Weak pointer to the facade delegate.
164 NavigationManagerFacadeDelegate* facade_delegate_; 195 NavigationManagerFacadeDelegate* facade_delegate_;
165 196
166 // List of transient url rewriters added by |AddTransientURLRewriter()|. 197 // List of transient url rewriters added by |AddTransientURLRewriter()|.
167 std::unique_ptr<std::vector<BrowserURLRewriter::URLRewriter>> 198 std::unique_ptr<std::vector<BrowserURLRewriter::URLRewriter>>
168 transient_url_rewriters_; 199 transient_url_rewriters_;
169 200
170 DISALLOW_COPY_AND_ASSIGN(NavigationManagerImpl); 201 DISALLOW_COPY_AND_ASSIGN(NavigationManagerImpl);
171 }; 202 };
172 203
173 } // namespace web 204 } // namespace web
174 205
175 #endif // IOS_WEB_NAVIGATION_NAVIGATION_MANAGER_IMPL_H_ 206 #endif // IOS_WEB_NAVIGATION_NAVIGATION_MANAGER_IMPL_H_
OLDNEW
« no previous file with comments | « ios/web/navigation/navigation_item_impl.mm ('k') | ios/web/navigation/navigation_manager_impl.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698