Enable right clicking on the applist doodle web contents and log the data.
[chromium-blink-merge.git] / media / blink / webcontentdecryptionmoduleaccess_impl.cc
blobab98b432058f8cff3981b761ef2072e61507df79
1 // Copyright 2013 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.
5 #include "media/blink/webcontentdecryptionmoduleaccess_impl.h"
7 #include "base/basictypes.h"
8 #include "base/bind.h"
9 #include "base/location.h"
10 #include "base/message_loop/message_loop_proxy.h"
11 #include "media/blink/webencryptedmediaclient_impl.h"
13 namespace media {
15 // The caller owns the created cdm (passed back using |result|).
16 static void CreateCdm(const base::WeakPtr<WebEncryptedMediaClientImpl>& client,
17 const blink::WebString& key_system,
18 const blink::WebSecurityOrigin& security_origin,
19 blink::WebContentDecryptionModuleResult result) {
20 // If |client| is gone (due to the frame getting destroyed), it is
21 // impossible to create the CDM, so fail.
22 if (!client) {
23 result.completeWithError(
24 blink::WebContentDecryptionModuleExceptionInvalidStateError, 0,
25 "Failed to create CDM.");
26 return;
29 client->CreateCdm(key_system, security_origin, result);
32 WebContentDecryptionModuleAccessImpl*
33 WebContentDecryptionModuleAccessImpl::Create(
34 const blink::WebString& key_system,
35 const blink::WebMediaKeySystemConfiguration& configuration,
36 const blink::WebSecurityOrigin& security_origin,
37 const base::WeakPtr<WebEncryptedMediaClientImpl>& client) {
38 return new WebContentDecryptionModuleAccessImpl(key_system, configuration,
39 security_origin, client);
42 WebContentDecryptionModuleAccessImpl::WebContentDecryptionModuleAccessImpl(
43 const blink::WebString& key_system,
44 const blink::WebMediaKeySystemConfiguration& configuration,
45 const blink::WebSecurityOrigin& security_origin,
46 const base::WeakPtr<WebEncryptedMediaClientImpl>& client)
47 : key_system_(key_system),
48 configuration_(configuration),
49 security_origin_(security_origin),
50 client_(client) {
53 WebContentDecryptionModuleAccessImpl::~WebContentDecryptionModuleAccessImpl() {
56 blink::WebMediaKeySystemConfiguration
57 WebContentDecryptionModuleAccessImpl::getConfiguration() {
58 return configuration_;
61 void WebContentDecryptionModuleAccessImpl::createContentDecryptionModule(
62 blink::WebContentDecryptionModuleResult result) {
63 // This method needs to run asynchronously, as it may need to load the CDM.
64 // As this object's lifetime is controlled by MediaKeySystemAccess on the
65 // blink side, copy all values needed by CreateCdm() in case the blink object
66 // gets garbage-collected.
67 base::MessageLoopProxy::current()->PostTask(
68 FROM_HERE,
69 base::Bind(&CreateCdm, client_, key_system_, security_origin_, result));
72 } // namespace media