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

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

Issue 1381463003: Add warning message for empty robustness. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: drop hasAudioCapabilities check Created 5 years, 2 months 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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"
11 #include "core/dom/Document.h" 11 #include "core/dom/Document.h"
12 #include "core/dom/ExceptionCode.h" 12 #include "core/dom/ExceptionCode.h"
13 #include "core/frame/OriginsUsingFeatures.h" 13 #include "core/frame/OriginsUsingFeatures.h"
14 #include "core/frame/UseCounter.h" 14 #include "core/frame/UseCounter.h"
15 #include "core/inspector/ConsoleMessage.h"
15 #include "modules/encryptedmedia/EncryptedMediaUtils.h" 16 #include "modules/encryptedmedia/EncryptedMediaUtils.h"
16 #include "modules/encryptedmedia/MediaKeySession.h" 17 #include "modules/encryptedmedia/MediaKeySession.h"
17 #include "modules/encryptedmedia/MediaKeySystemAccess.h" 18 #include "modules/encryptedmedia/MediaKeySystemAccess.h"
18 #include "modules/encryptedmedia/MediaKeysController.h" 19 #include "modules/encryptedmedia/MediaKeysController.h"
19 #include "platform/EncryptedMediaRequest.h" 20 #include "platform/EncryptedMediaRequest.h"
20 #include "platform/Logging.h" 21 #include "platform/Logging.h"
21 #include "platform/network/ParsedContentType.h" 22 #include "platform/network/ParsedContentType.h"
22 #include "public/platform/WebEncryptedMediaClient.h" 23 #include "public/platform/WebEncryptedMediaClient.h"
23 #include "public/platform/WebEncryptedMediaRequest.h" 24 #include "public/platform/WebEncryptedMediaRequest.h"
24 #include "public/platform/WebMediaKeySystemConfiguration.h" 25 #include "public/platform/WebMediaKeySystemConfiguration.h"
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 } 72 }
72 73
73 static WebVector<WebEncryptedMediaSessionType> convertSessionTypes(const Vector< String>& sessionTypes) 74 static WebVector<WebEncryptedMediaSessionType> convertSessionTypes(const Vector< String>& sessionTypes)
74 { 75 {
75 WebVector<WebEncryptedMediaSessionType> result(sessionTypes.size()); 76 WebVector<WebEncryptedMediaSessionType> result(sessionTypes.size());
76 for (size_t i = 0; i < sessionTypes.size(); ++i) 77 for (size_t i = 0; i < sessionTypes.size(); ++i)
77 result[i] = EncryptedMediaUtils::convertToSessionType(sessionTypes[i]); 78 result[i] = EncryptedMediaUtils::convertToSessionType(sessionTypes[i]);
78 return result; 79 return result;
79 } 80 }
80 81
82 static bool isWidevine(const String& keySystem)
83 {
84 return keySystem == "com.widevine.alpha";
ddorwin 2015/10/01 21:23:47 This should be in Chromium, though I don't know ho
xhwang 2015/10/01 22:49:43 Acknowledged.
85 }
86
87 // Returns true if the |config| has only one audio or video capability and the r obustness in that capability is empty.
88 static bool hasOneCapabilityAndRobustnessIsEmpty(const WebMediaKeySystemConfigur ation& config)
89 {
90 return (config.audioCapabilities.size() == 1 && config.audioCapabilities[0]. robustness.isEmpty())
sandersd (OOO until July 31) 2015/10/01 20:40:24 I'm not certain that we should restrict to the siz
ddorwin 2015/10/01 21:23:47 Good point. My assumption was that the empty one w
ddorwin 2015/10/01 21:23:47 Empty might be legit for audio. For example, it's
sandersd (OOO until July 31) 2015/10/01 21:34:45 The ideal design for compatibility would be to lis
xhwang 2015/10/01 22:49:43 I am going to do "any".
91 || (config.videoCapabilities.size() == 1 && config.videoCapabilities[0]. robustness.isEmpty());
92 }
93
81 // This class allows capabilities to be checked and a MediaKeySystemAccess 94 // This class allows capabilities to be checked and a MediaKeySystemAccess
82 // object to be created asynchronously. 95 // object to be created asynchronously.
83 class MediaKeySystemAccessInitializer final : public EncryptedMediaRequest { 96 class MediaKeySystemAccessInitializer final : public EncryptedMediaRequest {
84 WTF_MAKE_NONCOPYABLE(MediaKeySystemAccessInitializer); 97 WTF_MAKE_NONCOPYABLE(MediaKeySystemAccessInitializer);
85 98
86 public: 99 public:
87 MediaKeySystemAccessInitializer(ScriptState*, const String& keySystem, const HeapVector<MediaKeySystemConfiguration>& supportedConfigurations); 100 MediaKeySystemAccessInitializer(ScriptState*, const String& keySystem, const HeapVector<MediaKeySystemConfiguration>& supportedConfigurations);
88 ~MediaKeySystemAccessInitializer() override { } 101 ~MediaKeySystemAccessInitializer() override { }
89 102
90 // EncryptedMediaRequest implementation. 103 // EncryptedMediaRequest implementation.
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 webConfig.sessionTypes = convertSessionTypes(config.sessionTypes()); 150 webConfig.sessionTypes = convertSessionTypes(config.sessionTypes());
138 } 151 }
139 // If |label| is not present, it will be a null string. 152 // If |label| is not present, it will be a null string.
140 webConfig.label = config.label(); 153 webConfig.label = config.label();
141 m_supportedConfigurations[i] = webConfig; 154 m_supportedConfigurations[i] = webConfig;
142 } 155 }
143 } 156 }
144 157
145 void MediaKeySystemAccessInitializer::requestSucceeded(WebContentDecryptionModul eAccess* access) 158 void MediaKeySystemAccessInitializer::requestSucceeded(WebContentDecryptionModul eAccess* access)
146 { 159 {
160 // Check the config and generate warnings on empty robustness string.
161 // TODO(xhwang): Remove after we handle empty robustness correctly. See http ://crbug.com/482277
162 if (isWidevine(keySystem()) && hasOneCapabilityAndRobustnessIsEmpty(access-> getConfiguration())) {
163 m_resolver->scriptState()->executionContext()->addConsoleMessage(Console Message::create(JSMessageSource, WarningMessageLevel,
ddorwin 2015/10/01 21:23:47 Are we guaranteed that the EC will be valid?
xhwang 2015/10/01 22:49:43 Good question. Actually I don't know. But we have
164 "It is recommended that a robustness level be specified. In a future version, Chromium will be made "
sandersd (OOO until July 31) 2015/10/01 20:40:24 While this message is the one recommended by ddorw
ddorwin 2015/10/01 21:23:47 I think we generally use "Chrome" in console messa
ddorwin 2015/10/01 21:23:47 There aren't any plans to change the spec beyond w
sandersd (OOO until July 31) 2015/10/01 21:34:45 Perhaps we should just say that the behavior will
xhwang 2015/10/01 22:49:43 Updated the text...
165 "spec compliant such that the empty string is interpreted as the min imum robustness being acceptable."));
166 }
167
147 m_resolver->resolve(new MediaKeySystemAccess(m_keySystem, adoptPtr(access))) ; 168 m_resolver->resolve(new MediaKeySystemAccess(m_keySystem, adoptPtr(access))) ;
148 m_resolver.clear(); 169 m_resolver.clear();
149 } 170 }
150 171
151 void MediaKeySystemAccessInitializer::requestNotSupported(const WebString& error Message) 172 void MediaKeySystemAccessInitializer::requestNotSupported(const WebString& error Message)
152 { 173 {
153 m_resolver->reject(DOMException::create(NotSupportedError, errorMessage)); 174 m_resolver->reject(DOMException::create(NotSupportedError, errorMessage));
154 m_resolver.clear(); 175 m_resolver.clear();
155 } 176 }
156 177
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 // initialize the MediaKeySystemAccess object. 231 // initialize the MediaKeySystemAccess object.
211 MediaKeysController* controller = MediaKeysController::from(document->page() ); 232 MediaKeysController* controller = MediaKeysController::from(document->page() );
212 WebEncryptedMediaClient* mediaClient = controller->encryptedMediaClient(exec utionContext); 233 WebEncryptedMediaClient* mediaClient = controller->encryptedMediaClient(exec utionContext);
213 mediaClient->requestMediaKeySystemAccess(WebEncryptedMediaRequest(initialize r)); 234 mediaClient->requestMediaKeySystemAccess(WebEncryptedMediaRequest(initialize r));
214 235
215 // 8. Return promise. 236 // 8. Return promise.
216 return promise; 237 return promise;
217 } 238 }
218 239
219 } // namespace blink 240 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698