Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(241)

Side by Side Diff: ios/web/web_state/ui/crw_web_controller.mm

Issue 2854943003: [ios] Unregister CRWWebController delegates in -close. (Closed)
Patch Set: Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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>
(...skipping 1015 matching lines...) Expand 10 before | Expand all | Expand 10 after
1026 - (void)setDelegate:(id<CRWWebDelegate>)delegate { 1026 - (void)setDelegate:(id<CRWWebDelegate>)delegate {
1027 _delegate.reset(delegate); 1027 _delegate.reset(delegate);
1028 if ([self.nativeController respondsToSelector:@selector(setDelegate:)]) 1028 if ([self.nativeController respondsToSelector:@selector(setDelegate:)])
1029 [self.nativeController setDelegate:self]; 1029 [self.nativeController setDelegate:self];
1030 } 1030 }
1031 1031
1032 - (void)dealloc { 1032 - (void)dealloc {
1033 DCHECK([NSThread isMainThread]); 1033 DCHECK([NSThread isMainThread]);
1034 DCHECK(_isBeingDestroyed); // 'close' must have been called already. 1034 DCHECK(_isBeingDestroyed); // 'close' must have been called already.
1035 DCHECK(!_webView); 1035 DCHECK(!_webView);
1036 // TODO(crbug.com/662860): Don't set the delegate to nil.
1037 [_containerView setDelegate:nil];
1038 if ([self.nativeController respondsToSelector:@selector(setDelegate:)]) {
1039 [self.nativeController setDelegate:nil];
1040 }
1041 _touchTrackingRecognizer.get().touchTrackingDelegate = nil;
1042 [[_webViewProxy scrollViewProxy] removeObserver:self];
1043 [[NSNotificationCenter defaultCenter] removeObserver:self];
1044 [super dealloc]; 1036 [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 {
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
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;
1211
1212 DCHECK(!_webView);
1213 // TODO(crbug.com/662860): Don't set the delegate to nil.
1214 [_containerView setDelegate:nil];
1215 if ([self.nativeController respondsToSelector:@selector(setDelegate:)]) {
1216 [self.nativeController setDelegate:nil];
1217 }
1218 _touchTrackingRecognizer.get().touchTrackingDelegate = nil;
1219 [[_webViewProxy scrollViewProxy] removeObserver:self];
1220 [[NSNotificationCenter defaultCenter] removeObserver:self];
1219 } 1221 }
1220 1222
1221 // TODO(shreyasv): This code is shared with SnapshotManager. Remove this and add 1223 // TODO(shreyasv): This code is shared with SnapshotManager. Remove this and add
1222 // it as part of WebDelegate delegate API such that a default image is returned 1224 // it as part of WebDelegate delegate API such that a default image is returned
1223 // immediately. 1225 // immediately.
1224 + (UIImage*)defaultSnapshotImage { 1226 + (UIImage*)defaultSnapshotImage {
1225 static UIImage* defaultImage = nil; 1227 static UIImage* defaultImage = nil;
1226 1228
1227 if (!defaultImage) { 1229 if (!defaultImage) {
1228 CGRect frame = CGRectMake(0, 0, 2, 2); 1230 CGRect frame = CGRectMake(0, 0, 2, 2);
(...skipping 3834 matching lines...) Expand 10 before | Expand all | Expand 10 after
5063 - (NSUInteger)observerCount { 5065 - (NSUInteger)observerCount {
5064 DCHECK_EQ(_observerBridges.size(), [_observers count]); 5066 DCHECK_EQ(_observerBridges.size(), [_observers count]);
5065 return [_observers count]; 5067 return [_observers count];
5066 } 5068 }
5067 5069
5068 - (NSString*)referrerFromNavigationAction:(WKNavigationAction*)action { 5070 - (NSString*)referrerFromNavigationAction:(WKNavigationAction*)action {
5069 return [action.request valueForHTTPHeaderField:kReferrerHeaderName]; 5071 return [action.request valueForHTTPHeaderField:kReferrerHeaderName];
5070 } 5072 }
5071 5073
5072 @end 5074 @end
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698