Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(220)

Side by Side Diff: Source/modules/encryptedmedia/NavigatorRequestMediaKeySystemAccess.cpp

Issue 759443005: Replace MediaKeySystemOptions with MediaKeySystemConfiguration. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Update Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/encryptedmedia/NavigatorRequestMediaKeySystemAccess.h" 6 #include "modules/encryptedmedia/NavigatorRequestMediaKeySystemAccess.h"
7 7
8 #include "bindings/core/v8/ScriptPromiseResolver.h" 8 #include "bindings/core/v8/ScriptPromiseResolver.h"
9 #include "bindings/core/v8/ScriptState.h" 9 #include "bindings/core/v8/ScriptState.h"
10 #include "core/dom/DOMException.h" 10 #include "core/dom/DOMException.h"
(...skipping 14 matching lines...) Expand all
25 String codecs = type.parameter("codecs"); 25 String codecs = type.parameter("codecs");
26 return blink::MIMETypeRegistry::isSupportedEncryptedMediaMIMEType(keySystem, type.type(), codecs); 26 return blink::MIMETypeRegistry::isSupportedEncryptedMediaMIMEType(keySystem, type.type(), codecs);
27 } 27 }
28 28
29 // This class allows capabilities to be checked and a MediaKeySystemAccess 29 // This class allows capabilities to be checked and a MediaKeySystemAccess
30 // object to be created asynchronously. 30 // object to be created asynchronously.
31 class MediaKeySystemAccessInitializer final : public blink::ScriptPromiseResolve r { 31 class MediaKeySystemAccessInitializer final : public blink::ScriptPromiseResolve r {
32 WTF_MAKE_NONCOPYABLE(MediaKeySystemAccessInitializer); 32 WTF_MAKE_NONCOPYABLE(MediaKeySystemAccessInitializer);
33 33
34 public: 34 public:
35 static blink::ScriptPromise create(blink::ScriptState*, const String& keySys tem, const Vector<blink::MediaKeySystemOptions>& supportedConfigurations); 35 static blink::ScriptPromise create(blink::ScriptState*, const String& keySys tem, const Vector<blink::MediaKeySystemConfiguration>& supportedConfigurations);
36 virtual ~MediaKeySystemAccessInitializer(); 36 virtual ~MediaKeySystemAccessInitializer();
37 37
38 private: 38 private:
39 MediaKeySystemAccessInitializer(blink::ScriptState*, const String& keySystem , const Vector<blink::MediaKeySystemOptions>& supportedConfigurations); 39 MediaKeySystemAccessInitializer(blink::ScriptState*, const String& keySystem , const Vector<blink::MediaKeySystemConfiguration>& supportedConfigurations);
40 void timerFired(blink::Timer<MediaKeySystemAccessInitializer>*); 40 void timerFired(blink::Timer<MediaKeySystemAccessInitializer>*);
41 41
42 const String m_keySystem; 42 const String m_keySystem;
43 const Vector<blink::MediaKeySystemOptions> m_supportedConfigurations; 43 const Vector<blink::MediaKeySystemConfiguration> m_supportedConfigurations;
44 blink::Timer<MediaKeySystemAccessInitializer> m_timer; 44 blink::Timer<MediaKeySystemAccessInitializer> m_timer;
45 }; 45 };
46 46
47 blink::ScriptPromise MediaKeySystemAccessInitializer::create(blink::ScriptState* scriptState, const String& keySystem, const Vector<blink::MediaKeySystemOptions >& supportedConfigurations) 47 blink::ScriptPromise MediaKeySystemAccessInitializer::create(blink::ScriptState* scriptState, const String& keySystem, const Vector<blink::MediaKeySystemConfigu ration>& supportedConfigurations)
48 { 48 {
49 RefPtr<MediaKeySystemAccessInitializer> initializer = adoptRef(new MediaKeyS ystemAccessInitializer(scriptState, keySystem, supportedConfigurations)); 49 RefPtr<MediaKeySystemAccessInitializer> initializer = adoptRef(new MediaKeyS ystemAccessInitializer(scriptState, keySystem, supportedConfigurations));
50 initializer->suspendIfNeeded(); 50 initializer->suspendIfNeeded();
51 initializer->keepAliveWhilePending(); 51 initializer->keepAliveWhilePending();
52 return initializer->promise(); 52 return initializer->promise();
53 } 53 }
54 54
55 MediaKeySystemAccessInitializer::MediaKeySystemAccessInitializer(blink::ScriptSt ate* scriptState, const String& keySystem, const Vector<blink::MediaKeySystemOpt ions>& supportedConfigurations) 55 MediaKeySystemAccessInitializer::MediaKeySystemAccessInitializer(blink::ScriptSt ate* scriptState, const String& keySystem, const Vector<blink::MediaKeySystemCon figuration>& supportedConfigurations)
56 : blink::ScriptPromiseResolver(scriptState) 56 : blink::ScriptPromiseResolver(scriptState)
57 , m_keySystem(keySystem) 57 , m_keySystem(keySystem)
58 , m_supportedConfigurations(supportedConfigurations) 58 , m_supportedConfigurations(supportedConfigurations)
59 , m_timer(this, &MediaKeySystemAccessInitializer::timerFired) 59 , m_timer(this, &MediaKeySystemAccessInitializer::timerFired)
60 { 60 {
61 // Start the timer so that MediaKeySystemAccess can be created 61 // Start the timer so that MediaKeySystemAccess can be created
62 // asynchronously. 62 // asynchronously.
63 // FIXME: If creating MediaKeySystemAccess or 63 // FIXME: If creating MediaKeySystemAccess or
64 // isKeySystemSupportedWithContentType() is replaced with something 64 // isKeySystemSupportedWithContentType() is replaced with something
65 // asynchronous, wait for the event rather than using a timer. 65 // asynchronous, wait for the event rather than using a timer.
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 for (const auto& combination : m_supportedConfigurations) { 97 for (const auto& combination : m_supportedConfigurations) {
98 // 5.3.2.1 If the member's value cannot be satisfied together in 98 // 5.3.2.1 If the member's value cannot be satisfied together in
99 // combination with the previous members, continue to the next 99 // combination with the previous members, continue to the next
100 // iteration of the loop. 100 // iteration of the loop.
101 // 5.3.3 If keySystem is supported and allowed in the origin of the 101 // 5.3.3 If keySystem is supported and allowed in the origin of the
102 // calling context's Document in the configuration specified by 102 // calling context's Document in the configuration specified by
103 // the combination of the values in combination, execute the 103 // the combination of the values in combination, execute the
104 // following steps: 104 // following steps:
105 // FIXME: This test needs to be enhanced to use more values from 105 // FIXME: This test needs to be enhanced to use more values from
106 // combination. 106 // combination.
107 if (isKeySystemSupportedWithContentType(m_keySystem, combination.initDat aType())) { 107 for (const auto& initDataType : combination.initDataTypes()) {
108 // 5.3.3.1 Let access be a new MediaKeySystemAccess object, and 108 if (isKeySystemSupportedWithContentType(m_keySystem, initDataType)) {
109 // initialize it as follows: 109 // 5.3.3.1 Let access be a new MediaKeySystemAccess object, and
110 // 5.3.3.1.1 Set the keySystem attribute to keySystem. 110 // initialize it as follows:
111 blink::MediaKeySystemAccess* access = new blink::MediaKeySystemAcces s(m_keySystem); 111 // 5.3.3.1.1 Set the keySystem attribute to keySystem.
112 blink::MediaKeySystemAccess* access = new blink::MediaKeySystemA ccess(m_keySystem);
112 113
113 // 5.3.3.2 Resolve promise with access and abort these steps. 114 // 5.3.3.2 Resolve promise with access and abort these steps.
114 resolve(access); 115 resolve(access);
115 return; 116 return;
117 }
116 } 118 }
117 } 119 }
118 120
119 // 5.4 Reject promise with a new DOMException whose name is 121 // 5.4 Reject promise with a new DOMException whose name is
120 // NotSupportedError. 122 // NotSupportedError.
121 reject(blink::DOMException::create(blink::NotSupportedError, "There were no supported combinations in supportedConfigurations.")); 123 reject(blink::DOMException::create(blink::NotSupportedError, "There were no supported combinations in supportedConfigurations."));
122 } 124 }
123 125
124 } // namespace 126 } // namespace
125 127
(...skipping 30 matching lines...) Expand all
156 return ScriptPromise::rejectWithDOMException( 158 return ScriptPromise::rejectWithDOMException(
157 scriptState, DOMException::create(InvalidAccessError, "The keySystem parameter is empty.")); 159 scriptState, DOMException::create(InvalidAccessError, "The keySystem parameter is empty."));
158 } 160 }
159 161
160 // 2. If supportedConfigurations was provided and is empty, return a 162 // 2. If supportedConfigurations was provided and is empty, return a
161 // promise rejected with a new DOMException whose name is 163 // promise rejected with a new DOMException whose name is
162 // InvalidAccessError. 164 // InvalidAccessError.
163 // (no supportedConfigurations provided.) 165 // (no supportedConfigurations provided.)
164 166
165 // Remainder of steps handled in common routine below. 167 // Remainder of steps handled in common routine below.
166 return NavigatorRequestMediaKeySystemAccess::from(navigator).requestMediaKey SystemAccess(scriptState, keySystem, Vector<MediaKeySystemOptions>()); 168 return NavigatorRequestMediaKeySystemAccess::from(navigator).requestMediaKey SystemAccess(scriptState, keySystem, Vector<MediaKeySystemConfiguration>());
167 } 169 }
168 170
169 ScriptPromise NavigatorRequestMediaKeySystemAccess::requestMediaKeySystemAccess( 171 ScriptPromise NavigatorRequestMediaKeySystemAccess::requestMediaKeySystemAccess(
170 ScriptState* scriptState, 172 ScriptState* scriptState,
171 Navigator& navigator, 173 Navigator& navigator,
172 const String& keySystem, 174 const String& keySystem,
173 const Vector<MediaKeySystemOptions>& supportedConfigurations) 175 const Vector<MediaKeySystemConfiguration>& supportedConfigurations)
174 { 176 {
175 // From https://dvcs.w3.org/hg/html-media/raw-file/default/encrypted-media/e ncrypted-media.html#requestmediakeysystemaccess 177 // From https://dvcs.w3.org/hg/html-media/raw-file/default/encrypted-media/e ncrypted-media.html#requestmediakeysystemaccess
176 // When this method is invoked, the user agent must run the following steps: 178 // When this method is invoked, the user agent must run the following steps:
177 // 1. If keySystem is an empty string, return a promise rejected with a 179 // 1. If keySystem is an empty string, return a promise rejected with a
178 // new DOMException whose name is InvalidAccessError. 180 // new DOMException whose name is InvalidAccessError.
179 if (keySystem.isEmpty()) { 181 if (keySystem.isEmpty()) {
180 return ScriptPromise::rejectWithDOMException( 182 return ScriptPromise::rejectWithDOMException(
181 scriptState, DOMException::create(InvalidAccessError, "The keySystem parameter is empty.")); 183 scriptState, DOMException::create(InvalidAccessError, "The keySystem parameter is empty."));
182 } 184 }
183 185
184 // 2. If supportedConfigurations was provided and is empty, return a 186 // 2. If supportedConfigurations was provided and is empty, return a
185 // promise rejected with a new DOMException whose name is 187 // promise rejected with a new DOMException whose name is
186 // InvalidAccessError. 188 // InvalidAccessError.
187 if (!supportedConfigurations.size()) { 189 if (!supportedConfigurations.size()) {
188 return ScriptPromise::rejectWithDOMException( 190 return ScriptPromise::rejectWithDOMException(
189 scriptState, DOMException::create(InvalidAccessError, "The supported Configurations parameter is empty.")); 191 scriptState, DOMException::create(InvalidAccessError, "The supported Configurations parameter is empty."));
190 } 192 }
191 193
192 // Remainder of steps handled in common routine below. 194 // Remainder of steps handled in common routine below.
193 return NavigatorRequestMediaKeySystemAccess::from(navigator).requestMediaKey SystemAccess( 195 return NavigatorRequestMediaKeySystemAccess::from(navigator).requestMediaKey SystemAccess(
194 scriptState, keySystem, supportedConfigurations); 196 scriptState, keySystem, supportedConfigurations);
195 } 197 }
196 198
197 ScriptPromise NavigatorRequestMediaKeySystemAccess::requestMediaKeySystemAccess( 199 ScriptPromise NavigatorRequestMediaKeySystemAccess::requestMediaKeySystemAccess(
198 ScriptState* scriptState, 200 ScriptState* scriptState,
199 const String& keySystem, 201 const String& keySystem,
200 const Vector<MediaKeySystemOptions>& supportedConfigurations) 202 const Vector<MediaKeySystemConfiguration>& supportedConfigurations)
201 { 203 {
202 // Continued from above. 204 // Continued from above.
203 // 3. If keySystem is not one of the Key Systems supported by the user 205 // 3. If keySystem is not one of the Key Systems supported by the user
204 // agent, return a promise rejected with a new DOMException whose name 206 // agent, return a promise rejected with a new DOMException whose name
205 // is NotSupportedError. String comparison is case-sensitive. 207 // is NotSupportedError. String comparison is case-sensitive.
206 if (!isKeySystemSupportedWithContentType(keySystem, "")) { 208 if (!isKeySystemSupportedWithContentType(keySystem, "")) {
207 return ScriptPromise::rejectWithDOMException( 209 return ScriptPromise::rejectWithDOMException(
208 scriptState, DOMException::create(NotSupportedError, "The key system specified is not supported.")); 210 scriptState, DOMException::create(NotSupportedError, "The key system specified is not supported."));
209 } 211 }
210 212
211 // 4. Let promise be a new promise. 213 // 4. Let promise be a new promise.
212 // 5. Asynchronously determine support, and if allowed, create and 214 // 5. Asynchronously determine support, and if allowed, create and
213 // initialize the MediaKeySystemAccess object. 215 // initialize the MediaKeySystemAccess object.
214 // 6. Return promise. 216 // 6. Return promise.
215 return MediaKeySystemAccessInitializer::create(scriptState, keySystem, suppo rtedConfigurations); 217 return MediaKeySystemAccessInitializer::create(scriptState, keySystem, suppo rtedConfigurations);
216 } 218 }
217 219
218 const char* NavigatorRequestMediaKeySystemAccess::supplementName() 220 const char* NavigatorRequestMediaKeySystemAccess::supplementName()
219 { 221 {
220 return "RequestMediaKeySystemAccess"; 222 return "RequestMediaKeySystemAccess";
221 } 223 }
222 224
223 void NavigatorRequestMediaKeySystemAccess::trace(Visitor* visitor) 225 void NavigatorRequestMediaKeySystemAccess::trace(Visitor* visitor)
224 { 226 {
225 WillBeHeapSupplement<Navigator>::trace(visitor); 227 WillBeHeapSupplement<Navigator>::trace(visitor);
226 } 228 }
227 229
228 } // namespace blink 230 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698