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 "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
10 #include "base/values.h" | 10 #include "base/values.h" |
11 #include "extensions/common/api/cast_channel.h" | 11 #include "extensions/common/api/cast_channel.h" |
12 #include "extensions/common/api/cast_channel/cast_channel.pb.h" | 12 #include "extensions/common/api/cast_channel/cast_channel.pb.h" |
13 | 13 |
14 namespace { | 14 namespace { |
15 static const char kAuthNamespace[] = | 15 static const char kAuthNamespace[] = |
16 "urn:x-cast:com.google.cast.tp.deviceauth"; | 16 "urn:x-cast:com.google.cast.tp.deviceauth"; |
17 // Sender and receiver IDs to use for platform messages. | 17 // Sender and receiver IDs to use for platform messages. |
18 static const char kPlatformSenderId[] = "sender-0"; | 18 static const char kPlatformSenderId[] = "sender-0"; |
19 static const char kPlatformReceiverId[] = "receiver-0"; | 19 static const char kPlatformReceiverId[] = "receiver-0"; |
20 } // namespace | 20 } // namespace |
21 | 21 |
22 namespace extensions { | 22 namespace extensions { |
23 namespace core_api { | 23 namespace api { |
24 namespace cast_channel { | 24 namespace cast_channel { |
25 | 25 |
26 bool MessageInfoToCastMessage(const MessageInfo& message, | 26 bool MessageInfoToCastMessage(const MessageInfo& message, |
27 CastMessage* message_proto) { | 27 CastMessage* message_proto) { |
28 DCHECK(message_proto); | 28 DCHECK(message_proto); |
29 if (!message.data) | 29 if (!message.data) |
30 return false; | 30 return false; |
31 | 31 |
32 message_proto->set_protocol_version(CastMessage_ProtocolVersion_CASTV2_1_0); | 32 message_proto->set_protocol_version(CastMessage_ProtocolVersion_CASTV2_1_0); |
33 message_proto->set_source_id(message.source_id); | 33 message_proto->set_source_id(message.source_id); |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
150 message_proto->set_namespace_(kAuthNamespace); | 150 message_proto->set_namespace_(kAuthNamespace); |
151 message_proto->set_payload_type(CastMessage_PayloadType_BINARY); | 151 message_proto->set_payload_type(CastMessage_PayloadType_BINARY); |
152 message_proto->set_payload_binary(auth_message_string); | 152 message_proto->set_payload_binary(auth_message_string); |
153 } | 153 } |
154 | 154 |
155 bool IsAuthMessage(const CastMessage& message) { | 155 bool IsAuthMessage(const CastMessage& message) { |
156 return message.namespace_() == kAuthNamespace; | 156 return message.namespace_() == kAuthNamespace; |
157 } | 157 } |
158 | 158 |
159 } // namespace cast_channel | 159 } // namespace cast_channel |
160 } // namespace core_api | 160 } // namespace api |
161 } // namespace extensions | 161 } // namespace extensions |
OLD | NEW |