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

Unified Diff: chrome/browser/ui/webui/settings/profile_info_handler.cc

Issue 1942323002: Fix a used-after-free caused by an unremoved Observer. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address feedback Created 4 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/webui/settings/profile_info_handler.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/webui/settings/profile_info_handler.cc
diff --git a/chrome/browser/ui/webui/settings/profile_info_handler.cc b/chrome/browser/ui/webui/settings/profile_info_handler.cc
index 6116ba9b8aedec4a31da8dd053f9bbe8523dda62..c3b0de8a66be9a35e9db36343d7b9fe818ce9030 100644
--- a/chrome/browser/ui/webui/settings/profile_info_handler.cc
+++ b/chrome/browser/ui/webui/settings/profile_info_handler.cc
@@ -31,7 +31,11 @@ namespace settings {
const char ProfileInfoHandler::kProfileInfoChangedEventName[] =
"profile-info-changed";
-ProfileInfoHandler::ProfileInfoHandler(Profile* profile) : profile_(profile) {}
+ProfileInfoHandler::ProfileInfoHandler(Profile* profile)
+ : profile_(profile),
+ profile_observer_(this) {}
+
+ProfileInfoHandler::~ProfileInfoHandler() {}
void ProfileInfoHandler::RegisterMessages() {
web_ui()->RegisterMessageCallback(
@@ -40,9 +44,8 @@ void ProfileInfoHandler::RegisterMessages() {
}
void ProfileInfoHandler::OnJavascriptAllowed() {
- g_browser_process->profile_manager()
- ->GetProfileAttributesStorage()
- .AddObserver(this);
+ profile_observer_.Add(
+ &g_browser_process->profile_manager()->GetProfileAttributesStorage());
#if defined(OS_CHROMEOS)
registrar_.Add(this, chrome::NOTIFICATION_LOGIN_USER_IMAGE_CHANGED,
@@ -51,9 +54,8 @@ void ProfileInfoHandler::OnJavascriptAllowed() {
}
void ProfileInfoHandler::OnJavascriptDisallowed() {
- g_browser_process->profile_manager()
- ->GetProfileAttributesStorage()
- .RemoveObserver(this);
+ profile_observer_.Remove(
+ &g_browser_process->profile_manager()->GetProfileAttributesStorage());
#if defined(OS_CHROMEOS)
registrar_.RemoveAll();
« no previous file with comments | « chrome/browser/ui/webui/settings/profile_info_handler.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698