Chromium Code Reviews| Index: chrome/browser/extensions/api/cast_channel/cast_message_util.cc |
| =================================================================== |
| --- chrome/browser/extensions/api/cast_channel/cast_message_util.cc (revision 230132) |
| +++ chrome/browser/extensions/api/cast_channel/cast_message_util.cc (working copy) |
| @@ -11,6 +11,14 @@ |
| #include "chrome/browser/extensions/api/cast_channel/cast_channel.pb.h" |
| #include "chrome/common/extensions/api/cast_channel.h" |
| +namespace { |
| +static const char kAuthNamespace[] = |
| + "urn:x-cast:com.google.cast.tp.deviceauth"; |
| +// Sender and receiver IDs to use for platform messages. |
| +static const char kPlatformSenderId[] = "sender-0"; |
| +static const char kPlatformReceiverId[] = "receiver-0"; |
| +} // namespace |
| + |
| namespace extensions { |
| namespace api { |
| namespace cast_channel { |
| @@ -83,7 +91,7 @@ |
| } |
| } |
| -const std::string MessageProtoToString(const CastMessage& message_proto) { |
| +std::string CastMessageToString(const CastMessage& message_proto) { |
| std::string out("{"); |
| out += "namespace = " + message_proto.namespace_(); |
| out += ", sourceId = " + message_proto.source_id(); |
| @@ -93,6 +101,45 @@ |
| return out; |
| } |
| +std::string AuthMessageToString(const DeviceAuthMessage& message) { |
| + std::string out("{"); |
| + if (message.has_challenge()) { |
| + out += "\n challenge = {},"; |
| + } |
| + if (message.has_response()) { |
| + out += "\n response = {"; |
| + out += "\n signature = " + message.response().signature(); |
| + out += "\n, certificate = " + |
| + message.response().client_auth_certificate(); |
| + out += "\n }"; |
| + } |
| + if (message.has_error()) { |
| + out += "\n error = {"; |
| + out += base::IntToString(message.error().error_type()); |
| + out += "}"; |
| + } |
| + out += "}"; |
| + return out; |
|
Ryan Sleevi
2013/10/23 19:14:05
I can't recall any code where I've seen this sort
Munjal (Google)
2013/10/23 20:08:56
It is only used in logs.
|
| +} |
| + |
| +void CreateAuthChallengeMessage(CastMessage* message_proto) { |
| + CHECK(message_proto); |
| + DeviceAuthMessage auth_message; |
| + auth_message.mutable_challenge(); |
| + std::string auth_message_string; |
| + auth_message.SerializeToString(&auth_message_string); |
| + |
| + message_proto->set_source_id(kPlatformSenderId); |
| + message_proto->set_destination_id(kPlatformReceiverId); |
| + message_proto->set_namespace_(kAuthNamespace); |
| + message_proto->set_payload_type(CastMessage_PayloadType_BINARY); |
| + message_proto->set_payload_binary(auth_message_string); |
| +} |
| + |
| +bool IsAuthMessage(const CastMessage& message) { |
| + return message.namespace_() == kAuthNamespace; |
| +} |
| + |
| } // namespace cast_channel |
| } // namespace api |
| } // namespace extensions |