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 #ifndef MEDIA_BLINK_WEBENCRYPTEDMEDIACLIENT_IMPL_H_ | 5 #ifndef MEDIA_BLINK_WEBENCRYPTEDMEDIACLIENT_IMPL_H_ |
6 #define MEDIA_BLINK_WEBENCRYPTEDMEDIACLIENT_IMPL_H_ | 6 #define MEDIA_BLINK_WEBENCRYPTEDMEDIACLIENT_IMPL_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/containers/scoped_ptr_hash_map.h" | 10 #include "base/containers/scoped_ptr_hash_map.h" |
11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
12 #include "base/memory/weak_ptr.h" | 12 #include "base/memory/weak_ptr.h" |
13 #include "media/base/cdm_factory.h" | |
14 #include "media/base/media_export.h" | 13 #include "media/base/media_export.h" |
15 #include "third_party/WebKit/public/platform/WebContentDecryptionModuleResult.h" | 14 #include "media/blink/key_system_config_selector.h" |
16 #include "third_party/WebKit/public/platform/WebEncryptedMediaClient.h" | 15 #include "third_party/WebKit/public/platform/WebEncryptedMediaClient.h" |
17 #include "third_party/WebKit/public/web/WebSecurityOrigin.h" | 16 |
| 17 namespace blink { |
| 18 |
| 19 class WebContentDecryptionModuleResult; |
| 20 class WebMediaKeySystemConfiguration; |
| 21 class WebSecurityOrigin; |
| 22 |
| 23 } // namespace blink |
18 | 24 |
19 namespace media { | 25 namespace media { |
20 | 26 |
| 27 class CdmFactory; |
21 class KeySystems; | 28 class KeySystems; |
22 class MediaPermission; | 29 class MediaPermission; |
23 | 30 |
24 class MEDIA_EXPORT WebEncryptedMediaClientImpl | 31 class MEDIA_EXPORT WebEncryptedMediaClientImpl |
25 : public blink::WebEncryptedMediaClient { | 32 : public blink::WebEncryptedMediaClient { |
26 public: | 33 public: |
27 WebEncryptedMediaClientImpl(scoped_ptr<CdmFactory> cdm_factory, | 34 WebEncryptedMediaClientImpl(scoped_ptr<CdmFactory> cdm_factory, |
28 MediaPermission* media_permission); | 35 MediaPermission* media_permission); |
29 virtual ~WebEncryptedMediaClientImpl(); | 36 virtual ~WebEncryptedMediaClientImpl(); |
30 | 37 |
31 // WebEncryptedMediaClient implementation. | 38 // WebEncryptedMediaClient implementation. |
32 virtual void requestMediaKeySystemAccess( | 39 virtual void requestMediaKeySystemAccess( |
33 blink::WebEncryptedMediaRequest request); | 40 blink::WebEncryptedMediaRequest request); |
34 | 41 |
35 // Create the CDM for |key_system| and |security_origin|. The caller owns | 42 // Create the CDM for |key_system| and |security_origin|. The caller owns |
36 // the created cdm (passed back using |result|). | 43 // the created cdm (passed back using |result|). |
37 void CreateCdm(const blink::WebString& key_system, | 44 void CreateCdm(const blink::WebString& key_system, |
38 bool allow_distinctive_identifier, | 45 bool allow_distinctive_identifier, |
39 bool allow_persistent_state, | 46 bool allow_persistent_state, |
40 const blink::WebSecurityOrigin& security_origin, | 47 const blink::WebSecurityOrigin& security_origin, |
41 blink::WebContentDecryptionModuleResult result); | 48 blink::WebContentDecryptionModuleResult result); |
42 | 49 |
43 private: | 50 private: |
44 // Pick a supported configuration if possible, and complete the request. This | |
45 // method may asynchronously invoke itself after prompting for permissions. | |
46 void SelectSupportedConfiguration(blink::WebEncryptedMediaRequest request, | |
47 bool was_permission_requested, | |
48 bool is_permission_granted); | |
49 | |
50 // Report usage of key system to UMA. There are 2 different counts logged: | 51 // Report usage of key system to UMA. There are 2 different counts logged: |
51 // 1. The key system is requested. | 52 // 1. The key system is requested. |
52 // 2. The requested key system and options are supported. | 53 // 2. The requested key system and options are supported. |
53 // Each stat is only reported once per renderer frame per key system. | 54 // Each stat is only reported once per renderer frame per key system. |
54 class Reporter; | 55 class Reporter; |
55 | 56 |
| 57 // Complete a requestMediaKeySystemAccess() request with a supported |
| 58 // accumulated configuration. |
| 59 void OnRequestSucceeded( |
| 60 blink::WebEncryptedMediaRequest request, |
| 61 const blink::WebMediaKeySystemConfiguration& accumulated_configuration); |
| 62 |
| 63 // Complete a requestMediaKeySystemAccess() request with an error message. |
| 64 void OnRequestNotSupported( |
| 65 blink::WebEncryptedMediaRequest request, |
| 66 const blink::WebString& error_message); |
| 67 |
56 // Gets the Reporter for |key_system|. If it doesn't already exist, | 68 // Gets the Reporter for |key_system|. If it doesn't already exist, |
57 // create one. | 69 // create one. |
58 Reporter* GetReporter(const std::string& key_system); | 70 Reporter* GetReporter(const blink::WebString& key_system); |
59 | 71 |
60 // Key system <-> Reporter map. | 72 // Reporter singletons. |
61 typedef base::ScopedPtrHashMap<std::string, Reporter> Reporters; | 73 base::ScopedPtrHashMap<std::string, Reporter> reporters_; |
62 Reporters reporters_; | |
63 | 74 |
64 const KeySystems& key_systems_; | 75 KeySystemConfigSelector key_system_config_selector_; |
65 scoped_ptr<CdmFactory> cdm_factory_; | 76 scoped_ptr<CdmFactory> cdm_factory_; |
66 MediaPermission* media_permission_; | |
67 | |
68 base::WeakPtrFactory<WebEncryptedMediaClientImpl> weak_factory_; | 77 base::WeakPtrFactory<WebEncryptedMediaClientImpl> weak_factory_; |
69 }; | 78 }; |
70 | 79 |
71 } // namespace media | 80 } // namespace media |
72 | 81 |
73 #endif // MEDIA_BLINK_WEBENCRYPTEDMEDIACLIENT_IMPL_H_ | 82 #endif // MEDIA_BLINK_WEBENCRYPTEDMEDIACLIENT_IMPL_H_ |
OLD | NEW |