| 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 <objc/runtime.h> | 7 #import <objc/runtime.h> |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 | 9 |
| 10 #include <cmath> | 10 #include <cmath> |
| (...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 287 // Whether the web page is currently performing window.history.pushState or | 287 // Whether the web page is currently performing window.history.pushState or |
| 288 // window.history.replaceState | 288 // window.history.replaceState |
| 289 // Set to YES on window.history.willChangeState message. To NO on | 289 // Set to YES on window.history.willChangeState message. To NO on |
| 290 // window.history.didPushState or window.history.didReplaceState. | 290 // window.history.didPushState or window.history.didReplaceState. |
| 291 BOOL _changingHistoryState; | 291 BOOL _changingHistoryState; |
| 292 // YES if the web process backing _wkWebView is believed to currently be dead. | 292 // YES if the web process backing _wkWebView is believed to currently be dead. |
| 293 BOOL _webProcessIsDead; | 293 BOOL _webProcessIsDead; |
| 294 | 294 |
| 295 std::unique_ptr<web::NewWindowInfo> _externalRequest; | 295 std::unique_ptr<web::NewWindowInfo> _externalRequest; |
| 296 | 296 |
| 297 // The WebStateImpl instance associated with this CRWWebController. | 297 // WebStateImpl instance associated with this CRWWebController, web controller |
| 298 std::unique_ptr<WebStateImpl> _webStateImpl; | 298 // does not own this pointer. |
| 299 WebStateImpl* _webStateImpl; |
| 299 | 300 |
| 300 // A set of URLs opened in external applications; stored so that errors | 301 // A set of URLs opened in external applications; stored so that errors |
| 301 // from the web view can be identified as resulting from these events. | 302 // from the web view can be identified as resulting from these events. |
| 302 base::scoped_nsobject<NSMutableSet> _openedApplicationURL; | 303 base::scoped_nsobject<NSMutableSet> _openedApplicationURL; |
| 303 | 304 |
| 304 // Object that manages all early script injection into the web view. | 305 // Object that manages all early script injection into the web view. |
| 305 base::scoped_nsobject<CRWJSEarlyScriptManager> _earlyScriptManager; | 306 base::scoped_nsobject<CRWJSEarlyScriptManager> _earlyScriptManager; |
| 306 | 307 |
| 307 // A set of script managers whose scripts have been injected into the current | 308 // A set of script managers whose scripts have been injected into the current |
| 308 // page. | 309 // page. |
| (...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 626 + (instancetype)allocWithZone:(struct _NSZone*)zone { | 627 + (instancetype)allocWithZone:(struct _NSZone*)zone { |
| 627 if (self == [CRWWebController class]) { | 628 if (self == [CRWWebController class]) { |
| 628 // This is an abstract class which should not be instantiated directly. | 629 // This is an abstract class which should not be instantiated directly. |
| 629 // Callers should create concrete subclasses instead. | 630 // Callers should create concrete subclasses instead. |
| 630 NOTREACHED(); | 631 NOTREACHED(); |
| 631 return nil; | 632 return nil; |
| 632 } | 633 } |
| 633 return [super allocWithZone:zone]; | 634 return [super allocWithZone:zone]; |
| 634 } | 635 } |
| 635 | 636 |
| 636 - (instancetype)initWithWebState:(std::unique_ptr<WebStateImpl>)webState { | 637 - (instancetype)initWithWebState:(WebStateImpl*)webState { |
| 637 self = [super init]; | 638 self = [super init]; |
| 638 if (self) { | 639 if (self) { |
| 639 _webStateImpl = std::move(webState); | 640 _webStateImpl = webState; |
| 640 DCHECK(_webStateImpl); | 641 DCHECK(_webStateImpl); |
| 641 _webStateImpl->SetWebController(self); | |
| 642 _webStateImpl->InitializeRequestTracker(self); | 642 _webStateImpl->InitializeRequestTracker(self); |
| 643 // Load phase when no WebView present is 'loaded' because this represents | 643 // Load phase when no WebView present is 'loaded' because this represents |
| 644 // the idle state. | 644 // the idle state. |
| 645 _loadPhase = web::PAGE_LOADED; | 645 _loadPhase = web::PAGE_LOADED; |
| 646 // Content area is lazily instantiated. | 646 // Content area is lazily instantiated. |
| 647 _defaultURL = GURL(url::kAboutBlankURL); | 647 _defaultURL = GURL(url::kAboutBlankURL); |
| 648 _jsInjectionReceiver.reset( | 648 _jsInjectionReceiver.reset( |
| 649 [[CRWJSInjectionReceiver alloc] initWithEvaluator:self]); | 649 [[CRWJSInjectionReceiver alloc] initWithEvaluator:self]); |
| 650 _earlyScriptManager.reset([(CRWJSEarlyScriptManager*)[_jsInjectionReceiver | 650 _earlyScriptManager.reset([(CRWJSEarlyScriptManager*)[_jsInjectionReceiver |
| 651 instanceOfClass:[CRWJSEarlyScriptManager class]] retain]); | 651 instanceOfClass:[CRWJSEarlyScriptManager class]] retain]); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 678 - (id<CRWSwipeRecognizerProvider>)swipeRecognizerProvider { | 678 - (id<CRWSwipeRecognizerProvider>)swipeRecognizerProvider { |
| 679 return _swipeRecognizerProvider.get(); | 679 return _swipeRecognizerProvider.get(); |
| 680 } | 680 } |
| 681 | 681 |
| 682 - (void)setSwipeRecognizerProvider: | 682 - (void)setSwipeRecognizerProvider: |
| 683 (id<CRWSwipeRecognizerProvider>)swipeRecognizerProvider { | 683 (id<CRWSwipeRecognizerProvider>)swipeRecognizerProvider { |
| 684 _swipeRecognizerProvider.reset(swipeRecognizerProvider); | 684 _swipeRecognizerProvider.reset(swipeRecognizerProvider); |
| 685 } | 685 } |
| 686 | 686 |
| 687 - (WebState*)webState { | 687 - (WebState*)webState { |
| 688 return _webStateImpl.get(); | 688 return _webStateImpl; |
| 689 } | 689 } |
| 690 | 690 |
| 691 - (WebStateImpl*)webStateImpl { | 691 - (WebStateImpl*)webStateImpl { |
| 692 return _webStateImpl.get(); | 692 return _webStateImpl; |
| 693 } | 693 } |
| 694 | 694 |
| 695 - (void)clearTransientContentView { | 695 - (void)clearTransientContentView { |
| 696 // Early return if there is no transient content view. | 696 // Early return if there is no transient content view. |
| 697 if (!self.containerView.transientContentView) | 697 if (!self.containerView.transientContentView) |
| 698 return; | 698 return; |
| 699 | 699 |
| 700 // Remove the transient content view from the hierarchy. | 700 // Remove the transient content view from the hierarchy. |
| 701 [self.containerView clearTransientContentView]; | 701 [self.containerView clearTransientContentView]; |
| 702 | 702 |
| (...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 933 | 933 |
| 934 DCHECK(!_isBeingDestroyed); | 934 DCHECK(!_isBeingDestroyed); |
| 935 DCHECK(!_delegate); // Delegate should reset its association before closing. | 935 DCHECK(!_delegate); // Delegate should reset its association before closing. |
| 936 // Mark the destruction sequence has started, in case someone else holds a | 936 // Mark the destruction sequence has started, in case someone else holds a |
| 937 // strong reference and tries to continue using the tab. | 937 // strong reference and tries to continue using the tab. |
| 938 _isBeingDestroyed = YES; | 938 _isBeingDestroyed = YES; |
| 939 | 939 |
| 940 // Remove the web view now. Otherwise, delegate callbacks occur. | 940 // Remove the web view now. Otherwise, delegate callbacks occur. |
| 941 [self removeWebViewAllowingCachedReconstruction:NO]; | 941 [self removeWebViewAllowingCachedReconstruction:NO]; |
| 942 | 942 |
| 943 // Tear down web ui (in case this is part of this tab) and web state now, | 943 _webStateImpl = nullptr; |
| 944 // since the timing of dealloc can't be guaranteed. | |
| 945 _webStateImpl.reset(); | |
| 946 } | 944 } |
| 947 | 945 |
| 948 - (void)checkLinkPresenceUnderGesture:(UIGestureRecognizer*)gestureRecognizer | 946 - (void)checkLinkPresenceUnderGesture:(UIGestureRecognizer*)gestureRecognizer |
| 949 completionHandler:(void (^)(BOOL))completionHandler { | 947 completionHandler:(void (^)(BOOL))completionHandler { |
| 950 CGPoint webViewPoint = [gestureRecognizer locationInView:self.webView]; | 948 CGPoint webViewPoint = [gestureRecognizer locationInView:self.webView]; |
| 951 base::WeakNSObject<CRWWebController> weakSelf(self); | 949 base::WeakNSObject<CRWWebController> weakSelf(self); |
| 952 [self | 950 [self |
| 953 fetchDOMElementAtPoint:webViewPoint | 951 fetchDOMElementAtPoint:webViewPoint |
| 954 completionHandler:^(std::unique_ptr<base::DictionaryValue> element) { | 952 completionHandler:^(std::unique_ptr<base::DictionaryValue> element) { |
| 955 std::string link; | 953 std::string link; |
| (...skipping 3612 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4568 } | 4566 } |
| 4569 | 4567 |
| 4570 return web::WEB_VIEW_DOCUMENT_TYPE_GENERIC; | 4568 return web::WEB_VIEW_DOCUMENT_TYPE_GENERIC; |
| 4571 } | 4569 } |
| 4572 | 4570 |
| 4573 - (NSString*)refererFromNavigationAction:(WKNavigationAction*)action { | 4571 - (NSString*)refererFromNavigationAction:(WKNavigationAction*)action { |
| 4574 return [action.request valueForHTTPHeaderField:@"Referer"]; | 4572 return [action.request valueForHTTPHeaderField:@"Referer"]; |
| 4575 } | 4573 } |
| 4576 | 4574 |
| 4577 @end | 4575 @end |
| OLD | NEW |