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

Side by Side Diff: chrome/browser/ui/webui/options/manage_profile_handler.cc

Issue 895803003: [Profiles] Remove the NotificationService from the ProfileInfoCache (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 5 years, 9 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
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 #include "chrome/browser/ui/webui/options/manage_profile_handler.h" 5 #include "chrome/browser/ui/webui/options/manage_profile_handler.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/prefs/pref_service.h" 9 #include "base/prefs/pref_service.h"
10 #include "base/prefs/scoped_user_pref_update.h" 10 #include "base/prefs/scoped_user_pref_update.h"
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 121
122 localized_strings->SetBoolean("newAvatarMenuEnabled", 122 localized_strings->SetBoolean("newAvatarMenuEnabled",
123 switches::IsNewAvatarMenu()); 123 switches::IsNewAvatarMenu());
124 localized_strings->SetBoolean("profileShortcutsEnabled", 124 localized_strings->SetBoolean("profileShortcutsEnabled",
125 ProfileShortcutManager::IsFeatureEnabled()); 125 ProfileShortcutManager::IsFeatureEnabled());
126 126
127 GenerateSignedinUserSpecificStrings(localized_strings); 127 GenerateSignedinUserSpecificStrings(localized_strings);
128 } 128 }
129 129
130 void ManageProfileHandler::InitializeHandler() { 130 void ManageProfileHandler::InitializeHandler() {
131 registrar_.Add(this, chrome::NOTIFICATION_PROFILE_CACHED_INFO_CHANGED, 131 g_browser_process->profile_manager()->GetProfileInfoCache().AddObserver(this);
132 content::NotificationService::AllSources());
133 132
134 Profile* profile = Profile::FromWebUI(web_ui()); 133 Profile* profile = Profile::FromWebUI(web_ui());
135 pref_change_registrar_.Init(profile->GetPrefs()); 134 pref_change_registrar_.Init(profile->GetPrefs());
136 pref_change_registrar_.Add( 135 pref_change_registrar_.Add(
137 prefs::kSupervisedUserCreationAllowed, 136 prefs::kSupervisedUserCreationAllowed,
138 base::Bind(&ManageProfileHandler::OnCreateSupervisedUserPrefChange, 137 base::Bind(&ManageProfileHandler::OnCreateSupervisedUserPrefChange,
139 base::Unretained(this))); 138 base::Unretained(this)));
140 ProfileSyncService* service = 139 ProfileSyncService* service =
141 ProfileSyncServiceFactory::GetForProfile(profile); 140 ProfileSyncServiceFactory::GetForProfile(profile);
142 // Sync may be disabled for tests. 141 // Sync may be disabled for tests.
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 web_ui()->RegisterMessageCallback("refreshGaiaPicture", 181 web_ui()->RegisterMessageCallback("refreshGaiaPicture",
183 base::Bind(&ManageProfileHandler::RefreshGaiaPicture, 182 base::Bind(&ManageProfileHandler::RefreshGaiaPicture,
184 base::Unretained(this))); 183 base::Unretained(this)));
185 web_ui()->RegisterMessageCallback( 184 web_ui()->RegisterMessageCallback(
186 "showDisconnectManagedProfileDialog", 185 "showDisconnectManagedProfileDialog",
187 base::Bind(&ManageProfileHandler::ShowDisconnectManagedProfileDialog, 186 base::Bind(&ManageProfileHandler::ShowDisconnectManagedProfileDialog,
188 base::Unretained(this))); 187 base::Unretained(this)));
189 } 188 }
190 189
191 void ManageProfileHandler::Uninitialize() { 190 void ManageProfileHandler::Uninitialize() {
192 registrar_.RemoveAll(); 191 g_browser_process->profile_manager()->
192 GetProfileInfoCache().RemoveObserver(this);
193 } 193 }
194 194
195 void ManageProfileHandler::Observe( 195 void ManageProfileHandler::OnProfileAdded(const base::FilePath& profile_path) {
196 int type, 196 SendExistingProfileNames();
197 const content::NotificationSource& source, 197 }
198 const content::NotificationDetails& details) { 198
199 if (type == chrome::NOTIFICATION_PROFILE_CACHED_INFO_CHANGED) { 199 void ManageProfileHandler::OnProfileWasRemoved(
200 SendExistingProfileNames(); 200 const base::FilePath& profile_path,
201 base::StringValue value(kManageProfileIdentifier); 201 const base::string16& profile_name) {
202 SendProfileIconsAndNames(value); 202 SendExistingProfileNames();
203 } 203 }
204
205 void ManageProfileHandler::OnProfileNameChanged(
206 const base::FilePath& profile_path,
207 const base::string16& old_profile_name) {
208 base::StringValue value(kManageProfileIdentifier);
209 SendProfileIconsAndNames(value);
210 }
211
212 void ManageProfileHandler::OnProfileAvatarChanged(
213 const base::FilePath& profile_path) {
214 base::StringValue value(kManageProfileIdentifier);
215 SendProfileIconsAndNames(value);
204 } 216 }
205 217
206 void ManageProfileHandler::OnStateChanged() { 218 void ManageProfileHandler::OnStateChanged() {
207 RequestCreateProfileUpdate(NULL); 219 RequestCreateProfileUpdate(NULL);
208 } 220 }
209 221
210 void ManageProfileHandler::GenerateSignedinUserSpecificStrings( 222 void ManageProfileHandler::GenerateSignedinUserSpecificStrings(
211 base::DictionaryValue* dictionary) { 223 base::DictionaryValue* dictionary) {
212 std::string username; 224 std::string username;
213 std::string domain_name; 225 std::string domain_name;
(...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after
537 549
538 // Update the UI buttons. 550 // Update the UI buttons.
539 OnHasProfileShortcuts(false); 551 OnHasProfileShortcuts(false);
540 } 552 }
541 553
542 void ManageProfileHandler::RefreshGaiaPicture(const base::ListValue* args) { 554 void ManageProfileHandler::RefreshGaiaPicture(const base::ListValue* args) {
543 profiles::UpdateGaiaProfileInfoIfNeeded(Profile::FromWebUI(web_ui())); 555 profiles::UpdateGaiaProfileInfoIfNeeded(Profile::FromWebUI(web_ui()));
544 } 556 }
545 557
546 } // namespace options 558 } // namespace options
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/options/manage_profile_handler.h ('k') | chrome/browser/ui/webui/options/options_ui_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698