Chromium Code Reviews| 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 #import <WebKit/WebKit.h> | |
| 6 #include "base/logging.h" | |
| 7 | |
| 8 #include "ios/web/navigation/web_view_navigation_proxy_impl.h" | |
| 9 | |
| 10 namespace web { | |
| 11 | |
| 12 WebViewNavigationProxyImpl::WebViewNavigationProxyImpl(WKWebView* web_view) | |
| 13 : web_view_(web_view) {} | |
| 14 | |
| 15 bool WebViewNavigationProxyImpl::HasWebView() const { | |
| 16 return web_view_ != nullptr; | |
| 17 } | |
| 18 | |
| 19 bool WebViewNavigationProxyImpl::CanGoBack() const { | |
| 20 return web_view_ && [web_view_ canGoBack]; | |
| 21 } | |
| 22 | |
| 23 bool WebViewNavigationProxyImpl::CanGoForward() const { | |
| 24 return web_view_ && [web_view_ canGoForward]; | |
| 25 } | |
| 26 | |
| 27 void WebViewNavigationProxyImpl::GoBack() const { | |
| 28 if (web_view_) { | |
| 29 [web_view_ goBack]; | |
| 30 } | |
| 31 } | |
| 32 | |
| 33 void WebViewNavigationProxyImpl::GoForward() const { | |
| 34 if (web_view_) { | |
| 35 [web_view_ goForward]; | |
| 36 } | |
| 37 } | |
| 38 | |
| 39 void WebViewNavigationProxyImpl::GoToBackForwardListItem( | |
| 40 WKBackForwardListItem* item) const { | |
| 41 if (web_view_) { | |
| 42 [web_view_ goToBackForwardListItem:item]; | |
| 43 } | |
| 44 } | |
| 45 | |
| 46 WKBackForwardListItem* WebViewNavigationProxyImpl::GetCurrentItem() const { | |
| 47 if (web_view_) { | |
| 48 return web_view_.backForwardList.currentItem; | |
|
Eugene But (OOO till 7-30)
2017/06/27 22:02:00
nit: No need for |if (web_view_) {| check. it's ok
danyao
2017/06/28 22:11:04
Done.
| |
| 49 } else { | |
| 50 return nullptr; | |
| 51 } | |
| 52 } | |
| 53 | |
| 54 NSArray<WKBackForwardListItem*>* WebViewNavigationProxyImpl::GetBackList() | |
| 55 const { | |
| 56 DCHECK(web_view_); | |
| 57 return web_view_.backForwardList.backList; | |
| 58 } | |
| 59 | |
| 60 NSArray<WKBackForwardListItem*>* WebViewNavigationProxyImpl::GetForwardList() | |
| 61 const { | |
| 62 DCHECK(web_view_); | |
| 63 return web_view_.backForwardList.forwardList; | |
| 64 } | |
| 65 | |
| 66 WKBackForwardListItem* WebViewNavigationProxyImpl::GetItemAtOffset( | |
| 67 int offset) const { | |
| 68 DCHECK(web_view_); | |
| 69 return [web_view_.backForwardList itemAtIndex:offset]; | |
| 70 } | |
| 71 | |
| 72 void WebViewNavigationProxyImpl::SetWebView(WKWebView* web_view) { | |
| 73 web_view_ = web_view; | |
| 74 } | |
| 75 | |
| 76 } // namespace web | |
| OLD | NEW |