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 "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/prefs/pref_service.h" | 9 #include "base/prefs/pref_service.h" |
10 #include "base/prefs/scoped_user_pref_update.h" | 10 #include "base/prefs/scoped_user_pref_update.h" |
(...skipping 14 matching lines...) Expand all Loading... |
25 #endif | 25 #endif |
26 | 26 |
27 namespace { | 27 namespace { |
28 | 28 |
29 // Key name of the local device permit record dictonary in kEasyUnlockPairing. | 29 // Key name of the local device permit record dictonary in kEasyUnlockPairing. |
30 const char kKeyPermitAccess[] = "permitAccess"; | 30 const char kKeyPermitAccess[] = "permitAccess"; |
31 | 31 |
32 // Key name of the remote device list in kEasyUnlockPairing. | 32 // Key name of the remote device list in kEasyUnlockPairing. |
33 const char kKeyDevices[] = "devices"; | 33 const char kKeyDevices[] = "devices"; |
34 | 34 |
| 35 // Key name of the hardlocked flag in kEasyUnlockPairing. |
| 36 const char kKeyHardlocked[] = "hardlocked"; |
| 37 |
35 // Key name of the phone public key in a device dictionary. | 38 // Key name of the phone public key in a device dictionary. |
36 const char kKeyPhoneId[] = "permitRecord.id"; | 39 const char kKeyPhoneId[] = "permitRecord.id"; |
37 | 40 |
38 } // namespace | 41 } // namespace |
39 | 42 |
40 EasyUnlockServiceRegular::EasyUnlockServiceRegular(Profile* profile) | 43 EasyUnlockServiceRegular::EasyUnlockServiceRegular(Profile* profile) |
41 : EasyUnlockService(profile), | 44 : EasyUnlockService(profile), |
42 turn_off_flow_status_(EasyUnlockService::IDLE) { | 45 turn_off_flow_status_(EasyUnlockService::IDLE) { |
43 } | 46 } |
44 | 47 |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 prefs::kEasyUnlockPairing); | 106 prefs::kEasyUnlockPairing); |
104 pairing_update->SetWithoutPathExpansion(kKeyDevices, devices.DeepCopy()); | 107 pairing_update->SetWithoutPathExpansion(kKeyDevices, devices.DeepCopy()); |
105 } | 108 } |
106 | 109 |
107 void EasyUnlockServiceRegular::ClearRemoteDevices() { | 110 void EasyUnlockServiceRegular::ClearRemoteDevices() { |
108 DictionaryPrefUpdate pairing_update(profile()->GetPrefs(), | 111 DictionaryPrefUpdate pairing_update(profile()->GetPrefs(), |
109 prefs::kEasyUnlockPairing); | 112 prefs::kEasyUnlockPairing); |
110 pairing_update->RemoveWithoutPathExpansion(kKeyDevices, NULL); | 113 pairing_update->RemoveWithoutPathExpansion(kKeyDevices, NULL); |
111 } | 114 } |
112 | 115 |
| 116 void EasyUnlockServiceRegular::SetHardlocked(bool value) { |
| 117 DictionaryPrefUpdate pairing_update(profile()->GetPrefs(), |
| 118 prefs::kEasyUnlockPairing); |
| 119 pairing_update->SetBooleanWithoutPathExpansion(kKeyHardlocked, value); |
| 120 |
| 121 SetScreenlockHardlockedState(value); |
| 122 } |
| 123 |
| 124 bool EasyUnlockServiceRegular::IsHardlocked() const { |
| 125 const base::DictionaryValue* pairing_dict = |
| 126 profile()->GetPrefs()->GetDictionary(prefs::kEasyUnlockPairing); |
| 127 bool hardlocked = false; |
| 128 return pairing_dict && |
| 129 pairing_dict->GetBoolean(kKeyHardlocked, &hardlocked) && |
| 130 hardlocked; |
| 131 } |
| 132 |
113 void EasyUnlockServiceRegular::RunTurnOffFlow() { | 133 void EasyUnlockServiceRegular::RunTurnOffFlow() { |
114 if (turn_off_flow_status_ == PENDING) | 134 if (turn_off_flow_status_ == PENDING) |
115 return; | 135 return; |
116 | 136 |
117 SetTurnOffFlowStatus(PENDING); | 137 SetTurnOffFlowStatus(PENDING); |
118 | 138 |
119 // Currently there should only be one registered phone. | 139 // Currently there should only be one registered phone. |
120 // TODO(xiyuan): Revisit this when server supports toggle for all or | 140 // TODO(xiyuan): Revisit this when server supports toggle for all or |
121 // there are multiple phones. | 141 // there are multiple phones. |
122 const base::DictionaryValue* pairing_dict = | 142 const base::DictionaryValue* pairing_dict = |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
204 | 224 |
205 if (!success) { | 225 if (!success) { |
206 SetTurnOffFlowStatus(FAIL); | 226 SetTurnOffFlowStatus(FAIL); |
207 return; | 227 return; |
208 } | 228 } |
209 | 229 |
210 ClearRemoteDevices(); | 230 ClearRemoteDevices(); |
211 SetTurnOffFlowStatus(IDLE); | 231 SetTurnOffFlowStatus(IDLE); |
212 ReloadApp(); | 232 ReloadApp(); |
213 } | 233 } |
OLD | NEW |