| OLD | NEW |
| 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 #include "chrome/browser/ui/webui/settings/profile_info_handler.h" | 5 #include "chrome/browser/ui/webui/settings/profile_info_handler.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/memory/ptr_util.h" | 8 #include "base/memory/ptr_util.h" |
| 9 #include "chrome/browser/browser_process.h" | 9 #include "chrome/browser/browser_process.h" |
| 10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 &g_browser_process->profile_manager()->GetProfileAttributesStorage()); | 56 &g_browser_process->profile_manager()->GetProfileAttributesStorage()); |
| 57 | 57 |
| 58 PrefService* prefs = profile_->GetPrefs(); | 58 PrefService* prefs = profile_->GetPrefs(); |
| 59 profile_pref_registrar_.Init(prefs); | 59 profile_pref_registrar_.Init(prefs); |
| 60 profile_pref_registrar_.Add( | 60 profile_pref_registrar_.Add( |
| 61 prefs::kSupervisedUsers, | 61 prefs::kSupervisedUsers, |
| 62 base::Bind(&ProfileInfoHandler::PushProfileManagesSupervisedUsersStatus, | 62 base::Bind(&ProfileInfoHandler::PushProfileManagesSupervisedUsersStatus, |
| 63 base::Unretained(this))); | 63 base::Unretained(this))); |
| 64 | 64 |
| 65 #if defined(OS_CHROMEOS) | 65 #if defined(OS_CHROMEOS) |
| 66 registrar_.Add(this, chrome::NOTIFICATION_LOGIN_USER_IMAGE_CHANGED, | 66 user_manager::UserManager::Get()->AddObserver(this); |
| 67 content::NotificationService::AllSources()); | |
| 68 #endif | 67 #endif |
| 69 } | 68 } |
| 70 | 69 |
| 71 void ProfileInfoHandler::OnJavascriptDisallowed() { | 70 void ProfileInfoHandler::OnJavascriptDisallowed() { |
| 72 profile_observer_.Remove( | 71 profile_observer_.Remove( |
| 73 &g_browser_process->profile_manager()->GetProfileAttributesStorage()); | 72 &g_browser_process->profile_manager()->GetProfileAttributesStorage()); |
| 74 | 73 |
| 75 profile_pref_registrar_.RemoveAll(); | 74 profile_pref_registrar_.RemoveAll(); |
| 76 | 75 |
| 77 #if defined(OS_CHROMEOS) | 76 #if defined(OS_CHROMEOS) |
| 78 registrar_.RemoveAll(); | 77 user_manager::UserManager::Get()->RemoveObserver(this); |
| 79 #endif | 78 #endif |
| 80 } | 79 } |
| 81 | 80 |
| 82 #if defined(OS_CHROMEOS) | 81 #if defined(OS_CHROMEOS) |
| 83 void ProfileInfoHandler::Observe(int type, | 82 void ProfileInfoHandler::OnUserImageChanged(const user_manager::User& user) { |
| 84 const content::NotificationSource& source, | |
| 85 const content::NotificationDetails& details) { | |
| 86 DCHECK_EQ(chrome::NOTIFICATION_LOGIN_USER_IMAGE_CHANGED, type); | |
| 87 PushProfileInfo(); | 83 PushProfileInfo(); |
| 88 } | 84 } |
| 89 #endif | 85 #endif |
| 90 | 86 |
| 91 void ProfileInfoHandler::OnProfileNameChanged( | 87 void ProfileInfoHandler::OnProfileNameChanged( |
| 92 const base::FilePath& /* profile_path */, | 88 const base::FilePath& /* profile_path */, |
| 93 const base::string16& /* old_profile_name */) { | 89 const base::string16& /* old_profile_name */) { |
| 94 PushProfileInfo(); | 90 PushProfileInfo(); |
| 95 } | 91 } |
| 96 | 92 |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 response->SetString("name", name); | 173 response->SetString("name", name); |
| 178 response->SetString("iconUrl", icon_url); | 174 response->SetString("iconUrl", icon_url); |
| 179 return base::WrapUnique(response); | 175 return base::WrapUnique(response); |
| 180 } | 176 } |
| 181 | 177 |
| 182 bool ProfileInfoHandler::IsProfileManagingSupervisedUsers() const { | 178 bool ProfileInfoHandler::IsProfileManagingSupervisedUsers() const { |
| 183 return !profile_->GetPrefs()->GetDictionary(prefs::kSupervisedUsers)->empty(); | 179 return !profile_->GetPrefs()->GetDictionary(prefs::kSupervisedUsers)->empty(); |
| 184 } | 180 } |
| 185 | 181 |
| 186 } // namespace settings | 182 } // namespace settings |
| OLD | NEW |