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

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

Issue 2957163002: [Navigation Experiment] Add WKBasedNavigationManagerImpl. (Closed)
Patch Set: Patch for review 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 {
26
27 web::WebViewNavigationProxy* GetWebViewOrDie(
Eugene But (OOO till 7-30) 2017/06/29 01:48:19 Generally it is uncommon in chromium code to DHECK
danyao 2017/06/29 16:05:25 Done.
28 web::NavigationManagerDelegate* delegate) {
29 DCHECK(delegate);
30 web::WebViewNavigationProxy* proxy = delegate->GetWebViewNavigationProxy();
31 DCHECK(proxy);
32 return proxy;
33 }
34
35 } // namespace
36
37 namespace web {
38
39 WKBasedNavigationManagerImpl::WKBasedNavigationManagerImpl()
40 : delegate_(nullptr), browser_state_(nullptr) {}
41
42 WKBasedNavigationManagerImpl::~WKBasedNavigationManagerImpl() {}
Eugene But (OOO till 7-30) 2017/06/29 01:48:19 nit: WKBasedNavigationManagerImpl::~WKBasedNavigat
danyao 2017/06/29 16:05:26 Done.
43
44 void WKBasedNavigationManagerImpl::SetDelegate(
45 NavigationManagerDelegate* delegate) {
46 delegate_ = delegate;
47 }
48
49 void WKBasedNavigationManagerImpl::SetBrowserState(
50 BrowserState* browser_state) {
51 browser_state_ = browser_state;
52 }
53
54 void WKBasedNavigationManagerImpl::SetSessionController(
55 CRWSessionController* session_controller) {}
56
57 void WKBasedNavigationManagerImpl::InitializeSession() {}
58
59 void WKBasedNavigationManagerImpl::ReplaceSessionHistory(
60 std::vector<std::unique_ptr<NavigationItem>> items,
61 int current_index) {
62 DLOG(WARNING) << "Not yet implemented.";
63 }
64
65 void WKBasedNavigationManagerImpl::OnNavigationItemsPruned(
66 size_t pruned_item_count) {
67 delegate_->OnNavigationItemsPruned(pruned_item_count);
68 }
69
70 void WKBasedNavigationManagerImpl::OnNavigationItemChanged() {
71 delegate_->OnNavigationItemChanged();
72 }
73
74 void WKBasedNavigationManagerImpl::OnNavigationItemCommitted() {
75 LoadCommittedDetails details;
76 details.item = GetLastCommittedItem();
77 DCHECK(details.item);
78 details.previous_item_index = GetPreviousItemIndex();
79 if (details.previous_item_index >= 0) {
80 NavigationItem* previous_item = GetItemAtIndex(details.previous_item_index);
81 DCHECK(previous_item);
82 details.previous_url = previous_item->GetURL();
83 details.is_in_page =
84 AreURLsInPageNavigation(details.previous_url, details.item->GetURL());
85 } else {
86 details.previous_url = GURL();
87 details.is_in_page = NO;
88 }
89
90 delegate_->OnNavigationItemCommitted(details);
91 }
92
93 CRWSessionController* WKBasedNavigationManagerImpl::GetSessionController()
94 const {
95 return nullptr;
96 }
97
98 void WKBasedNavigationManagerImpl::AddTransientItem(const GURL& url) {
99 DLOG(WARNING) << "Not yet implemented.";
100 }
101
102 void WKBasedNavigationManagerImpl::AddPendingItem(
103 const GURL& url,
104 const web::Referrer& referrer,
105 ui::PageTransition navigation_type,
106 NavigationInitiationType initiation_type,
107 UserAgentOverrideOption user_agent_override_option) {
108 DLOG(WARNING) << "Not yet implemented.";
109 }
110
111 void WKBasedNavigationManagerImpl::CommitPendingItem() {
112 DLOG(WARNING) << "Not yet implemented.";
113 }
114
115 int WKBasedNavigationManagerImpl::GetIndexForOffset(int offset) const {
116 DLOG(WARNING) << "Not yet implemented.";
117 return -1;
118 }
119
120 BrowserState* WKBasedNavigationManagerImpl::GetBrowserState() const {
121 return browser_state_;
122 }
123
124 WebState* WKBasedNavigationManagerImpl::GetWebState() const {
125 return delegate_->GetWebState();
126 }
127
128 NavigationItem* WKBasedNavigationManagerImpl::GetVisibleItem() const {
129 DLOG(WARNING) << "Not yet implemented.";
130 return nullptr;
131 }
132
133 NavigationItem* WKBasedNavigationManagerImpl::GetLastCommittedItem() const {
134 DLOG(WARNING) << "Not yet implemented.";
135 return nullptr;
136 }
137
138 NavigationItem* WKBasedNavigationManagerImpl::GetPendingItem() const {
139 DLOG(WARNING) << "Not yet implemented.";
140 return nullptr;
141 }
142
143 NavigationItem* WKBasedNavigationManagerImpl::GetTransientItem() const {
144 DLOG(WARNING) << "Not yet implemented.";
145 return nullptr;
146 }
147
148 void WKBasedNavigationManagerImpl::DiscardNonCommittedItems() {
149 DLOG(WARNING) << "Not yet implemented.";
150 }
151
152 void WKBasedNavigationManagerImpl::LoadURLWithParams(
153 const NavigationManager::WebLoadParams&) {
154 DLOG(WARNING) << "Not yet implemented.";
155 }
156
157 void WKBasedNavigationManagerImpl::AddTransientURLRewriter(
158 BrowserURLRewriter::URLRewriter rewriter) {
159 DCHECK(rewriter);
160 if (!transient_url_rewriters_) {
161 transient_url_rewriters_.reset(
162 new std::vector<BrowserURLRewriter::URLRewriter>());
163 }
164 transient_url_rewriters_->push_back(rewriter);
165 }
166
167 int WKBasedNavigationManagerImpl::GetItemCount() const {
168 WebViewNavigationProxy* proxy = delegate_->GetWebViewNavigationProxy();
169 if (proxy) {
170 NSUInteger count_current_page = proxy->GetCurrentItem() ? 1 : 0;
171 return (int)(proxy->GetBackList().count + count_current_page +
Eugene But (OOO till 7-30) 2017/06/29 01:48:19 Please use C++ casting: https://google.github.io/
danyao 2017/06/29 16:05:26 Done.
172 proxy->GetForwardList().count);
173 }
174
175 // If WebView has not been created, it's fair to say navigation has 0 item.
176 return 0;
177 }
178
179 NavigationItem* WKBasedNavigationManagerImpl::GetItemAtIndex(
180 size_t index) const {
181 DLOG(WARNING) << "Not yet implemented.";
182 return nullptr;
183 }
184
185 int WKBasedNavigationManagerImpl::GetIndexOfItem(
186 const NavigationItem* item) const {
187 DLOG(WARNING) << "Not yet implemented.";
188 return -1;
189 }
190
191 int WKBasedNavigationManagerImpl::GetPendingItemIndex() const {
192 DLOG(WARNING) << "Not yet implemented.";
193 return -1;
194 }
195
196 int WKBasedNavigationManagerImpl::GetLastCommittedItemIndex() const {
197 WebViewNavigationProxy* proxy = delegate_->GetWebViewNavigationProxy();
198 if (proxy && proxy->GetCurrentItem()) {
199 return static_cast<int>(proxy->GetBackList().count);
200 }
201 return -1;
202 }
203
204 bool WKBasedNavigationManagerImpl::RemoveItemAtIndex(int index) {
205 DLOG(WARNING) << "Not yet implemented.";
206 return true;
207 }
208
209 bool WKBasedNavigationManagerImpl::CanGoBack() const {
210 WebViewNavigationProxy* proxy = delegate_->GetWebViewNavigationProxy();
211 return proxy && proxy->CanGoBack();
212 }
213
214 bool WKBasedNavigationManagerImpl::CanGoForward() const {
215 WebViewNavigationProxy* proxy = delegate_->GetWebViewNavigationProxy();
216 return proxy && proxy->CanGoForward();
217 }
218
219 bool WKBasedNavigationManagerImpl::CanGoToOffset(int offset) const {
220 int index = GetIndexForOffset(offset);
221 return index >= 0 && index < GetItemCount();
222 }
223
224 void WKBasedNavigationManagerImpl::GoBack() {
225 GetWebViewOrDie(delegate_)->GoBack();
226 }
227
228 void WKBasedNavigationManagerImpl::GoForward() {
229 GetWebViewOrDie(delegate_)->GoForward();
230 }
231
232 void WKBasedNavigationManagerImpl::GoToIndex(int index) {
233 DLOG(WARNING) << "Not yet implemented.";
234 }
235
236 void WKBasedNavigationManagerImpl::Reload(ReloadType reload_type,
237 bool check_for_reposts) {
238 DLOG(WARNING) << "Not yet implemented.";
239 }
240
241 NavigationItemList WKBasedNavigationManagerImpl::GetBackwardItems() const {
242 DLOG(WARNING) << "Not yet implemented.";
243 return NavigationItemList();
244 }
245
246 NavigationItemList WKBasedNavigationManagerImpl::GetForwardItems() const {
247 DLOG(WARNING) << "Not yet implemented.";
248 return NavigationItemList();
249 }
250
251 void WKBasedNavigationManagerImpl::CopyStateFromAndPrune(
252 const NavigationManager* source) {
253 DLOG(WARNING) << "Not yet implemented.";
254 }
255
256 bool WKBasedNavigationManagerImpl::CanPruneAllButLastCommittedItem() const {
257 DLOG(WARNING) << "Not yet implemented.";
258 return true;
259 }
260
261 void WKBasedNavigationManagerImpl::RemoveTransientURLRewriters() {
262 transient_url_rewriters_.reset();
263 }
264
265 std::unique_ptr<std::vector<BrowserURLRewriter::URLRewriter>>
266 WKBasedNavigationManagerImpl::GetTransientURLRewriters() {
267 return std::move(transient_url_rewriters_);
268 };
269
270 NavigationItemImpl* WKBasedNavigationManagerImpl::GetNavigationItemImplAtIndex(
271 size_t index) const {
272 DLOG(WARNING) << "Not yet implemented.";
273 return nullptr;
274 }
275
276 int WKBasedNavigationManagerImpl::GetPreviousItemIndex() const {
277 return std::max(-1, GetIndexForOffset(-1));
Eugene But (OOO till 7-30) 2017/06/29 01:48:19 "previous" in this context means "the old" not "cu
danyao 2017/06/29 16:05:26 Done.
278 }
279
280 } // namespace web
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698