| 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 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 270 // reconstruction that should use cache aggressively. | 270 // reconstruction that should use cache aggressively. |
| 271 GURL _expectedReconstructionURL; | 271 GURL _expectedReconstructionURL; |
| 272 // Whether the web page is currently performing window.history.pushState or | 272 // Whether the web page is currently performing window.history.pushState or |
| 273 // window.history.replaceState | 273 // window.history.replaceState |
| 274 // Set to YES on window.history.willChangeState message. To NO on | 274 // Set to YES on window.history.willChangeState message. To NO on |
| 275 // window.history.didPushState or window.history.didReplaceState. | 275 // window.history.didPushState or window.history.didReplaceState. |
| 276 BOOL _changingHistoryState; | 276 BOOL _changingHistoryState; |
| 277 | 277 |
| 278 std::unique_ptr<web::NewWindowInfo> _externalRequest; | 278 std::unique_ptr<web::NewWindowInfo> _externalRequest; |
| 279 | 279 |
| 280 // The WebStateImpl instance associated with this CRWWebController. | 280 // Unowned WebStateImpl instance associated with this CRWWebController. |
| 281 std::unique_ptr<WebStateImpl> _webStateImpl; | 281 WebStateImpl* _webStateImpl; |
| 282 | 282 |
| 283 // A set of URLs opened in external applications; stored so that errors | 283 // A set of URLs opened in external applications; stored so that errors |
| 284 // from the web view can be identified as resulting from these events. | 284 // from the web view can be identified as resulting from these events. |
| 285 base::scoped_nsobject<NSMutableSet> _openedApplicationURL; | 285 base::scoped_nsobject<NSMutableSet> _openedApplicationURL; |
| 286 | 286 |
| 287 // Object that manages all early script injection into the web view. | 287 // Object that manages all early script injection into the web view. |
| 288 base::scoped_nsobject<CRWJSEarlyScriptManager> _earlyScriptManager; | 288 base::scoped_nsobject<CRWJSEarlyScriptManager> _earlyScriptManager; |
| 289 | 289 |
| 290 // Script manager for setting the windowID. | 290 // Script manager for setting the windowID. |
| 291 base::scoped_nsobject<CRWJSWindowIdManager> _windowIDJSManager; | 291 base::scoped_nsobject<CRWJSWindowIdManager> _windowIDJSManager; |
| (...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 571 + (instancetype)allocWithZone:(struct _NSZone*)zone { | 571 + (instancetype)allocWithZone:(struct _NSZone*)zone { |
| 572 if (self == [CRWWebController class]) { | 572 if (self == [CRWWebController class]) { |
| 573 // This is an abstract class which should not be instantiated directly. | 573 // This is an abstract class which should not be instantiated directly. |
| 574 // Callers should create concrete subclasses instead. | 574 // Callers should create concrete subclasses instead. |
| 575 NOTREACHED(); | 575 NOTREACHED(); |
| 576 return nil; | 576 return nil; |
| 577 } | 577 } |
| 578 return [super allocWithZone:zone]; | 578 return [super allocWithZone:zone]; |
| 579 } | 579 } |
| 580 | 580 |
| 581 - (instancetype)initWithWebState:(std::unique_ptr<WebStateImpl>)webState { | 581 - (instancetype)initWithWebState:(WebStateImpl*)webState { |
| 582 self = [super init]; | 582 self = [super init]; |
| 583 if (self) { | 583 if (self) { |
| 584 _webStateImpl = std::move(webState); | 584 _webStateImpl = webState; |
| 585 DCHECK(_webStateImpl); | 585 DCHECK(_webStateImpl); |
| 586 _webStateImpl->SetWebController(self); | |
| 587 _webStateImpl->InitializeRequestTracker(self); | 586 _webStateImpl->InitializeRequestTracker(self); |
| 588 // Load phase when no WebView present is 'loaded' because this represents | 587 // Load phase when no WebView present is 'loaded' because this represents |
| 589 // the idle state. | 588 // the idle state. |
| 590 _loadPhase = web::PAGE_LOADED; | 589 _loadPhase = web::PAGE_LOADED; |
| 591 // Content area is lazily instantiated. | 590 // Content area is lazily instantiated. |
| 592 _defaultURL = GURL(url::kAboutBlankURL); | 591 _defaultURL = GURL(url::kAboutBlankURL); |
| 593 _jsInjectionReceiver.reset( | 592 _jsInjectionReceiver.reset( |
| 594 [[CRWJSInjectionReceiver alloc] initWithEvaluator:self]); | 593 [[CRWJSInjectionReceiver alloc] initWithEvaluator:self]); |
| 595 _earlyScriptManager.reset([(CRWJSEarlyScriptManager*)[_jsInjectionReceiver | 594 _earlyScriptManager.reset([(CRWJSEarlyScriptManager*)[_jsInjectionReceiver |
| 596 instanceOfClass:[CRWJSEarlyScriptManager class]] retain]); | 595 instanceOfClass:[CRWJSEarlyScriptManager class]] retain]); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 623 - (id<CRWSwipeRecognizerProvider>)swipeRecognizerProvider { | 622 - (id<CRWSwipeRecognizerProvider>)swipeRecognizerProvider { |
| 624 return _swipeRecognizerProvider.get(); | 623 return _swipeRecognizerProvider.get(); |
| 625 } | 624 } |
| 626 | 625 |
| 627 - (void)setSwipeRecognizerProvider: | 626 - (void)setSwipeRecognizerProvider: |
| 628 (id<CRWSwipeRecognizerProvider>)swipeRecognizerProvider { | 627 (id<CRWSwipeRecognizerProvider>)swipeRecognizerProvider { |
| 629 _swipeRecognizerProvider.reset(swipeRecognizerProvider); | 628 _swipeRecognizerProvider.reset(swipeRecognizerProvider); |
| 630 } | 629 } |
| 631 | 630 |
| 632 - (WebState*)webState { | 631 - (WebState*)webState { |
| 633 return _webStateImpl.get(); | 632 return _webStateImpl; |
| 634 } | 633 } |
| 635 | 634 |
| 636 - (WebStateImpl*)webStateImpl { | 635 - (WebStateImpl*)webStateImpl { |
| 637 return _webStateImpl.get(); | 636 return _webStateImpl; |
| 638 } | 637 } |
| 639 | 638 |
| 640 - (void)clearTransientContentView { | 639 - (void)clearTransientContentView { |
| 641 // Early return if there is no transient content view. | 640 // Early return if there is no transient content view. |
| 642 if (!self.containerView.transientContentView) | 641 if (!self.containerView.transientContentView) |
| 643 return; | 642 return; |
| 644 | 643 |
| 645 // Remove the transient content view from the hierarchy. | 644 // Remove the transient content view from the hierarchy. |
| 646 [self.containerView clearTransientContentView]; | 645 [self.containerView clearTransientContentView]; |
| 647 | 646 |
| (...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 866 | 865 |
| 867 DCHECK(!_isBeingDestroyed); | 866 DCHECK(!_isBeingDestroyed); |
| 868 DCHECK(!_delegate); // Delegate should reset its association before closing. | 867 DCHECK(!_delegate); // Delegate should reset its association before closing. |
| 869 // Mark the destruction sequence has started, in case someone else holds a | 868 // Mark the destruction sequence has started, in case someone else holds a |
| 870 // strong reference and tries to continue using the tab. | 869 // strong reference and tries to continue using the tab. |
| 871 _isBeingDestroyed = YES; | 870 _isBeingDestroyed = YES; |
| 872 | 871 |
| 873 // Remove the web view now. Otherwise, delegate callbacks occur. | 872 // Remove the web view now. Otherwise, delegate callbacks occur. |
| 874 [self removeWebViewAllowingCachedReconstruction:NO]; | 873 [self removeWebViewAllowingCachedReconstruction:NO]; |
| 875 | 874 |
| 876 // Tear down web ui (in case this is part of this tab) and web state now, | 875 _webStateImpl = nullptr; |
| 877 // since the timing of dealloc can't be guaranteed. | |
| 878 _webStateImpl.reset(); | |
| 879 } | 876 } |
| 880 | 877 |
| 881 - (void)checkLinkPresenceUnderGesture:(UIGestureRecognizer*)gestureRecognizer | 878 - (void)checkLinkPresenceUnderGesture:(UIGestureRecognizer*)gestureRecognizer |
| 882 completionHandler:(void (^)(BOOL))completionHandler { | 879 completionHandler:(void (^)(BOOL))completionHandler { |
| 883 CGPoint webViewPoint = [gestureRecognizer locationInView:self.webView]; | 880 CGPoint webViewPoint = [gestureRecognizer locationInView:self.webView]; |
| 884 base::WeakNSObject<CRWWebController> weakSelf(self); | 881 base::WeakNSObject<CRWWebController> weakSelf(self); |
| 885 [self | 882 [self |
| 886 fetchDOMElementAtPoint:webViewPoint | 883 fetchDOMElementAtPoint:webViewPoint |
| 887 completionHandler:^(std::unique_ptr<base::DictionaryValue> element) { | 884 completionHandler:^(std::unique_ptr<base::DictionaryValue> element) { |
| 888 std::string link; | 885 std::string link; |
| (...skipping 3062 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3951 if ([MIMEType isEqualToString:@"text/html"] || | 3948 if ([MIMEType isEqualToString:@"text/html"] || |
| 3952 [MIMEType isEqualToString:@"application/xhtml+xml"] || | 3949 [MIMEType isEqualToString:@"application/xhtml+xml"] || |
| 3953 [MIMEType isEqualToString:@"application/xml"]) { | 3950 [MIMEType isEqualToString:@"application/xml"]) { |
| 3954 return web::WEB_VIEW_DOCUMENT_TYPE_HTML; | 3951 return web::WEB_VIEW_DOCUMENT_TYPE_HTML; |
| 3955 } | 3952 } |
| 3956 | 3953 |
| 3957 return web::WEB_VIEW_DOCUMENT_TYPE_GENERIC; | 3954 return web::WEB_VIEW_DOCUMENT_TYPE_GENERIC; |
| 3958 } | 3955 } |
| 3959 | 3956 |
| 3960 @end | 3957 @end |
| OLD | NEW |