Chromium Code Reviews| 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 602 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 613 if (CommandLine::ForCurrentProcess()->HasSwitch( | 613 if (CommandLine::ForCurrentProcess()->HasSwitch( |
| 614 switches::kPermissionRequestApiUrl)) { | 614 switches::kPermissionRequestApiUrl)) { |
| 615 permissions_creator_ = | 615 permissions_creator_ = |
| 616 PermissionRequestCreatorApiary::CreateWithProfile(profile_); | 616 PermissionRequestCreatorApiary::CreateWithProfile(profile_); |
| 617 } else { | 617 } else { |
| 618 PrefService* pref_service = profile_->GetPrefs(); | 618 PrefService* pref_service = profile_->GetPrefs(); |
| 619 permissions_creator_.reset(new PermissionRequestCreatorSync( | 619 permissions_creator_.reset(new PermissionRequestCreatorSync( |
| 620 settings_service, | 620 settings_service, |
| 621 SupervisedUserSharedSettingsServiceFactory::GetForBrowserContext( | 621 SupervisedUserSharedSettingsServiceFactory::GetForBrowserContext( |
| 622 profile_), | 622 profile_), |
| 623 pref_service->GetString(prefs::kProfileName), | 623 GetSupervisedUserName(), |
| 624 pref_service->GetString(prefs::kSupervisedUserId))); | 624 pref_service->GetString(prefs::kSupervisedUserId))); |
| 625 } | 625 } |
| 626 | 626 |
| 627 pref_change_registrar_.Add( | 627 pref_change_registrar_.Add( |
| 628 prefs::kDefaultSupervisedUserFilteringBehavior, | 628 prefs::kDefaultSupervisedUserFilteringBehavior, |
| 629 base::Bind(&SupervisedUserService::OnDefaultFilteringBehaviorChanged, | 629 base::Bind(&SupervisedUserService::OnDefaultFilteringBehaviorChanged, |
| 630 base::Unretained(this))); | 630 base::Unretained(this))); |
| 631 pref_change_registrar_.Add(prefs::kSupervisedUserManualHosts, | 631 pref_change_registrar_.Add(prefs::kSupervisedUserManualHosts, |
| 632 base::Bind(&SupervisedUserService::UpdateManualHosts, | 632 base::Bind(&SupervisedUserService::UpdateManualHosts, |
| 633 base::Unretained(this))); | 633 base::Unretained(this))); |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 757 | 757 |
| 758 void SupervisedUserService::OnBrowserSetLastActive(Browser* browser) { | 758 void SupervisedUserService::OnBrowserSetLastActive(Browser* browser) { |
| 759 bool profile_became_active = profile_->IsSameProfile(browser->profile()); | 759 bool profile_became_active = profile_->IsSameProfile(browser->profile()); |
| 760 if (!is_profile_active_ && profile_became_active) | 760 if (!is_profile_active_ && profile_became_active) |
| 761 content::RecordAction(UserMetricsAction("ManagedUsers_OpenProfile")); | 761 content::RecordAction(UserMetricsAction("ManagedUsers_OpenProfile")); |
| 762 else if (is_profile_active_ && !profile_became_active) | 762 else if (is_profile_active_ && !profile_became_active) |
| 763 content::RecordAction(UserMetricsAction("ManagedUsers_SwitchProfile")); | 763 content::RecordAction(UserMetricsAction("ManagedUsers_SwitchProfile")); |
| 764 | 764 |
| 765 is_profile_active_ = profile_became_active; | 765 is_profile_active_ = profile_became_active; |
| 766 } | 766 } |
| 767 | |
| 768 std::string SupervisedUserService::GetSupervisedUserName() const { | |
| 769 #if defined(OS_CHROMEOS) | |
| 770 // The active user can be NULL in unit tests. | |
| 771 if (chromeos::UserManager::Get()->GetActiveUser()) { | |
| 772 return UTF16ToUTF8(chromeos::UserManager::Get()->GetUserDisplayName( | |
| 773 chromeos::UserManager::Get()->GetActiveUser()->GetUserID())); | |
| 774 } | |
| 775 return ""; | |
|
Nikita (slow)
2014/08/01 11:27:17
nit: std::string()
Adrian Kuegel
2014/08/01 11:43:01
Done.
| |
| 776 #else | |
| 777 return profile_->GetPrefs()->GetString(prefs::kProfileName); | |
| 778 #endif | |
| 779 } | |
| OLD | NEW |