| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #import "ios/web_view/public/cwv_web_view.h" | 5 #import "ios/web_view/public/cwv_web_view.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #import "base/ios/weak_nsobject.h" | 10 #import "base/ios/weak_nsobject.h" |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 _javaScriptDialogPresenter; | 72 _javaScriptDialogPresenter; |
| 73 } | 73 } |
| 74 | 74 |
| 75 // Redefine the property as readwrite. | 75 // Redefine the property as readwrite. |
| 76 @property(nonatomic, copy) CWVWebViewConfiguration* configuration; | 76 @property(nonatomic, copy) CWVWebViewConfiguration* configuration; |
| 77 // Redefine these properties as readwrite to define setters, which send KVO | 77 // Redefine these properties as readwrite to define setters, which send KVO |
| 78 // notifications. | 78 // notifications. |
| 79 @property(nonatomic, readwrite) double estimatedProgress; | 79 @property(nonatomic, readwrite) double estimatedProgress; |
| 80 @property(nonatomic, readwrite) BOOL canGoBack; | 80 @property(nonatomic, readwrite) BOOL canGoBack; |
| 81 @property(nonatomic, readwrite) BOOL canGoForward; | 81 @property(nonatomic, readwrite) BOOL canGoForward; |
| 82 @property(nonatomic, readwrite, copy) NSString* title; |
| 82 | 83 |
| 83 // Updates the availability of the back/forward navigation properties exposed | 84 // Updates the availability of the back/forward navigation properties exposed |
| 84 // through |canGoBack| and |canGoForward|. | 85 // through |canGoBack| and |canGoForward|. |
| 85 - (void)updateNavigationAvailability; | 86 - (void)updateNavigationAvailability; |
| 86 | 87 |
| 87 @end | 88 @end |
| 88 | 89 |
| 89 static NSString* gUserAgentProduct = nil; | 90 static NSString* gUserAgentProduct = nil; |
| 90 | 91 |
| 91 @implementation CWVWebView | 92 @implementation CWVWebView |
| 92 | 93 |
| 93 @synthesize canGoBack = _canGoBack; | 94 @synthesize canGoBack = _canGoBack; |
| 94 @synthesize canGoForward = _canGoForward; | 95 @synthesize canGoForward = _canGoForward; |
| 95 @synthesize configuration = _configuration; | 96 @synthesize configuration = _configuration; |
| 96 @synthesize estimatedProgress = _estimatedProgress; | 97 @synthesize estimatedProgress = _estimatedProgress; |
| 97 @synthesize navigationDelegate = _navigationDelegate; | 98 @synthesize navigationDelegate = _navigationDelegate; |
| 99 @synthesize title = _title; |
| 98 @synthesize translationController = _translationController; | 100 @synthesize translationController = _translationController; |
| 99 @synthesize UIDelegate = _UIDelegate; | 101 @synthesize UIDelegate = _UIDelegate; |
| 100 @synthesize scrollView = _scrollView; | 102 @synthesize scrollView = _scrollView; |
| 101 | 103 |
| 102 + (NSString*)userAgentProduct { | 104 + (NSString*)userAgentProduct { |
| 103 return gUserAgentProduct; | 105 return gUserAgentProduct; |
| 104 } | 106 } |
| 105 | 107 |
| 106 + (void)setUserAgentProduct:(NSString*)product { | 108 + (void)setUserAgentProduct:(NSString*)product { |
| 107 gUserAgentProduct = [product copy]; | 109 gUserAgentProduct = [product copy]; |
| (...skipping 30 matching lines...) Expand all Loading... |
| 138 } | 140 } |
| 139 | 141 |
| 140 - (NSURL*)visibleURL { | 142 - (NSURL*)visibleURL { |
| 141 return net::NSURLWithGURL(_webState->GetVisibleURL()); | 143 return net::NSURLWithGURL(_webState->GetVisibleURL()); |
| 142 } | 144 } |
| 143 | 145 |
| 144 - (NSURL*)lastCommittedURL { | 146 - (NSURL*)lastCommittedURL { |
| 145 return net::NSURLWithGURL(_webState->GetLastCommittedURL()); | 147 return net::NSURLWithGURL(_webState->GetLastCommittedURL()); |
| 146 } | 148 } |
| 147 | 149 |
| 148 - (NSString*)title { | |
| 149 return base::SysUTF16ToNSString(_webState->GetTitle()); | |
| 150 } | |
| 151 | |
| 152 - (void)goBack { | 150 - (void)goBack { |
| 153 if (_webState->GetNavigationManager()) | 151 if (_webState->GetNavigationManager()) |
| 154 _webState->GetNavigationManager()->GoBack(); | 152 _webState->GetNavigationManager()->GoBack(); |
| 155 } | 153 } |
| 156 | 154 |
| 157 - (void)goForward { | 155 - (void)goForward { |
| 158 if (_webState->GetNavigationManager()) | 156 if (_webState->GetNavigationManager()) |
| 159 _webState->GetNavigationManager()->GoForward(); | 157 _webState->GetNavigationManager()->GoForward(); |
| 160 } | 158 } |
| 161 | 159 |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 224 if ([_navigationDelegate respondsToSelector:selector]) { | 222 if ([_navigationDelegate respondsToSelector:selector]) { |
| 225 [_navigationDelegate webView:self didLoadPageWithSuccess:success]; | 223 [_navigationDelegate webView:self didLoadPageWithSuccess:success]; |
| 226 } | 224 } |
| 227 } | 225 } |
| 228 | 226 |
| 229 - (void)webState:(web::WebState*)webState | 227 - (void)webState:(web::WebState*)webState |
| 230 didChangeLoadingProgress:(double)progress { | 228 didChangeLoadingProgress:(double)progress { |
| 231 self.estimatedProgress = progress; | 229 self.estimatedProgress = progress; |
| 232 } | 230 } |
| 233 | 231 |
| 232 - (void)webStateDidChangeTitle:(web::WebState*)webState { |
| 233 self.title = base::SysUTF16ToNSString(_webState->GetTitle()); |
| 234 } |
| 235 |
| 234 - (void)renderProcessGoneForWebState:(web::WebState*)webState { | 236 - (void)renderProcessGoneForWebState:(web::WebState*)webState { |
| 235 SEL selector = @selector(webViewWebContentProcessDidTerminate:); | 237 SEL selector = @selector(webViewWebContentProcessDidTerminate:); |
| 236 if ([_navigationDelegate respondsToSelector:selector]) { | 238 if ([_navigationDelegate respondsToSelector:selector]) { |
| 237 [_navigationDelegate webViewWebContentProcessDidTerminate:self]; | 239 [_navigationDelegate webViewWebContentProcessDidTerminate:self]; |
| 238 } | 240 } |
| 239 } | 241 } |
| 240 | 242 |
| 241 - (BOOL)webState:(web::WebState*)webState | 243 - (BOOL)webState:(web::WebState*)webState |
| 242 handleContextMenu:(const web::ContextMenuParams&)params { | 244 handleContextMenu:(const web::ContextMenuParams&)params { |
| 243 SEL selector = @selector(webView:runContextMenuWithTitle:forHTMLElement:inView | 245 SEL selector = @selector(webView:runContextMenuWithTitle:forHTMLElement:inView |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 376 [self addSubview:subview]; | 378 [self addSubview:subview]; |
| 377 } | 379 } |
| 378 | 380 |
| 379 - (void)updateNavigationAvailability { | 381 - (void)updateNavigationAvailability { |
| 380 self.canGoBack = _webState && _webState->GetNavigationManager()->CanGoBack(); | 382 self.canGoBack = _webState && _webState->GetNavigationManager()->CanGoBack(); |
| 381 self.canGoForward = | 383 self.canGoForward = |
| 382 _webState && _webState->GetNavigationManager()->CanGoForward(); | 384 _webState && _webState->GetNavigationManager()->CanGoForward(); |
| 383 } | 385 } |
| 384 | 386 |
| 385 @end | 387 @end |
| OLD | NEW |