OLD | NEW |
---|---|
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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/web_state/ui/crw_web_controller.h" | 5 #import "ios/web/web_state/ui/crw_web_controller.h" |
6 | 6 |
7 #import <WebKit/WebKit.h> | 7 #import <WebKit/WebKit.h> |
8 | 8 |
9 #import <objc/runtime.h> | 9 #import <objc/runtime.h> |
10 #include <stddef.h> | 10 #include <stddef.h> |
11 | 11 |
12 #include <cmath> | 12 #include <cmath> |
13 #include <memory> | 13 #include <memory> |
14 #include <utility> | 14 #include <utility> |
15 #include <vector> | 15 #include <vector> |
16 | 16 |
17 #include "base/callback.h" | 17 #include "base/callback.h" |
18 #include "base/containers/mru_cache.h" | 18 #include "base/containers/mru_cache.h" |
19 #import "base/ios/block_types.h" | 19 #import "base/ios/block_types.h" |
20 #include "base/ios/ios_util.h" | 20 #include "base/ios/ios_util.h" |
21 #import "base/ios/ns_error_util.h" | 21 #import "base/ios/ns_error_util.h" |
22 #import "base/ios/weak_nsobject.h" | |
23 #include "base/json/string_escape.h" | 22 #include "base/json/string_escape.h" |
24 #include "base/logging.h" | 23 #include "base/logging.h" |
25 #import "base/mac/bind_objc_block.h" | 24 #import "base/mac/bind_objc_block.h" |
26 #include "base/mac/bundle_locations.h" | 25 #include "base/mac/bundle_locations.h" |
27 #include "base/mac/foundation_util.h" | 26 #include "base/mac/foundation_util.h" |
28 #import "base/mac/objc_property_releaser.h" | |
29 #include "base/mac/scoped_cftyperef.h" | 27 #include "base/mac/scoped_cftyperef.h" |
30 #import "base/mac/scoped_nsobject.h" | |
31 #include "base/memory/ptr_util.h" | 28 #include "base/memory/ptr_util.h" |
32 #include "base/metrics/histogram_macros.h" | 29 #include "base/metrics/histogram_macros.h" |
33 #include "base/metrics/user_metrics.h" | 30 #include "base/metrics/user_metrics.h" |
34 #include "base/metrics/user_metrics_action.h" | 31 #include "base/metrics/user_metrics_action.h" |
35 #include "base/strings/string_util.h" | 32 #include "base/strings/string_util.h" |
36 #include "base/strings/sys_string_conversions.h" | 33 #include "base/strings/sys_string_conversions.h" |
37 #include "base/strings/utf_string_conversions.h" | 34 #include "base/strings/utf_string_conversions.h" |
38 #include "base/time/time.h" | 35 #include "base/time/time.h" |
39 #include "base/values.h" | 36 #include "base/values.h" |
40 #import "ios/net/http_response_headers_util.h" | 37 #import "ios/net/http_response_headers_util.h" |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
100 #import "ios/web/webui/crw_web_ui_manager.h" | 97 #import "ios/web/webui/crw_web_ui_manager.h" |
101 #import "ios/web/webui/mojo_facade.h" | 98 #import "ios/web/webui/mojo_facade.h" |
102 #import "net/base/mac/url_conversions.h" | 99 #import "net/base/mac/url_conversions.h" |
103 #include "net/base/net_errors.h" | 100 #include "net/base/net_errors.h" |
104 #include "net/cert/x509_util_ios.h" | 101 #include "net/cert/x509_util_ios.h" |
105 #include "net/ssl/ssl_info.h" | 102 #include "net/ssl/ssl_info.h" |
106 #include "ui/base/page_transition_types.h" | 103 #include "ui/base/page_transition_types.h" |
107 #include "url/gurl.h" | 104 #include "url/gurl.h" |
108 #include "url/url_constants.h" | 105 #include "url/url_constants.h" |
109 | 106 |
107 #if !defined(__has_feature) || !__has_feature(objc_arc) | |
108 #error "This file requires ARC support." | |
109 #endif | |
110 | |
110 using base::UserMetricsAction; | 111 using base::UserMetricsAction; |
111 using web::NavigationManager; | 112 using web::NavigationManager; |
112 using web::NavigationManagerImpl; | 113 using web::NavigationManagerImpl; |
113 using web::WebState; | 114 using web::WebState; |
114 using web::WebStateImpl; | 115 using web::WebStateImpl; |
115 | 116 |
116 namespace { | 117 namespace { |
117 | 118 |
118 // Struct to capture data about a user interaction. Records the time of the | 119 // Struct to capture data about a user interaction. Records the time of the |
119 // interaction and the main document URL at that time. | 120 // interaction and the main document URL at that time. |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
198 // Utility function for getting the source of NSErrors received by WKWebViews. | 199 // Utility function for getting the source of NSErrors received by WKWebViews. |
199 WKWebViewErrorSource WKWebViewErrorSourceFromError(NSError* error) { | 200 WKWebViewErrorSource WKWebViewErrorSourceFromError(NSError* error) { |
200 DCHECK(error); | 201 DCHECK(error); |
201 return static_cast<WKWebViewErrorSource>( | 202 return static_cast<WKWebViewErrorSource>( |
202 [error.userInfo[kWKWebViewErrorSourceKey] integerValue]); | 203 [error.userInfo[kWKWebViewErrorSourceKey] integerValue]); |
203 } | 204 } |
204 // Utility function for converting the WKWebViewErrorSource to the NSError | 205 // Utility function for converting the WKWebViewErrorSource to the NSError |
205 // received by WKWebViews. | 206 // received by WKWebViews. |
206 NSError* WKWebViewErrorWithSource(NSError* error, WKWebViewErrorSource source) { | 207 NSError* WKWebViewErrorWithSource(NSError* error, WKWebViewErrorSource source) { |
207 DCHECK(error); | 208 DCHECK(error); |
208 base::scoped_nsobject<NSMutableDictionary> userInfo( | 209 NSMutableDictionary* userInfo = [error.userInfo mutableCopy]; |
209 [error.userInfo mutableCopy]); | |
210 [userInfo setObject:@(source) forKey:kWKWebViewErrorSourceKey]; | 210 [userInfo setObject:@(source) forKey:kWKWebViewErrorSourceKey]; |
211 return | 211 return |
212 [NSError errorWithDomain:error.domain code:error.code userInfo:userInfo]; | 212 [NSError errorWithDomain:error.domain code:error.code userInfo:userInfo]; |
213 } | 213 } |
214 } // namespace | 214 } // namespace |
215 | 215 |
216 #pragma mark - | 216 #pragma mark - |
217 | 217 |
218 // A container object for any navigation information that is only available | 218 // A container object for any navigation information that is only available |
219 // during pre-commit delegate callbacks, and thus must be held until the | 219 // during pre-commit delegate callbacks, and thus must be held until the |
220 // navigation commits and the informatino can be used. | 220 // navigation commits and the informatino can be used. |
221 @interface CRWWebControllerPendingNavigationInfo : NSObject { | 221 @interface CRWWebControllerPendingNavigationInfo : NSObject { |
222 base::mac::ObjCPropertyReleaser | |
223 _propertyReleaser_CRWWebControllerPendingNavigationInfo; | |
224 } | 222 } |
225 // The referrer for the page. | 223 // The referrer for the page. |
226 @property(nonatomic, copy) NSString* referrer; | 224 @property(nonatomic, copy) NSString* referrer; |
227 // The MIME type for the page. | 225 // The MIME type for the page. |
228 @property(nonatomic, copy) NSString* MIMEType; | 226 @property(nonatomic, copy) NSString* MIMEType; |
229 // The navigation type for the load. | 227 // The navigation type for the load. |
230 @property(nonatomic, assign) WKNavigationType navigationType; | 228 @property(nonatomic, assign) WKNavigationType navigationType; |
231 // HTTP request method for the load. | 229 // HTTP request method for the load. |
232 @property(nonatomic, copy) NSString* HTTPMethod; | 230 @property(nonatomic, copy) NSString* HTTPMethod; |
233 // Whether the pending navigation has been directly cancelled before the | 231 // Whether the pending navigation has been directly cancelled before the |
234 // navigation is committed. | 232 // navigation is committed. |
235 // Cancelled navigations should be simply discarded without handling any | 233 // Cancelled navigations should be simply discarded without handling any |
236 // specific error. | 234 // specific error. |
237 @property(nonatomic, assign) BOOL cancelled; | 235 @property(nonatomic, assign) BOOL cancelled; |
238 @end | 236 @end |
239 | 237 |
240 @implementation CRWWebControllerPendingNavigationInfo | 238 @implementation CRWWebControllerPendingNavigationInfo |
241 @synthesize referrer = _referrer; | 239 @synthesize referrer = _referrer; |
242 @synthesize MIMEType = _MIMEType; | 240 @synthesize MIMEType = _MIMEType; |
243 @synthesize navigationType = _navigationType; | 241 @synthesize navigationType = _navigationType; |
244 @synthesize HTTPMethod = _HTTPMethod; | 242 @synthesize HTTPMethod = _HTTPMethod; |
245 @synthesize cancelled = _cancelled; | 243 @synthesize cancelled = _cancelled; |
246 | 244 |
247 - (instancetype)init { | 245 - (instancetype)init { |
248 if ((self = [super init])) { | 246 if ((self = [super init])) { |
249 _propertyReleaser_CRWWebControllerPendingNavigationInfo.Init( | |
250 self, [CRWWebControllerPendingNavigationInfo class]); | |
251 _navigationType = WKNavigationTypeOther; | 247 _navigationType = WKNavigationTypeOther; |
252 } | 248 } |
253 return self; | 249 return self; |
254 } | 250 } |
255 @end | 251 @end |
256 | 252 |
257 @interface CRWWebController ()<CRWContextMenuDelegate, | 253 @interface CRWWebController ()<CRWContextMenuDelegate, |
258 CRWNativeContentDelegate, | 254 CRWNativeContentDelegate, |
259 CRWSSLStatusUpdaterDataSource, | 255 CRWSSLStatusUpdaterDataSource, |
260 CRWSSLStatusUpdaterDelegate, | 256 CRWSSLStatusUpdaterDelegate, |
261 CRWWebControllerContainerViewDelegate, | 257 CRWWebControllerContainerViewDelegate, |
262 CRWWebViewScrollViewProxyObserver, | 258 CRWWebViewScrollViewProxyObserver, |
263 WKNavigationDelegate, | 259 WKNavigationDelegate, |
264 WKUIDelegate> { | 260 WKUIDelegate> { |
265 base::WeakNSProtocol<id<CRWWebDelegate>> _delegate; | 261 __weak id<CRWWebDelegate> _delegate; |
266 base::WeakNSProtocol<id<CRWNativeContentProvider>> _nativeProvider; | 262 __weak id<CRWNativeContentProvider> _nativeProvider; |
267 base::WeakNSProtocol<id<CRWSwipeRecognizerProvider>> _swipeRecognizerProvider; | 263 __weak id<CRWSwipeRecognizerProvider> _swipeRecognizerProvider; |
268 // The WKWebView managed by this instance. | 264 // The WKWebView managed by this instance. |
269 base::scoped_nsobject<WKWebView> _webView; | 265 WKWebView* _webView; |
270 // The CRWWebViewProxy is the wrapper to give components access to the | 266 // The CRWWebViewProxy is the wrapper to give components access to the |
271 // web view in a controlled and limited way. | 267 // web view in a controlled and limited way. |
272 base::scoped_nsobject<CRWWebViewProxyImpl> _webViewProxy; | 268 CRWWebViewProxyImpl* _webViewProxy; |
273 // The view used to display content. Must outlive |_webViewProxy|. The | 269 // The view used to display content. Must outlive |_webViewProxy|. The |
274 // container view should be accessed through this property rather than | 270 // container view should be accessed through this property rather than |
275 // |self.view| from within this class, as |self.view| triggers creation while | 271 // |self.view| from within this class, as |self.view| triggers creation while |
276 // |self.containerView| will return nil if the view hasn't been instantiated. | 272 // |self.containerView| will return nil if the view hasn't been instantiated. |
277 base::scoped_nsobject<CRWWebControllerContainerView> _containerView; | 273 CRWWebControllerContainerView* _containerView; |
278 // If |_contentView| contains a native view rather than a web view, this | 274 // If |_contentView| contains a native view rather than a web view, this |
279 // is its controller. If it's a web view, this is nil. | 275 // is its controller. If it's a web view, this is nil. |
280 base::scoped_nsprotocol<id<CRWNativeContent>> _nativeController; | 276 id<CRWNativeContent> _nativeController; |
281 BOOL _isHalted; // YES if halted. Halting happens prior to destruction. | 277 BOOL _isHalted; // YES if halted. Halting happens prior to destruction. |
282 BOOL _isBeingDestroyed; // YES if in the process of closing. | 278 BOOL _isBeingDestroyed; // YES if in the process of closing. |
283 // All CRWWebControllerObservers attached to the CRWWebController. A | 279 // All CRWWebControllerObservers attached to the CRWWebController. A |
284 // specially-constructed set is used that does not retain its elements. | 280 // specially-constructed set is used that does not retain its elements. |
285 base::scoped_nsobject<NSMutableSet> _observers; | 281 NSMutableSet* _observers; |
286 // Each observer in |_observers| is associated with a | 282 // Each observer in |_observers| is associated with a |
287 // WebControllerObserverBridge in order to listen from WebState callbacks. | 283 // WebControllerObserverBridge in order to listen from WebState callbacks. |
288 // TODO(droger): Remove |_observerBridges| when all CRWWebControllerObservers | 284 // TODO(droger): Remove |_observerBridges| when all CRWWebControllerObservers |
289 // are converted to WebStateObservers. | 285 // are converted to WebStateObservers. |
290 std::vector<std::unique_ptr<web::WebControllerObserverBridge>> | 286 std::vector<std::unique_ptr<web::WebControllerObserverBridge>> |
291 _observerBridges; | 287 _observerBridges; |
292 // YES if a user interaction has been registered at any time once the page has | 288 // YES if a user interaction has been registered at any time once the page has |
293 // loaded. | 289 // loaded. |
294 BOOL _userInteractionRegistered; | 290 BOOL _userInteractionRegistered; |
295 // YES if the user has interacted with the content area since the last URL | 291 // YES if the user has interacted with the content area since the last URL |
(...skipping 12 matching lines...) Expand all Loading... | |
308 // Page loading phase. | 304 // Page loading phase. |
309 web::LoadPhase _loadPhase; | 305 web::LoadPhase _loadPhase; |
310 // The web::PageDisplayState recorded when the page starts loading. | 306 // The web::PageDisplayState recorded when the page starts loading. |
311 web::PageDisplayState _displayStateOnStartLoading; | 307 web::PageDisplayState _displayStateOnStartLoading; |
312 // Whether or not the page has zoomed since the current navigation has been | 308 // Whether or not the page has zoomed since the current navigation has been |
313 // committed, either by user interaction or via |-restoreStateFromHistory|. | 309 // committed, either by user interaction or via |-restoreStateFromHistory|. |
314 BOOL _pageHasZoomed; | 310 BOOL _pageHasZoomed; |
315 // Whether a PageDisplayState is currently being applied. | 311 // Whether a PageDisplayState is currently being applied. |
316 BOOL _applyingPageState; | 312 BOOL _applyingPageState; |
317 // Actions to execute once the page load is complete. | 313 // Actions to execute once the page load is complete. |
318 base::scoped_nsobject<NSMutableArray> _pendingLoadCompleteActions; | 314 NSMutableArray* _pendingLoadCompleteActions; |
319 // UIGestureRecognizers to add to the web view. | 315 // UIGestureRecognizers to add to the web view. |
320 base::scoped_nsobject<NSMutableArray> _gestureRecognizers; | 316 NSMutableArray* _gestureRecognizers; |
321 // Toolbars to add to the web view. | 317 // Toolbars to add to the web view. |
322 base::scoped_nsobject<NSMutableArray> _webViewToolbars; | 318 NSMutableArray* _webViewToolbars; |
323 // Flag to say if browsing is enabled. | 319 // Flag to say if browsing is enabled. |
324 BOOL _webUsageEnabled; | 320 BOOL _webUsageEnabled; |
325 // Content view was reset due to low memory. Use the placeholder overlay on | 321 // Content view was reset due to low memory. Use the placeholder overlay on |
326 // next creation. | 322 // next creation. |
327 BOOL _usePlaceholderOverlay; | 323 BOOL _usePlaceholderOverlay; |
328 // The next time the view is requested, reload the page (using the placeholder | 324 // The next time the view is requested, reload the page (using the placeholder |
329 // overlay until it's loaded). | 325 // overlay until it's loaded). |
330 BOOL _requireReloadOnDisplay; | 326 BOOL _requireReloadOnDisplay; |
331 // Overlay view used instead of webView. | 327 // Overlay view used instead of webView. |
332 base::scoped_nsobject<UIImageView> _placeholderOverlayView; | 328 UIImageView* _placeholderOverlayView; |
333 // The touch tracking recognizer allowing us to decide if a navigation is | 329 // The touch tracking recognizer allowing us to decide if a navigation is |
334 // started by the user. | 330 // started by the user. |
335 base::scoped_nsobject<CRWTouchTrackingRecognizer> _touchTrackingRecognizer; | 331 CRWTouchTrackingRecognizer* _touchTrackingRecognizer; |
336 // The controller that tracks long press and check context menu trigger. | 332 // The controller that tracks long press and check context menu trigger. |
337 base::scoped_nsobject<CRWContextMenuController> _contextMenuController; | 333 CRWContextMenuController* _contextMenuController; |
338 // Whether a click is in progress. | 334 // Whether a click is in progress. |
339 BOOL _clickInProgress; | 335 BOOL _clickInProgress; |
340 // Data on the recorded last user interaction. | 336 // Data on the recorded last user interaction. |
341 std::unique_ptr<UserInteractionEvent> _lastUserInteraction; | 337 std::unique_ptr<UserInteractionEvent> _lastUserInteraction; |
342 // YES if there has been user interaction with views owned by this controller. | 338 // YES if there has been user interaction with views owned by this controller. |
343 BOOL _userInteractedWithWebController; | 339 BOOL _userInteractedWithWebController; |
344 // The time of the last page transfer start, measured in seconds since Jan 1 | 340 // The time of the last page transfer start, measured in seconds since Jan 1 |
345 // 2001. | 341 // 2001. |
346 CFAbsoluteTime _lastTransferTimeInSeconds; | 342 CFAbsoluteTime _lastTransferTimeInSeconds; |
347 // Default URL (about:blank). | 343 // Default URL (about:blank). |
(...skipping 10 matching lines...) Expand all Loading... | |
358 // Set to YES on window.history.willChangeState message. To NO on | 354 // Set to YES on window.history.willChangeState message. To NO on |
359 // window.history.didPushState or window.history.didReplaceState. | 355 // window.history.didPushState or window.history.didReplaceState. |
360 BOOL _changingHistoryState; | 356 BOOL _changingHistoryState; |
361 // Set to YES when a hashchange event is manually dispatched for same-document | 357 // Set to YES when a hashchange event is manually dispatched for same-document |
362 // history navigations. | 358 // history navigations. |
363 BOOL _dispatchingSameDocumentHashChangeEvent; | 359 BOOL _dispatchingSameDocumentHashChangeEvent; |
364 // YES if the web process backing _wkWebView is believed to currently be dead. | 360 // YES if the web process backing _wkWebView is believed to currently be dead. |
365 BOOL _webProcessIsDead; | 361 BOOL _webProcessIsDead; |
366 | 362 |
367 // Object for loading POST requests with body. | 363 // Object for loading POST requests with body. |
368 base::scoped_nsobject<CRWJSPOSTRequestLoader> _POSTRequestLoader; | 364 CRWJSPOSTRequestLoader* _POSTRequestLoader; |
369 | 365 |
370 // WebStateImpl instance associated with this CRWWebController, web controller | 366 // WebStateImpl instance associated with this CRWWebController, web controller |
371 // does not own this pointer. | 367 // does not own this pointer. |
372 WebStateImpl* _webStateImpl; | 368 WebStateImpl* _webStateImpl; |
373 | 369 |
374 // A set of URLs opened in external applications; stored so that errors | 370 // A set of URLs opened in external applications; stored so that errors |
375 // from the web view can be identified as resulting from these events. | 371 // from the web view can be identified as resulting from these events. |
376 base::scoped_nsobject<NSMutableSet> _openedApplicationURL; | 372 NSMutableSet* _openedApplicationURL; |
377 | 373 |
378 // A set of script managers whose scripts have been injected into the current | 374 // A set of script managers whose scripts have been injected into the current |
379 // page. | 375 // page. |
380 // TODO(stuartmorgan): Revisit this approach; it's intended only as a stopgap | 376 // TODO(stuartmorgan): Revisit this approach; it's intended only as a stopgap |
381 // measure to make all the existing script managers work. Longer term, there | 377 // measure to make all the existing script managers work. Longer term, there |
382 // should probably be a couple of points where managers can register to have | 378 // should probably be a couple of points where managers can register to have |
383 // things happen automatically based on page lifecycle, and if they don't want | 379 // things happen automatically based on page lifecycle, and if they don't want |
384 // to use one of those fixed points, they should make their scripts internally | 380 // to use one of those fixed points, they should make their scripts internally |
385 // idempotent. | 381 // idempotent. |
386 base::scoped_nsobject<NSMutableSet> _injectedScriptManagers; | 382 NSMutableSet* _injectedScriptManagers; |
387 | 383 |
388 // Script manager for setting the windowID. | 384 // Script manager for setting the windowID. |
389 base::scoped_nsobject<CRWJSWindowIDManager> _windowIDJSManager; | 385 CRWJSWindowIDManager* _windowIDJSManager; |
390 | 386 |
391 // The receiver of JavaScripts. | 387 // The receiver of JavaScripts. |
392 base::scoped_nsobject<CRWJSInjectionReceiver> _jsInjectionReceiver; | 388 CRWJSInjectionReceiver* _jsInjectionReceiver; |
393 | 389 |
394 // Handles downloading PassKit data for WKWebView. Lazy initialized. | 390 // Handles downloading PassKit data for WKWebView. Lazy initialized. |
395 base::scoped_nsobject<CRWPassKitDownloader> _passKitDownloader; | 391 CRWPassKitDownloader* _passKitDownloader; |
396 | 392 |
397 // Backs up property with the same name. | 393 // Backs up property with the same name. |
398 std::unique_ptr<web::MojoFacade> _mojoFacade; | 394 std::unique_ptr<web::MojoFacade> _mojoFacade; |
399 | 395 |
400 // Referrer for the current page; does not include the fragment. | 396 // Referrer for the current page; does not include the fragment. |
401 base::scoped_nsobject<NSString> _currentReferrerString; | 397 NSString* _currentReferrerString; |
402 | 398 |
403 // Pending information for an in-progress page navigation. The lifetime of | 399 // Pending information for an in-progress page navigation. The lifetime of |
404 // this object starts at |decidePolicyForNavigationAction| where the info is | 400 // this object starts at |decidePolicyForNavigationAction| where the info is |
405 // extracted from the request, and ends at either |didCommitNavigation| or | 401 // extracted from the request, and ends at either |didCommitNavigation| or |
406 // |didFailProvisionalNavigation|. | 402 // |didFailProvisionalNavigation|. |
407 base::scoped_nsobject<CRWWebControllerPendingNavigationInfo> | 403 CRWWebControllerPendingNavigationInfo* _pendingNavigationInfo; |
408 _pendingNavigationInfo; | |
409 | 404 |
410 // Holds all WKNavigation objects and their states which are currently in | 405 // Holds all WKNavigation objects and their states which are currently in |
411 // flight. | 406 // flight. |
412 base::scoped_nsobject<CRWWKNavigationStates> _navigationStates; | 407 CRWWKNavigationStates* _navigationStates; |
413 | 408 |
414 // The WKNavigation captured when |stopLoading| was called. Used for reporting | 409 // The WKNavigation captured when |stopLoading| was called. Used for reporting |
415 // WebController.EmptyNavigationManagerCausedByStopLoading UMA metric which | 410 // WebController.EmptyNavigationManagerCausedByStopLoading UMA metric which |
416 // helps with diagnosing a navigation related crash (crbug.com/565457). | 411 // helps with diagnosing a navigation related crash (crbug.com/565457). |
417 base::WeakNSObject<WKNavigation> _stoppedWKNavigation; | 412 __weak WKNavigation* _stoppedWKNavigation; |
418 | 413 |
419 // CRWWebUIManager object for loading WebUI pages. | 414 // CRWWebUIManager object for loading WebUI pages. |
420 base::scoped_nsobject<CRWWebUIManager> _webUIManager; | 415 CRWWebUIManager* _webUIManager; |
421 | 416 |
422 // Updates SSLStatus for current navigation item. | 417 // Updates SSLStatus for current navigation item. |
423 base::scoped_nsobject<CRWSSLStatusUpdater> _SSLStatusUpdater; | 418 CRWSSLStatusUpdater* _SSLStatusUpdater; |
424 | 419 |
425 // Controller used for certs verification to help with blocking requests with | 420 // Controller used for certs verification to help with blocking requests with |
426 // bad SSL cert, presenting SSL interstitials and determining SSL status for | 421 // bad SSL cert, presenting SSL interstitials and determining SSL status for |
427 // Navigation Items. | 422 // Navigation Items. |
428 base::scoped_nsobject<CRWCertVerificationController> | 423 CRWCertVerificationController* _certVerificationController; |
429 _certVerificationController; | |
430 | 424 |
431 // CertVerification errors which happened inside | 425 // CertVerification errors which happened inside |
432 // |webView:didReceiveAuthenticationChallenge:completionHandler:|. | 426 // |webView:didReceiveAuthenticationChallenge:completionHandler:|. |
433 // Key is leaf-cert/host pair. This storage is used to carry calculated | 427 // Key is leaf-cert/host pair. This storage is used to carry calculated |
434 // cert status from |didReceiveAuthenticationChallenge:| to | 428 // cert status from |didReceiveAuthenticationChallenge:| to |
435 // |didFailProvisionalNavigation:| delegate method. | 429 // |didFailProvisionalNavigation:| delegate method. |
436 std::unique_ptr<CertVerificationErrorsCacheType> _certVerificationErrors; | 430 std::unique_ptr<CertVerificationErrorsCacheType> _certVerificationErrors; |
437 } | 431 } |
438 | 432 |
439 // If |contentView_| contains a web view, this is the web view it contains. | 433 // If |contentView_| contains a web view, this is the web view it contains. |
440 // If not, it's nil. | 434 // If not, it's nil. |
441 @property(nonatomic, readonly) WKWebView* webView; | 435 @property(weak, nonatomic, readonly) WKWebView* webView; |
442 // The scroll view of |webView|. | 436 // The scroll view of |webView|. |
443 @property(nonatomic, readonly) UIScrollView* webScrollView; | 437 @property(weak, nonatomic, readonly) UIScrollView* webScrollView; |
444 // The current page state of the web view. Writing to this property | 438 // The current page state of the web view. Writing to this property |
445 // asynchronously applies the passed value to the current web view. | 439 // asynchronously applies the passed value to the current web view. |
446 @property(nonatomic, readwrite) web::PageDisplayState pageDisplayState; | 440 @property(nonatomic, readwrite) web::PageDisplayState pageDisplayState; |
447 // The currently displayed native controller, if any. | 441 // The currently displayed native controller, if any. |
448 @property(nonatomic, readwrite) id<CRWNativeContent> nativeController; | 442 @property(weak, nonatomic, readwrite) id<CRWNativeContent> nativeController; |
449 // Returns NavigationManager's session controller. | 443 // Returns NavigationManager's session controller. |
450 @property(nonatomic, readonly) CRWSessionController* sessionController; | 444 @property(weak, nonatomic, readonly) CRWSessionController* sessionController; |
451 // The associated NavigationManagerImpl. | 445 // The associated NavigationManagerImpl. |
452 @property(nonatomic, readonly) NavigationManagerImpl* navigationManagerImpl; | 446 @property(nonatomic, readonly) NavigationManagerImpl* navigationManagerImpl; |
453 // Whether the associated WebState has an opener. | 447 // Whether the associated WebState has an opener. |
454 @property(nonatomic, readonly) BOOL hasOpener; | 448 @property(nonatomic, readonly) BOOL hasOpener; |
455 // Dictionary where keys are the names of WKWebView properties and values are | 449 // Dictionary where keys are the names of WKWebView properties and values are |
456 // selector names which should be called when a corresponding property has | 450 // selector names which should be called when a corresponding property has |
457 // changed. e.g. @{ @"URL" : @"webViewURLDidChange" } means that | 451 // changed. e.g. @{ @"URL" : @"webViewURLDidChange" } means that |
458 // -[self webViewURLDidChange] must be called every time when WKWebView.URL is | 452 // -[self webViewURLDidChange] must be called every time when WKWebView.URL is |
459 // changed. | 453 // changed. |
460 @property(nonatomic, readonly) NSDictionary* WKWebViewObservers; | 454 @property(weak, nonatomic, readonly) NSDictionary* WKWebViewObservers; |
461 // Downloader for PassKit files. Lazy initialized. | 455 // Downloader for PassKit files. Lazy initialized. |
462 @property(nonatomic, readonly) CRWPassKitDownloader* passKitDownloader; | 456 @property(weak, nonatomic, readonly) CRWPassKitDownloader* passKitDownloader; |
463 | 457 |
464 // The web view's view of the current URL. During page transitions | 458 // The web view's view of the current URL. During page transitions |
465 // this may not be the same as the session history's view of the current URL. | 459 // this may not be the same as the session history's view of the current URL. |
466 // This method can change the state of the CRWWebController, as it will display | 460 // This method can change the state of the CRWWebController, as it will display |
467 // an error if the returned URL is not reliable from a security point of view. | 461 // an error if the returned URL is not reliable from a security point of view. |
468 // Note that this method is expensive, so it should always be cached locally if | 462 // Note that this method is expensive, so it should always be cached locally if |
469 // it's needed multiple times in a method. | 463 // it's needed multiple times in a method. |
470 @property(nonatomic, readonly) GURL currentURL; | 464 @property(nonatomic, readonly) GURL currentURL; |
471 // Returns the referrer for the current page. | 465 // Returns the referrer for the current page. |
472 @property(nonatomic, readonly) web::Referrer currentReferrer; | 466 @property(nonatomic, readonly) web::Referrer currentReferrer; |
(...skipping 12 matching lines...) Expand all Loading... | |
485 // TODO(crbug.com/692871): Remove these functions and replace with more | 479 // TODO(crbug.com/692871): Remove these functions and replace with more |
486 // appropriate NavigationItem getters. | 480 // appropriate NavigationItem getters. |
487 // Returns the navigation item for the current page. | 481 // Returns the navigation item for the current page. |
488 @property(nonatomic, readonly) web::NavigationItemImpl* currentNavItem; | 482 @property(nonatomic, readonly) web::NavigationItemImpl* currentNavItem; |
489 // Returns the current transition type. | 483 // Returns the current transition type. |
490 @property(nonatomic, readonly) ui::PageTransition currentTransition; | 484 @property(nonatomic, readonly) ui::PageTransition currentTransition; |
491 // Returns the referrer for current navigation item. May be empty. | 485 // Returns the referrer for current navigation item. May be empty. |
492 @property(nonatomic, readonly) web::Referrer currentNavItemReferrer; | 486 @property(nonatomic, readonly) web::Referrer currentNavItemReferrer; |
493 // The HTTP headers associated with the current navigation item. These are nil | 487 // The HTTP headers associated with the current navigation item. These are nil |
494 // unless the request was a POST. | 488 // unless the request was a POST. |
495 @property(nonatomic, readonly) NSDictionary* currentHTTPHeaders; | 489 @property(weak, nonatomic, readonly) NSDictionary* currentHTTPHeaders; |
496 | 490 |
497 // YES if a user interaction has been registered at any time since the page has | 491 // YES if a user interaction has been registered at any time since the page has |
498 // loaded. | 492 // loaded. |
499 @property(nonatomic, readwrite) BOOL userInteractionRegistered; | 493 @property(nonatomic, readwrite) BOOL userInteractionRegistered; |
500 | 494 |
501 // Updates web view's user agent according to |userAgentType|. It is no-op if | 495 // Updates web view's user agent according to |userAgentType|. It is no-op if |
502 // |userAgentType| is NONE. | 496 // |userAgentType| is NONE. |
503 - (void)updateWebViewUserAgentFromUserAgentType: | 497 - (void)updateWebViewUserAgentFromUserAgentType: |
504 (web::UserAgentType)userAgentType; | 498 (web::UserAgentType)userAgentType; |
505 | 499 |
(...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
950 - (instancetype)initWithWebState:(WebStateImpl*)webState { | 944 - (instancetype)initWithWebState:(WebStateImpl*)webState { |
951 self = [super init]; | 945 self = [super init]; |
952 if (self) { | 946 if (self) { |
953 _webStateImpl = webState; | 947 _webStateImpl = webState; |
954 DCHECK(_webStateImpl); | 948 DCHECK(_webStateImpl); |
955 // Load phase when no WebView present is 'loaded' because this represents | 949 // Load phase when no WebView present is 'loaded' because this represents |
956 // the idle state. | 950 // the idle state. |
957 _loadPhase = web::PAGE_LOADED; | 951 _loadPhase = web::PAGE_LOADED; |
958 // Content area is lazily instantiated. | 952 // Content area is lazily instantiated. |
959 _defaultURL = GURL(url::kAboutBlankURL); | 953 _defaultURL = GURL(url::kAboutBlankURL); |
960 _jsInjectionReceiver.reset( | 954 _jsInjectionReceiver = |
961 [[CRWJSInjectionReceiver alloc] initWithEvaluator:self]); | 955 [[CRWJSInjectionReceiver alloc] initWithEvaluator:self]; |
962 _webViewProxy.reset( | 956 _webViewProxy = [[CRWWebViewProxyImpl alloc] initWithWebController:self]; |
963 [[CRWWebViewProxyImpl alloc] initWithWebController:self]); | |
964 [[_webViewProxy scrollViewProxy] addObserver:self]; | 957 [[_webViewProxy scrollViewProxy] addObserver:self]; |
965 _gestureRecognizers.reset([[NSMutableArray alloc] init]); | 958 _gestureRecognizers = [[NSMutableArray alloc] init]; |
966 _webViewToolbars.reset([[NSMutableArray alloc] init]); | 959 _webViewToolbars = [[NSMutableArray alloc] init]; |
967 _pendingLoadCompleteActions.reset([[NSMutableArray alloc] init]); | 960 _pendingLoadCompleteActions = [[NSMutableArray alloc] init]; |
968 web::BrowserState* browserState = _webStateImpl->GetBrowserState(); | 961 web::BrowserState* browserState = _webStateImpl->GetBrowserState(); |
969 _certVerificationController.reset([[CRWCertVerificationController alloc] | 962 _certVerificationController = [[CRWCertVerificationController alloc] |
970 initWithBrowserState:browserState]); | 963 initWithBrowserState:browserState]; |
971 _certVerificationErrors.reset( | 964 _certVerificationErrors.reset( |
972 new CertVerificationErrorsCacheType(kMaxCertErrorsCount)); | 965 new CertVerificationErrorsCacheType(kMaxCertErrorsCount)); |
973 _navigationStates.reset([[CRWWKNavigationStates alloc] init]); | 966 _navigationStates = [[CRWWKNavigationStates alloc] init]; |
974 [[NSNotificationCenter defaultCenter] | 967 [[NSNotificationCenter defaultCenter] |
975 addObserver:self | 968 addObserver:self |
976 selector:@selector(orientationDidChange) | 969 selector:@selector(orientationDidChange) |
977 name:UIApplicationDidChangeStatusBarOrientationNotification | 970 name:UIApplicationDidChangeStatusBarOrientationNotification |
978 object:nil]; | 971 object:nil]; |
979 } | 972 } |
980 return self; | 973 return self; |
981 } | 974 } |
982 | 975 |
983 - (id<CRWNativeContentProvider>)nativeProvider { | 976 - (id<CRWNativeContentProvider>)nativeProvider { |
984 return _nativeProvider.get(); | 977 return _nativeProvider; |
985 } | 978 } |
986 | 979 |
987 - (void)setNativeProvider:(id<CRWNativeContentProvider>)nativeProvider { | 980 - (void)setNativeProvider:(id<CRWNativeContentProvider>)nativeProvider { |
988 _nativeProvider.reset(nativeProvider); | 981 _nativeProvider = nativeProvider; |
989 } | 982 } |
990 | 983 |
991 - (id<CRWSwipeRecognizerProvider>)swipeRecognizerProvider { | 984 - (id<CRWSwipeRecognizerProvider>)swipeRecognizerProvider { |
992 return _swipeRecognizerProvider.get(); | 985 return _swipeRecognizerProvider; |
993 } | 986 } |
994 | 987 |
995 - (void)setSwipeRecognizerProvider: | 988 - (void)setSwipeRecognizerProvider: |
996 (id<CRWSwipeRecognizerProvider>)swipeRecognizerProvider { | 989 (id<CRWSwipeRecognizerProvider>)swipeRecognizerProvider { |
997 _swipeRecognizerProvider.reset(swipeRecognizerProvider); | 990 _swipeRecognizerProvider = swipeRecognizerProvider; |
998 } | 991 } |
999 | 992 |
1000 - (WebState*)webState { | 993 - (WebState*)webState { |
1001 return _webStateImpl; | 994 return _webStateImpl; |
1002 } | 995 } |
1003 | 996 |
1004 - (WebStateImpl*)webStateImpl { | 997 - (WebStateImpl*)webStateImpl { |
1005 return _webStateImpl; | 998 return _webStateImpl; |
1006 } | 999 } |
1007 | 1000 |
(...skipping 13 matching lines...) Expand all Loading... | |
1021 - (void)showTransientContentView:(CRWContentView*)contentView { | 1014 - (void)showTransientContentView:(CRWContentView*)contentView { |
1022 DCHECK(contentView); | 1015 DCHECK(contentView); |
1023 DCHECK(contentView.scrollView); | 1016 DCHECK(contentView.scrollView); |
1024 // TODO(crbug.com/556848) Reenable DCHECK when |CRWWebControllerContainerView| | 1017 // TODO(crbug.com/556848) Reenable DCHECK when |CRWWebControllerContainerView| |
1025 // is restructured so that subviews are not added during |layoutSubviews|. | 1018 // is restructured so that subviews are not added during |layoutSubviews|. |
1026 // DCHECK([contentView.scrollView isDescendantOfView:contentView]); | 1019 // DCHECK([contentView.scrollView isDescendantOfView:contentView]); |
1027 [_containerView displayTransientContent:contentView]; | 1020 [_containerView displayTransientContent:contentView]; |
1028 } | 1021 } |
1029 | 1022 |
1030 - (id<CRWWebDelegate>)delegate { | 1023 - (id<CRWWebDelegate>)delegate { |
1031 return _delegate.get(); | 1024 return _delegate; |
1032 } | 1025 } |
1033 | 1026 |
1034 - (void)setDelegate:(id<CRWWebDelegate>)delegate { | 1027 - (void)setDelegate:(id<CRWWebDelegate>)delegate { |
1035 _delegate.reset(delegate); | 1028 _delegate = delegate; |
1036 if ([self.nativeController respondsToSelector:@selector(setDelegate:)]) | 1029 if ([self.nativeController respondsToSelector:@selector(setDelegate:)]) |
1037 [self.nativeController setDelegate:self]; | 1030 [self.nativeController setDelegate:self]; |
1038 } | 1031 } |
1039 | 1032 |
1040 - (void)dealloc { | 1033 - (void)dealloc { |
1041 DCHECK([NSThread isMainThread]); | 1034 DCHECK([NSThread isMainThread]); |
1042 DCHECK(_isBeingDestroyed); // 'close' must have been called already. | 1035 DCHECK(_isBeingDestroyed); // 'close' must have been called already. |
1043 DCHECK(!_webView); | 1036 DCHECK(!_webView); |
1044 [super dealloc]; | |
1045 } | 1037 } |
1046 | 1038 |
1047 - (void)dismissKeyboard { | 1039 - (void)dismissKeyboard { |
1048 [_webView endEditing:YES]; | 1040 [_webView endEditing:YES]; |
1049 if ([self.nativeController respondsToSelector:@selector(dismissKeyboard)]) | 1041 if ([self.nativeController respondsToSelector:@selector(dismissKeyboard)]) |
1050 [self.nativeController dismissKeyboard]; | 1042 [self.nativeController dismissKeyboard]; |
1051 } | 1043 } |
1052 | 1044 |
1053 - (id<CRWNativeContent>)nativeController { | 1045 - (id<CRWNativeContent>)nativeController { |
1054 return [_containerView nativeController]; | 1046 return [_containerView nativeController]; |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1106 // WKWebView autoreleases its WKProcessPool on removal from superview. | 1098 // WKWebView autoreleases its WKProcessPool on removal from superview. |
1107 // Deferring WKProcessPool deallocation may lead to issues with cookie | 1099 // Deferring WKProcessPool deallocation may lead to issues with cookie |
1108 // clearing and and Browsing Data Partitioning implementation. | 1100 // clearing and and Browsing Data Partitioning implementation. |
1109 @autoreleasepool { | 1101 @autoreleasepool { |
1110 [self setNativeControllerWebUsageEnabled:_webUsageEnabled]; | 1102 [self setNativeControllerWebUsageEnabled:_webUsageEnabled]; |
1111 if (enabled) { | 1103 if (enabled) { |
1112 // Don't create the web view; let it be lazy created as needed. | 1104 // Don't create the web view; let it be lazy created as needed. |
1113 } else { | 1105 } else { |
1114 [self clearTransientContentView]; | 1106 [self clearTransientContentView]; |
1115 [self removeWebViewAllowingCachedReconstruction:YES]; | 1107 [self removeWebViewAllowingCachedReconstruction:YES]; |
1116 _touchTrackingRecognizer.get().touchTrackingDelegate = nil; | 1108 _touchTrackingRecognizer.touchTrackingDelegate = nil; |
1117 _touchTrackingRecognizer.reset(); | 1109 _touchTrackingRecognizer = nil; |
1118 [self resetContainerView]; | 1110 [self resetContainerView]; |
1119 } | 1111 } |
1120 } | 1112 } |
1121 } | 1113 } |
1122 | 1114 |
1123 - (void)requirePageReconstruction { | 1115 - (void)requirePageReconstruction { |
1124 [self removeWebViewAllowingCachedReconstruction:NO]; | 1116 [self removeWebViewAllowingCachedReconstruction:NO]; |
1125 } | 1117 } |
1126 | 1118 |
1127 - (void)requirePageReload { | 1119 - (void)requirePageReload { |
1128 _requireReloadOnDisplay = YES; | 1120 _requireReloadOnDisplay = YES; |
1129 } | 1121 } |
1130 | 1122 |
1131 - (void)resetContainerView { | 1123 - (void)resetContainerView { |
1132 [_containerView removeFromSuperview]; | 1124 [_containerView removeFromSuperview]; |
1133 _containerView.reset(); | 1125 _containerView = nil; |
1134 } | 1126 } |
1135 | 1127 |
1136 - (void)handleLowMemory { | 1128 - (void)handleLowMemory { |
1137 [self removeWebViewAllowingCachedReconstruction:YES]; | 1129 [self removeWebViewAllowingCachedReconstruction:YES]; |
1138 _touchTrackingRecognizer.get().touchTrackingDelegate = nil; | 1130 _touchTrackingRecognizer.touchTrackingDelegate = nil; |
1139 _touchTrackingRecognizer.reset(); | 1131 _touchTrackingRecognizer = nil; |
1140 [self resetContainerView]; | 1132 [self resetContainerView]; |
1141 _usePlaceholderOverlay = YES; | 1133 _usePlaceholderOverlay = YES; |
1142 } | 1134 } |
1143 | 1135 |
1144 - (void)reinitializeWebViewAndReload:(BOOL)reload { | 1136 - (void)reinitializeWebViewAndReload:(BOOL)reload { |
1145 if (_webView) { | 1137 if (_webView) { |
1146 [self removeWebViewAllowingCachedReconstruction:NO]; | 1138 [self removeWebViewAllowingCachedReconstruction:NO]; |
1147 if (reload) { | 1139 if (reload) { |
1148 [self loadCurrentURLInWebView]; | 1140 [self loadCurrentURLInWebView]; |
1149 } else { | 1141 } else { |
1150 // Clear the space for the web view to lazy load when needed. | 1142 // Clear the space for the web view to lazy load when needed. |
1151 _usePlaceholderOverlay = YES; | 1143 _usePlaceholderOverlay = YES; |
1152 _touchTrackingRecognizer.get().touchTrackingDelegate = nil; | 1144 _touchTrackingRecognizer.touchTrackingDelegate = nil; |
1153 _touchTrackingRecognizer.reset(); | 1145 _touchTrackingRecognizer = nil; |
1154 [self resetContainerView]; | 1146 [self resetContainerView]; |
1155 } | 1147 } |
1156 } | 1148 } |
1157 } | 1149 } |
1158 | 1150 |
1159 - (BOOL)isViewAlive { | 1151 - (BOOL)isViewAlive { |
1160 return !_webProcessIsDead && [_containerView isViewAlive]; | 1152 return !_webProcessIsDead && [_containerView isViewAlive]; |
1161 } | 1153 } |
1162 | 1154 |
1163 - (BOOL)contentIsHTML { | 1155 - (BOOL)contentIsHTML { |
(...skipping 18 matching lines...) Expand all Loading... | |
1182 | 1174 |
1183 - (void)dismissModals { | 1175 - (void)dismissModals { |
1184 if ([self.nativeController respondsToSelector:@selector(dismissModals)]) | 1176 if ([self.nativeController respondsToSelector:@selector(dismissModals)]) |
1185 [self.nativeController dismissModals]; | 1177 [self.nativeController dismissModals]; |
1186 } | 1178 } |
1187 | 1179 |
1188 // Caller must reset the delegate before calling. | 1180 // Caller must reset the delegate before calling. |
1189 - (void)close { | 1181 - (void)close { |
1190 _webStateImpl->CancelDialogs(); | 1182 _webStateImpl->CancelDialogs(); |
1191 | 1183 |
1192 _SSLStatusUpdater.reset(); | 1184 _SSLStatusUpdater = nil; |
1193 | 1185 |
1194 self.nativeProvider = nil; | 1186 self.nativeProvider = nil; |
1195 self.swipeRecognizerProvider = nil; | 1187 self.swipeRecognizerProvider = nil; |
1196 if ([self.nativeController respondsToSelector:@selector(close)]) | 1188 if ([self.nativeController respondsToSelector:@selector(close)]) |
1197 [self.nativeController close]; | 1189 [self.nativeController close]; |
1198 | 1190 |
1199 base::scoped_nsobject<NSSet> observers([_observers copy]); | 1191 NSSet* observers = [_observers copy]; |
1200 for (id it in observers.get()) { | 1192 for (id it in observers) { |
1201 if ([it respondsToSelector:@selector(webControllerWillClose:)]) | 1193 if ([it respondsToSelector:@selector(webControllerWillClose:)]) |
1202 [it webControllerWillClose:self]; | 1194 [it webControllerWillClose:self]; |
1203 } | 1195 } |
1204 | 1196 |
1205 if (!_isHalted) { | 1197 if (!_isHalted) { |
1206 [self terminateNetworkActivity]; | 1198 [self terminateNetworkActivity]; |
1207 } | 1199 } |
1208 | 1200 |
1209 DCHECK(!_isBeingDestroyed); | 1201 DCHECK(!_isBeingDestroyed); |
1210 DCHECK(!_delegate); // Delegate should reset its association before closing. | 1202 DCHECK(!_delegate); // Delegate should reset its association before closing. |
1211 // Mark the destruction sequence has started, in case someone else holds a | 1203 // Mark the destruction sequence has started, in case someone else holds a |
1212 // strong reference and tries to continue using the tab. | 1204 // strong reference and tries to continue using the tab. |
1213 _isBeingDestroyed = YES; | 1205 _isBeingDestroyed = YES; |
1214 | 1206 |
1215 // Remove the web view now. Otherwise, delegate callbacks occur. | 1207 // Remove the web view now. Otherwise, delegate callbacks occur. |
1216 [self removeWebViewAllowingCachedReconstruction:NO]; | 1208 [self removeWebViewAllowingCachedReconstruction:NO]; |
1217 | 1209 |
1218 _webStateImpl = nullptr; | 1210 _webStateImpl = nullptr; |
1219 | 1211 |
1220 DCHECK(!_webView); | 1212 DCHECK(!_webView); |
1221 // TODO(crbug.com/662860): Don't set the delegate to nil. | 1213 // TODO(crbug.com/662860): Don't set the delegate to nil. |
1222 [_containerView setDelegate:nil]; | 1214 [_containerView setDelegate:nil]; |
1223 if ([self.nativeController respondsToSelector:@selector(setDelegate:)]) { | 1215 if ([self.nativeController respondsToSelector:@selector(setDelegate:)]) { |
1224 [self.nativeController setDelegate:nil]; | 1216 [self.nativeController setDelegate:nil]; |
1225 } | 1217 } |
1226 _touchTrackingRecognizer.get().touchTrackingDelegate = nil; | 1218 _touchTrackingRecognizer.touchTrackingDelegate = nil; |
1227 [[_webViewProxy scrollViewProxy] removeObserver:self]; | 1219 [[_webViewProxy scrollViewProxy] removeObserver:self]; |
1228 [[NSNotificationCenter defaultCenter] removeObserver:self]; | 1220 [[NSNotificationCenter defaultCenter] removeObserver:self]; |
1229 } | 1221 } |
1230 | 1222 |
1231 // TODO(crbug.com/661642): This code is shared with SnapshotManager. Remove this | 1223 // TODO(crbug.com/661642): This code is shared with SnapshotManager. Remove this |
1232 // and add it as part of WebDelegate delegate API such that a default image is | 1224 // and add it as part of WebDelegate delegate API such that a default image is |
1233 // returned immediately. | 1225 // returned immediately. |
1234 + (UIImage*)defaultSnapshotImage { | 1226 + (UIImage*)defaultSnapshotImage { |
1235 static UIImage* defaultImage = nil; | 1227 static UIImage* defaultImage = nil; |
1236 | 1228 |
1237 if (!defaultImage) { | 1229 if (!defaultImage) { |
1238 CGRect frame = CGRectMake(0, 0, 2, 2); | 1230 CGRect frame = CGRectMake(0, 0, 2, 2); |
1239 UIGraphicsBeginImageContext(frame.size); | 1231 UIGraphicsBeginImageContext(frame.size); |
1240 [[UIColor whiteColor] setFill]; | 1232 [[UIColor whiteColor] setFill]; |
1241 CGContextFillRect(UIGraphicsGetCurrentContext(), frame); | 1233 CGContextFillRect(UIGraphicsGetCurrentContext(), frame); |
1242 | 1234 |
1243 UIImage* result = UIGraphicsGetImageFromCurrentImageContext(); | 1235 UIImage* result = UIGraphicsGetImageFromCurrentImageContext(); |
1244 UIGraphicsEndImageContext(); | 1236 UIGraphicsEndImageContext(); |
1245 | 1237 |
1246 defaultImage = | 1238 defaultImage = [result stretchableImageWithLeftCapWidth:1 topCapHeight:1]; |
1247 [[result stretchableImageWithLeftCapWidth:1 topCapHeight:1] retain]; | |
1248 } | 1239 } |
1249 return defaultImage; | 1240 return defaultImage; |
1250 } | 1241 } |
1251 | 1242 |
1252 - (CGPoint)scrollPosition { | 1243 - (CGPoint)scrollPosition { |
1253 CGPoint position = CGPointMake(0.0, 0.0); | 1244 CGPoint position = CGPointMake(0.0, 0.0); |
1254 if (!self.webScrollView) | 1245 if (!self.webScrollView) |
1255 return position; | 1246 return position; |
1256 return self.webScrollView.contentOffset; | 1247 return self.webScrollView.contentOffset; |
1257 } | 1248 } |
(...skipping 24 matching lines...) Expand all Loading... | |
1282 return [self.nativeController virtualURL]; | 1273 return [self.nativeController virtualURL]; |
1283 } else { | 1274 } else { |
1284 return [self.nativeController url]; | 1275 return [self.nativeController url]; |
1285 } | 1276 } |
1286 } | 1277 } |
1287 web::NavigationItem* item = self.currentNavItem; | 1278 web::NavigationItem* item = self.currentNavItem; |
1288 return item ? item->GetVirtualURL() : GURL::EmptyGURL(); | 1279 return item ? item->GetVirtualURL() : GURL::EmptyGURL(); |
1289 } | 1280 } |
1290 | 1281 |
1291 - (WKWebView*)webView { | 1282 - (WKWebView*)webView { |
1292 return _webView.get(); | 1283 return _webView; |
1293 } | 1284 } |
1294 | 1285 |
1295 - (UIScrollView*)webScrollView { | 1286 - (UIScrollView*)webScrollView { |
1296 return [_webView scrollView]; | 1287 return [_webView scrollView]; |
1297 } | 1288 } |
1298 | 1289 |
1299 - (GURL)currentURL { | 1290 - (GURL)currentURL { |
1300 web::URLVerificationTrustLevel trustLevel = | 1291 web::URLVerificationTrustLevel trustLevel = |
1301 web::URLVerificationTrustLevel::kNone; | 1292 web::URLVerificationTrustLevel::kNone; |
1302 return [self currentURLWithTrustLevel:&trustLevel]; | 1293 return [self currentURLWithTrustLevel:&trustLevel]; |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1433 | 1424 |
1434 - (UIView*)view { | 1425 - (UIView*)view { |
1435 // Kick off the process of lazily creating the view and starting the load if | 1426 // Kick off the process of lazily creating the view and starting the load if |
1436 // necessary; this creates _containerView if it doesn't exist. | 1427 // necessary; this creates _containerView if it doesn't exist. |
1437 [self triggerPendingLoad]; | 1428 [self triggerPendingLoad]; |
1438 DCHECK(_containerView); | 1429 DCHECK(_containerView); |
1439 return _containerView; | 1430 return _containerView; |
1440 } | 1431 } |
1441 | 1432 |
1442 - (id<CRWWebViewProxy>)webViewProxy { | 1433 - (id<CRWWebViewProxy>)webViewProxy { |
1443 return _webViewProxy.get(); | 1434 return _webViewProxy; |
1444 } | 1435 } |
1445 | 1436 |
1446 - (UIView*)viewForPrinting { | 1437 - (UIView*)viewForPrinting { |
1447 // Printing is not supported for native controllers. | 1438 // Printing is not supported for native controllers. |
1448 return _webView; | 1439 return _webView; |
1449 } | 1440 } |
1450 | 1441 |
1451 - (double)loadingProgress { | 1442 - (double)loadingProgress { |
1452 return [_webView estimatedProgress]; | 1443 return [_webView estimatedProgress]; |
1453 } | 1444 } |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1623 if (sameDocumentNavigation) { | 1614 if (sameDocumentNavigation) { |
1624 [script | 1615 [script |
1625 appendString:[self javaScriptToDispatchPopStateWithObject:stateObject]]; | 1616 appendString:[self javaScriptToDispatchPopStateWithObject:stateObject]]; |
1626 } | 1617 } |
1627 if (dispatchHashChange) { | 1618 if (dispatchHashChange) { |
1628 web::NavigationItemImpl* previousItem = self.sessionController.previousItem; | 1619 web::NavigationItemImpl* previousItem = self.sessionController.previousItem; |
1629 const GURL oldURL = previousItem ? previousItem->GetURL() : GURL(); | 1620 const GURL oldURL = previousItem ? previousItem->GetURL() : GURL(); |
1630 [script appendString:[self javaScriptToDispatchHashChangeWithOldURL:oldURL | 1621 [script appendString:[self javaScriptToDispatchHashChangeWithOldURL:oldURL |
1631 newURL:URL]]; | 1622 newURL:URL]]; |
1632 } | 1623 } |
1633 base::WeakNSObject<CRWWebController> weakSelf(self); | 1624 __weak CRWWebController* weakSelf = self; |
1634 [self executeJavaScript:script | 1625 [self executeJavaScript:script |
1635 completionHandler:^(id, NSError*) { | 1626 completionHandler:^(id, NSError*) { |
1636 if (!weakSelf || weakSelf.get()->_isBeingDestroyed) | 1627 CRWWebController* strongSelf = weakSelf; |
1628 if (!strongSelf || strongSelf->_isBeingDestroyed) | |
1637 return; | 1629 return; |
1638 base::scoped_nsobject<CRWWebController> strongSelf([weakSelf retain]); | 1630 strongSelf->_URLOnStartLoading = URL; |
1639 strongSelf.get()->_URLOnStartLoading = URL; | 1631 strongSelf->_lastRegisteredRequestURL = URL; |
1640 strongSelf.get()->_lastRegisteredRequestURL = URL; | |
1641 }]; | 1632 }]; |
1642 } | 1633 } |
1643 | 1634 |
1644 // Load the current URL in a web view, first ensuring the web view is visible. | 1635 // Load the current URL in a web view, first ensuring the web view is visible. |
1645 - (void)loadCurrentURLInWebView { | 1636 - (void)loadCurrentURLInWebView { |
1646 // Clear the set of URLs opened in external applications. | 1637 // Clear the set of URLs opened in external applications. |
1647 _openedApplicationURL.reset([[NSMutableSet alloc] init]); | 1638 _openedApplicationURL = [[NSMutableSet alloc] init]; |
1648 | 1639 |
1649 web::NavigationItem* item = self.currentNavItem; | 1640 web::NavigationItem* item = self.currentNavItem; |
1650 GURL targetURL = item ? item->GetVirtualURL() : GURL::EmptyGURL(); | 1641 GURL targetURL = item ? item->GetVirtualURL() : GURL::EmptyGURL(); |
1651 // Load the url. The UIWebView delegate callbacks take care of updating the | 1642 // Load the url. The UIWebView delegate callbacks take care of updating the |
1652 // session history and UI. | 1643 // session history and UI. |
1653 if (!targetURL.is_valid()) { | 1644 if (!targetURL.is_valid()) { |
1654 [self didFinishWithURL:targetURL loadSuccess:NO]; | 1645 [self didFinishWithURL:targetURL loadSuccess:NO]; |
1655 return; | 1646 return; |
1656 } | 1647 } |
1657 | 1648 |
1658 // JavaScript should never be evaluated here. User-entered JS should be | 1649 // JavaScript should never be evaluated here. User-entered JS should be |
1659 // evaluated via stringByEvaluatingUserJavaScriptFromString. | 1650 // evaluated via stringByEvaluatingUserJavaScriptFromString. |
1660 DCHECK(!targetURL.SchemeIs(url::kJavaScriptScheme)); | 1651 DCHECK(!targetURL.SchemeIs(url::kJavaScriptScheme)); |
1661 | 1652 |
1662 [self ensureWebViewCreated]; | 1653 [self ensureWebViewCreated]; |
1663 | 1654 |
1664 // Update web view's user agent is called for every load, which may have | 1655 // Update web view's user agent is called for every load, which may have |
1665 // performance implications because update web view's user agent may | 1656 // performance implications because update web view's user agent may |
1666 // potentially send a message to a separate thread. However, this is not an | 1657 // potentially send a message to a separate thread. However, this is not an |
1667 // issue for WKWebView because WKWebView's |setCustomUserAgent| is non-op if | 1658 // issue for WKWebView because WKWebView's |setCustomUserAgent| is non-op if |
1668 // user agent stays thesame. | 1659 // user agent stays thesame. |
1669 [self updateWebViewUserAgentFromUserAgentType:self.userAgentType]; | 1660 [self updateWebViewUserAgentFromUserAgentType:self.userAgentType]; |
1670 | 1661 |
1671 [self loadRequestForCurrentNavigationItem]; | 1662 [self loadRequestForCurrentNavigationItem]; |
1672 } | 1663 } |
1673 | 1664 |
1674 - (void)updatePendingNavigationInfoFromNavigationAction: | 1665 - (void)updatePendingNavigationInfoFromNavigationAction: |
1675 (WKNavigationAction*)action { | 1666 (WKNavigationAction*)action { |
1676 if (action.targetFrame.mainFrame) { | 1667 if (action.targetFrame.mainFrame) { |
1677 _pendingNavigationInfo.reset( | 1668 _pendingNavigationInfo = |
1678 [[CRWWebControllerPendingNavigationInfo alloc] init]); | 1669 [[CRWWebControllerPendingNavigationInfo alloc] init]; |
1679 [_pendingNavigationInfo | 1670 [_pendingNavigationInfo |
1680 setReferrer:[self referrerFromNavigationAction:action]]; | 1671 setReferrer:[self referrerFromNavigationAction:action]]; |
1681 [_pendingNavigationInfo setNavigationType:action.navigationType]; | 1672 [_pendingNavigationInfo setNavigationType:action.navigationType]; |
1682 [_pendingNavigationInfo setHTTPMethod:action.request.HTTPMethod]; | 1673 [_pendingNavigationInfo setHTTPMethod:action.request.HTTPMethod]; |
1683 } | 1674 } |
1684 } | 1675 } |
1685 | 1676 |
1686 - (void)updatePendingNavigationInfoFromNavigationResponse: | 1677 - (void)updatePendingNavigationInfoFromNavigationResponse: |
1687 (WKNavigationResponse*)response { | 1678 (WKNavigationResponse*)response { |
1688 if (response.isForMainFrame) { | 1679 if (response.isForMainFrame) { |
1689 if (!_pendingNavigationInfo) { | 1680 if (!_pendingNavigationInfo) { |
1690 _pendingNavigationInfo.reset( | 1681 _pendingNavigationInfo = |
1691 [[CRWWebControllerPendingNavigationInfo alloc] init]); | 1682 [[CRWWebControllerPendingNavigationInfo alloc] init]; |
1692 } | 1683 } |
1693 [_pendingNavigationInfo setMIMEType:response.response.MIMEType]; | 1684 [_pendingNavigationInfo setMIMEType:response.response.MIMEType]; |
1694 } | 1685 } |
1695 } | 1686 } |
1696 | 1687 |
1697 - (void)commitPendingNavigationInfo { | 1688 - (void)commitPendingNavigationInfo { |
1698 if ([_pendingNavigationInfo referrer]) { | 1689 if ([_pendingNavigationInfo referrer]) { |
1699 _currentReferrerString.reset([[_pendingNavigationInfo referrer] copy]); | 1690 _currentReferrerString = [[_pendingNavigationInfo referrer] copy]; |
1700 } | 1691 } |
1701 if ([_pendingNavigationInfo MIMEType]) { | 1692 if ([_pendingNavigationInfo MIMEType]) { |
1702 self.webStateImpl->SetContentsMimeType( | 1693 self.webStateImpl->SetContentsMimeType( |
1703 base::SysNSStringToUTF8([_pendingNavigationInfo MIMEType])); | 1694 base::SysNSStringToUTF8([_pendingNavigationInfo MIMEType])); |
1704 } | 1695 } |
1705 [self updateCurrentBackForwardListItemHolder]; | 1696 [self updateCurrentBackForwardListItemHolder]; |
1706 | 1697 |
1707 _pendingNavigationInfo.reset(); | 1698 _pendingNavigationInfo = nil; |
1708 } | 1699 } |
1709 | 1700 |
1710 - (NSMutableURLRequest*)requestForCurrentNavigationItem { | 1701 - (NSMutableURLRequest*)requestForCurrentNavigationItem { |
1711 web::NavigationItem* item = self.currentNavItem; | 1702 web::NavigationItem* item = self.currentNavItem; |
1712 const GURL currentNavigationURL = | 1703 const GURL currentNavigationURL = |
1713 item ? item->GetVirtualURL() : GURL::EmptyGURL(); | 1704 item ? item->GetVirtualURL() : GURL::EmptyGURL(); |
1714 NSMutableURLRequest* request = [NSMutableURLRequest | 1705 NSMutableURLRequest* request = [NSMutableURLRequest |
1715 requestWithURL:net::NSURLWithGURL(currentNavigationURL)]; | 1706 requestWithURL:net::NSURLWithGURL(currentNavigationURL)]; |
1716 const web::Referrer referrer(self.currentNavItemReferrer); | 1707 const web::Referrer referrer(self.currentNavItemReferrer); |
1717 if (referrer.url.is_valid()) { | 1708 if (referrer.url.is_valid()) { |
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1953 !_webStateImpl->HasWebUI(); | 1944 !_webStateImpl->HasWebUI(); |
1954 } | 1945 } |
1955 | 1946 |
1956 - (void)triggerPendingLoad { | 1947 - (void)triggerPendingLoad { |
1957 if (!_containerView) { | 1948 if (!_containerView) { |
1958 DCHECK(!_isBeingDestroyed); | 1949 DCHECK(!_isBeingDestroyed); |
1959 // Create the top-level parent view, which will contain the content (whether | 1950 // Create the top-level parent view, which will contain the content (whether |
1960 // native or web). Note, this needs to be created with a non-zero size | 1951 // native or web). Note, this needs to be created with a non-zero size |
1961 // to allow for (native) subviews with autosize constraints to be correctly | 1952 // to allow for (native) subviews with autosize constraints to be correctly |
1962 // processed. | 1953 // processed. |
1963 _containerView.reset( | 1954 _containerView = |
1964 [[CRWWebControllerContainerView alloc] initWithDelegate:self]); | 1955 [[CRWWebControllerContainerView alloc] initWithDelegate:self]; |
1965 | 1956 |
1966 // This will be resized later, but matching the final frame will minimize | 1957 // This will be resized later, but matching the final frame will minimize |
1967 // re-rendering. Use the screen size because the application's key window | 1958 // re-rendering. Use the screen size because the application's key window |
1968 // may still be nil. | 1959 // may still be nil. |
1969 // TODO(crbug.com/688259): Stop subtracting status bar height. | 1960 // TODO(crbug.com/688259): Stop subtracting status bar height. |
1970 CGFloat statusBarHeight = | 1961 CGFloat statusBarHeight = |
1971 [[UIApplication sharedApplication] statusBarFrame].size.height; | 1962 [[UIApplication sharedApplication] statusBarFrame].size.height; |
1972 CGRect containerViewFrame = [UIScreen mainScreen].bounds; | 1963 CGRect containerViewFrame = [UIScreen mainScreen].bounds; |
1973 containerViewFrame.origin.y += statusBarHeight; | 1964 containerViewFrame.origin.y += statusBarHeight; |
1974 containerViewFrame.size.height -= statusBarHeight; | 1965 containerViewFrame.size.height -= statusBarHeight; |
1975 _containerView.get().frame = containerViewFrame; | 1966 _containerView.frame = containerViewFrame; |
1976 DCHECK(!CGRectIsEmpty(_containerView.get().frame)); | 1967 DCHECK(!CGRectIsEmpty(_containerView.frame)); |
1977 | 1968 |
1978 // TODO(crbug.com/691116): Remove this workaround once tests are no longer | 1969 // TODO(crbug.com/691116): Remove this workaround once tests are no longer |
1979 // dependent upon this accessibility ID. | 1970 // dependent upon this accessibility ID. |
1980 if (!base::ios::IsRunningOnIOS10OrLater()) | 1971 if (!base::ios::IsRunningOnIOS10OrLater()) |
1981 [_containerView setAccessibilityIdentifier:@"Container View"]; | 1972 [_containerView setAccessibilityIdentifier:@"Container View"]; |
1982 | 1973 |
1983 [_containerView addGestureRecognizer:[self touchTrackingRecognizer]]; | 1974 [_containerView addGestureRecognizer:[self touchTrackingRecognizer]]; |
1984 // Is |currentUrl| a web scheme or native chrome scheme. | 1975 // Is |currentUrl| a web scheme or native chrome scheme. |
1985 web::NavigationItem* item = self.currentNavItem; | 1976 web::NavigationItem* item = self.currentNavItem; |
1986 const GURL currentNavigationURL = | 1977 const GURL currentNavigationURL = |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2019 return (transition & ui::PAGE_TRANSITION_FROM_ADDRESS_BAR) && item && | 2010 return (transition & ui::PAGE_TRANSITION_FROM_ADDRESS_BAR) && item && |
2020 (destinationURL == item->GetURL() || | 2011 (destinationURL == item->GetURL() || |
2021 destinationURL == item->GetOriginalRequestURL()); | 2012 destinationURL == item->GetOriginalRequestURL()); |
2022 } | 2013 } |
2023 | 2014 |
2024 - (void)reload { | 2015 - (void)reload { |
2025 // Clear last user interaction. | 2016 // Clear last user interaction. |
2026 // TODO(crbug.com/546337): Move to after the load commits, in the subclass | 2017 // TODO(crbug.com/546337): Move to after the load commits, in the subclass |
2027 // implementation. This will be inaccurate if the reload fails or is | 2018 // implementation. This will be inaccurate if the reload fails or is |
2028 // cancelled. | 2019 // cancelled. |
2029 _lastUserInteraction.reset(); | 2020 _lastUserInteraction = nil; |
2030 base::RecordAction(UserMetricsAction("Reload")); | 2021 base::RecordAction(UserMetricsAction("Reload")); |
2031 GURL url = self.currentNavItem->GetURL(); | 2022 GURL url = self.currentNavItem->GetURL(); |
2032 if ([self shouldLoadURLInNativeView:url]) { | 2023 if ([self shouldLoadURLInNativeView:url]) { |
2033 std::unique_ptr<web::NavigationContextImpl> navigationContext = [self | 2024 std::unique_ptr<web::NavigationContextImpl> navigationContext = [self |
2034 registerLoadRequestForURL:url | 2025 registerLoadRequestForURL:url |
2035 referrer:self.currentNavItemReferrer | 2026 referrer:self.currentNavItemReferrer |
2036 transition:ui::PageTransition::PAGE_TRANSITION_RELOAD]; | 2027 transition:ui::PageTransition::PAGE_TRANSITION_RELOAD]; |
2037 [self didStartLoadingURL:url]; | 2028 [self didStartLoadingURL:url]; |
2038 [self.nativeController reload]; | 2029 [self.nativeController reload]; |
2039 _webStateImpl->OnNavigationFinished(navigationContext.get()); | 2030 _webStateImpl->OnNavigationFinished(navigationContext.get()); |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2143 (!_lastRegisteredRequestURL.is_valid() && | 2134 (!_lastRegisteredRequestURL.is_valid() && |
2144 _documentURL.spec() == url::kAboutBlankURL)) | 2135 _documentURL.spec() == url::kAboutBlankURL)) |
2145 << std::endl | 2136 << std::endl |
2146 << "currentURL = [" << currentURL << "]" << std::endl | 2137 << "currentURL = [" << currentURL << "]" << std::endl |
2147 << "_lastRegisteredRequestURL = [" << _lastRegisteredRequestURL << "]"; | 2138 << "_lastRegisteredRequestURL = [" << _lastRegisteredRequestURL << "]"; |
2148 | 2139 |
2149 // Perform post-load-finished updates. | 2140 // Perform post-load-finished updates. |
2150 [self didFinishWithURL:currentURL loadSuccess:loadSuccess]; | 2141 [self didFinishWithURL:currentURL loadSuccess:loadSuccess]; |
2151 | 2142 |
2152 // Execute the pending LoadCompleteActions. | 2143 // Execute the pending LoadCompleteActions. |
2153 for (ProceduralBlock action in _pendingLoadCompleteActions.get()) { | 2144 for (ProceduralBlock action in _pendingLoadCompleteActions) { |
2154 action(); | 2145 action(); |
2155 } | 2146 } |
2156 [_pendingLoadCompleteActions removeAllObjects]; | 2147 [_pendingLoadCompleteActions removeAllObjects]; |
2157 } | 2148 } |
2158 | 2149 |
2159 - (void)didFinishWithURL:(const GURL&)currentURL loadSuccess:(BOOL)loadSuccess { | 2150 - (void)didFinishWithURL:(const GURL&)currentURL loadSuccess:(BOOL)loadSuccess { |
2160 DCHECK(_loadPhase == web::PAGE_LOADED); | 2151 DCHECK(_loadPhase == web::PAGE_LOADED); |
2161 // Rather than creating a new WKBackForwardListItem when loading WebUI pages, | 2152 // Rather than creating a new WKBackForwardListItem when loading WebUI pages, |
2162 // WKWebView will cache the WebUI HTML in the previous WKBackForwardListItem | 2153 // WKWebView will cache the WebUI HTML in the previous WKBackForwardListItem |
2163 // since it's loaded via |-loadHTML:forURL:| instead of an NSURLRequest. As a | 2154 // since it's loaded via |-loadHTML:forURL:| instead of an NSURLRequest. As a |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2256 if (!_mojoFacade) { | 2247 if (!_mojoFacade) { |
2257 service_manager::mojom::InterfaceProvider* interfaceProvider = | 2248 service_manager::mojom::InterfaceProvider* interfaceProvider = |
2258 _webStateImpl->GetWebStateInterfaceProvider(); | 2249 _webStateImpl->GetWebStateInterfaceProvider(); |
2259 _mojoFacade.reset(new web::MojoFacade(interfaceProvider, self)); | 2250 _mojoFacade.reset(new web::MojoFacade(interfaceProvider, self)); |
2260 } | 2251 } |
2261 return _mojoFacade.get(); | 2252 return _mojoFacade.get(); |
2262 } | 2253 } |
2263 | 2254 |
2264 - (CRWPassKitDownloader*)passKitDownloader { | 2255 - (CRWPassKitDownloader*)passKitDownloader { |
2265 if (_passKitDownloader) { | 2256 if (_passKitDownloader) { |
2266 return _passKitDownloader.get(); | 2257 return _passKitDownloader; |
2267 } | 2258 } |
2268 base::WeakNSObject<CRWWebController> weakSelf(self); | 2259 __weak CRWWebController* weakSelf = self; |
2269 web::PassKitCompletionHandler passKitCompletion = ^(NSData* data) { | 2260 web::PassKitCompletionHandler passKitCompletion = ^(NSData* data) { |
2270 base::scoped_nsobject<CRWWebController> strongSelf([weakSelf retain]); | 2261 CRWWebController* strongSelf = weakSelf; |
2271 if (!strongSelf) { | 2262 if (!strongSelf) { |
2272 return; | 2263 return; |
2273 } | 2264 } |
2274 // Cancel load to update web state, since the PassKit download happens | 2265 // Cancel load to update web state, since the PassKit download happens |
2275 // through a separate flow. This follows the same flow as when PassKit is | 2266 // through a separate flow. This follows the same flow as when PassKit is |
2276 // downloaded through UIWebView. | 2267 // downloaded through UIWebView. |
2277 [strongSelf loadCancelled]; | 2268 [strongSelf loadCancelled]; |
2278 SEL didLoadPassKitObject = @selector(webController:didLoadPassKitObject:); | 2269 SEL didLoadPassKitObject = @selector(webController:didLoadPassKitObject:); |
2279 id<CRWWebDelegate> delegate = [strongSelf delegate]; | 2270 id<CRWWebDelegate> delegate = [strongSelf delegate]; |
2280 if ([delegate respondsToSelector:didLoadPassKitObject]) { | 2271 if ([delegate respondsToSelector:didLoadPassKitObject]) { |
2281 [delegate webController:strongSelf didLoadPassKitObject:data]; | 2272 [delegate webController:strongSelf didLoadPassKitObject:data]; |
2282 } | 2273 } |
2283 }; | 2274 }; |
2284 web::BrowserState* browserState = self.webStateImpl->GetBrowserState(); | 2275 web::BrowserState* browserState = self.webStateImpl->GetBrowserState(); |
2285 _passKitDownloader.reset([[CRWPassKitDownloader alloc] | 2276 _passKitDownloader = [[CRWPassKitDownloader alloc] |
2286 initWithContextGetter:browserState->GetRequestContext() | 2277 initWithContextGetter:browserState->GetRequestContext() |
2287 completionHandler:passKitCompletion]); | 2278 completionHandler:passKitCompletion]; |
2288 return _passKitDownloader.get(); | 2279 return _passKitDownloader; |
2289 } | 2280 } |
2290 | 2281 |
2291 - (void)updateWebViewUserAgentFromUserAgentType: | 2282 - (void)updateWebViewUserAgentFromUserAgentType: |
2292 (web::UserAgentType)userAgentType { | 2283 (web::UserAgentType)userAgentType { |
2293 if (userAgentType == web::UserAgentType::NONE) | 2284 if (userAgentType == web::UserAgentType::NONE) |
2294 return; | 2285 return; |
2295 | 2286 |
2296 NSString* userAgent = | 2287 NSString* userAgent = |
2297 base::SysUTF8ToNSString(web::GetWebClient()->GetUserAgent(userAgentType)); | 2288 base::SysUTF8ToNSString(web::GetWebClient()->GetUserAgent(userAgentType)); |
2298 [_webView setCustomUserAgent:userAgent]; | 2289 [_webView setCustomUserAgent:userAgent]; |
2299 } | 2290 } |
2300 | 2291 |
2301 #pragma mark - | 2292 #pragma mark - |
2302 #pragma mark CRWWebControllerContainerViewDelegate | 2293 #pragma mark CRWWebControllerContainerViewDelegate |
2303 | 2294 |
2304 - (CRWWebViewProxyImpl*)contentViewProxyForContainerView: | 2295 - (CRWWebViewProxyImpl*)contentViewProxyForContainerView: |
2305 (CRWWebControllerContainerView*)containerView { | 2296 (CRWWebControllerContainerView*)containerView { |
2306 return _webViewProxy.get(); | 2297 return _webViewProxy; |
2307 } | 2298 } |
2308 | 2299 |
2309 - (CGFloat)headerHeightForContainerView: | 2300 - (CGFloat)headerHeightForContainerView: |
2310 (CRWWebControllerContainerView*)containerView { | 2301 (CRWWebControllerContainerView*)containerView { |
2311 return [self headerHeight]; | 2302 return [self headerHeight]; |
2312 } | 2303 } |
2313 | 2304 |
2314 #pragma mark - | 2305 #pragma mark - |
2315 #pragma mark CRWJSInjectionEvaluator Methods | 2306 #pragma mark CRWJSInjectionEvaluator Methods |
2316 | 2307 |
(...skipping 21 matching lines...) Expand all Loading... | |
2338 #pragma mark - | 2329 #pragma mark - |
2339 | 2330 |
2340 - (void)executeUserJavaScript:(NSString*)script | 2331 - (void)executeUserJavaScript:(NSString*)script |
2341 completionHandler:(web::JavaScriptResultBlock)completion { | 2332 completionHandler:(web::JavaScriptResultBlock)completion { |
2342 // For security reasons, executing JavaScript on pages with app-specific URLs | 2333 // For security reasons, executing JavaScript on pages with app-specific URLs |
2343 // is not allowed, because those pages may have elevated privileges. | 2334 // is not allowed, because those pages may have elevated privileges. |
2344 GURL lastCommittedURL = self.webState->GetLastCommittedURL(); | 2335 GURL lastCommittedURL = self.webState->GetLastCommittedURL(); |
2345 if (web::GetWebClient()->IsAppSpecificURL(lastCommittedURL)) { | 2336 if (web::GetWebClient()->IsAppSpecificURL(lastCommittedURL)) { |
2346 if (completion) { | 2337 if (completion) { |
2347 dispatch_async(dispatch_get_main_queue(), ^{ | 2338 dispatch_async(dispatch_get_main_queue(), ^{ |
2348 base::scoped_nsobject<NSError> error([[NSError alloc] | 2339 NSError* error = [[NSError alloc] |
2349 initWithDomain:web::kJSEvaluationErrorDomain | 2340 initWithDomain:web::kJSEvaluationErrorDomain |
2350 code:web::JS_EVALUATION_ERROR_CODE_NO_WEB_VIEW | 2341 code:web::JS_EVALUATION_ERROR_CODE_NO_WEB_VIEW |
2351 userInfo:nil]); | 2342 userInfo:nil]; |
2352 completion(nil, error); | 2343 completion(nil, error); |
2353 }); | 2344 }); |
2354 } | 2345 } |
2355 return; | 2346 return; |
2356 } | 2347 } |
2357 | 2348 |
2358 [self setUserInteractionRegistered:YES]; | 2349 [self setUserInteractionRegistered:YES]; |
2359 [self executeJavaScript:script completionHandler:completion]; | 2350 [self executeJavaScript:script completionHandler:completion]; |
2360 } | 2351 } |
2361 | 2352 |
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2605 | 2596 |
2606 - (BOOL)handleDocumentSubmitMessage:(base::DictionaryValue*)message | 2597 - (BOOL)handleDocumentSubmitMessage:(base::DictionaryValue*)message |
2607 context:(NSDictionary*)context { | 2598 context:(NSDictionary*)context { |
2608 std::string href; | 2599 std::string href; |
2609 if (!message->GetString("href", &href)) { | 2600 if (!message->GetString("href", &href)) { |
2610 DLOG(WARNING) << "JS message parameter not found: href"; | 2601 DLOG(WARNING) << "JS message parameter not found: href"; |
2611 return NO; | 2602 return NO; |
2612 } | 2603 } |
2613 std::string formName; | 2604 std::string formName; |
2614 message->GetString("formName", &formName); | 2605 message->GetString("formName", &formName); |
2615 base::scoped_nsobject<NSSet> observers([_observers copy]); | 2606 |
2616 // We decide the form is user-submitted if the user has interacted with | 2607 // We decide the form is user-submitted if the user has interacted with |
2617 // the main page (using logic from the popup blocker), or if the keyboard | 2608 // the main page (using logic from the popup blocker), or if the keyboard |
2618 // is visible. | 2609 // is visible. |
2619 BOOL submittedByUser = [context[kUserIsInteractingKey] boolValue] || | 2610 BOOL submittedByUser = [context[kUserIsInteractingKey] boolValue] || |
2620 [_webViewProxy keyboardAccessory]; | 2611 [_webViewProxy keyboardAccessory]; |
2621 _webStateImpl->OnDocumentSubmitted(formName, submittedByUser); | 2612 _webStateImpl->OnDocumentSubmitted(formName, submittedByUser); |
2622 return YES; | 2613 return YES; |
2623 } | 2614 } |
2624 | 2615 |
2625 - (BOOL)handleFormActivityMessage:(base::DictionaryValue*)message | 2616 - (BOOL)handleFormActivityMessage:(base::DictionaryValue*)message |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2751 // TODO(crbug.com/549301): Improve transition detection. | 2742 // TODO(crbug.com/549301): Improve transition detection. |
2752 ui::PageTransition transition = self.userInteractionRegistered | 2743 ui::PageTransition transition = self.userInteractionRegistered |
2753 ? ui::PAGE_TRANSITION_LINK | 2744 ? ui::PAGE_TRANSITION_LINK |
2754 : ui::PAGE_TRANSITION_CLIENT_REDIRECT; | 2745 : ui::PAGE_TRANSITION_CLIENT_REDIRECT; |
2755 [self pushStateWithPageURL:pushURL | 2746 [self pushStateWithPageURL:pushURL |
2756 stateObject:stateObject | 2747 stateObject:stateObject |
2757 transition:transition]; | 2748 transition:transition]; |
2758 | 2749 |
2759 NSString* replaceWebViewJS = | 2750 NSString* replaceWebViewJS = |
2760 [self javaScriptToReplaceWebViewURL:pushURL stateObjectJSON:stateObject]; | 2751 [self javaScriptToReplaceWebViewURL:pushURL stateObjectJSON:stateObject]; |
2761 base::WeakNSObject<CRWWebController> weakSelf(self); | 2752 __weak CRWWebController* weakSelf = self; |
2762 [self executeJavaScript:replaceWebViewJS completionHandler:^(id, NSError*) { | 2753 [self executeJavaScript:replaceWebViewJS |
2763 if (!weakSelf || weakSelf.get()->_isBeingDestroyed) | 2754 completionHandler:^(id, NSError*) { |
2764 return; | 2755 CRWWebController* strongSelf = weakSelf; |
2765 base::scoped_nsobject<CRWWebController> strongSelf([weakSelf retain]); | 2756 if (!strongSelf || strongSelf->_isBeingDestroyed) |
2766 [strongSelf optOutScrollsToTopForSubviews]; | 2757 return; |
2767 [strongSelf didFinishNavigation:nil]; | 2758 [strongSelf optOutScrollsToTopForSubviews]; |
2768 }]; | 2759 [strongSelf didFinishNavigation:nil]; |
2760 }]; | |
2769 return YES; | 2761 return YES; |
2770 } | 2762 } |
2771 | 2763 |
2772 - (BOOL)handleWindowHistoryDidReplaceStateMessage: | 2764 - (BOOL)handleWindowHistoryDidReplaceStateMessage: |
2773 (base::DictionaryValue*)message | 2765 (base::DictionaryValue*)message |
2774 context:(NSDictionary*)context { | 2766 context:(NSDictionary*)context { |
2775 DCHECK(_changingHistoryState); | 2767 DCHECK(_changingHistoryState); |
2776 _changingHistoryState = NO; | 2768 _changingHistoryState = NO; |
2777 | 2769 |
2778 std::string pageURL; | 2770 std::string pageURL; |
(...skipping 28 matching lines...) Expand all Loading... | |
2807 if (!message->GetString("stateObject", &stateObjectJSON)) { | 2799 if (!message->GetString("stateObject", &stateObjectJSON)) { |
2808 DLOG(WARNING) << "JS message parameter not found: stateObject"; | 2800 DLOG(WARNING) << "JS message parameter not found: stateObject"; |
2809 return NO; | 2801 return NO; |
2810 } | 2802 } |
2811 NSString* stateObject = base::SysUTF8ToNSString(stateObjectJSON); | 2803 NSString* stateObject = base::SysUTF8ToNSString(stateObjectJSON); |
2812 _URLOnStartLoading = replaceURL; | 2804 _URLOnStartLoading = replaceURL; |
2813 _lastRegisteredRequestURL = replaceURL; | 2805 _lastRegisteredRequestURL = replaceURL; |
2814 [self replaceStateWithPageURL:replaceURL stateObject:stateObject]; | 2806 [self replaceStateWithPageURL:replaceURL stateObject:stateObject]; |
2815 NSString* replaceStateJS = [self javaScriptToReplaceWebViewURL:replaceURL | 2807 NSString* replaceStateJS = [self javaScriptToReplaceWebViewURL:replaceURL |
2816 stateObjectJSON:stateObject]; | 2808 stateObjectJSON:stateObject]; |
2817 base::WeakNSObject<CRWWebController> weakSelf(self); | 2809 __weak CRWWebController* weakSelf = self; |
2818 [self executeJavaScript:replaceStateJS completionHandler:^(id, NSError*) { | 2810 [self executeJavaScript:replaceStateJS |
2819 if (!weakSelf || weakSelf.get()->_isBeingDestroyed) | 2811 completionHandler:^(id, NSError*) { |
2820 return; | 2812 CRWWebController* strongSelf = weakSelf; |
2821 base::scoped_nsobject<CRWWebController> strongSelf([weakSelf retain]); | 2813 if (!strongSelf || strongSelf->_isBeingDestroyed) |
2822 [strongSelf didFinishNavigation:nil]; | 2814 return; |
2823 }]; | 2815 [strongSelf didFinishNavigation:nil]; |
2816 }]; | |
2824 return YES; | 2817 return YES; |
2825 } | 2818 } |
2826 | 2819 |
2827 #pragma mark - | 2820 #pragma mark - |
2828 | 2821 |
2829 - (BOOL)wantsKeyboardShield { | 2822 - (BOOL)wantsKeyboardShield { |
2830 if ([self.nativeController | 2823 if ([self.nativeController |
2831 respondsToSelector:@selector(wantsKeyboardShield)]) { | 2824 respondsToSelector:@selector(wantsKeyboardShield)]) { |
2832 return [self.nativeController wantsKeyboardShield]; | 2825 return [self.nativeController wantsKeyboardShield]; |
2833 } | 2826 } |
(...skipping 25 matching lines...) Expand all Loading... | |
2859 } | 2852 } |
2860 | 2853 |
2861 // TODO(stuartmorgan): This shouldn't be called for hash state or | 2854 // TODO(stuartmorgan): This shouldn't be called for hash state or |
2862 // push/replaceState. | 2855 // push/replaceState. |
2863 [self resetDocumentSpecificState]; | 2856 [self resetDocumentSpecificState]; |
2864 | 2857 |
2865 [self didStartLoadingURL:currentURL]; | 2858 [self didStartLoadingURL:currentURL]; |
2866 } | 2859 } |
2867 | 2860 |
2868 - (void)resetDocumentSpecificState { | 2861 - (void)resetDocumentSpecificState { |
2869 _lastUserInteraction.reset(); | 2862 _lastUserInteraction = nil; |
2870 _clickInProgress = NO; | 2863 _clickInProgress = NO; |
2871 } | 2864 } |
2872 | 2865 |
2873 - (void)didStartLoadingURL:(const GURL&)URL { | 2866 - (void)didStartLoadingURL:(const GURL&)URL { |
2874 _loadPhase = web::PAGE_LOADING; | 2867 _loadPhase = web::PAGE_LOADING; |
2875 _URLOnStartLoading = URL; | 2868 _URLOnStartLoading = URL; |
2876 _displayStateOnStartLoading = self.pageDisplayState; | 2869 _displayStateOnStartLoading = self.pageDisplayState; |
2877 | 2870 |
2878 self.userInteractionRegistered = NO; | 2871 self.userInteractionRegistered = NO; |
2879 _pageHasZoomed = NO; | 2872 _pageHasZoomed = NO; |
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3194 | 3187 |
3195 #pragma mark - | 3188 #pragma mark - |
3196 #pragma mark WebUI | 3189 #pragma mark WebUI |
3197 | 3190 |
3198 - (void)createWebUIForURL:(const GURL&)URL { | 3191 - (void)createWebUIForURL:(const GURL&)URL { |
3199 // |CreateWebUI| will do nothing if |URL| is not a WebUI URL and then | 3192 // |CreateWebUI| will do nothing if |URL| is not a WebUI URL and then |
3200 // |HasWebUI| will return false. | 3193 // |HasWebUI| will return false. |
3201 _webStateImpl->CreateWebUI(URL); | 3194 _webStateImpl->CreateWebUI(URL); |
3202 bool isWebUIURL = _webStateImpl->HasWebUI(); | 3195 bool isWebUIURL = _webStateImpl->HasWebUI(); |
3203 if (isWebUIURL) { | 3196 if (isWebUIURL) { |
3204 _webUIManager.reset( | 3197 _webUIManager = [[CRWWebUIManager alloc] initWithWebState:_webStateImpl]; |
3205 [[CRWWebUIManager alloc] initWithWebState:_webStateImpl]); | |
3206 } | 3198 } |
3207 } | 3199 } |
3208 | 3200 |
3209 - (void)clearWebUI { | 3201 - (void)clearWebUI { |
3210 _webStateImpl->ClearWebUI(); | 3202 _webStateImpl->ClearWebUI(); |
3211 _webUIManager.reset(); | 3203 _webUIManager = nil; |
3212 } | 3204 } |
3213 | 3205 |
3214 #pragma mark - | 3206 #pragma mark - |
3215 #pragma mark Auth Challenge | 3207 #pragma mark Auth Challenge |
3216 | 3208 |
3217 - (void)processAuthChallenge:(NSURLAuthenticationChallenge*)challenge | 3209 - (void)processAuthChallenge:(NSURLAuthenticationChallenge*)challenge |
3218 forCertAcceptPolicy:(web::CertAcceptPolicy)policy | 3210 forCertAcceptPolicy:(web::CertAcceptPolicy)policy |
3219 certStatus:(net::CertStatus)certStatus | 3211 certStatus:(net::CertStatus)certStatus |
3220 completionHandler:(void (^)(NSURLSessionAuthChallengeDisposition, | 3212 completionHandler:(void (^)(NSURLSessionAuthChallengeDisposition, |
3221 NSURLCredential*))completionHandler { | 3213 NSURLCredential*))completionHandler { |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3257 (void (^)(NSURLSessionAuthChallengeDisposition, | 3249 (void (^)(NSURLSessionAuthChallengeDisposition, |
3258 NSURLCredential*))completionHandler { | 3250 NSURLCredential*))completionHandler { |
3259 NSURLProtectionSpace* space = challenge.protectionSpace; | 3251 NSURLProtectionSpace* space = challenge.protectionSpace; |
3260 DCHECK( | 3252 DCHECK( |
3261 [space.authenticationMethod isEqual:NSURLAuthenticationMethodHTTPBasic] || | 3253 [space.authenticationMethod isEqual:NSURLAuthenticationMethodHTTPBasic] || |
3262 [space.authenticationMethod isEqual:NSURLAuthenticationMethodNTLM] || | 3254 [space.authenticationMethod isEqual:NSURLAuthenticationMethodNTLM] || |
3263 [space.authenticationMethod isEqual:NSURLAuthenticationMethodHTTPDigest]); | 3255 [space.authenticationMethod isEqual:NSURLAuthenticationMethodHTTPDigest]); |
3264 | 3256 |
3265 _webStateImpl->OnAuthRequired( | 3257 _webStateImpl->OnAuthRequired( |
3266 space, challenge.proposedCredential, | 3258 space, challenge.proposedCredential, |
3267 base::BindBlock(^(NSString* user, NSString* password) { | 3259 base::BindBlockArc(^(NSString* user, NSString* password) { |
3268 [CRWWebController processHTTPAuthForUser:user | 3260 [CRWWebController processHTTPAuthForUser:user |
3269 password:password | 3261 password:password |
3270 completionHandler:completionHandler]; | 3262 completionHandler:completionHandler]; |
3271 })); | 3263 })); |
3272 } | 3264 } |
3273 | 3265 |
3274 + (void)processHTTPAuthForUser:(NSString*)user | 3266 + (void)processHTTPAuthForUser:(NSString*)user |
3275 password:(NSString*)password | 3267 password:(NSString*)password |
3276 completionHandler:(void (^)(NSURLSessionAuthChallengeDisposition, | 3268 completionHandler:(void (^)(NSURLSessionAuthChallengeDisposition, |
3277 NSURLCredential*))completionHandler { | 3269 NSURLCredential*))completionHandler { |
(...skipping 21 matching lines...) Expand all Loading... | |
3299 completion:(void (^)(BOOL, NSString*))completionHandler { | 3291 completion:(void (^)(BOOL, NSString*))completionHandler { |
3300 DCHECK(completionHandler); | 3292 DCHECK(completionHandler); |
3301 if (self.shouldSuppressDialogs) { | 3293 if (self.shouldSuppressDialogs) { |
3302 _webStateImpl->OnDialogSuppressed(); | 3294 _webStateImpl->OnDialogSuppressed(); |
3303 completionHandler(NO, nil); | 3295 completionHandler(NO, nil); |
3304 return; | 3296 return; |
3305 } | 3297 } |
3306 | 3298 |
3307 self.webStateImpl->RunJavaScriptDialog( | 3299 self.webStateImpl->RunJavaScriptDialog( |
3308 net::GURLWithNSURL(frame.request.URL), type, message, defaultText, | 3300 net::GURLWithNSURL(frame.request.URL), type, message, defaultText, |
3309 base::BindBlock(^(bool success, NSString* input) { | 3301 base::BindBlockArc(^(bool success, NSString* input) { |
3310 completionHandler(success, input); | 3302 completionHandler(success, input); |
3311 })); | 3303 })); |
3312 } | 3304 } |
3313 | 3305 |
3314 #pragma mark - | 3306 #pragma mark - |
3315 #pragma mark TouchTracking | 3307 #pragma mark TouchTracking |
3316 | 3308 |
3317 - (void)touched:(BOOL)touched { | 3309 - (void)touched:(BOOL)touched { |
3318 _clickInProgress = touched; | 3310 _clickInProgress = touched; |
3319 if (touched) { | 3311 if (touched) { |
3320 self.userInteractionRegistered = YES; | 3312 self.userInteractionRegistered = YES; |
3321 _userInteractedWithWebController = YES; | 3313 _userInteractedWithWebController = YES; |
3322 if (_isBeingDestroyed) | 3314 if (_isBeingDestroyed) |
3323 return; | 3315 return; |
3324 const web::NavigationManagerImpl& navigationManager = | 3316 const web::NavigationManagerImpl& navigationManager = |
3325 self.webStateImpl->GetNavigationManagerImpl(); | 3317 self.webStateImpl->GetNavigationManagerImpl(); |
3326 GURL mainDocumentURL = | 3318 GURL mainDocumentURL = |
3327 navigationManager.GetItemCount() | 3319 navigationManager.GetItemCount() |
3328 ? navigationManager.GetLastCommittedItem()->GetURL() | 3320 ? navigationManager.GetLastCommittedItem()->GetURL() |
3329 : [self currentURL]; | 3321 : [self currentURL]; |
3330 _lastUserInteraction.reset(new UserInteractionEvent(mainDocumentURL)); | 3322 _lastUserInteraction = |
3323 base::MakeUnique<UserInteractionEvent>(mainDocumentURL); | |
3331 } | 3324 } |
3332 } | 3325 } |
3333 | 3326 |
3334 - (CRWTouchTrackingRecognizer*)touchTrackingRecognizer { | 3327 - (CRWTouchTrackingRecognizer*)touchTrackingRecognizer { |
3335 if (!_touchTrackingRecognizer) { | 3328 if (!_touchTrackingRecognizer) { |
3336 _touchTrackingRecognizer.reset( | 3329 _touchTrackingRecognizer = |
3337 [[CRWTouchTrackingRecognizer alloc] initWithDelegate:self]); | 3330 [[CRWTouchTrackingRecognizer alloc] initWithDelegate:self]; |
3338 } | 3331 } |
3339 return _touchTrackingRecognizer.get(); | 3332 return _touchTrackingRecognizer; |
3340 } | 3333 } |
3341 | 3334 |
3342 - (BOOL)userIsInteracting { | 3335 - (BOOL)userIsInteracting { |
3343 // If page transfer started after last click, user is deemed to be no longer | 3336 // If page transfer started after last click, user is deemed to be no longer |
3344 // interacting. | 3337 // interacting. |
3345 if (!_lastUserInteraction || | 3338 if (!_lastUserInteraction || |
3346 _lastTransferTimeInSeconds > _lastUserInteraction->time) { | 3339 _lastTransferTimeInSeconds > _lastUserInteraction->time) { |
3347 return NO; | 3340 return NO; |
3348 } | 3341 } |
3349 return [self userClickedRecently]; | 3342 return [self userClickedRecently]; |
(...skipping 19 matching lines...) Expand all Loading... | |
3369 - (void)addPlaceholderOverlay { | 3362 - (void)addPlaceholderOverlay { |
3370 if (!_overlayPreviewMode) { | 3363 if (!_overlayPreviewMode) { |
3371 // Create |kSnapshotOverlayDelay| second timer to remove image with | 3364 // Create |kSnapshotOverlayDelay| second timer to remove image with |
3372 // transition. | 3365 // transition. |
3373 [self performSelector:@selector(removePlaceholderOverlay) | 3366 [self performSelector:@selector(removePlaceholderOverlay) |
3374 withObject:nil | 3367 withObject:nil |
3375 afterDelay:kSnapshotOverlayDelay]; | 3368 afterDelay:kSnapshotOverlayDelay]; |
3376 } | 3369 } |
3377 | 3370 |
3378 // Add overlay image. | 3371 // Add overlay image. |
3379 _placeholderOverlayView.reset([[UIImageView alloc] init]); | 3372 _placeholderOverlayView = [[UIImageView alloc] init]; |
3380 CGRect frame = [self visibleFrame]; | 3373 CGRect frame = [self visibleFrame]; |
3381 [_placeholderOverlayView setFrame:frame]; | 3374 [_placeholderOverlayView setFrame:frame]; |
3382 [_placeholderOverlayView | 3375 [_placeholderOverlayView |
3383 setAutoresizingMask:UIViewAutoresizingFlexibleWidth | | 3376 setAutoresizingMask:UIViewAutoresizingFlexibleWidth | |
3384 UIViewAutoresizingFlexibleHeight]; | 3377 UIViewAutoresizingFlexibleHeight]; |
3385 [_placeholderOverlayView setContentMode:UIViewContentModeScaleAspectFill]; | 3378 [_placeholderOverlayView setContentMode:UIViewContentModeScaleAspectFill]; |
3386 [_containerView addSubview:_placeholderOverlayView]; | 3379 [_containerView addSubview:_placeholderOverlayView]; |
3387 | 3380 |
3388 id callback = ^(UIImage* image) { | 3381 id callback = ^(UIImage* image) { |
3389 [_placeholderOverlayView setImage:image]; | 3382 [_placeholderOverlayView setImage:image]; |
3390 }; | 3383 }; |
3391 [_delegate webController:self retrievePlaceholderOverlayImage:callback]; | 3384 [_delegate webController:self retrievePlaceholderOverlayImage:callback]; |
3392 | 3385 |
3393 if (!_placeholderOverlayView.get().image) { | 3386 if (!_placeholderOverlayView.image) { |
3394 _placeholderOverlayView.get().image = [[self class] defaultSnapshotImage]; | 3387 _placeholderOverlayView.image = [[self class] defaultSnapshotImage]; |
3395 } | 3388 } |
3396 } | 3389 } |
3397 | 3390 |
3398 - (void)removePlaceholderOverlay { | 3391 - (void)removePlaceholderOverlay { |
3399 if (!_placeholderOverlayView || _overlayPreviewMode) | 3392 if (!_placeholderOverlayView || _overlayPreviewMode) |
3400 return; | 3393 return; |
3401 | 3394 |
3402 [NSObject | 3395 [NSObject |
3403 cancelPreviousPerformRequestsWithTarget:self | 3396 cancelPreviousPerformRequestsWithTarget:self |
3404 selector:@selector( | 3397 selector:@selector( |
3405 removePlaceholderOverlay) | 3398 removePlaceholderOverlay) |
3406 object:nil]; | 3399 object:nil]; |
3407 // Remove overlay with transition. | 3400 // Remove overlay with transition. |
3408 [UIView animateWithDuration:kSnapshotOverlayTransition | 3401 [UIView animateWithDuration:kSnapshotOverlayTransition |
3409 animations:^{ | 3402 animations:^{ |
3410 [_placeholderOverlayView setAlpha:0.0f]; | 3403 [_placeholderOverlayView setAlpha:0.0f]; |
3411 } | 3404 } |
3412 completion:^(BOOL finished) { | 3405 completion:^(BOOL finished) { |
3413 [_placeholderOverlayView removeFromSuperview]; | 3406 [_placeholderOverlayView removeFromSuperview]; |
3414 _placeholderOverlayView.reset(); | 3407 _placeholderOverlayView = nil; |
3415 }]; | 3408 }]; |
3416 } | 3409 } |
3417 | 3410 |
3418 - (void)setOverlayPreviewMode:(BOOL)overlayPreviewMode { | 3411 - (void)setOverlayPreviewMode:(BOOL)overlayPreviewMode { |
3419 _overlayPreviewMode = overlayPreviewMode; | 3412 _overlayPreviewMode = overlayPreviewMode; |
3420 | 3413 |
3421 // If we were showing the preview, remove it. | 3414 // If we were showing the preview, remove it. |
3422 if (!_overlayPreviewMode && _placeholderOverlayView) { | 3415 if (!_overlayPreviewMode && _placeholderOverlayView) { |
3423 [self resetContainerView]; | 3416 [self resetContainerView]; |
3424 // Reset |_placeholderOverlayView| directly instead of calling | 3417 // Reset |_placeholderOverlayView| directly instead of calling |
3425 // -removePlaceholderOverlay, which removes |_placeholderOverlayView| in an | 3418 // -removePlaceholderOverlay, which removes |_placeholderOverlayView| in an |
3426 // animation. | 3419 // animation. |
3427 [_placeholderOverlayView removeFromSuperview]; | 3420 [_placeholderOverlayView removeFromSuperview]; |
3428 _placeholderOverlayView.reset(); | 3421 _placeholderOverlayView = nil; |
3429 // There are cases when resetting the contentView, above, may happen after | 3422 // There are cases when resetting the contentView, above, may happen after |
3430 // the web view has been created. Re-add it here, rather than | 3423 // the web view has been created. Re-add it here, rather than |
3431 // relying on a subsequent call to loadCurrentURLInWebView. | 3424 // relying on a subsequent call to loadCurrentURLInWebView. |
3432 if (_webView) { | 3425 if (_webView) { |
3433 [[self view] addSubview:_webView]; | 3426 [[self view] addSubview:_webView]; |
3434 } | 3427 } |
3435 } | 3428 } |
3436 } | 3429 } |
3437 | 3430 |
3438 #pragma mark - | 3431 #pragma mark - |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3478 return currentItem ? currentItem->GetHttpRequestHeaders() : nil; | 3471 return currentItem ? currentItem->GetHttpRequestHeaders() : nil; |
3479 } | 3472 } |
3480 | 3473 |
3481 #pragma mark - | 3474 #pragma mark - |
3482 #pragma mark CRWWebViewScrollViewProxyObserver | 3475 #pragma mark CRWWebViewScrollViewProxyObserver |
3483 | 3476 |
3484 - (void)webViewScrollViewDidZoom: | 3477 - (void)webViewScrollViewDidZoom: |
3485 (CRWWebViewScrollViewProxy*)webViewScrollViewProxy { | 3478 (CRWWebViewScrollViewProxy*)webViewScrollViewProxy { |
3486 _pageHasZoomed = YES; | 3479 _pageHasZoomed = YES; |
3487 | 3480 |
3488 base::WeakNSObject<UIScrollView> weakScrollView(self.webScrollView); | 3481 __weak UIScrollView* weakScrollView = self.webScrollView; |
3489 [self extractViewportTagWithCompletion:^( | 3482 [self extractViewportTagWithCompletion:^( |
3490 const web::PageViewportState* viewportState) { | 3483 const web::PageViewportState* viewportState) { |
3491 if (!weakScrollView) | 3484 if (!weakScrollView) |
3492 return; | 3485 return; |
3493 base::scoped_nsobject<UIScrollView> scrollView([weakScrollView retain]); | 3486 UIScrollView* scrollView = weakScrollView; |
3494 if (viewportState && !viewportState->viewport_tag_present() && | 3487 if (viewportState && !viewportState->viewport_tag_present() && |
3495 [scrollView minimumZoomScale] == [scrollView maximumZoomScale] && | 3488 [scrollView minimumZoomScale] == [scrollView maximumZoomScale] && |
3496 [scrollView zoomScale] > 1.0) { | 3489 [scrollView zoomScale] > 1.0) { |
3497 UMA_HISTOGRAM_BOOLEAN(kUMAViewportZoomBugCount, true); | 3490 UMA_HISTOGRAM_BOOLEAN(kUMAViewportZoomBugCount, true); |
3498 } | 3491 } |
3499 }]; | 3492 }]; |
3500 } | 3493 } |
3501 | 3494 |
3502 - (void)webViewScrollViewDidResetContentSize: | 3495 - (void)webViewScrollViewDidResetContentSize: |
3503 (CRWWebViewScrollViewProxy*)webViewScrollViewProxy { | 3496 (CRWWebViewScrollViewProxy*)webViewScrollViewProxy { |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3598 - (void)extractViewportTagWithCompletion:(ViewportStateCompletion)completion { | 3591 - (void)extractViewportTagWithCompletion:(ViewportStateCompletion)completion { |
3599 DCHECK(completion); | 3592 DCHECK(completion); |
3600 web::NavigationItem* currentItem = self.currentNavItem; | 3593 web::NavigationItem* currentItem = self.currentNavItem; |
3601 if (!currentItem) { | 3594 if (!currentItem) { |
3602 completion(nullptr); | 3595 completion(nullptr); |
3603 return; | 3596 return; |
3604 } | 3597 } |
3605 NSString* const kViewportContentQuery = | 3598 NSString* const kViewportContentQuery = |
3606 @"var viewport = document.querySelector('meta[name=\"viewport\"]');" | 3599 @"var viewport = document.querySelector('meta[name=\"viewport\"]');" |
3607 "viewport ? viewport.content : '';"; | 3600 "viewport ? viewport.content : '';"; |
3608 base::WeakNSObject<CRWWebController> weakSelf(self); | 3601 __weak CRWWebController* weakSelf = self; |
3609 int itemID = currentItem->GetUniqueID(); | 3602 int itemID = currentItem->GetUniqueID(); |
3610 [self executeJavaScript:kViewportContentQuery | 3603 [self executeJavaScript:kViewportContentQuery |
3611 completionHandler:^(id viewportContent, NSError*) { | 3604 completionHandler:^(id viewportContent, NSError*) { |
3612 web::NavigationItem* item = [weakSelf currentNavItem]; | 3605 web::NavigationItem* item = [weakSelf currentNavItem]; |
3613 if (item && item->GetUniqueID() == itemID) { | 3606 if (item && item->GetUniqueID() == itemID) { |
3614 web::PageViewportState viewportState( | 3607 web::PageViewportState viewportState( |
3615 base::mac::ObjCCast<NSString>(viewportContent)); | 3608 base::mac::ObjCCast<NSString>(viewportContent)); |
3616 completion(&viewportState); | 3609 completion(&viewportState); |
3617 } else { | 3610 } else { |
3618 completion(nullptr); | 3611 completion(nullptr); |
(...skipping 28 matching lines...) Expand all Loading... | |
3647 displayState.zoom_state().set_zoom_scale( | 3640 displayState.zoom_state().set_zoom_scale( |
3648 displayState.zoom_state().minimum_zoom_scale() + | 3641 displayState.zoom_state().minimum_zoom_scale() + |
3649 zoomPercentage * displayState.zoom_state().GetMinMaxZoomDifference()); | 3642 zoomPercentage * displayState.zoom_state().GetMinMaxZoomDifference()); |
3650 currentItem->SetPageDisplayState(displayState); | 3643 currentItem->SetPageDisplayState(displayState); |
3651 [self applyPageDisplayState:currentItem->GetPageDisplayState()]; | 3644 [self applyPageDisplayState:currentItem->GetPageDisplayState()]; |
3652 } | 3645 } |
3653 | 3646 |
3654 - (void)applyPageDisplayState:(const web::PageDisplayState&)displayState { | 3647 - (void)applyPageDisplayState:(const web::PageDisplayState&)displayState { |
3655 if (!displayState.IsValid()) | 3648 if (!displayState.IsValid()) |
3656 return; | 3649 return; |
3657 base::WeakNSObject<CRWWebController> weakSelf(self); | 3650 __weak CRWWebController* weakSelf = self; |
3658 web::PageDisplayState displayStateCopy = displayState; | 3651 web::PageDisplayState displayStateCopy = displayState; |
3659 [self extractViewportTagWithCompletion:^( | 3652 [self extractViewportTagWithCompletion:^( |
3660 const web::PageViewportState* viewportState) { | 3653 const web::PageViewportState* viewportState) { |
3661 if (viewportState) { | 3654 if (viewportState) { |
3662 [weakSelf applyPageDisplayState:displayStateCopy | 3655 [weakSelf applyPageDisplayState:displayStateCopy |
3663 userScalable:viewportState->user_scalable()]; | 3656 userScalable:viewportState->user_scalable()]; |
3664 } | 3657 } |
3665 }]; | 3658 }]; |
3666 } | 3659 } |
3667 | 3660 |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3736 (const web::PageScrollState&)scrollState { | 3729 (const web::PageScrollState&)scrollState { |
3737 DCHECK(scrollState.IsValid()); | 3730 DCHECK(scrollState.IsValid()); |
3738 CGPoint scrollOffset = | 3731 CGPoint scrollOffset = |
3739 CGPointMake(scrollState.offset_x(), scrollState.offset_y()); | 3732 CGPointMake(scrollState.offset_x(), scrollState.offset_y()); |
3740 if (_loadPhase == web::PAGE_LOADED) { | 3733 if (_loadPhase == web::PAGE_LOADED) { |
3741 // If the page is loaded, update the scroll immediately. | 3734 // If the page is loaded, update the scroll immediately. |
3742 [self.webScrollView setContentOffset:scrollOffset]; | 3735 [self.webScrollView setContentOffset:scrollOffset]; |
3743 } else { | 3736 } else { |
3744 // If the page isn't loaded, store the action to update the scroll | 3737 // If the page isn't loaded, store the action to update the scroll |
3745 // when the page finishes loading. | 3738 // when the page finishes loading. |
3746 base::WeakNSObject<UIScrollView> weakScrollView(self.webScrollView); | 3739 __weak UIScrollView* weakScrollView = self.webScrollView; |
3747 base::scoped_nsprotocol<ProceduralBlock> action([^{ | 3740 ProceduralBlock action = ^{ |
3748 [weakScrollView setContentOffset:scrollOffset]; | 3741 [weakScrollView setContentOffset:scrollOffset]; |
3749 } copy]); | 3742 }; |
3750 [_pendingLoadCompleteActions addObject:action]; | 3743 [_pendingLoadCompleteActions addObject:action]; |
3751 } | 3744 } |
3752 } | 3745 } |
3753 | 3746 |
3754 #pragma mark - | 3747 #pragma mark - |
3755 #pragma mark Fullscreen | 3748 #pragma mark Fullscreen |
3756 | 3749 |
3757 - (CGRect)visibleFrame { | 3750 - (CGRect)visibleFrame { |
3758 CGRect frame = [_containerView bounds]; | 3751 CGRect frame = [_containerView bounds]; |
3759 CGFloat headerHeight = [self headerHeight]; | 3752 CGFloat headerHeight = [self headerHeight]; |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3856 return; | 3849 return; |
3857 } | 3850 } |
3858 | 3851 |
3859 web::NavigationManager* navManager = self.webState->GetNavigationManager(); | 3852 web::NavigationManager* navManager = self.webState->GetNavigationManager(); |
3860 web::NavigationItem* currentNavItem = navManager->GetLastCommittedItem(); | 3853 web::NavigationItem* currentNavItem = navManager->GetLastCommittedItem(); |
3861 if (!currentNavItem) { | 3854 if (!currentNavItem) { |
3862 return; | 3855 return; |
3863 } | 3856 } |
3864 | 3857 |
3865 if (!_SSLStatusUpdater) { | 3858 if (!_SSLStatusUpdater) { |
3866 _SSLStatusUpdater.reset([[CRWSSLStatusUpdater alloc] | 3859 _SSLStatusUpdater = |
3867 initWithDataSource:self | 3860 [[CRWSSLStatusUpdater alloc] initWithDataSource:self |
3868 navigationManager:navManager]); | 3861 navigationManager:navManager]; |
3869 [_SSLStatusUpdater setDelegate:self]; | 3862 [_SSLStatusUpdater setDelegate:self]; |
3870 } | 3863 } |
3871 NSString* host = base::SysUTF8ToNSString(_documentURL.host()); | 3864 NSString* host = base::SysUTF8ToNSString(_documentURL.host()); |
3872 BOOL hasOnlySecureContent = [_webView hasOnlySecureContent]; | 3865 BOOL hasOnlySecureContent = [_webView hasOnlySecureContent]; |
3873 base::ScopedCFTypeRef<SecTrustRef> trust; | 3866 base::ScopedCFTypeRef<SecTrustRef> trust; |
3874 if (base::ios::IsRunningOnIOS10OrLater()) { | 3867 if (base::ios::IsRunningOnIOS10OrLater()) { |
3875 trust.reset([_webView serverTrust], base::scoped_policy::RETAIN); | 3868 trust.reset([_webView serverTrust], base::scoped_policy::RETAIN); |
3876 } else { | 3869 } else { |
3877 trust = web::CreateServerTrustFromChain([_webView certificateChain], host); | 3870 trust = web::CreateServerTrustFromChain([_webView certificateChain], host); |
3878 } | 3871 } |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3940 } | 3933 } |
3941 UMA_HISTOGRAM_BOOLEAN("WebController.CertVerificationErrorsCacheHit", | 3934 UMA_HISTOGRAM_BOOLEAN("WebController.CertVerificationErrorsCacheHit", |
3942 cacheHit); | 3935 cacheHit); |
3943 } | 3936 } |
3944 } | 3937 } |
3945 | 3938 |
3946 // Ask web client if this cert error should be allowed. | 3939 // Ask web client if this cert error should be allowed. |
3947 web::GetWebClient()->AllowCertificateError( | 3940 web::GetWebClient()->AllowCertificateError( |
3948 _webStateImpl, net::MapCertStatusToNetError(info.cert_status), info, | 3941 _webStateImpl, net::MapCertStatusToNetError(info.cert_status), info, |
3949 net::GURLWithNSURL(requestURL), recoverable, | 3942 net::GURLWithNSURL(requestURL), recoverable, |
3950 base::BindBlock(^(bool proceed) { | 3943 base::BindBlockArc(^(bool proceed) { |
3951 if (proceed) { | 3944 if (proceed) { |
3952 DCHECK(recoverable); | 3945 DCHECK(recoverable); |
3953 [_certVerificationController allowCert:leafCert | 3946 [_certVerificationController allowCert:leafCert |
3954 forHost:host | 3947 forHost:host |
3955 status:info.cert_status]; | 3948 status:info.cert_status]; |
3956 _webStateImpl->GetSessionCertificatePolicyCache() | 3949 _webStateImpl->GetSessionCertificatePolicyCache() |
3957 ->RegisterAllowedCertificate( | 3950 ->RegisterAllowedCertificate( |
3958 leafCert, base::SysNSStringToUTF8(host), info.cert_status); | 3951 leafCert, base::SysNSStringToUTF8(host), info.cert_status); |
3959 [self loadCurrentURL]; | 3952 [self loadCurrentURL]; |
3960 } else { | 3953 } else { |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4002 // Create a dependency between the |webView| pan gesture and BVC side swipe | 3995 // Create a dependency between the |webView| pan gesture and BVC side swipe |
4003 // gestures. Note: This needs to be added before the longPress recognizers | 3996 // gestures. Note: This needs to be added before the longPress recognizers |
4004 // below, or the longPress appears to deadlock the remaining recognizers, | 3997 // below, or the longPress appears to deadlock the remaining recognizers, |
4005 // thereby breaking scroll. | 3998 // thereby breaking scroll. |
4006 NSSet* recognizers = [_swipeRecognizerProvider swipeRecognizers]; | 3999 NSSet* recognizers = [_swipeRecognizerProvider swipeRecognizers]; |
4007 for (UISwipeGestureRecognizer* swipeRecognizer in recognizers) { | 4000 for (UISwipeGestureRecognizer* swipeRecognizer in recognizers) { |
4008 [self.webScrollView.panGestureRecognizer | 4001 [self.webScrollView.panGestureRecognizer |
4009 requireGestureRecognizerToFail:swipeRecognizer]; | 4002 requireGestureRecognizerToFail:swipeRecognizer]; |
4010 } | 4003 } |
4011 | 4004 |
4012 _contextMenuController.reset([[CRWContextMenuController alloc] | 4005 _contextMenuController = |
4013 initWithWebView:_webView | 4006 [[CRWContextMenuController alloc] initWithWebView:_webView |
4014 injectionEvaluator:self | 4007 injectionEvaluator:self |
4015 delegate:self]); | 4008 delegate:self]; |
4016 | 4009 |
4017 // Add all additional gesture recognizers to the web view. | 4010 // Add all additional gesture recognizers to the web view. |
4018 for (UIGestureRecognizer* recognizer in _gestureRecognizers.get()) { | 4011 for (UIGestureRecognizer* recognizer in _gestureRecognizers) { |
4019 [_webView addGestureRecognizer:recognizer]; | 4012 [_webView addGestureRecognizer:recognizer]; |
4020 } | 4013 } |
4021 | 4014 |
4022 _URLOnStartLoading = _defaultURL; | 4015 _URLOnStartLoading = _defaultURL; |
4023 | 4016 |
4024 // WKWebViews with invalid or empty frames have exhibited rendering bugs, so | 4017 // WKWebViews with invalid or empty frames have exhibited rendering bugs, so |
4025 // resize the view to match the container view upon creation. | 4018 // resize the view to match the container view upon creation. |
4026 [_webView setFrame:[_containerView bounds]]; | 4019 [_webView setFrame:[_containerView bounds]]; |
4027 | 4020 |
4028 // If the visible NavigationItem should be loaded in this web view, display | 4021 // If the visible NavigationItem should be loaded in this web view, display |
(...skipping 10 matching lines...) Expand all Loading... | |
4039 | 4032 |
4040 - (WKWebView*)webViewWithConfiguration:(WKWebViewConfiguration*)config { | 4033 - (WKWebView*)webViewWithConfiguration:(WKWebViewConfiguration*)config { |
4041 // Do not attach the context menu controller immediately as the JavaScript | 4034 // Do not attach the context menu controller immediately as the JavaScript |
4042 // delegate must be specified. | 4035 // delegate must be specified. |
4043 return web::BuildWKWebView(CGRectZero, config, | 4036 return web::BuildWKWebView(CGRectZero, config, |
4044 self.webStateImpl->GetBrowserState(), | 4037 self.webStateImpl->GetBrowserState(), |
4045 self.userAgentType); | 4038 self.userAgentType); |
4046 } | 4039 } |
4047 | 4040 |
4048 - (void)setWebView:(WKWebView*)webView { | 4041 - (void)setWebView:(WKWebView*)webView { |
4049 DCHECK_NE(_webView.get(), webView); | 4042 DCHECK_NE(_webView, webView); |
4050 | 4043 |
4051 // Unwind the old web view. | 4044 // Unwind the old web view. |
4052 // TODO(eugenebut): Remove CRWWKScriptMessageRouter once crbug.com/543374 is | 4045 // TODO(eugenebut): Remove CRWWKScriptMessageRouter once crbug.com/543374 is |
4053 // fixed. | 4046 // fixed. |
4054 CRWWKScriptMessageRouter* messageRouter = | 4047 CRWWKScriptMessageRouter* messageRouter = |
4055 [self webViewConfigurationProvider].GetScriptMessageRouter(); | 4048 [self webViewConfigurationProvider].GetScriptMessageRouter(); |
4056 if (_webView) { | 4049 if (_webView) { |
4057 [messageRouter removeAllScriptMessageHandlersForWebView:_webView]; | 4050 [messageRouter removeAllScriptMessageHandlersForWebView:_webView]; |
4058 } | 4051 } |
4059 [_webView setNavigationDelegate:nil]; | 4052 [_webView setNavigationDelegate:nil]; |
4060 [_webView setUIDelegate:nil]; | 4053 [_webView setUIDelegate:nil]; |
4061 for (NSString* keyPath in self.WKWebViewObservers) { | 4054 for (NSString* keyPath in self.WKWebViewObservers) { |
4062 [_webView removeObserver:self forKeyPath:keyPath]; | 4055 [_webView removeObserver:self forKeyPath:keyPath]; |
4063 } | 4056 } |
4064 | 4057 |
4065 _webView.reset([webView retain]); | 4058 _webView = webView; |
4066 | 4059 |
4067 // Set up the new web view. | 4060 // Set up the new web view. |
4068 if (webView) { | 4061 if (webView) { |
4069 base::WeakNSObject<CRWWebController> weakSelf(self); | 4062 __weak CRWWebController* weakSelf = self; |
4070 [messageRouter setScriptMessageHandler:^(WKScriptMessage* message) { | 4063 [messageRouter setScriptMessageHandler:^(WKScriptMessage* message) { |
4071 [weakSelf didReceiveScriptMessage:message]; | 4064 [weakSelf didReceiveScriptMessage:message]; |
4072 } | 4065 } |
4073 name:kScriptMessageName | 4066 name:kScriptMessageName |
4074 webView:webView]; | 4067 webView:webView]; |
4075 _windowIDJSManager.reset( | 4068 _windowIDJSManager = [[CRWJSWindowIDManager alloc] initWithWebView:webView]; |
4076 [[CRWJSWindowIDManager alloc] initWithWebView:webView]); | |
4077 } else { | 4069 } else { |
4078 _windowIDJSManager.reset(); | 4070 _windowIDJSManager = nil; |
4079 } | 4071 } |
4080 [_webView setNavigationDelegate:self]; | 4072 [_webView setNavigationDelegate:self]; |
4081 [_webView setUIDelegate:self]; | 4073 [_webView setUIDelegate:self]; |
4082 for (NSString* keyPath in self.WKWebViewObservers) { | 4074 for (NSString* keyPath in self.WKWebViewObservers) { |
4083 [_webView addObserver:self forKeyPath:keyPath options:0 context:nullptr]; | 4075 [_webView addObserver:self forKeyPath:keyPath options:0 context:nullptr]; |
4084 } | 4076 } |
4085 _injectedScriptManagers.reset([[NSMutableSet alloc] init]); | 4077 _injectedScriptManagers = [[NSMutableSet alloc] init]; |
4086 [self setDocumentURL:_defaultURL]; | 4078 [self setDocumentURL:_defaultURL]; |
4087 } | 4079 } |
4088 | 4080 |
4089 - (void)displayWebView { | 4081 - (void)displayWebView { |
4090 if (!self.webView || [_containerView webViewContentView]) | 4082 if (!self.webView || [_containerView webViewContentView]) |
4091 return; | 4083 return; |
4092 | 4084 |
4093 // Add the web toolbars. | 4085 // Add the web toolbars. |
4094 [_containerView addToolbars:_webViewToolbars]; | 4086 [_containerView addToolbars:_webViewToolbars]; |
4095 | 4087 |
4096 base::scoped_nsobject<CRWWebViewContentView> webViewContentView( | 4088 CRWWebViewContentView* webViewContentView = |
4097 [[CRWWebViewContentView alloc] initWithWebView:_webView | 4089 [[CRWWebViewContentView alloc] initWithWebView:_webView |
4098 scrollView:self.webScrollView]); | 4090 scrollView:self.webScrollView]; |
4099 [_containerView displayWebViewContentView:webViewContentView]; | 4091 [_containerView displayWebViewContentView:webViewContentView]; |
4100 } | 4092 } |
4101 | 4093 |
4102 - (void)removeWebViewAllowingCachedReconstruction:(BOOL)allowCache { | 4094 - (void)removeWebViewAllowingCachedReconstruction:(BOOL)allowCache { |
4103 if (!_webView) | 4095 if (!_webView) |
4104 return; | 4096 return; |
4105 | 4097 |
4106 _webStateImpl->CancelDialogs(); | 4098 _webStateImpl->CancelDialogs(); |
4107 | 4099 |
4108 web::NavigationItem* item = self.currentNavItem; | 4100 web::NavigationItem* item = self.currentNavItem; |
(...skipping 22 matching lines...) Expand all Loading... | |
4131 | 4123 |
4132 - (WKNavigation*)loadRequest:(NSMutableURLRequest*)request { | 4124 - (WKNavigation*)loadRequest:(NSMutableURLRequest*)request { |
4133 WKNavigation* navigation = [_webView loadRequest:request]; | 4125 WKNavigation* navigation = [_webView loadRequest:request]; |
4134 [_navigationStates setState:web::WKNavigationState::REQUESTED | 4126 [_navigationStates setState:web::WKNavigationState::REQUESTED |
4135 forNavigation:navigation]; | 4127 forNavigation:navigation]; |
4136 return navigation; | 4128 return navigation; |
4137 } | 4129 } |
4138 | 4130 |
4139 - (WKNavigation*)loadPOSTRequest:(NSMutableURLRequest*)request { | 4131 - (WKNavigation*)loadPOSTRequest:(NSMutableURLRequest*)request { |
4140 if (!_POSTRequestLoader) { | 4132 if (!_POSTRequestLoader) { |
4141 _POSTRequestLoader.reset([[CRWJSPOSTRequestLoader alloc] init]); | 4133 _POSTRequestLoader = [[CRWJSPOSTRequestLoader alloc] init]; |
4142 } | 4134 } |
4143 | 4135 |
4144 CRWWKScriptMessageRouter* messageRouter = | 4136 CRWWKScriptMessageRouter* messageRouter = |
4145 [self webViewConfigurationProvider].GetScriptMessageRouter(); | 4137 [self webViewConfigurationProvider].GetScriptMessageRouter(); |
4146 | 4138 |
4147 return [_POSTRequestLoader | 4139 return [_POSTRequestLoader |
4148 loadPOSTRequest:request | 4140 loadPOSTRequest:request |
4149 inWebView:_webView | 4141 inWebView:_webView |
4150 messageRouter:messageRouter | 4142 messageRouter:messageRouter |
4151 completionHandler:^(NSError* loadError) { | 4143 completionHandler:^(NSError* loadError) { |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4192 - (void)loadHTML:(NSString*)HTML forAppSpecificURL:(const GURL&)URL { | 4184 - (void)loadHTML:(NSString*)HTML forAppSpecificURL:(const GURL&)URL { |
4193 CHECK(web::GetWebClient()->IsAppSpecificURL(URL)); | 4185 CHECK(web::GetWebClient()->IsAppSpecificURL(URL)); |
4194 [self loadHTML:HTML forURL:URL]; | 4186 [self loadHTML:HTML forURL:URL]; |
4195 } | 4187 } |
4196 | 4188 |
4197 - (void)loadHTMLForCurrentURL:(NSString*)HTML { | 4189 - (void)loadHTMLForCurrentURL:(NSString*)HTML { |
4198 [self loadHTML:HTML forURL:self.currentURL]; | 4190 [self loadHTML:HTML forURL:self.currentURL]; |
4199 } | 4191 } |
4200 | 4192 |
4201 - (void)stopLoading { | 4193 - (void)stopLoading { |
4202 _stoppedWKNavigation.reset([_navigationStates lastAddedNavigation]); | 4194 _stoppedWKNavigation = [_navigationStates lastAddedNavigation]; |
4203 | 4195 |
4204 base::RecordAction(UserMetricsAction("Stop")); | 4196 base::RecordAction(UserMetricsAction("Stop")); |
4205 // Discard the pending and transient entried before notifying the tab model | 4197 // Discard the pending and transient entried before notifying the tab model |
4206 // observers of the change via |-abortLoad|. | 4198 // observers of the change via |-abortLoad|. |
4207 [[self sessionController] discardNonCommittedItems]; | 4199 [[self sessionController] discardNonCommittedItems]; |
4208 [self abortLoad]; | 4200 [self abortLoad]; |
4209 web::NavigationItem* item = self.currentNavItem; | 4201 web::NavigationItem* item = self.currentNavItem; |
4210 GURL navigationURL = item ? item->GetVirtualURL() : GURL::EmptyGURL(); | 4202 GURL navigationURL = item ? item->GetVirtualURL() : GURL::EmptyGURL(); |
4211 // If discarding the non-committed entries results in an app-specific URL, | 4203 // If discarding the non-committed entries results in an app-specific URL, |
4212 // reload it in its native view. | 4204 // reload it in its native view. |
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4535 error = WKWebViewErrorWithSource(error, PROVISIONAL_LOAD); | 4527 error = WKWebViewErrorWithSource(error, PROVISIONAL_LOAD); |
4536 | 4528 |
4537 if (web::IsWKWebViewSSLCertError(error)) | 4529 if (web::IsWKWebViewSSLCertError(error)) |
4538 [self handleSSLCertError:error forNavigation:navigation]; | 4530 [self handleSSLCertError:error forNavigation:navigation]; |
4539 else | 4531 else |
4540 [self handleLoadError:error inMainFrame:YES forNavigation:navigation]; | 4532 [self handleLoadError:error inMainFrame:YES forNavigation:navigation]; |
4541 } | 4533 } |
4542 | 4534 |
4543 // This must be reset at the end, since code above may need information about | 4535 // This must be reset at the end, since code above may need information about |
4544 // the pending load. | 4536 // the pending load. |
4545 _pendingNavigationInfo.reset(); | 4537 _pendingNavigationInfo = nil; |
4546 _certVerificationErrors->Clear(); | 4538 _certVerificationErrors->Clear(); |
4547 [_navigationStates removeNavigation:navigation]; | 4539 [_navigationStates removeNavigation:navigation]; |
4548 } | 4540 } |
4549 | 4541 |
4550 - (void)webView:(WKWebView*)webView | 4542 - (void)webView:(WKWebView*)webView |
4551 didCommitNavigation:(WKNavigation*)navigation { | 4543 didCommitNavigation:(WKNavigation*)navigation { |
4552 [self displayWebView]; | 4544 [self displayWebView]; |
4553 | 4545 |
4554 // Record the navigation state. | 4546 // Record the navigation state. |
4555 [_navigationStates setState:web::WKNavigationState::COMMITTED | 4547 [_navigationStates setState:web::WKNavigationState::COMMITTED |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4593 NSString* storedMIMEType = | 4585 NSString* storedMIMEType = |
4594 [self currentBackForwardListItemHolder]->mime_type(); | 4586 [self currentBackForwardListItemHolder]->mime_type(); |
4595 if (storedMIMEType) { | 4587 if (storedMIMEType) { |
4596 self.webStateImpl->SetContentsMimeType( | 4588 self.webStateImpl->SetContentsMimeType( |
4597 base::SysNSStringToUTF8(storedMIMEType)); | 4589 base::SysNSStringToUTF8(storedMIMEType)); |
4598 } | 4590 } |
4599 } | 4591 } |
4600 | 4592 |
4601 // This point should closely approximate the document object change, so reset | 4593 // This point should closely approximate the document object change, so reset |
4602 // the list of injected scripts to those that are automatically injected. | 4594 // the list of injected scripts to those that are automatically injected. |
4603 _injectedScriptManagers.reset([[NSMutableSet alloc] init]); | 4595 _injectedScriptManagers = [[NSMutableSet alloc] init]; |
4604 if ([self contentIsHTML] || self.webState->GetContentsMimeType().empty()) { | 4596 if ([self contentIsHTML] || self.webState->GetContentsMimeType().empty()) { |
4605 // In unit tests MIME type will be empty, because loadHTML:forURL: does not | 4597 // In unit tests MIME type will be empty, because loadHTML:forURL: does not |
4606 // notify web view delegate about received response, so web controller does | 4598 // notify web view delegate about received response, so web controller does |
4607 // not get a chance to properly update MIME type. | 4599 // not get a chance to properly update MIME type. |
4608 [_windowIDJSManager inject]; | 4600 [_windowIDJSManager inject]; |
4609 } | 4601 } |
4610 | 4602 |
4611 if (isLastNavigation) { | 4603 if (isLastNavigation) { |
4612 [self webPageChanged]; | 4604 [self webPageChanged]; |
4613 } else { | 4605 } else { |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4687 } | 4679 } |
4688 | 4680 |
4689 if (![authMethod isEqual:NSURLAuthenticationMethodServerTrust]) { | 4681 if (![authMethod isEqual:NSURLAuthenticationMethodServerTrust]) { |
4690 completionHandler(NSURLSessionAuthChallengeRejectProtectionSpace, nil); | 4682 completionHandler(NSURLSessionAuthChallengeRejectProtectionSpace, nil); |
4691 return; | 4683 return; |
4692 } | 4684 } |
4693 | 4685 |
4694 SecTrustRef trust = challenge.protectionSpace.serverTrust; | 4686 SecTrustRef trust = challenge.protectionSpace.serverTrust; |
4695 base::ScopedCFTypeRef<SecTrustRef> scopedTrust(trust, | 4687 base::ScopedCFTypeRef<SecTrustRef> scopedTrust(trust, |
4696 base::scoped_policy::RETAIN); | 4688 base::scoped_policy::RETAIN); |
4697 base::WeakNSObject<CRWWebController> weakSelf(self); | 4689 __weak CRWWebController* weakSelf = self; |
4698 [_certVerificationController | 4690 [_certVerificationController |
4699 decideLoadPolicyForTrust:scopedTrust | 4691 decideLoadPolicyForTrust:scopedTrust |
4700 host:challenge.protectionSpace.host | 4692 host:challenge.protectionSpace.host |
4701 completionHandler:^(web::CertAcceptPolicy policy, | 4693 completionHandler:^(web::CertAcceptPolicy policy, |
4702 net::CertStatus status) { | 4694 net::CertStatus status) { |
4703 base::scoped_nsobject<CRWWebController> strongSelf( | 4695 CRWWebController* strongSelf = weakSelf; |
4704 [weakSelf retain]); | |
4705 if (!strongSelf) { | 4696 if (!strongSelf) { |
4706 completionHandler( | 4697 completionHandler( |
4707 NSURLSessionAuthChallengeRejectProtectionSpace, nil); | 4698 NSURLSessionAuthChallengeRejectProtectionSpace, nil); |
4708 return; | 4699 return; |
4709 } | 4700 } |
4710 [strongSelf processAuthChallenge:challenge | 4701 [strongSelf processAuthChallenge:challenge |
4711 forCertAcceptPolicy:policy | 4702 forCertAcceptPolicy:policy |
4712 certStatus:status | 4703 certStatus:status |
4713 completionHandler:completionHandler]; | 4704 completionHandler:completionHandler]; |
4714 }]; | 4705 }]; |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4765 | 4756 |
4766 #pragma mark - | 4757 #pragma mark - |
4767 #pragma mark KVO Observation | 4758 #pragma mark KVO Observation |
4768 | 4759 |
4769 - (void)observeValueForKeyPath:(NSString*)keyPath | 4760 - (void)observeValueForKeyPath:(NSString*)keyPath |
4770 ofObject:(id)object | 4761 ofObject:(id)object |
4771 change:(NSDictionary*)change | 4762 change:(NSDictionary*)change |
4772 context:(void*)context { | 4763 context:(void*)context { |
4773 NSString* dispatcherSelectorName = self.WKWebViewObservers[keyPath]; | 4764 NSString* dispatcherSelectorName = self.WKWebViewObservers[keyPath]; |
4774 DCHECK(dispatcherSelectorName); | 4765 DCHECK(dispatcherSelectorName); |
4775 if (dispatcherSelectorName) | 4766 if (dispatcherSelectorName) { |
4776 [self performSelector:NSSelectorFromString(dispatcherSelectorName)]; | 4767 // With ARC memory management, it is not known what a method called |
4768 // via a selector will return. If a method returns a retained value | |
4769 // (e.g. NS_RETURNS_RETAINED) that returned object will leak as ARC is | |
4770 // unable to property insert the correct release calls for it. | |
4771 // We know that all selectors used here return void and take no parameters | |
4772 // so we will manually call a function mapping to the method implementation. | |
4773 | |
4774 SEL selector = NSSelectorFromString(dispatcherSelectorName); | |
4775 IMP methodImplementation = [self methodForSelector:selector]; | |
4776 if (methodImplementation) { | |
4777 void (*methodCallFunction)(id, SEL) = | |
4778 (void (*)(id, SEL))methodImplementation; | |
4779 methodCallFunction(self, selector); | |
PL
2017/06/01 01:56:21
This is one manual piece of conversion work that m
| |
4780 } | |
4781 } | |
4777 } | 4782 } |
4778 | 4783 |
4779 - (void)webViewEstimatedProgressDidChange { | 4784 - (void)webViewEstimatedProgressDidChange { |
4780 if (!_isBeingDestroyed) { | 4785 if (!_isBeingDestroyed) { |
4781 self.webStateImpl->SendChangeLoadProgress([_webView estimatedProgress]); | 4786 self.webStateImpl->SendChangeLoadProgress([_webView estimatedProgress]); |
4782 } | 4787 } |
4783 } | 4788 } |
4784 | 4789 |
4785 - (void)webViewSecurityFeaturesDidChange { | 4790 - (void)webViewSecurityFeaturesDidChange { |
4786 if (self.loadPhase == web::LOAD_REQUESTED) { | 4791 if (self.loadPhase == web::LOAD_REQUESTED) { |
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5010 navigationContext->SetIsSameDocument(true); | 5015 navigationContext->SetIsSameDocument(true); |
5011 _webStateImpl->OnNavigationFinished(navigationContext); | 5016 _webStateImpl->OnNavigationFinished(navigationContext); |
5012 | 5017 |
5013 [self updateSSLStatusForCurrentNavigationItem]; | 5018 [self updateSSLStatusForCurrentNavigationItem]; |
5014 [self didFinishNavigation:nil]; | 5019 [self didFinishNavigation:nil]; |
5015 } | 5020 } |
5016 } | 5021 } |
5017 | 5022 |
5018 - (web::NavigationContextImpl*)contextForPendingNavigationWithURL: | 5023 - (web::NavigationContextImpl*)contextForPendingNavigationWithURL: |
5019 (const GURL&)URL { | 5024 (const GURL&)URL { |
5020 for (id navigation in [_navigationStates pendingNavigations]) { | 5025 for (__strong id navigation in [_navigationStates pendingNavigations]) { |
5021 if (navigation == [NSNull null]) { | 5026 if (navigation == [NSNull null]) { |
5022 // null is a valid navigation object passed to WKNavigationDelegate | 5027 // null is a valid navigation object passed to WKNavigationDelegate |
5023 // callbacks and represents window opening action. | 5028 // callbacks and represents window opening action. |
5024 navigation = nil; | 5029 navigation = nil; |
5025 } | 5030 } |
5026 | 5031 |
5027 web::NavigationContextImpl* context = | 5032 web::NavigationContextImpl* context = |
5028 [_navigationStates contextForNavigation:navigation]; | 5033 [_navigationStates contextForNavigation:navigation]; |
5029 if (context->GetUrl() == URL) { | 5034 if (context->GetUrl() == URL) { |
5030 return context; | 5035 return context; |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5140 | 5145 |
5141 if (!repostedForm || currentItem->ShouldSkipRepostFormConfirmation()) { | 5146 if (!repostedForm || currentItem->ShouldSkipRepostFormConfirmation()) { |
5142 webViewNavigationBlock(); | 5147 webViewNavigationBlock(); |
5143 return; | 5148 return; |
5144 } | 5149 } |
5145 | 5150 |
5146 // If the request is form submission or resubmission, then prompt the | 5151 // If the request is form submission or resubmission, then prompt the |
5147 // user before proceeding. | 5152 // user before proceeding. |
5148 DCHECK(repostedForm); | 5153 DCHECK(repostedForm); |
5149 _webStateImpl->ShowRepostFormWarningDialog( | 5154 _webStateImpl->ShowRepostFormWarningDialog( |
5150 base::BindBlock(^(bool shouldContinue) { | 5155 base::BindBlockArc(^(bool shouldContinue) { |
5151 if (shouldContinue) | 5156 if (shouldContinue) |
5152 webViewNavigationBlock(); | 5157 webViewNavigationBlock(); |
5153 else | 5158 else |
5154 [self stopLoading]; | 5159 [self stopLoading]; |
5155 })); | 5160 })); |
5156 } | 5161 } |
5157 | 5162 |
5158 - (void)reportBackForwardNavigationTypeForFastNavigation:(BOOL)isFast { | 5163 - (void)reportBackForwardNavigationTypeForFastNavigation:(BOOL)isFast { |
5159 // TODO(crbug.com/665189): Use NavigationManager::GetPendingItemIndex() once | 5164 // TODO(crbug.com/665189): Use NavigationManager::GetPendingItemIndex() once |
5160 // it returns correct result. | 5165 // it returns correct result. |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5196 } | 5201 } |
5197 | 5202 |
5198 - (void)addObserver:(id<CRWWebControllerObserver>)observer { | 5203 - (void)addObserver:(id<CRWWebControllerObserver>)observer { |
5199 DCHECK(observer); | 5204 DCHECK(observer); |
5200 if (!_observers) { | 5205 if (!_observers) { |
5201 // We don't want our observer set to block dealloc on the observers. For the | 5206 // We don't want our observer set to block dealloc on the observers. For the |
5202 // observer container, make an object compatible with NSMutableSet that does | 5207 // observer container, make an object compatible with NSMutableSet that does |
5203 // not perform retain or release on the contained objects (weak references). | 5208 // not perform retain or release on the contained objects (weak references). |
5204 CFSetCallBacks callbacks = | 5209 CFSetCallBacks callbacks = |
5205 {0, NULL, NULL, CFCopyDescription, CFEqual, CFHash}; | 5210 {0, NULL, NULL, CFCopyDescription, CFEqual, CFHash}; |
5206 _observers.reset(base::mac::CFToNSCast( | 5211 _observers = base::mac::CFToNSCast( |
5207 CFSetCreateMutable(kCFAllocatorDefault, 1, &callbacks))); | 5212 CFSetCreateMutable(kCFAllocatorDefault, 1, &callbacks)); |
5208 } | 5213 } |
5209 DCHECK(![_observers containsObject:observer]); | 5214 DCHECK(![_observers containsObject:observer]); |
5210 [_observers addObject:observer]; | 5215 [_observers addObject:observer]; |
5211 _observerBridges.push_back(base::MakeUnique<web::WebControllerObserverBridge>( | 5216 _observerBridges.push_back(base::MakeUnique<web::WebControllerObserverBridge>( |
5212 observer, self.webStateImpl, self)); | 5217 observer, self.webStateImpl, self)); |
5213 | 5218 |
5214 if ([observer respondsToSelector:@selector(setWebViewProxy:controller:)]) | 5219 if ([observer respondsToSelector:@selector(setWebViewProxy:controller:)]) |
5215 [observer setWebViewProxy:_webViewProxy controller:self]; | 5220 [observer setWebViewProxy:_webViewProxy controller:self]; |
5216 } | 5221 } |
5217 | 5222 |
(...skipping 14 matching lines...) Expand all Loading... | |
5232 - (NSUInteger)observerCount { | 5237 - (NSUInteger)observerCount { |
5233 DCHECK_EQ(_observerBridges.size(), [_observers count]); | 5238 DCHECK_EQ(_observerBridges.size(), [_observers count]); |
5234 return [_observers count]; | 5239 return [_observers count]; |
5235 } | 5240 } |
5236 | 5241 |
5237 - (NSString*)referrerFromNavigationAction:(WKNavigationAction*)action { | 5242 - (NSString*)referrerFromNavigationAction:(WKNavigationAction*)action { |
5238 return [action.request valueForHTTPHeaderField:kReferrerHeaderName]; | 5243 return [action.request valueForHTTPHeaderField:kReferrerHeaderName]; |
5239 } | 5244 } |
5240 | 5245 |
5241 @end | 5246 @end |
OLD | NEW |