Commit 5f6d548a authored by Scott Wu's avatar Scott Wu Committed by Commit Bot

Remove the public detach method from password controller.

Please see detail description in the bug.

Bug: 875176
Cq-Include-Trybots: luci.chromium.try:ios-simulator-full-configs;master.tryserver.chromium.mac:ios-simulator-cronet
Change-Id: Ib6c09079db1475deca5983a929335eda6e1bf1b3
Reviewed-on: https://chromium-review.googlesource.com/1179546Reviewed-by: default avatarVasilii Sukhanov <vasilii@chromium.org>
Reviewed-by: default avatarHiroshi Ichikawa <ichikawa@chromium.org>
Commit-Queue: Scott Wu <scottwu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#584397}
parent b94686b1
...@@ -78,10 +78,6 @@ class PasswordManagerDriver; ...@@ -78,10 +78,6 @@ class PasswordManagerDriver;
- (instancetype)init NS_UNAVAILABLE; - (instancetype)init NS_UNAVAILABLE;
// Releases all tab-specific members. Must be called when the Tab is closing,
// otherwise invalid memory might be accessed during destruction.
- (void)detach;
@end @end
#endif // IOS_CHROME_BROWSER_PASSWORDS_PASSWORD_CONTROLLER_H_ #endif // IOS_CHROME_BROWSER_PASSWORDS_PASSWORD_CONTROLLER_H_
...@@ -112,9 +112,6 @@ void LogSuggestionShown(PasswordSuggestionType type) { ...@@ -112,9 +112,6 @@ void LogSuggestionShown(PasswordSuggestionType type) {
@interface PasswordController () @interface PasswordController ()
// This is set to YES as soon as the associated WebState is destroyed.
@property(readonly) BOOL isWebStateDestroyed;
// View controller for auto sign-in notification, owned by this // View controller for auto sign-in notification, owned by this
// PasswordController. // PasswordController.
@property(nonatomic, strong) @property(nonatomic, strong)
...@@ -281,8 +278,6 @@ bool GetPageURLAndCheckTrustLevel(web::WebState* web_state, GURL* page_url) { ...@@ -281,8 +278,6 @@ bool GetPageURLAndCheckTrustLevel(web::WebState* web_state, GURL* page_url) {
formActivityObserverBridge_; formActivityObserverBridge_;
} }
@synthesize isWebStateDestroyed = _isWebStateDestroyed;
@synthesize baseViewController = _baseViewController; @synthesize baseViewController = _baseViewController;
@synthesize dispatcher = _dispatcher; @synthesize dispatcher = _dispatcher;
...@@ -342,13 +337,9 @@ bool GetPageURLAndCheckTrustLevel(web::WebState* web_state, GURL* page_url) { ...@@ -342,13 +337,9 @@ bool GetPageURLAndCheckTrustLevel(web::WebState* web_state, GURL* page_url) {
} }
- (void)dealloc { - (void)dealloc {
[self detach];
if (webState_) { if (webState_) {
formActivityObserverBridge_.reset(); webState_->RemoveScriptCommandCallback(kCommandPrefix);
webState_->RemoveObserver(webStateObserverBridge_.get()); webState_->RemoveObserver(webStateObserverBridge_.get());
webStateObserverBridge_.reset();
webState_ = nullptr;
} }
} }
...@@ -362,21 +353,6 @@ bool GetPageURLAndCheckTrustLevel(web::WebState* web_state, GURL* page_url) { ...@@ -362,21 +353,6 @@ bool GetPageURLAndCheckTrustLevel(web::WebState* web_state, GURL* page_url) {
return webState_ ? webState_->GetLastCommittedURL() : GURL::EmptyGURL(); return webState_ ? webState_->GetLastCommittedURL() : GURL::EmptyGURL();
} }
- (void)detach {
if (webState_) {
formActivityObserverBridge_.reset();
webState_->RemoveScriptCommandCallback(kCommandPrefix);
webState_->RemoveObserver(webStateObserverBridge_.get());
webStateObserverBridge_.reset();
webState_ = nullptr;
}
passwordManagerDriver_.reset();
passwordManager_.reset();
passwordManagerClient_.reset();
credentialManager_.reset();
}
#pragma mark - #pragma mark -
#pragma mark Properties #pragma mark Properties
...@@ -424,8 +400,7 @@ bool GetPageURLAndCheckTrustLevel(web::WebState* web_state, GURL* page_url) { ...@@ -424,8 +400,7 @@ bool GetPageURLAndCheckTrustLevel(web::WebState* web_state, GURL* page_url) {
// TODO(crbug.com/418827): Fix this by passing in more data from the JS side. // TODO(crbug.com/418827): Fix this by passing in more data from the JS side.
id completionHandler = ^(BOOL found, const autofill::PasswordForm& form) { id completionHandler = ^(BOOL found, const autofill::PasswordForm& form) {
PasswordController* strongSelf = weakSelf; PasswordController* strongSelf = weakSelf;
if (!strongSelf || [strongSelf isWebStateDestroyed] || if (!strongSelf || !strongSelf->webState_ || !strongSelf.passwordManager) {
!strongSelf.passwordManager) {
return; return;
} }
if (formInMainFrame) { if (formInMainFrame) {
...@@ -492,8 +467,17 @@ bool GetPageURLAndCheckTrustLevel(web::WebState* web_state, GURL* page_url) { ...@@ -492,8 +467,17 @@ bool GetPageURLAndCheckTrustLevel(web::WebState* web_state, GURL* page_url) {
- (void)webStateDestroyed:(web::WebState*)webState { - (void)webStateDestroyed:(web::WebState*)webState {
DCHECK_EQ(webState_, webState); DCHECK_EQ(webState_, webState);
_isWebStateDestroyed = YES; if (webState_) {
[self detach]; formActivityObserverBridge_.reset();
webState_->RemoveScriptCommandCallback(kCommandPrefix);
webState_->RemoveObserver(webStateObserverBridge_.get());
webStateObserverBridge_.reset();
webState_ = nullptr;
}
passwordManagerDriver_.reset();
passwordManager_.reset();
passwordManagerClient_.reset();
credentialManager_.reset();
} }
#pragma mark - Private methods. #pragma mark - Private methods.
...@@ -866,7 +850,7 @@ bool GetPageURLAndCheckTrustLevel(web::WebState* web_state, GURL* page_url) { ...@@ -866,7 +850,7 @@ bool GetPageURLAndCheckTrustLevel(web::WebState* web_state, GURL* page_url) {
if (!form) if (!form)
return NO; return NO;
if (![self isWebStateDestroyed]) { if (webState_) {
self.passwordManager->OnPasswordFormSubmitted(self.passwordManagerDriver, self.passwordManager->OnPasswordFormSubmitted(self.passwordManagerDriver,
*form); *form);
return YES; return YES;
......
...@@ -1159,7 +1159,6 @@ TEST_F(PasswordControllerTestSimple, SaveOnNonHTMLLandingPage) { ...@@ -1159,7 +1159,6 @@ TEST_F(PasswordControllerTestSimple, SaveOnNonHTMLLandingPage) {
web_state.SetContentIsHTML(false); web_state.SetContentIsHTML(false);
web_state.SetCurrentURL(GURL("https://example.com")); web_state.SetCurrentURL(GURL("https://example.com"));
[passwordController webState:&web_state didLoadPageWithSuccess:YES]; [passwordController webState:&web_state didLoadPageWithSuccess:YES];
[passwordController detach];
} }
// Tests that an HTTP page without a password field does not update the SSL // Tests that an HTTP page without a password field does not update the SSL
......
...@@ -54,6 +54,5 @@ PasswordTabHelper::PasswordTabHelper(web::WebState* web_state) ...@@ -54,6 +54,5 @@ PasswordTabHelper::PasswordTabHelper(web::WebState* web_state)
void PasswordTabHelper::WebStateDestroyed(web::WebState* web_state) { void PasswordTabHelper::WebStateDestroyed(web::WebState* web_state) {
web_state->RemoveObserver(this); web_state->RemoveObserver(this);
[controller_ detach];
controller_ = nil; controller_ = nil;
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment