Commit b57d396b authored by Ehimare Okoyomon's avatar Ehimare Okoyomon Committed by Commit Bot

Add RemoveObserver to CookieControlsHandler destructor

OnJavascriptDisallowed does not get called to remove the observer if
the incognito ntp tab is closed, which can result in a crash (see bug).
To fix this, add RemoveObserver call to the destructor.

Bug: 1058769
Change-Id: I18413d0ae54593adc032aa017f39f5787bd5bc31
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2088713
Commit-Queue: Ehimare Okoyomon <eokoyomon@chromium.org>
Reviewed-by: default avatarEvan Stade <estade@chromium.org>
Cr-Commit-Position: refs/heads/master@{#747692}
parent 3ec14816
...@@ -17,11 +17,12 @@ static const char* kSettingsIcon = "cr:settings_icon"; ...@@ -17,11 +17,12 @@ static const char* kSettingsIcon = "cr:settings_icon";
static const char* kPolicyIcon = "cr20:domain"; static const char* kPolicyIcon = "cr20:domain";
} // namespace } // namespace
CookieControlsHandler::CookieControlsHandler(Profile* profile) { CookieControlsHandler::CookieControlsHandler(Profile* profile)
service_ = CookieControlsServiceFactory::GetForProfile(profile); : service_(CookieControlsServiceFactory::GetForProfile(profile)) {}
}
CookieControlsHandler::~CookieControlsHandler() = default; CookieControlsHandler::~CookieControlsHandler() {
service_->RemoveObserver(this);
}
void CookieControlsHandler::RegisterMessages() { void CookieControlsHandler::RegisterMessages() {
web_ui()->RegisterMessageCallback( web_ui()->RegisterMessageCallback(
......
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