| 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 "config.h" | 5 #include "config.h" |
| 6 #include "modules/mediasource/TrackDefault.h" | 6 #include "modules/mediasource/TrackDefault.h" |
| 7 | 7 |
| 8 #include "bindings/core/v8/ExceptionState.h" | 8 #include "bindings/core/v8/ExceptionState.h" |
| 9 #include "core/dom/ExceptionCode.h" | 9 #include "core/dom/ExceptionCode.h" |
| 10 #include "core/html/track/AudioTrack.h" | 10 #include "core/html/track/AudioTrack.h" |
| 11 #include "core/html/track/TextTrack.h" | 11 #include "core/html/track/TextTrack.h" |
| 12 #include "core/html/track/VideoTrack.h" | 12 #include "core/html/track/VideoTrack.h" |
| 13 #include "public/platform/Platform.h" |
| 13 | 14 |
| 14 namespace blink { | 15 namespace blink { |
| 15 | 16 |
| 16 static const AtomicString& audioKeyword() | 17 static const AtomicString& audioKeyword() |
| 17 { | 18 { |
| 18 DEFINE_STATIC_LOCAL(const AtomicString, audio, ("audio", AtomicString::Const
ructFromLiteral)); | 19 DEFINE_STATIC_LOCAL(const AtomicString, audio, ("audio", AtomicString::Const
ructFromLiteral)); |
| 19 return audio; | 20 return audio; |
| 20 } | 21 } |
| 21 | 22 |
| 22 static const AtomicString& videoKeyword() | 23 static const AtomicString& videoKeyword() |
| (...skipping 10 matching lines...) Expand all Loading... |
| 33 | 34 |
| 34 TrackDefault* TrackDefault::create(const AtomicString& type, const String& langu
age, const String& label, const Vector<String>& kinds, const String& byteStreamT
rackID, ExceptionState& exceptionState) | 35 TrackDefault* TrackDefault::create(const AtomicString& type, const String& langu
age, const String& label, const Vector<String>& kinds, const String& byteStreamT
rackID, ExceptionState& exceptionState) |
| 35 { | 36 { |
| 36 // Per 11 Nov 2014 Editor's Draft | 37 // Per 11 Nov 2014 Editor's Draft |
| 37 // https://dvcs.w3.org/hg/html-media/raw-file/tip/media-source/media-source.
html#idl-def-TrackDefault | 38 // https://dvcs.w3.org/hg/html-media/raw-file/tip/media-source/media-source.
html#idl-def-TrackDefault |
| 38 // with expectation that | 39 // with expectation that |
| 39 // https://www.w3.org/Bugs/Public/show_bug.cgi?id=27352 will be fixed soon: | 40 // https://www.w3.org/Bugs/Public/show_bug.cgi?id=27352 will be fixed soon: |
| 40 // When this method is invoked, the user agent must run the following steps: | 41 // When this method is invoked, the user agent must run the following steps: |
| 41 // 1. if |language| is not an empty string and |language| is not a BCP 47 | 42 // 1. if |language| is not an empty string and |language| is not a BCP 47 |
| 42 // language tag, then throw an INVALID_ACCESS_ERR and abort these steps. | 43 // language tag, then throw an INVALID_ACCESS_ERR and abort these steps. |
| 43 // FIXME: Implement BCP 47 language tag validation. | 44 if (!Platform::current()->isValidLocaleSyntax(language)) { |
| 45 exceptionState.throwDOMException(InvalidAccessError, "Invalid BCP 47 lan
guage tag"); |
| 46 return nullptr; |
| 47 } |
| 44 | 48 |
| 45 if (type == audioKeyword()) { | 49 if (type == audioKeyword()) { |
| 46 // 2.1. If |type| equals "audio": | 50 // 2.1. If |type| equals "audio": |
| 47 // If any string in |kinds| contains a value that is not listed as | 51 // If any string in |kinds| contains a value that is not listed as |
| 48 // applying to audio in the kind categories table, then throw a | 52 // applying to audio in the kind categories table, then throw a |
| 49 // TypeError and abort these steps. | 53 // TypeError and abort these steps. |
| 50 for (const String& kind : kinds) { | 54 for (const String& kind : kinds) { |
| 51 if (!AudioTrack::isValidKindKeyword(kind)) { | 55 if (!AudioTrack::isValidKindKeyword(kind)) { |
| 52 exceptionState.throwTypeError("Invalid audio track default kind
'" + kind + "'"); | 56 exceptionState.throwTypeError("Invalid audio track default kind
'" + kind + "'"); |
| 53 return nullptr; | 57 return nullptr; |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 TrackDefault::TrackDefault(const AtomicString& type, const String& language, con
st String& label, const Vector<String>& kinds, const String& byteStreamTrackID) | 101 TrackDefault::TrackDefault(const AtomicString& type, const String& language, con
st String& label, const Vector<String>& kinds, const String& byteStreamTrackID) |
| 98 : m_type(type) | 102 : m_type(type) |
| 99 , m_byteStreamTrackID(byteStreamTrackID) | 103 , m_byteStreamTrackID(byteStreamTrackID) |
| 100 , m_language(language) | 104 , m_language(language) |
| 101 , m_label(label) | 105 , m_label(label) |
| 102 , m_kinds(kinds) | 106 , m_kinds(kinds) |
| 103 { | 107 { |
| 104 } | 108 } |
| 105 | 109 |
| 106 } // namespace blink | 110 } // namespace blink |
| OLD | NEW |