OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/supervised_user/supervised_user_service.h" | 5 #include "chrome/browser/supervised_user/supervised_user_service.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
9 #include "base/files/file_util.h" | 9 #include "base/files/file_util.h" |
10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
326 } | 326 } |
327 | 327 |
328 std::string SupervisedUserService::GetCustodianEmailAddress() const { | 328 std::string SupervisedUserService::GetCustodianEmailAddress() const { |
329 std::string custodian_email = profile_->GetPrefs()->GetString( | 329 std::string custodian_email = profile_->GetPrefs()->GetString( |
330 prefs::kSupervisedUserCustodianEmail); | 330 prefs::kSupervisedUserCustodianEmail); |
331 #if defined(OS_CHROMEOS) | 331 #if defined(OS_CHROMEOS) |
332 if (custodian_email.empty()) { | 332 if (custodian_email.empty()) { |
333 custodian_email = chromeos::ChromeUserManager::Get() | 333 custodian_email = chromeos::ChromeUserManager::Get() |
334 ->GetSupervisedUserManager() | 334 ->GetSupervisedUserManager() |
335 ->GetManagerDisplayEmail( | 335 ->GetManagerDisplayEmail( |
336 user_manager::UserManager::Get()->GetActiveUser()->email()); | 336 user_manager::UserManager::Get()->GetActiveUser()->GetUserID()); |
337 } | 337 } |
338 #endif | 338 #endif |
339 return custodian_email; | 339 return custodian_email; |
340 } | 340 } |
341 | 341 |
342 std::string SupervisedUserService::GetCustodianName() const { | 342 std::string SupervisedUserService::GetCustodianName() const { |
343 std::string name = profile_->GetPrefs()->GetString( | 343 std::string name = profile_->GetPrefs()->GetString( |
344 prefs::kSupervisedUserCustodianName); | 344 prefs::kSupervisedUserCustodianName); |
345 #if defined(OS_CHROMEOS) | 345 #if defined(OS_CHROMEOS) |
346 if (name.empty()) { | 346 if (name.empty()) { |
347 name = base::UTF16ToUTF8(chromeos::ChromeUserManager::Get() | 347 name = base::UTF16ToUTF8(chromeos::ChromeUserManager::Get() |
348 ->GetSupervisedUserManager() | 348 ->GetSupervisedUserManager() |
349 ->GetManagerDisplayName( | 349 ->GetManagerDisplayName( |
350 user_manager::UserManager::Get()->GetActiveUser()->email())); | 350 user_manager::UserManager::Get()->GetActiveUser()->GetUserID())); |
351 } | 351 } |
352 #endif | 352 #endif |
353 return name.empty() ? GetCustodianEmailAddress() : name; | 353 return name.empty() ? GetCustodianEmailAddress() : name; |
354 } | 354 } |
355 | 355 |
356 std::string SupervisedUserService::GetSecondCustodianEmailAddress() const { | 356 std::string SupervisedUserService::GetSecondCustodianEmailAddress() const { |
357 return profile_->GetPrefs()->GetString( | 357 return profile_->GetPrefs()->GetString( |
358 prefs::kSupervisedUserSecondCustodianEmail); | 358 prefs::kSupervisedUserSecondCustodianEmail); |
359 } | 359 } |
360 | 360 |
(...skipping 481 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
842 // TODO(bauerb): Get rid of the platform-specific #ifdef here. | 842 // TODO(bauerb): Get rid of the platform-specific #ifdef here. |
843 // http://crbug.com/313377 | 843 // http://crbug.com/313377 |
844 BrowserList::RemoveObserver(this); | 844 BrowserList::RemoveObserver(this); |
845 #endif | 845 #endif |
846 } | 846 } |
847 } | 847 } |
848 | 848 |
849 void SupervisedUserService::RegisterAndInitSync( | 849 void SupervisedUserService::RegisterAndInitSync( |
850 SupervisedUserRegistrationUtility* registration_utility, | 850 SupervisedUserRegistrationUtility* registration_utility, |
851 Profile* custodian_profile, | 851 Profile* custodian_profile, |
852 const std::string& supervised_user_id, | 852 const user_manager::UserID& supervised_user_id, |
853 const AuthErrorCallback& callback) { | 853 const AuthErrorCallback& callback) { |
854 DCHECK(ProfileIsSupervised()); | 854 DCHECK(ProfileIsSupervised()); |
855 DCHECK(!custodian_profile->IsSupervised()); | 855 DCHECK(!custodian_profile->IsSupervised()); |
856 | 856 |
857 base::string16 name = base::UTF8ToUTF16( | 857 base::string16 name = base::UTF8ToUTF16( |
858 profile_->GetPrefs()->GetString(prefs::kProfileName)); | 858 profile_->GetPrefs()->GetString(prefs::kProfileName)); |
859 int avatar_index = profile_->GetPrefs()->GetInteger( | 859 int avatar_index = profile_->GetPrefs()->GetInteger( |
860 prefs::kProfileAvatarIndex); | 860 prefs::kProfileAvatarIndex); |
861 SupervisedUserRegistrationInfo info(name, avatar_index); | 861 SupervisedUserRegistrationInfo info(name, avatar_index); |
862 registration_utility->Register( | 862 registration_utility->Register( |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
954 // The active user can be NULL in unit tests. | 954 // The active user can be NULL in unit tests. |
955 if (user_manager::UserManager::Get()->GetActiveUser()) { | 955 if (user_manager::UserManager::Get()->GetActiveUser()) { |
956 return UTF16ToUTF8(user_manager::UserManager::Get()->GetUserDisplayName( | 956 return UTF16ToUTF8(user_manager::UserManager::Get()->GetUserDisplayName( |
957 user_manager::UserManager::Get()->GetActiveUser()->GetUserID())); | 957 user_manager::UserManager::Get()->GetActiveUser()->GetUserID())); |
958 } | 958 } |
959 return std::string(); | 959 return std::string(); |
960 #else | 960 #else |
961 return profile_->GetPrefs()->GetString(prefs::kProfileName); | 961 return profile_->GetPrefs()->GetString(prefs::kProfileName); |
962 #endif | 962 #endif |
963 } | 963 } |
OLD | NEW |