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/signin/easy_unlock_service_regular.h" | 5 #include "chrome/browser/signin/easy_unlock_service_regular.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 227 pairing_dict->GetDictionary(kKeyPermitAccess, &permit_dict)) | 227 pairing_dict->GetDictionary(kKeyPermitAccess, &permit_dict)) |
| 228 return permit_dict; | 228 return permit_dict; |
| 229 | 229 |
| 230 return NULL; | 230 return NULL; |
| 231 } | 231 } |
| 232 | 232 |
| 233 void EasyUnlockServiceRegular::SetPermitAccess( | 233 void EasyUnlockServiceRegular::SetPermitAccess( |
| 234 const base::DictionaryValue& permit) { | 234 const base::DictionaryValue& permit) { |
| 235 DictionaryPrefUpdate pairing_update(profile()->GetPrefs(), | 235 DictionaryPrefUpdate pairing_update(profile()->GetPrefs(), |
| 236 prefs::kEasyUnlockPairing); | 236 prefs::kEasyUnlockPairing); |
| 237 pairing_update->SetWithoutPathExpansion(kKeyPermitAccess, permit.DeepCopy()); | 237 pairing_update->SetWithoutPathExpansion(kKeyPermitAccess, |
| 238 permit.CreateDeepCopy()); | |
|
vabr (Chromium)
2017/04/28 07:23:40
I thought the best way to do a deep copy is
MakeUn
jdoerrie
2017/04/28 08:40:12
Yes, you are right, thank you! I initially didn't
| |
| 238 } | 239 } |
| 239 | 240 |
| 240 void EasyUnlockServiceRegular::ClearPermitAccess() { | 241 void EasyUnlockServiceRegular::ClearPermitAccess() { |
| 241 DictionaryPrefUpdate pairing_update(profile()->GetPrefs(), | 242 DictionaryPrefUpdate pairing_update(profile()->GetPrefs(), |
| 242 prefs::kEasyUnlockPairing); | 243 prefs::kEasyUnlockPairing); |
| 243 pairing_update->RemoveWithoutPathExpansion(kKeyPermitAccess, NULL); | 244 pairing_update->RemoveWithoutPathExpansion(kKeyPermitAccess, NULL); |
| 244 } | 245 } |
| 245 | 246 |
| 246 const base::ListValue* EasyUnlockServiceRegular::GetRemoteDevices() const { | 247 const base::ListValue* EasyUnlockServiceRegular::GetRemoteDevices() const { |
| 247 const base::DictionaryValue* pairing_dict = | 248 const base::DictionaryValue* pairing_dict = |
| 248 profile()->GetPrefs()->GetDictionary(prefs::kEasyUnlockPairing); | 249 profile()->GetPrefs()->GetDictionary(prefs::kEasyUnlockPairing); |
| 249 const base::ListValue* devices = NULL; | 250 const base::ListValue* devices = NULL; |
| 250 if (pairing_dict && pairing_dict->GetList(kKeyDevices, &devices)) | 251 if (pairing_dict && pairing_dict->GetList(kKeyDevices, &devices)) |
| 251 return devices; | 252 return devices; |
| 252 return NULL; | 253 return NULL; |
| 253 } | 254 } |
| 254 | 255 |
| 255 void EasyUnlockServiceRegular::SetRemoteDevices( | 256 void EasyUnlockServiceRegular::SetRemoteDevices( |
| 256 const base::ListValue& devices) { | 257 const base::ListValue& devices) { |
| 257 DictionaryPrefUpdate pairing_update(profile()->GetPrefs(), | 258 DictionaryPrefUpdate pairing_update(profile()->GetPrefs(), |
| 258 prefs::kEasyUnlockPairing); | 259 prefs::kEasyUnlockPairing); |
| 259 if (devices.empty()) | 260 if (devices.empty()) |
| 260 pairing_update->RemoveWithoutPathExpansion(kKeyDevices, NULL); | 261 pairing_update->RemoveWithoutPathExpansion(kKeyDevices, NULL); |
| 261 else | 262 else |
| 262 pairing_update->SetWithoutPathExpansion(kKeyDevices, devices.DeepCopy()); | 263 pairing_update->SetWithoutPathExpansion(kKeyDevices, |
| 264 devices.CreateDeepCopy()); | |
| 263 | 265 |
| 264 #if defined(OS_CHROMEOS) | 266 #if defined(OS_CHROMEOS) |
| 265 // TODO(tengs): Investigate if we can determine if the remote devices were set | 267 // TODO(tengs): Investigate if we can determine if the remote devices were set |
| 266 // from sync or from the setup app. | 268 // from sync or from the setup app. |
| 267 if (short_lived_user_context_ && short_lived_user_context_->user_context()) { | 269 if (short_lived_user_context_ && short_lived_user_context_->user_context()) { |
| 268 // We may already have the password cached, so proceed to create the | 270 // We may already have the password cached, so proceed to create the |
| 269 // cryptohome keys for sign-in or the system will be hardlocked. | 271 // cryptohome keys for sign-in or the system will be hardlocked. |
| 270 chromeos::UserSessionManager::GetInstance() | 272 chromeos::UserSessionManager::GetInstance() |
| 271 ->GetEasyUnlockKeyManager() | 273 ->GetEasyUnlockKeyManager() |
| 272 ->RefreshKeys( | 274 ->RefreshKeys( |
| (...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 591 | 593 |
| 592 cryptauth::CryptAuthDeviceManager* | 594 cryptauth::CryptAuthDeviceManager* |
| 593 EasyUnlockServiceRegular::GetCryptAuthDeviceManager() { | 595 EasyUnlockServiceRegular::GetCryptAuthDeviceManager() { |
| 594 cryptauth::CryptAuthDeviceManager* manager = | 596 cryptauth::CryptAuthDeviceManager* manager = |
| 595 ChromeCryptAuthServiceFactory::GetInstance() | 597 ChromeCryptAuthServiceFactory::GetInstance() |
| 596 ->GetForBrowserContext(profile()) | 598 ->GetForBrowserContext(profile()) |
| 597 ->GetCryptAuthDeviceManager(); | 599 ->GetCryptAuthDeviceManager(); |
| 598 DCHECK(manager); | 600 DCHECK(manager); |
| 599 return manager; | 601 return manager; |
| 600 } | 602 } |
| OLD | NEW |