Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4)

Side by Side Diff: chrome/browser/chromeos/ownership/owner_settings_service_chromeos.cc

Issue 2539363004: Make base::Value::TYPE a scoped enum. (Closed)
Patch Set: Rebase Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/chromeos/ownership/owner_settings_service_chromeos.h" 5 #include "chrome/browser/chromeos/ownership/owner_settings_service_chromeos.h"
6 6
7 #include <keyhi.h> 7 #include <keyhi.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 namespace { 52 namespace {
53 53
54 bool IsOwnerInTests(const std::string& user_id) { 54 bool IsOwnerInTests(const std::string& user_id) {
55 if (user_id.empty() || 55 if (user_id.empty() ||
56 !base::CommandLine::ForCurrentProcess()->HasSwitch( 56 !base::CommandLine::ForCurrentProcess()->HasSwitch(
57 ::switches::kTestType) || 57 ::switches::kTestType) ||
58 !CrosSettings::IsInitialized()) { 58 !CrosSettings::IsInitialized()) {
59 return false; 59 return false;
60 } 60 }
61 const base::Value* value = CrosSettings::Get()->GetPref(kDeviceOwner); 61 const base::Value* value = CrosSettings::Get()->GetPref(kDeviceOwner);
62 if (!value || value->GetType() != base::Value::TYPE_STRING) 62 if (!value || value->GetType() != base::Value::Type::STRING)
63 return false; 63 return false;
64 return static_cast<const base::StringValue*>(value)->GetString() == user_id; 64 return static_cast<const base::StringValue*>(value)->GetString() == user_id;
65 } 65 }
66 66
67 void LoadPrivateKeyByPublicKey( 67 void LoadPrivateKeyByPublicKey(
68 const scoped_refptr<OwnerKeyUtil>& owner_key_util, 68 const scoped_refptr<OwnerKeyUtil>& owner_key_util,
69 scoped_refptr<PublicKey> public_key, 69 scoped_refptr<PublicKey> public_key,
70 const std::string& username_hash, 70 const std::string& username_hash,
71 const base::Callback<void(const scoped_refptr<PublicKey>& public_key, 71 const base::Callback<void(const scoped_refptr<PublicKey>& public_key,
72 const scoped_refptr<PrivateKey>& private_key)>& 72 const scoped_refptr<PrivateKey>& private_key)>&
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
268 for (auto& observer : observers_) 268 for (auto& observer : observers_)
269 observer.OnTentativeChangesInPolicy(policy_data); 269 observer.OnTentativeChangesInPolicy(policy_data);
270 StorePendingChanges(); 270 StorePendingChanges();
271 return true; 271 return true;
272 } 272 }
273 273
274 bool OwnerSettingsServiceChromeOS::AppendToList(const std::string& setting, 274 bool OwnerSettingsServiceChromeOS::AppendToList(const std::string& setting,
275 const base::Value& value) { 275 const base::Value& value) {
276 DCHECK(thread_checker_.CalledOnValidThread()); 276 DCHECK(thread_checker_.CalledOnValidThread());
277 const base::Value* old_value = CrosSettings::Get()->GetPref(setting); 277 const base::Value* old_value = CrosSettings::Get()->GetPref(setting);
278 if (old_value && !old_value->IsType(base::Value::TYPE_LIST)) 278 if (old_value && !old_value->IsType(base::Value::Type::LIST))
279 return false; 279 return false;
280 std::unique_ptr<base::ListValue> new_value( 280 std::unique_ptr<base::ListValue> new_value(
281 old_value ? static_cast<const base::ListValue*>(old_value)->DeepCopy() 281 old_value ? static_cast<const base::ListValue*>(old_value)->DeepCopy()
282 : new base::ListValue()); 282 : new base::ListValue());
283 new_value->Append(value.CreateDeepCopy()); 283 new_value->Append(value.CreateDeepCopy());
284 return Set(setting, *new_value); 284 return Set(setting, *new_value);
285 } 285 }
286 286
287 bool OwnerSettingsServiceChromeOS::RemoveFromList(const std::string& setting, 287 bool OwnerSettingsServiceChromeOS::RemoveFromList(const std::string& setting,
288 const base::Value& value) { 288 const base::Value& value) {
289 DCHECK(thread_checker_.CalledOnValidThread()); 289 DCHECK(thread_checker_.CalledOnValidThread());
290 const base::Value* old_value = CrosSettings::Get()->GetPref(setting); 290 const base::Value* old_value = CrosSettings::Get()->GetPref(setting);
291 if (old_value && !old_value->IsType(base::Value::TYPE_LIST)) 291 if (old_value && !old_value->IsType(base::Value::Type::LIST))
292 return false; 292 return false;
293 std::unique_ptr<base::ListValue> new_value( 293 std::unique_ptr<base::ListValue> new_value(
294 old_value ? static_cast<const base::ListValue*>(old_value)->DeepCopy() 294 old_value ? static_cast<const base::ListValue*>(old_value)->DeepCopy()
295 : new base::ListValue()); 295 : new base::ListValue());
296 new_value->Remove(value, nullptr); 296 new_value->Remove(value, nullptr);
297 return Set(setting, *new_value); 297 return Set(setting, *new_value);
298 } 298 }
299 299
300 bool OwnerSettingsServiceChromeOS::CommitTentativeDeviceSettings( 300 bool OwnerSettingsServiceChromeOS::CommitTentativeDeviceSettings(
301 std::unique_ptr<enterprise_management::PolicyData> policy) { 301 std::unique_ptr<enterprise_management::PolicyData> policy) {
(...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after
728 728
729 void OwnerSettingsServiceChromeOS::ReportStatusAndContinueStoring( 729 void OwnerSettingsServiceChromeOS::ReportStatusAndContinueStoring(
730 bool success) { 730 bool success) {
731 store_settings_factory_.InvalidateWeakPtrs(); 731 store_settings_factory_.InvalidateWeakPtrs();
732 for (auto& observer : observers_) 732 for (auto& observer : observers_)
733 observer.OnSignedPolicyStored(success); 733 observer.OnSignedPolicyStored(success);
734 StorePendingChanges(); 734 StorePendingChanges();
735 } 735 }
736 736
737 } // namespace chromeos 737 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698