Chromium Code Reviews| Index: chrome/browser/chromeos/ownership/owner_settings_service_chromeos.cc |
| diff --git a/chrome/browser/chromeos/ownership/owner_settings_service_chromeos.cc b/chrome/browser/chromeos/ownership/owner_settings_service_chromeos.cc |
| index 20fdd78e8d435fccaeb0ae4fefbe0d16794675b4..ee5aa3375ca6054d698e35b89e9c917ae128d6d4 100644 |
| --- a/chrome/browser/chromeos/ownership/owner_settings_service_chromeos.cc |
| +++ b/chrome/browser/chromeos/ownership/owner_settings_service_chromeos.cc |
| @@ -48,7 +48,7 @@ namespace chromeos { |
| namespace { |
| -bool IsOwnerInTests(const std::string& user_id) { |
| +bool IsOwnerInTests(const user_manager::UserID& user_id) { |
| if (user_id.empty() || |
| !base::CommandLine::ForCurrentProcess()->HasSwitch( |
| ::switches::kTestType) || |
| @@ -58,7 +58,7 @@ bool IsOwnerInTests(const std::string& user_id) { |
| const base::Value* value = CrosSettings::Get()->GetPref(kDeviceOwner); |
| if (!value || value->GetType() != base::Value::TYPE_STRING) |
| return false; |
| - return static_cast<const base::StringValue*>(value)->GetString() == user_id; |
| + return static_cast<const base::StringValue*>(value)->GetString() == user_id.GetUserEmail(); |
| } |
| void LoadPrivateKeyByPublicKey( |
| @@ -196,6 +196,7 @@ OwnerSettingsServiceChromeOS::OwnerSettingsServiceChromeOS( |
| : ownership::OwnerSettingsService(owner_key_util), |
| device_settings_service_(device_settings_service), |
| profile_(profile), |
| + user_id_(std::string(), std::string()), |
|
Denis Kuznetsov (DE-MUC)
2015/06/10 16:50:45
EmptyUserId()
|
| waiting_for_profile_creation_(true), |
| waiting_for_tpm_token_(true), |
| has_pending_fixups_(false), |
| @@ -283,7 +284,7 @@ bool OwnerSettingsServiceChromeOS::Set(const std::string& setting, |
| } |
| UpdateDeviceSettings(setting, value, settings); |
| em::PolicyData policy_data; |
| - policy_data.set_username(user_id_); |
| + policy_data.set_username(user_id_.GetUserEmail()); |
| CHECK(settings.SerializeToString(policy_data.mutable_policy_value())); |
| FOR_EACH_OBSERVER(OwnerSettingsService::Observer, observers_, |
| OnTentativeChangesInPolicy(policy_data)); |
| @@ -321,9 +322,9 @@ bool OwnerSettingsServiceChromeOS::CommitTentativeDeviceSettings( |
| scoped_ptr<enterprise_management::PolicyData> policy) { |
| if (!IsOwner() && !IsOwnerInTests(user_id_)) |
| return false; |
| - if (policy->username() != user_id_) { |
| + if (user_manager::UserID::FromUserEmail(policy->username()) != user_id_) { |
| LOG(ERROR) << "Username mismatch: " << policy->username() << " vs. " |
| - << user_id_; |
| + << user_id_.GetUserEmail(); |
| return false; |
| } |
| tentative_settings_.reset(new em::ChromeDeviceSettingsProto); |
| @@ -424,7 +425,7 @@ void OwnerSettingsServiceChromeOS::IsOwnerForSafeModeAsync( |
| // static |
| scoped_ptr<em::PolicyData> OwnerSettingsServiceChromeOS::AssemblePolicy( |
| - const std::string& user_id, |
| + const user_manager::UserID& user_id, |
| const em::PolicyData* policy_data, |
| bool apply_pending_management_settings, |
| const ManagementSettings& pending_management_settings, |
| @@ -460,7 +461,7 @@ scoped_ptr<em::PolicyData> OwnerSettingsServiceChromeOS::AssemblePolicy( |
| policy->set_policy_type(policy::dm_protocol::kChromeDevicePolicyType); |
| policy->set_timestamp( |
| (base::Time::Now() - base::Time::UnixEpoch()).InMilliseconds()); |
| - policy->set_username(user_id); |
| + policy->set_username(user_id.GetUserEmail()); |
| if (policy_data->management_mode() == em::PolicyData::LOCAL_OWNER || |
| policy_data->management_mode() == em::PolicyData::CONSUMER_MANAGED) { |
| FixupLocalOwnerPolicy(user_id, settings); |
| @@ -473,7 +474,7 @@ scoped_ptr<em::PolicyData> OwnerSettingsServiceChromeOS::AssemblePolicy( |
| // static |
| void OwnerSettingsServiceChromeOS::FixupLocalOwnerPolicy( |
| - const std::string& user_id, |
| + const user_manager::UserID& user_id, |
| enterprise_management::ChromeDeviceSettingsProto* settings) { |
| if (!settings->has_allow_new_users()) |
| settings->mutable_allow_new_users()->set_allow_new_users(true); |
| @@ -481,8 +482,8 @@ void OwnerSettingsServiceChromeOS::FixupLocalOwnerPolicy( |
| em::UserWhitelistProto* whitelist_proto = settings->mutable_user_whitelist(); |
| if (whitelist_proto->user_whitelist().end() == |
| std::find(whitelist_proto->user_whitelist().begin(), |
| - whitelist_proto->user_whitelist().end(), user_id)) { |
| - whitelist_proto->add_user_whitelist(user_id); |
| + whitelist_proto->user_whitelist().end(), user_id.GetUserEmail())) { |
| + whitelist_proto->add_user_whitelist(user_id.GetUserEmail()); |
| } |
| } |
| @@ -629,8 +630,10 @@ void OwnerSettingsServiceChromeOS::UpdateDeviceSettings( |
| i != users->end(); |
| ++i) { |
| std::string email; |
| - if ((*i)->GetAsString(&email)) |
| - whitelist_proto->add_user_whitelist(email); |
| + if ((*i)->GetAsString(&email)) { |
| + const user_manager::UserID user_id(user_manager::UserID::FromUserEmail(email)); |
| + whitelist_proto->add_user_whitelist(user_id.GetUserEmail()); |
| + } |
| } |
| } |
| } else if (path == kAccountsPrefEphemeralUsersEnabled) { |
| @@ -716,7 +719,7 @@ void OwnerSettingsServiceChromeOS::OnPostKeypairLoadedActions() { |
| const user_manager::User* user = |
| ProfileHelper::Get()->GetUserByProfile(profile_); |
| - user_id_ = user ? user->GetUserID() : std::string(); |
| + user_id_ = user ? user->GetUserID() : user_manager::EmptyUserID(); |
| const bool is_owner = IsOwner() || IsOwnerInTests(user_id_); |
| if (is_owner && device_settings_service_) |