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

Side by Side Diff: chrome/browser/ui/webui/settings/profile_info_handler.h

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: Created 4 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 | chrome/browser/ui/webui/settings/profile_info_handler.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 #ifndef CHROME_BROWSER_UI_WEBUI_SETTINGS_PROFILE_INFO_HANDLER_H_ 5 #ifndef CHROME_BROWSER_UI_WEBUI_SETTINGS_PROFILE_INFO_HANDLER_H_
6 #define CHROME_BROWSER_UI_WEBUI_SETTINGS_PROFILE_INFO_HANDLER_H_ 6 #define CHROME_BROWSER_UI_WEBUI_SETTINGS_PROFILE_INFO_HANDLER_H_
7 7
8 #include <memory> 8 #include <memory>
9 9
10 #include "base/macros.h" 10 #include "base/macros.h"
11 #include "base/scoped_observer.h"
11 #include "build/build_config.h" 12 #include "build/build_config.h"
12 #include "chrome/browser/profiles/profile_attributes_storage.h" 13 #include "chrome/browser/profiles/profile_attributes_storage.h"
13 #include "chrome/browser/ui/webui/settings/settings_page_ui_handler.h" 14 #include "chrome/browser/ui/webui/settings/settings_page_ui_handler.h"
14 15
15 #if defined(OS_CHROMEOS) 16 #if defined(OS_CHROMEOS)
16 #include "content/public/browser/notification_observer.h" 17 #include "content/public/browser/notification_observer.h"
17 #include "content/public/browser/notification_registrar.h" 18 #include "content/public/browser/notification_registrar.h"
18 #endif 19 #endif
19 20
20 class Profile; 21 class Profile;
21 22
22 namespace settings { 23 namespace settings {
23 24
24 class ProfileInfoHandler : public SettingsPageUIHandler, 25 class ProfileInfoHandler : public SettingsPageUIHandler,
25 #if defined(OS_CHROMEOS) 26 #if defined(OS_CHROMEOS)
26 public content::NotificationObserver, 27 public content::NotificationObserver,
27 #endif 28 #endif
28 public ProfileAttributesStorage::Observer { 29 public ProfileAttributesStorage::Observer {
29 public: 30 public:
30 static const char kProfileInfoChangedEventName[]; 31 static const char kProfileInfoChangedEventName[];
31 32
32 explicit ProfileInfoHandler(Profile* profile); 33 explicit ProfileInfoHandler(Profile* profile);
33 ~ProfileInfoHandler() override {} 34 ~ProfileInfoHandler() override;
34 35
35 // SettingsPageUIHandler implementation. 36 // SettingsPageUIHandler implementation.
36 void RegisterMessages() override; 37 void RegisterMessages() override;
37 void OnJavascriptAllowed() override; 38 void OnJavascriptAllowed() override;
38 void OnJavascriptDisallowed() override; 39 void OnJavascriptDisallowed() override;
39 40
40 #if defined(OS_CHROMEOS) 41 #if defined(OS_CHROMEOS)
41 // content::NotificationObserver implementation. 42 // content::NotificationObserver implementation.
42 void Observe(int type, 43 void Observe(int type,
43 const content::NotificationSource& source, 44 const content::NotificationSource& source,
(...skipping 12 matching lines...) Expand all
56 // Callbacks from the page. 57 // Callbacks from the page.
57 void HandleGetProfileInfo(const base::ListValue* args); 58 void HandleGetProfileInfo(const base::ListValue* args);
58 59
59 void PushProfileInfo(); 60 void PushProfileInfo();
60 61
61 std::unique_ptr<base::DictionaryValue> GetAccountNameAndIcon() const; 62 std::unique_ptr<base::DictionaryValue> GetAccountNameAndIcon() const;
62 63
63 // Weak pointer. 64 // Weak pointer.
64 Profile* profile_; 65 Profile* profile_;
65 66
67 ScopedObserver<ProfileAttributesStorage, ProfileInfoHandler> scoped_observer_;
tommycli 2016/05/03 17:23:48 Can we call this profile_observer_ just to be clea
anthonyvd 2016/05/03 18:12:10 Done.
68
66 #if defined(OS_CHROMEOS) 69 #if defined(OS_CHROMEOS)
67 // Used to listen to ChromeOS user image changes. 70 // Used to listen to ChromeOS user image changes.
68 content::NotificationRegistrar registrar_; 71 content::NotificationRegistrar registrar_;
69 #endif 72 #endif
70 73
71 DISALLOW_COPY_AND_ASSIGN(ProfileInfoHandler); 74 DISALLOW_COPY_AND_ASSIGN(ProfileInfoHandler);
72 }; 75 };
73 76
74 } // namespace settings 77 } // namespace settings
75 78
76 #endif // CHROME_BROWSER_UI_WEBUI_SETTINGS_PROFILE_INFO_HANDLER_H_ 79 #endif // CHROME_BROWSER_UI_WEBUI_SETTINGS_PROFILE_INFO_HANDLER_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/webui/settings/profile_info_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698