Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "content/common/presentation/presentation_struct_traits.h" | |
| 6 | |
| 7 #include "url/mojo/url_gurl_struct_traits.h" | |
| 8 | |
| 9 namespace mojo { | |
| 10 | |
| 11 bool StructTraits<blink::mojom::PresentationSessionInfoDataView, | |
| 12 content::PresentationSessionInfo>:: | |
| 13 Read(blink::mojom::PresentationSessionInfoDataView data, | |
| 14 content::PresentationSessionInfo* out) { | |
| 15 if (!data.ReadUrl(&(out->presentation_url)) || | |
| 16 !data.ReadId(&(out->presentation_id))) { | |
| 17 return false; | |
| 18 } | |
| 19 | |
| 20 if (out->presentation_id.empty() || | |
| 21 !base::IsStringASCII(out->presentation_id) || | |
| 22 out->presentation_id.length() > | |
| 23 content::PresentationSessionInfo::kMaxIdLength) { | |
| 24 return false; | |
| 25 } | |
| 26 return true; | |
| 27 } | |
| 28 | |
| 29 bool StructTraits<blink::mojom::PresentationErrorDataView, | |
| 30 content::PresentationError>:: | |
| 31 Read(blink::mojom::PresentationErrorDataView data, | |
| 32 content::PresentationError* out) { | |
| 33 if (!data.ReadErrorType(&(out->error_type)) || | |
| 34 !data.ReadMessage(&(out->message))) { | |
| 35 return false; | |
| 36 } | |
| 37 | |
| 38 if (!base::IsStringUTF8(out->message) || | |
|
dcheng
2017/02/28 06:45:27
I think Mojo requires that strings are utf-8. +yzs
yzshen1
2017/02/28 18:22:07
We don't enforce it during validation at the momen
| |
| 39 out->message.length() > content::PresentationError::kMaxMessageLength) { | |
| 40 return false; | |
| 41 } | |
| 42 | |
| 43 return true; | |
| 44 } | |
| 45 | |
| 46 bool UnionTraits<blink::mojom::PresentationConnectionMessageDataView, | |
| 47 content::PresentationConnectionMessage>:: | |
| 48 Read(blink::mojom::PresentationConnectionMessageDataView data, | |
| 49 content::PresentationConnectionMessage* out) { | |
| 50 if (data.is_message()) { | |
| 51 // out->message = std::string(); | |
|
dcheng
2017/02/28 06:45:27
Nit: remove commented out code here and below
mark a. foltz
2017/02/28 18:35:21
Done.
| |
| 52 if (!data.ReadMessage(&(out->message)) || | |
| 53 out->message->length() > | |
| 54 content::kMaxPresentationConnectionMessageSize) { | |
| 55 return false; | |
| 56 } | |
| 57 } else { | |
| 58 // out->data = std::vector<uint8_t>(); | |
| 59 if (!data.ReadData(&(out->data)) || | |
| 60 out->data->size() > content::kMaxPresentationConnectionMessageSize) { | |
| 61 return false; | |
| 62 } | |
| 63 } | |
| 64 return true; | |
| 65 } | |
| 66 } | |
| OLD | NEW |