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

Side by Side Diff: ios/web/navigation/wk_based_navigation_manager_impl.mm

Issue 2957163002: [Navigation Experiment] Add WKBasedNavigationManagerImpl. (Closed)
Patch Set: Changed WebViewNavigationProxy to a protocol Created 3 years, 5 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
(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 #import "ios/web/navigation/wk_based_navigation_manager_impl.h"
6
7 #include <memory>
8
9 #include "base/logging.h"
10 #include "base/memory/ptr_util.h"
11 #import "ios/web/navigation/navigation_item_impl.h"
12 #import "ios/web/navigation/navigation_manager_delegate.h"
13 #include "ios/web/public/load_committed_details.h"
14 #import "ios/web/public/navigation_item.h"
15 #import "ios/web/public/web_client.h"
16 #import "ios/web/web_state/ui/web_view_navigation_proxy.h"
17 #import "net/base/mac/url_conversions.h"
18
19 #if !defined(__has_feature) || !__has_feature(objc_arc)
20 #error "This file requires ARC support."
21 #endif
22
23 @class CRWSessionController;
24
25 namespace web {
26
27 WKBasedNavigationManagerImpl::WKBasedNavigationManagerImpl()
Eugene But (OOO till 7-30) 2017/06/29 22:28:02 Could you please add a unit test for this specific
danyao 2017/06/29 23:09:47 I was planning on adding tests to navigation_manag
Eugene But (OOO till 7-30) 2017/06/30 00:59:53 If you think you can maintain good coverage for th
28 : delegate_(nullptr), browser_state_(nullptr) {}
29
30 WKBasedNavigationManagerImpl::~WKBasedNavigationManagerImpl() = default;
31
32 void WKBasedNavigationManagerImpl::SetDelegate(
33 NavigationManagerDelegate* delegate) {
34 delegate_ = delegate;
35 }
36
37 void WKBasedNavigationManagerImpl::SetBrowserState(
38 BrowserState* browser_state) {
39 browser_state_ = browser_state;
40 }
41
42 void WKBasedNavigationManagerImpl::SetSessionController(
43 CRWSessionController* session_controller) {}
44
45 void WKBasedNavigationManagerImpl::InitializeSession() {}
46
47 void WKBasedNavigationManagerImpl::ReplaceSessionHistory(
48 std::vector<std::unique_ptr<NavigationItem>> items,
49 int current_index) {
50 DLOG(WARNING) << "Not yet implemented.";
51 }
52
53 void WKBasedNavigationManagerImpl::OnNavigationItemsPruned(
54 size_t pruned_item_count) {
55 delegate_->OnNavigationItemsPruned(pruned_item_count);
56 }
57
58 void WKBasedNavigationManagerImpl::OnNavigationItemChanged() {
59 delegate_->OnNavigationItemChanged();
60 }
61
62 void WKBasedNavigationManagerImpl::OnNavigationItemCommitted() {
63 LoadCommittedDetails details;
64 details.item = GetLastCommittedItem();
65 DCHECK(details.item);
66 details.previous_item_index = GetPreviousItemIndex();
67 if (details.previous_item_index >= 0) {
68 NavigationItem* previous_item = GetItemAtIndex(details.previous_item_index);
69 DCHECK(previous_item);
70 details.previous_url = previous_item->GetURL();
71 details.is_in_page = AreUrlsFragmentChangeNavigation(
72 details.previous_url, details.item->GetURL());
73 } else {
74 details.previous_url = GURL();
75 details.is_in_page = NO;
76 }
77
78 delegate_->OnNavigationItemCommitted(details);
79 }
80
81 CRWSessionController* WKBasedNavigationManagerImpl::GetSessionController()
82 const {
83 return nullptr;
Eugene But (OOO till 7-30) 2017/06/29 22:28:02 nit: Sorry, missed this previously s/nullptr/nil
danyao 2017/06/29 23:09:47 Done.
84 }
85
86 void WKBasedNavigationManagerImpl::AddTransientItem(const GURL& url) {
87 DLOG(WARNING) << "Not yet implemented.";
88 }
89
90 void WKBasedNavigationManagerImpl::AddPendingItem(
91 const GURL& url,
92 const web::Referrer& referrer,
93 ui::PageTransition navigation_type,
94 NavigationInitiationType initiation_type,
95 UserAgentOverrideOption user_agent_override_option) {
96 DLOG(WARNING) << "Not yet implemented.";
97 }
98
99 void WKBasedNavigationManagerImpl::CommitPendingItem() {
100 DLOG(WARNING) << "Not yet implemented.";
101 }
102
103 int WKBasedNavigationManagerImpl::GetIndexForOffset(int offset) const {
104 DLOG(WARNING) << "Not yet implemented.";
105 return -1;
106 }
107
108 BrowserState* WKBasedNavigationManagerImpl::GetBrowserState() const {
109 return browser_state_;
110 }
111
112 WebState* WKBasedNavigationManagerImpl::GetWebState() const {
113 return delegate_->GetWebState();
114 }
115
116 NavigationItem* WKBasedNavigationManagerImpl::GetVisibleItem() const {
117 DLOG(WARNING) << "Not yet implemented.";
118 return nullptr;
119 }
120
121 NavigationItem* WKBasedNavigationManagerImpl::GetLastCommittedItem() const {
122 DLOG(WARNING) << "Not yet implemented.";
123 return nullptr;
124 }
125
126 NavigationItem* WKBasedNavigationManagerImpl::GetPendingItem() const {
127 DLOG(WARNING) << "Not yet implemented.";
128 return nullptr;
129 }
130
131 NavigationItem* WKBasedNavigationManagerImpl::GetTransientItem() const {
132 DLOG(WARNING) << "Not yet implemented.";
133 return nullptr;
134 }
135
136 void WKBasedNavigationManagerImpl::DiscardNonCommittedItems() {
137 DLOG(WARNING) << "Not yet implemented.";
138 }
139
140 void WKBasedNavigationManagerImpl::LoadURLWithParams(
141 const NavigationManager::WebLoadParams&) {
142 DLOG(WARNING) << "Not yet implemented.";
143 }
144
145 void WKBasedNavigationManagerImpl::AddTransientURLRewriter(
146 BrowserURLRewriter::URLRewriter rewriter) {
147 DCHECK(rewriter);
148 if (!transient_url_rewriters_) {
149 transient_url_rewriters_.reset(
150 new std::vector<BrowserURLRewriter::URLRewriter>());
151 }
152 transient_url_rewriters_->push_back(rewriter);
153 }
154
155 int WKBasedNavigationManagerImpl::GetItemCount() const {
156 id<WebViewNavigationProxy> proxy = delegate_->GetWebViewNavigationProxy();
157 if (proxy) {
158 int count_current_page = proxy.backForwardList.currentItem ? 1 : 0;
159 return static_cast<int>(proxy.backForwardList.backList.count) +
160 count_current_page +
161 static_cast<int>(proxy.backForwardList.forwardList.count);
162 }
163
164 // If WebView has not been created, it's fair to say navigation has 0 item.
165 return 0;
166 }
167
168 NavigationItem* WKBasedNavigationManagerImpl::GetItemAtIndex(
169 size_t index) const {
170 DLOG(WARNING) << "Not yet implemented.";
171 return nullptr;
172 }
173
174 int WKBasedNavigationManagerImpl::GetIndexOfItem(
175 const NavigationItem* item) const {
176 DLOG(WARNING) << "Not yet implemented.";
177 return -1;
178 }
179
180 int WKBasedNavigationManagerImpl::GetPendingItemIndex() const {
181 DLOG(WARNING) << "Not yet implemented.";
182 return -1;
183 }
184
185 int WKBasedNavigationManagerImpl::GetLastCommittedItemIndex() const {
186 id<WebViewNavigationProxy> proxy = delegate_->GetWebViewNavigationProxy();
187 if (proxy.backForwardList.currentItem) {
188 return static_cast<int>(proxy.backForwardList.backList.count);
189 }
190 return -1;
191 }
192
193 bool WKBasedNavigationManagerImpl::RemoveItemAtIndex(int index) {
194 DLOG(WARNING) << "Not yet implemented.";
195 return true;
196 }
197
198 bool WKBasedNavigationManagerImpl::CanGoBack() const {
199 return [delegate_->GetWebViewNavigationProxy() canGoBack];
200 }
201
202 bool WKBasedNavigationManagerImpl::CanGoForward() const {
203 return [delegate_->GetWebViewNavigationProxy() canGoForward];
204 }
205
206 bool WKBasedNavigationManagerImpl::CanGoToOffset(int offset) const {
207 int index = GetIndexForOffset(offset);
208 return index >= 0 && index < GetItemCount();
209 }
210
211 void WKBasedNavigationManagerImpl::GoBack() {
212 [delegate_->GetWebViewNavigationProxy() goBack];
213 }
214
215 void WKBasedNavigationManagerImpl::GoForward() {
216 [delegate_->GetWebViewNavigationProxy() goForward];
217 }
218
219 void WKBasedNavigationManagerImpl::GoToIndex(int index) {
220 DLOG(WARNING) << "Not yet implemented.";
221 }
222
223 void WKBasedNavigationManagerImpl::Reload(ReloadType reload_type,
224 bool check_for_reposts) {
225 DLOG(WARNING) << "Not yet implemented.";
226 }
227
228 NavigationItemList WKBasedNavigationManagerImpl::GetBackwardItems() const {
229 DLOG(WARNING) << "Not yet implemented.";
230 return NavigationItemList();
231 }
232
233 NavigationItemList WKBasedNavigationManagerImpl::GetForwardItems() const {
234 DLOG(WARNING) << "Not yet implemented.";
235 return NavigationItemList();
236 }
237
238 void WKBasedNavigationManagerImpl::CopyStateFromAndPrune(
239 const NavigationManager* source) {
240 DLOG(WARNING) << "Not yet implemented.";
241 }
242
243 bool WKBasedNavigationManagerImpl::CanPruneAllButLastCommittedItem() const {
244 DLOG(WARNING) << "Not yet implemented.";
245 return true;
246 }
247
248 void WKBasedNavigationManagerImpl::RemoveTransientURLRewriters() {
249 transient_url_rewriters_.reset();
250 }
251
252 std::unique_ptr<std::vector<BrowserURLRewriter::URLRewriter>>
253 WKBasedNavigationManagerImpl::GetTransientURLRewriters() {
254 return std::move(transient_url_rewriters_);
255 };
256
257 NavigationItemImpl* WKBasedNavigationManagerImpl::GetNavigationItemImplAtIndex(
258 size_t index) const {
259 DLOG(WARNING) << "Not yet implemented.";
260 return nullptr;
261 }
262
263 int WKBasedNavigationManagerImpl::GetPreviousItemIndex() const {
264 DLOG(WARNING) << "Not yet implemented.";
265 return -1;
266 }
267
268 } // namespace web
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698