| 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 23 matching lines...) Expand all Loading... |
| 34 const char ProfileInfoHandler::kProfileInfoChangedEventName[] = | 34 const char ProfileInfoHandler::kProfileInfoChangedEventName[] = |
| 35 "profile-info-changed"; | 35 "profile-info-changed"; |
| 36 const char | 36 const char |
| 37 ProfileInfoHandler::kProfileManagesSupervisedUsersChangedEventName[] = | 37 ProfileInfoHandler::kProfileManagesSupervisedUsersChangedEventName[] = |
| 38 "profile-manages-supervised-users-changed"; | 38 "profile-manages-supervised-users-changed"; |
| 39 const char ProfileInfoHandler::kProfileStatsCountReadyEventName[] = | 39 const char ProfileInfoHandler::kProfileStatsCountReadyEventName[] = |
| 40 "profile-stats-count-ready"; | 40 "profile-stats-count-ready"; |
| 41 | 41 |
| 42 ProfileInfoHandler::ProfileInfoHandler(Profile* profile) | 42 ProfileInfoHandler::ProfileInfoHandler(Profile* profile) |
| 43 : profile_(profile), | 43 : profile_(profile), |
| 44 #if defined(OS_CHROMEOS) |
| 45 user_manager_observer_(this), |
| 46 #endif |
| 44 profile_observer_(this) { | 47 profile_observer_(this) { |
| 45 #if defined(OS_CHROMEOS) | 48 #if defined(OS_CHROMEOS) |
| 46 // Set up the chrome://userimage/ source. | 49 // Set up the chrome://userimage/ source. |
| 47 content::URLDataSource::Add(profile, | 50 content::URLDataSource::Add(profile, |
| 48 new chromeos::options::UserImageSource()); | 51 new chromeos::options::UserImageSource()); |
| 49 #endif | 52 #endif |
| 50 } | 53 } |
| 51 | 54 |
| 52 ProfileInfoHandler::~ProfileInfoHandler() {} | 55 ProfileInfoHandler::~ProfileInfoHandler() {} |
| 53 | 56 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 72 &g_browser_process->profile_manager()->GetProfileAttributesStorage()); | 75 &g_browser_process->profile_manager()->GetProfileAttributesStorage()); |
| 73 | 76 |
| 74 PrefService* prefs = profile_->GetPrefs(); | 77 PrefService* prefs = profile_->GetPrefs(); |
| 75 profile_pref_registrar_.Init(prefs); | 78 profile_pref_registrar_.Init(prefs); |
| 76 profile_pref_registrar_.Add( | 79 profile_pref_registrar_.Add( |
| 77 prefs::kSupervisedUsers, | 80 prefs::kSupervisedUsers, |
| 78 base::Bind(&ProfileInfoHandler::PushProfileManagesSupervisedUsersStatus, | 81 base::Bind(&ProfileInfoHandler::PushProfileManagesSupervisedUsersStatus, |
| 79 base::Unretained(this))); | 82 base::Unretained(this))); |
| 80 | 83 |
| 81 #if defined(OS_CHROMEOS) | 84 #if defined(OS_CHROMEOS) |
| 82 user_manager::UserManager::Get()->AddObserver(this); | 85 user_manager_observer_.Add(user_manager::UserManager::Get()); |
| 83 #endif | 86 #endif |
| 84 } | 87 } |
| 85 | 88 |
| 86 void ProfileInfoHandler::OnJavascriptDisallowed() { | 89 void ProfileInfoHandler::OnJavascriptDisallowed() { |
| 87 profile_observer_.Remove( | 90 profile_observer_.Remove( |
| 88 &g_browser_process->profile_manager()->GetProfileAttributesStorage()); | 91 &g_browser_process->profile_manager()->GetProfileAttributesStorage()); |
| 89 | 92 |
| 90 profile_pref_registrar_.RemoveAll(); | 93 profile_pref_registrar_.RemoveAll(); |
| 91 | 94 |
| 92 #if defined(OS_CHROMEOS) | 95 #if defined(OS_CHROMEOS) |
| 93 user_manager::UserManager::Get()->RemoveObserver(this); | 96 user_manager_observer_.Remove(user_manager::UserManager::Get()); |
| 94 #endif | 97 #endif |
| 95 } | 98 } |
| 96 | 99 |
| 97 #if defined(OS_CHROMEOS) | 100 #if defined(OS_CHROMEOS) |
| 98 void ProfileInfoHandler::OnUserImageChanged(const user_manager::User& user) { | 101 void ProfileInfoHandler::OnUserImageChanged(const user_manager::User& user) { |
| 99 PushProfileInfo(); | 102 PushProfileInfo(); |
| 100 } | 103 } |
| 101 #endif | 104 #endif |
| 102 | 105 |
| 103 void ProfileInfoHandler::OnProfileNameChanged( | 106 void ProfileInfoHandler::OnProfileNameChanged( |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 219 response->SetString("name", name); | 222 response->SetString("name", name); |
| 220 response->SetString("iconUrl", icon_url); | 223 response->SetString("iconUrl", icon_url); |
| 221 return base::WrapUnique(response); | 224 return base::WrapUnique(response); |
| 222 } | 225 } |
| 223 | 226 |
| 224 bool ProfileInfoHandler::IsProfileManagingSupervisedUsers() const { | 227 bool ProfileInfoHandler::IsProfileManagingSupervisedUsers() const { |
| 225 return !profile_->GetPrefs()->GetDictionary(prefs::kSupervisedUsers)->empty(); | 228 return !profile_->GetPrefs()->GetDictionary(prefs::kSupervisedUsers)->empty(); |
| 226 } | 229 } |
| 227 | 230 |
| 228 } // namespace settings | 231 } // namespace settings |
| OLD | NEW |