| 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/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
| 9 #include "base/prefs/pref_service.h" | 9 #include "base/prefs/pref_service.h" |
| 10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
| (...skipping 575 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 586 if (CommandLine::ForCurrentProcess()->HasSwitch( | 586 if (CommandLine::ForCurrentProcess()->HasSwitch( |
| 587 switches::kPermissionRequestApiUrl)) { | 587 switches::kPermissionRequestApiUrl)) { |
| 588 permissions_creator_ = | 588 permissions_creator_ = |
| 589 PermissionRequestCreatorApiary::CreateWithProfile(profile_); | 589 PermissionRequestCreatorApiary::CreateWithProfile(profile_); |
| 590 } else { | 590 } else { |
| 591 PrefService* pref_service = profile_->GetPrefs(); | 591 PrefService* pref_service = profile_->GetPrefs(); |
| 592 permissions_creator_.reset(new PermissionRequestCreatorSync( | 592 permissions_creator_.reset(new PermissionRequestCreatorSync( |
| 593 settings_service, | 593 settings_service, |
| 594 SupervisedUserSharedSettingsServiceFactory::GetForBrowserContext( | 594 SupervisedUserSharedSettingsServiceFactory::GetForBrowserContext( |
| 595 profile_), | 595 profile_), |
| 596 pref_service->GetString(prefs::kProfileName), | 596 GetSupervisedUserName(), |
| 597 pref_service->GetString(prefs::kSupervisedUserId))); | 597 pref_service->GetString(prefs::kSupervisedUserId))); |
| 598 } | 598 } |
| 599 | 599 |
| 600 if (management_policy) | 600 if (management_policy) |
| 601 management_policy->RegisterProvider(this); | 601 management_policy->RegisterProvider(this); |
| 602 | 602 |
| 603 extension_registry_observer_.Add( | 603 extension_registry_observer_.Add( |
| 604 extensions::ExtensionRegistry::Get(profile_)); | 604 extensions::ExtensionRegistry::Get(profile_)); |
| 605 | 605 |
| 606 pref_change_registrar_.Add( | 606 pref_change_registrar_.Add( |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 741 | 741 |
| 742 void SupervisedUserService::OnBrowserSetLastActive(Browser* browser) { | 742 void SupervisedUserService::OnBrowserSetLastActive(Browser* browser) { |
| 743 bool profile_became_active = profile_->IsSameProfile(browser->profile()); | 743 bool profile_became_active = profile_->IsSameProfile(browser->profile()); |
| 744 if (!is_profile_active_ && profile_became_active) | 744 if (!is_profile_active_ && profile_became_active) |
| 745 content::RecordAction(UserMetricsAction("ManagedUsers_OpenProfile")); | 745 content::RecordAction(UserMetricsAction("ManagedUsers_OpenProfile")); |
| 746 else if (is_profile_active_ && !profile_became_active) | 746 else if (is_profile_active_ && !profile_became_active) |
| 747 content::RecordAction(UserMetricsAction("ManagedUsers_SwitchProfile")); | 747 content::RecordAction(UserMetricsAction("ManagedUsers_SwitchProfile")); |
| 748 | 748 |
| 749 is_profile_active_ = profile_became_active; | 749 is_profile_active_ = profile_became_active; |
| 750 } | 750 } |
| 751 |
| 752 std::string SupervisedUserService::GetSupervisedUserName() const { |
| 753 #if defined(OS_CHROMEOS) |
| 754 // The active user can be NULL in unit tests. |
| 755 if (chromeos::UserManager::Get()->GetActiveUser()) { |
| 756 return UTF16ToUTF8(chromeos::UserManager::Get()->GetUserDisplayName( |
| 757 chromeos::UserManager::Get()->GetActiveUser()->GetUserID())); |
| 758 } |
| 759 return std::string(); |
| 760 #else |
| 761 return profile_->GetPrefs()->GetString(prefs::kProfileName); |
| 762 #endif |
| 763 } |
| OLD | NEW |