| 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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 // JS string | 42 // JS string |
| 43 case base::Value::Type::STRING: | 43 case base::Value::Type::STRING: |
| 44 if (message.data->GetAsString(&data)) { | 44 if (message.data->GetAsString(&data)) { |
| 45 message_proto->set_payload_type(CastMessage_PayloadType_STRING); | 45 message_proto->set_payload_type(CastMessage_PayloadType_STRING); |
| 46 message_proto->set_payload_utf8(data); | 46 message_proto->set_payload_utf8(data); |
| 47 } | 47 } |
| 48 break; | 48 break; |
| 49 // JS ArrayBuffer | 49 // JS ArrayBuffer |
| 50 case base::Value::Type::BINARY: | 50 case base::Value::Type::BINARY: |
| 51 message_proto->set_payload_type(CastMessage_PayloadType_BINARY); | 51 message_proto->set_payload_type(CastMessage_PayloadType_BINARY); |
| 52 message_proto->set_payload_binary(message.data->GetBuffer(), | 52 message_proto->set_payload_binary(message.data->GetBlob().data(), |
| 53 message.data->GetSize()); | 53 message.data->GetBlob().size()); |
| 54 break; | 54 break; |
| 55 default: | 55 default: |
| 56 // Unknown value type. message_proto will remain uninitialized because | 56 // Unknown value type. message_proto will remain uninitialized because |
| 57 // payload_type is unset. | 57 // payload_type is unset. |
| 58 break; | 58 break; |
| 59 } | 59 } |
| 60 return message_proto->IsInitialized(); | 60 return message_proto->IsInitialized(); |
| 61 } | 61 } |
| 62 | 62 |
| 63 bool IsCastMessageValid(const CastMessage& message_proto) { | 63 bool IsCastMessageValid(const CastMessage& message_proto) { |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 message_proto->set_payload_binary(auth_message_string); | 151 message_proto->set_payload_binary(auth_message_string); |
| 152 } | 152 } |
| 153 | 153 |
| 154 bool IsAuthMessage(const CastMessage& message) { | 154 bool IsAuthMessage(const CastMessage& message) { |
| 155 return message.namespace_() == kAuthNamespace; | 155 return message.namespace_() == kAuthNamespace; |
| 156 } | 156 } |
| 157 | 157 |
| 158 } // namespace cast_channel | 158 } // namespace cast_channel |
| 159 } // namespace api | 159 } // namespace api |
| 160 } // namespace extensions | 160 } // namespace extensions |
| OLD | NEW |