Chromium Code Reviews| 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 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 271 // reconstruction that should use cache aggressively. | 271 // reconstruction that should use cache aggressively. |
| 272 GURL _expectedReconstructionURL; | 272 GURL _expectedReconstructionURL; |
| 273 // Whether the web page is currently performing window.history.pushState or | 273 // Whether the web page is currently performing window.history.pushState or |
| 274 // window.history.replaceState | 274 // window.history.replaceState |
| 275 // Set to YES on window.history.willChangeState message. To NO on | 275 // Set to YES on window.history.willChangeState message. To NO on |
| 276 // window.history.didPushState or window.history.didReplaceState. | 276 // window.history.didPushState or window.history.didReplaceState. |
| 277 BOOL _changingHistoryState; | 277 BOOL _changingHistoryState; |
| 278 | 278 |
| 279 std::unique_ptr<web::NewWindowInfo> _externalRequest; | 279 std::unique_ptr<web::NewWindowInfo> _externalRequest; |
| 280 | 280 |
| 281 // The WebStateImpl instance associated with this CRWWebController. | 281 // Unowned WebStateImpl instance associated with this CRWWebController. |
|
kkhorimoto
2016/04/12 21:36:13
"Unowned" seems kinda strangely worded. It would
Eugene But (OOO till 7-30)
2016/04/13 02:51:26
WC should not make any assumptions about it's owne
Eugene But (OOO till 7-30)
2016/04/13 13:57:58
Eliminated "unowned" word.
| |
| 282 std::unique_ptr<WebStateImpl> _webStateImpl; | 282 WebStateImpl* _webStateImpl; |
| 283 | 283 |
| 284 // A set of URLs opened in external applications; stored so that errors | 284 // A set of URLs opened in external applications; stored so that errors |
| 285 // from the web view can be identified as resulting from these events. | 285 // from the web view can be identified as resulting from these events. |
| 286 base::scoped_nsobject<NSMutableSet> _openedApplicationURL; | 286 base::scoped_nsobject<NSMutableSet> _openedApplicationURL; |
| 287 | 287 |
| 288 // Object that manages all early script injection into the web view. | 288 // Object that manages all early script injection into the web view. |
| 289 base::scoped_nsobject<CRWJSEarlyScriptManager> _earlyScriptManager; | 289 base::scoped_nsobject<CRWJSEarlyScriptManager> _earlyScriptManager; |
| 290 | 290 |
| 291 // Script manager for setting the windowID. | 291 // Script manager for setting the windowID. |
| 292 base::scoped_nsobject<CRWJSWindowIdManager> _windowIDJSManager; | 292 base::scoped_nsobject<CRWJSWindowIdManager> _windowIDJSManager; |
| (...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 590 + (instancetype)allocWithZone:(struct _NSZone*)zone { | 590 + (instancetype)allocWithZone:(struct _NSZone*)zone { |
| 591 if (self == [CRWWebController class]) { | 591 if (self == [CRWWebController class]) { |
| 592 // This is an abstract class which should not be instantiated directly. | 592 // This is an abstract class which should not be instantiated directly. |
| 593 // Callers should create concrete subclasses instead. | 593 // Callers should create concrete subclasses instead. |
| 594 NOTREACHED(); | 594 NOTREACHED(); |
| 595 return nil; | 595 return nil; |
| 596 } | 596 } |
| 597 return [super allocWithZone:zone]; | 597 return [super allocWithZone:zone]; |
| 598 } | 598 } |
| 599 | 599 |
| 600 - (instancetype)initWithWebState:(std::unique_ptr<WebStateImpl>)webState { | 600 - (instancetype)initWithWebState:(WebStateImpl*)webState { |
| 601 self = [super init]; | 601 self = [super init]; |
| 602 if (self) { | 602 if (self) { |
| 603 _webStateImpl = std::move(webState); | 603 _webStateImpl = webState; |
| 604 DCHECK(_webStateImpl); | 604 DCHECK(_webStateImpl); |
| 605 _webStateImpl->SetWebController(self); | |
| 606 _webStateImpl->InitializeRequestTracker(self); | 605 _webStateImpl->InitializeRequestTracker(self); |
| 607 // Load phase when no WebView present is 'loaded' because this represents | 606 // Load phase when no WebView present is 'loaded' because this represents |
| 608 // the idle state. | 607 // the idle state. |
| 609 _loadPhase = web::PAGE_LOADED; | 608 _loadPhase = web::PAGE_LOADED; |
| 610 // Content area is lazily instantiated. | 609 // Content area is lazily instantiated. |
| 611 _defaultURL = GURL(url::kAboutBlankURL); | 610 _defaultURL = GURL(url::kAboutBlankURL); |
| 612 _jsInjectionReceiver.reset( | 611 _jsInjectionReceiver.reset( |
| 613 [[CRWJSInjectionReceiver alloc] initWithEvaluator:self]); | 612 [[CRWJSInjectionReceiver alloc] initWithEvaluator:self]); |
| 614 _earlyScriptManager.reset([(CRWJSEarlyScriptManager*)[_jsInjectionReceiver | 613 _earlyScriptManager.reset([(CRWJSEarlyScriptManager*)[_jsInjectionReceiver |
| 615 instanceOfClass:[CRWJSEarlyScriptManager class]] retain]); | 614 instanceOfClass:[CRWJSEarlyScriptManager class]] retain]); |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 642 - (id<CRWSwipeRecognizerProvider>)swipeRecognizerProvider { | 641 - (id<CRWSwipeRecognizerProvider>)swipeRecognizerProvider { |
| 643 return _swipeRecognizerProvider.get(); | 642 return _swipeRecognizerProvider.get(); |
| 644 } | 643 } |
| 645 | 644 |
| 646 - (void)setSwipeRecognizerProvider: | 645 - (void)setSwipeRecognizerProvider: |
| 647 (id<CRWSwipeRecognizerProvider>)swipeRecognizerProvider { | 646 (id<CRWSwipeRecognizerProvider>)swipeRecognizerProvider { |
| 648 _swipeRecognizerProvider.reset(swipeRecognizerProvider); | 647 _swipeRecognizerProvider.reset(swipeRecognizerProvider); |
| 649 } | 648 } |
| 650 | 649 |
| 651 - (WebState*)webState { | 650 - (WebState*)webState { |
| 652 return _webStateImpl.get(); | 651 return _webStateImpl; |
| 653 } | 652 } |
| 654 | 653 |
| 655 - (WebStateImpl*)webStateImpl { | 654 - (WebStateImpl*)webStateImpl { |
| 656 return _webStateImpl.get(); | 655 return _webStateImpl; |
| 657 } | 656 } |
| 658 | 657 |
| 659 - (void)clearTransientContentView { | 658 - (void)clearTransientContentView { |
| 660 // Early return if there is no transient content view. | 659 // Early return if there is no transient content view. |
| 661 if (!self.containerView.transientContentView) | 660 if (!self.containerView.transientContentView) |
| 662 return; | 661 return; |
| 663 | 662 |
| 664 // Remove the transient content view from the hierarchy. | 663 // Remove the transient content view from the hierarchy. |
| 665 [self.containerView clearTransientContentView]; | 664 [self.containerView clearTransientContentView]; |
| 666 | 665 |
| (...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 889 | 888 |
| 890 DCHECK(!_isBeingDestroyed); | 889 DCHECK(!_isBeingDestroyed); |
| 891 DCHECK(!_delegate); // Delegate should reset its association before closing. | 890 DCHECK(!_delegate); // Delegate should reset its association before closing. |
| 892 // Mark the destruction sequence has started, in case someone else holds a | 891 // Mark the destruction sequence has started, in case someone else holds a |
| 893 // strong reference and tries to continue using the tab. | 892 // strong reference and tries to continue using the tab. |
| 894 _isBeingDestroyed = YES; | 893 _isBeingDestroyed = YES; |
| 895 | 894 |
| 896 // Remove the web view now. Otherwise, delegate callbacks occur. | 895 // Remove the web view now. Otherwise, delegate callbacks occur. |
| 897 [self removeWebViewAllowingCachedReconstruction:NO]; | 896 [self removeWebViewAllowingCachedReconstruction:NO]; |
| 898 | 897 |
| 899 // Tear down web ui (in case this is part of this tab) and web state now, | 898 _webStateImpl = nullptr; |
| 900 // since the timing of dealloc can't be guaranteed. | |
| 901 _webStateImpl.reset(); | |
| 902 } | 899 } |
| 903 | 900 |
| 904 - (void)checkLinkPresenceUnderGesture:(UIGestureRecognizer*)gestureRecognizer | 901 - (void)checkLinkPresenceUnderGesture:(UIGestureRecognizer*)gestureRecognizer |
| 905 completionHandler:(void (^)(BOOL))completionHandler { | 902 completionHandler:(void (^)(BOOL))completionHandler { |
| 906 CGPoint webViewPoint = [gestureRecognizer locationInView:self.webView]; | 903 CGPoint webViewPoint = [gestureRecognizer locationInView:self.webView]; |
| 907 base::WeakNSObject<CRWWebController> weakSelf(self); | 904 base::WeakNSObject<CRWWebController> weakSelf(self); |
| 908 [self | 905 [self |
| 909 fetchDOMElementAtPoint:webViewPoint | 906 fetchDOMElementAtPoint:webViewPoint |
| 910 completionHandler:^(std::unique_ptr<base::DictionaryValue> element) { | 907 completionHandler:^(std::unique_ptr<base::DictionaryValue> element) { |
| 911 std::string link; | 908 std::string link; |
| (...skipping 3165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4077 } | 4074 } |
| 4078 | 4075 |
| 4079 return web::WEB_VIEW_DOCUMENT_TYPE_GENERIC; | 4076 return web::WEB_VIEW_DOCUMENT_TYPE_GENERIC; |
| 4080 } | 4077 } |
| 4081 | 4078 |
| 4082 - (NSString*)refererFromNavigationAction:(WKNavigationAction*)action { | 4079 - (NSString*)refererFromNavigationAction:(WKNavigationAction*)action { |
| 4083 return [action.request valueForHTTPHeaderField:@"Referer"]; | 4080 return [action.request valueForHTTPHeaderField:@"Referer"]; |
| 4084 } | 4081 } |
| 4085 | 4082 |
| 4086 @end | 4083 @end |
| OLD | NEW |