Chromium Code Reviews| Index: ios/web/navigation/web_view_navigation_proxy_impl.mm |
| diff --git a/ios/web/navigation/web_view_navigation_proxy_impl.mm b/ios/web/navigation/web_view_navigation_proxy_impl.mm |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..3402ad82f4f74a2dfa0cc5f4d9416bf3f3959be8 |
| --- /dev/null |
| +++ b/ios/web/navigation/web_view_navigation_proxy_impl.mm |
| @@ -0,0 +1,76 @@ |
| +// Copyright 2017 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#import <WebKit/WebKit.h> |
| +#include "base/logging.h" |
| + |
| +#include "ios/web/navigation/web_view_navigation_proxy_impl.h" |
| + |
| +namespace web { |
| + |
| +WebViewNavigationProxyImpl::WebViewNavigationProxyImpl(WKWebView* web_view) |
| + : web_view_(web_view) {} |
| + |
| +bool WebViewNavigationProxyImpl::HasWebView() const { |
| + return web_view_ != nullptr; |
| +} |
| + |
| +bool WebViewNavigationProxyImpl::CanGoBack() const { |
| + return web_view_ && [web_view_ canGoBack]; |
| +} |
| + |
| +bool WebViewNavigationProxyImpl::CanGoForward() const { |
| + return web_view_ && [web_view_ canGoForward]; |
| +} |
| + |
| +void WebViewNavigationProxyImpl::GoBack() const { |
| + if (web_view_) { |
| + [web_view_ goBack]; |
| + } |
| +} |
| + |
| +void WebViewNavigationProxyImpl::GoForward() const { |
| + if (web_view_) { |
| + [web_view_ goForward]; |
| + } |
| +} |
| + |
| +void WebViewNavigationProxyImpl::GoToBackForwardListItem( |
| + WKBackForwardListItem* item) const { |
| + if (web_view_) { |
| + [web_view_ goToBackForwardListItem:item]; |
| + } |
| +} |
| + |
| +WKBackForwardListItem* WebViewNavigationProxyImpl::GetCurrentItem() const { |
| + if (web_view_) { |
| + 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.
|
| + } else { |
| + return nullptr; |
| + } |
| +} |
| + |
| +NSArray<WKBackForwardListItem*>* WebViewNavigationProxyImpl::GetBackList() |
| + const { |
| + DCHECK(web_view_); |
| + return web_view_.backForwardList.backList; |
| +} |
| + |
| +NSArray<WKBackForwardListItem*>* WebViewNavigationProxyImpl::GetForwardList() |
| + const { |
| + DCHECK(web_view_); |
| + return web_view_.backForwardList.forwardList; |
| +} |
| + |
| +WKBackForwardListItem* WebViewNavigationProxyImpl::GetItemAtOffset( |
| + int offset) const { |
| + DCHECK(web_view_); |
| + return [web_view_.backForwardList itemAtIndex:offset]; |
| +} |
| + |
| +void WebViewNavigationProxyImpl::SetWebView(WKWebView* web_view) { |
| + web_view_ = web_view; |
| +} |
| + |
| +} // namespace web |