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 "core/html/media/MediaError.h" |
| 6 |
| 7 #include "platform/json/JSONValues.h" |
| 8 |
| 9 namespace blink { |
| 10 |
| 11 MediaError::MediaError(ErrorCode code, const JSONObject* messages) |
| 12 : code_(code) { |
| 13 if (!messages->size()) { |
| 14 // A message containing an empty serialized JSON object ("{}") is invalid |
| 15 // and just an empty string should be used in this case per spec: |
| 16 // https://html.spec.whatwg.org/multipage/embedded-content.html#mediaerror |
| 17 // "...whose message is a string containing any details the user agent is |
| 18 // able to supply about the cause of the error condition, or the empty |
| 19 // string if the user agent is unable to supply such details..." |
| 20 message_ = ""; |
| 21 return; |
| 22 } |
| 23 |
| 24 // https://html.spec.whatwg.org/multipage/embedded-content.html#mediaerror |
| 25 // "The message and message format are not generally uniform across |
| 26 // different user agents." |
| 27 // We use a readily-parsable serialized JSON object to represent these error |
| 28 // messages, if we have anything additional to report beyond just the code. |
| 29 message_ = messages->ToJSONString(); |
| 30 } |
| 31 |
| 32 } // namespace blink |
OLD | NEW |