| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "remoting/host/pairing_registry_delegate_win.h" | 5 #include "remoting/host/pairing_registry_delegate_win.h" |
| 6 | 6 |
| 7 #include "base/json/json_string_value_serializer.h" | 7 #include "base/json/json_string_value_serializer.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 10 #include "base/values.h" | 10 #include "base/values.h" |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 SetLastError(result); | 132 SetLastError(result); |
| 133 PLOG(ERROR) << "Cannot get the name of value " << index; | 133 PLOG(ERROR) << "Cannot get the name of value " << index; |
| 134 continue; | 134 continue; |
| 135 } | 135 } |
| 136 | 136 |
| 137 PairingRegistry::Pairing pairing = Load(base::WideToUTF8(value_name)); | 137 PairingRegistry::Pairing pairing = Load(base::WideToUTF8(value_name)); |
| 138 if (pairing.is_valid()) | 138 if (pairing.is_valid()) |
| 139 pairings->Append(pairing.ToValue().release()); | 139 pairings->Append(pairing.ToValue().release()); |
| 140 } | 140 } |
| 141 | 141 |
| 142 return pairings.Pass(); | 142 return pairings; |
| 143 } | 143 } |
| 144 | 144 |
| 145 bool PairingRegistryDelegateWin::DeleteAll() { | 145 bool PairingRegistryDelegateWin::DeleteAll() { |
| 146 if (!privileged_.Valid()) { | 146 if (!privileged_.Valid()) { |
| 147 LOG(ERROR) << "Cannot delete pairings: the delegate is read-only."; | 147 LOG(ERROR) << "Cannot delete pairings: the delegate is read-only."; |
| 148 return false; | 148 return false; |
| 149 } | 149 } |
| 150 | 150 |
| 151 // Enumerate and delete the values in the privileged and unprivileged keys | 151 // Enumerate and delete the values in the privileged and unprivileged keys |
| 152 // separately in case they get out of sync. | 152 // separately in case they get out of sync. |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 216 // Extract the shared secret to a separate dictionary. | 216 // Extract the shared secret to a separate dictionary. |
| 217 scoped_ptr<base::Value> secret_key; | 217 scoped_ptr<base::Value> secret_key; |
| 218 CHECK(pairing_json->Remove(PairingRegistry::kSharedSecretKey, &secret_key)); | 218 CHECK(pairing_json->Remove(PairingRegistry::kSharedSecretKey, &secret_key)); |
| 219 scoped_ptr<base::DictionaryValue> secret_json(new base::DictionaryValue()); | 219 scoped_ptr<base::DictionaryValue> secret_json(new base::DictionaryValue()); |
| 220 secret_json->Set(PairingRegistry::kSharedSecretKey, secret_key.release()); | 220 secret_json->Set(PairingRegistry::kSharedSecretKey, secret_key.release()); |
| 221 | 221 |
| 222 // presubmit: allow wstring | 222 // presubmit: allow wstring |
| 223 std::wstring value_name = base::UTF8ToWide(pairing.client_id()); | 223 std::wstring value_name = base::UTF8ToWide(pairing.client_id()); |
| 224 | 224 |
| 225 // Write pairing to the registry. | 225 // Write pairing to the registry. |
| 226 if (!WriteValue(privileged_, value_name.c_str(), secret_json.Pass()) || | 226 if (!WriteValue(privileged_, value_name.c_str(), std::move(secret_json)) || |
| 227 !WriteValue(unprivileged_, value_name.c_str(), pairing_json.Pass())) { | 227 !WriteValue(unprivileged_, value_name.c_str(), std::move(pairing_json))) { |
| 228 return false; | 228 return false; |
| 229 } | 229 } |
| 230 | 230 |
| 231 return true; | 231 return true; |
| 232 } | 232 } |
| 233 | 233 |
| 234 bool PairingRegistryDelegateWin::Delete(const std::string& client_id) { | 234 bool PairingRegistryDelegateWin::Delete(const std::string& client_id) { |
| 235 if (!privileged_.Valid()) { | 235 if (!privileged_.Valid()) { |
| 236 LOG(ERROR) << "Cannot delete pairing entry '" << client_id | 236 LOG(ERROR) << "Cannot delete pairing entry '" << client_id |
| 237 << "': the delegate is read-only."; | 237 << "': the delegate is read-only."; |
| (...skipping 21 matching lines...) Expand all Loading... |
| 259 } | 259 } |
| 260 | 260 |
| 261 return true; | 261 return true; |
| 262 } | 262 } |
| 263 | 263 |
| 264 scoped_ptr<PairingRegistry::Delegate> CreatePairingRegistryDelegate() { | 264 scoped_ptr<PairingRegistry::Delegate> CreatePairingRegistryDelegate() { |
| 265 return make_scoped_ptr(new PairingRegistryDelegateWin()); | 265 return make_scoped_ptr(new PairingRegistryDelegateWin()); |
| 266 } | 266 } |
| 267 | 267 |
| 268 } // namespace remoting | 268 } // namespace remoting |
| OLD | NEW |