| 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 "extensions/browser/api/cast_channel/cast_message_util.h" | 5 #include "extensions/browser/api/cast_channel/cast_message_util.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 } | 131 } |
| 132 if (message.has_error()) { | 132 if (message.has_error()) { |
| 133 out += ", error: {"; | 133 out += ", error: {"; |
| 134 out += base::IntToString(message.error().error_type()); | 134 out += base::IntToString(message.error().error_type()); |
| 135 out += "}"; | 135 out += "}"; |
| 136 } | 136 } |
| 137 out += "}"; | 137 out += "}"; |
| 138 return out; | 138 return out; |
| 139 } | 139 } |
| 140 | 140 |
| 141 void CreateAuthChallengeMessage(CastMessage* message_proto) { | 141 void CreateAuthChallengeMessage(CastMessage* message_proto, std::string nonce) { |
| 142 CHECK(message_proto); | 142 CHECK(message_proto); |
| 143 DeviceAuthMessage auth_message; | 143 DeviceAuthMessage auth_message; |
| 144 auth_message.mutable_challenge(); | 144 auth_message.mutable_challenge()->set_sender_nonce(nonce); |
| 145 std::string auth_message_string; | 145 std::string auth_message_string; |
| 146 auth_message.SerializeToString(&auth_message_string); | 146 auth_message.SerializeToString(&auth_message_string); |
| 147 | 147 |
| 148 message_proto->set_protocol_version(CastMessage_ProtocolVersion_CASTV2_1_0); | 148 message_proto->set_protocol_version(CastMessage_ProtocolVersion_CASTV2_1_0); |
| 149 message_proto->set_source_id(kPlatformSenderId); | 149 message_proto->set_source_id(kPlatformSenderId); |
| 150 message_proto->set_destination_id(kPlatformReceiverId); | 150 message_proto->set_destination_id(kPlatformReceiverId); |
| 151 message_proto->set_namespace_(kAuthNamespace); | 151 message_proto->set_namespace_(kAuthNamespace); |
| 152 message_proto->set_payload_type(CastMessage_PayloadType_BINARY); | 152 message_proto->set_payload_type(CastMessage_PayloadType_BINARY); |
| 153 message_proto->set_payload_binary(auth_message_string); | 153 message_proto->set_payload_binary(auth_message_string); |
| 154 } | 154 } |
| 155 | 155 |
| 156 bool IsAuthMessage(const CastMessage& message) { | 156 bool IsAuthMessage(const CastMessage& message) { |
| 157 return message.namespace_() == kAuthNamespace; | 157 return message.namespace_() == kAuthNamespace; |
| 158 } | 158 } |
| 159 | 159 |
| 160 } // namespace cast_channel | 160 } // namespace cast_channel |
| 161 } // namespace api | 161 } // namespace api |
| 162 } // namespace extensions | 162 } // namespace extensions |
| OLD | NEW |