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 "components/proximity_auth/client.h" | 5 #include "components/proximity_auth/client.h" |
6 | 6 |
7 #include "base/json/json_reader.h" | 7 #include "base/json/json_reader.h" |
8 #include "base/json/json_writer.h" | 8 #include "base/json/json_writer.h" |
9 #include "base/values.h" | 9 #include "base/values.h" |
10 #include "components/proximity_auth/client_observer.h" | 10 #include "components/proximity_auth/client_observer.h" |
(...skipping 19 matching lines...) Expand all Loading... |
30 const char kMessageTypeDecryptResponse[] = "decrypt_response"; | 30 const char kMessageTypeDecryptResponse[] = "decrypt_response"; |
31 const char kMessageTypeUnlockRequest[] = "unlock_request"; | 31 const char kMessageTypeUnlockRequest[] = "unlock_request"; |
32 const char kMessageTypeUnlockResponse[] = "unlock_response"; | 32 const char kMessageTypeUnlockResponse[] = "unlock_response"; |
33 | 33 |
34 // The name for an unlock event originating from the local device. | 34 // The name for an unlock event originating from the local device. |
35 const char kUnlockEventName[] = "easy_unlock"; | 35 const char kUnlockEventName[] = "easy_unlock"; |
36 | 36 |
37 // Serializes the |value| to a JSON string and returns the result. | 37 // Serializes the |value| to a JSON string and returns the result. |
38 std::string SerializeValueToJson(const base::Value& value) { | 38 std::string SerializeValueToJson(const base::Value& value) { |
39 std::string json; | 39 std::string json; |
40 base::JSONWriter::Write(&value, &json); | 40 base::JSONWriter::Write(value, &json); |
41 return json; | 41 return json; |
42 } | 42 } |
43 | 43 |
44 // Returns the message type represented by the |message|. This is a convenience | 44 // Returns the message type represented by the |message|. This is a convenience |
45 // wrapper that should only be called when the |message| is known to specify its | 45 // wrapper that should only be called when the |message| is known to specify its |
46 // message type, i.e. this should not be called for untrusted input. | 46 // message type, i.e. this should not be called for untrusted input. |
47 std::string GetMessageType(const base::DictionaryValue& message) { | 47 std::string GetMessageType(const base::DictionaryValue& message) { |
48 std::string type; | 48 std::string type; |
49 message.GetString(kTypeKey, &type); | 49 message.GetString(kTypeKey, &type); |
50 return type; | 50 return type; |
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
280 } else { | 280 } else { |
281 VLOG(1) << "[Client] Message of unknown type '" << pending_message_->type | 281 VLOG(1) << "[Client] Message of unknown type '" << pending_message_->type |
282 << "sent."; | 282 << "sent."; |
283 } | 283 } |
284 | 284 |
285 pending_message_.reset(); | 285 pending_message_.reset(); |
286 ProcessMessageQueue(); | 286 ProcessMessageQueue(); |
287 } | 287 } |
288 | 288 |
289 } // namespace proximity_auth | 289 } // namespace proximity_auth |
OLD | NEW |