| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 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 CONTENT_BROWSER_MEDIA_ANDROID_MEDIA_DRM_CREDENTIAL_MANAGER_H_ | 5 #ifndef CONTENT_BROWSER_MEDIA_ANDROID_MEDIA_DRM_CREDENTIAL_MANAGER_H_ |
| 6 #define CONTENT_BROWSER_MEDIA_ANDROID_MEDIA_DRM_CREDENTIAL_MANAGER_H_ | 6 #define CONTENT_BROWSER_MEDIA_ANDROID_MEDIA_DRM_CREDENTIAL_MANAGER_H_ |
| 7 | 7 |
| 8 #include <jni.h> |
| 8 #include <string> | 9 #include <string> |
| 9 | 10 |
| 10 #include "base/callback.h" | 11 #include "base/callback.h" |
| 11 | 12 #include "base/memory/singleton.h" |
| 12 namespace media { | 13 #include "media/base/android/media_drm_bridge.h" |
| 13 class MediaDrmBridge; | |
| 14 } | |
| 15 | 14 |
| 16 namespace content { | 15 namespace content { |
| 17 | 16 |
| 18 // This class manages the media DRM credentials on Android. | 17 // This class manages the media DRM credentials on Android. |
| 19 class MediaDrmCredentialManager { | 18 class MediaDrmCredentialManager { |
| 20 public: | 19 public: |
| 21 MediaDrmCredentialManager(); | 20 static MediaDrmCredentialManager* GetInstance(); |
| 22 ~MediaDrmCredentialManager(); | |
| 23 | 21 |
| 24 typedef base::Callback<void(bool)> ResetCredentialsCB; | 22 typedef base::Callback<void(bool)> ResetCredentialsCB; |
| 25 | 23 |
| 24 // Called to reset the DRM credentials. (for Java) |
| 25 static void ResetCredentials(JNIEnv* env, jclass clazz, jobject callback); |
| 26 |
| 26 // Called to reset the DRM credentials. | 27 // Called to reset the DRM credentials. |
| 27 void ResetCredentials(const ResetCredentialsCB& callback); | 28 void ResetCredentials(const ResetCredentialsCB& callback); |
| 28 | 29 |
| 30 static bool RegisterMediaDrmCredentialManager(JNIEnv* env); |
| 31 |
| 29 private: | 32 private: |
| 33 friend struct DefaultSingletonTraits<MediaDrmCredentialManager>; |
| 34 friend class Singleton<MediaDrmCredentialManager>; |
| 35 |
| 36 MediaDrmCredentialManager() {}; |
| 37 ~MediaDrmCredentialManager() {}; |
| 38 |
| 39 |
| 30 // Callback function passed to MediaDrmBridge. It is called when reset | 40 // Callback function passed to MediaDrmBridge. It is called when reset |
| 31 // completed. | 41 // completed. |
| 32 void OnResetCredentialsCompleted(const std::string& security_level, | 42 void OnResetCredentialsCompleted(const std::string& security_level, |
| 33 bool success); | 43 bool success); |
| 34 | 44 |
| 35 // Reset DRM credentials for a particular security level. Returns false if | 45 // Reset DRM credentials for a particular security level. Returns false if |
| 36 // we fail to create the MediaDrmBridge, or true otherwise. | 46 // we fail to create the MediaDrmBridge, or true otherwise. |
| 37 bool ResetCredentialsInternal(const std::string& security_level); | 47 bool ResetCredentialsInternal(const std::string& security_level); |
| 38 | 48 |
| 39 // The MediaDrmBridge object used to perform the credential reset. | 49 // The MediaDrmBridge object used to perform the credential reset. |
| 40 scoped_ptr<media::MediaDrmBridge> media_drm_bridge_; | 50 scoped_ptr<media::MediaDrmBridge> media_drm_bridge_; |
| 41 | 51 |
| 42 // The callback provided by the caller. | 52 // The callback provided by the caller. |
| 43 ResetCredentialsCB reset_credentials_cb_; | 53 ResetCredentialsCB reset_credentials_cb_; |
| 44 | 54 |
| 45 DISALLOW_COPY_AND_ASSIGN(MediaDrmCredentialManager); | 55 DISALLOW_COPY_AND_ASSIGN(MediaDrmCredentialManager); |
| 46 }; | 56 }; |
| 47 | 57 |
| 48 } // namespace content | 58 } // namespace content |
| 49 | 59 |
| 50 #endif // CONTENT_BROWSER_MEDIA_ANDROID_MEDIA_DRM_CREDENTIAL_MANAGER_H_ | 60 #endif // CONTENT_BROWSER_MEDIA_ANDROID_MEDIA_DRM_CREDENTIAL_MANAGER_H_ |
| OLD | NEW |