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 #ifndef CONTENT_BROWSER_MEDIA_ANDROID_MEDIA_DRM_CREDENTIAL_MANAGER_H_
6 #define CONTENT_BROWSER_MEDIA_ANDROID_MEDIA_DRM_CREDENTIAL_MANAGER_H_
11 #include "base/callback.h"
12 #include "base/memory/singleton.h"
13 #include "media/base/android/media_drm_bridge.h"
17 // This class manages the media DRM credentials on Android.
18 class MediaDrmCredentialManager
{
20 static MediaDrmCredentialManager
* GetInstance();
22 typedef base::Callback
<void(bool)> ResetCredentialsCB
;
24 // Called to reset the DRM credentials. (for Java)
25 // Only clears credentials for Widevine.
26 // TODO(ddorwin): This should accept a key system parameter so that this is
27 // clear to the caller, which can call it repeatedly as necessary.
28 // http://crbug.com/459400
29 static void ResetCredentials(JNIEnv
* env
, jclass clazz
, jobject callback
);
31 // Called to reset the DRM credentials. The result is returned in the
32 // |reset_credentials_cb|.
33 void ResetCredentials(const ResetCredentialsCB
& reset_credentials_cb
);
35 static bool RegisterMediaDrmCredentialManager(JNIEnv
* env
);
38 friend struct base::DefaultSingletonTraits
<MediaDrmCredentialManager
>;
39 typedef media::MediaDrmBridge::SecurityLevel SecurityLevel
;
41 MediaDrmCredentialManager();
42 ~MediaDrmCredentialManager();
44 // Callback function passed to MediaDrmBridge. It is called when credentials
45 // reset is completed.
46 void OnResetCredentialsCompleted(SecurityLevel security_level
, bool success
);
48 // Resets DRM credentials for a particular |security_level|. Returns false if
49 // we fail to create the MediaDrmBridge at all, in which case we cannot reset
50 // the credentials. Otherwise, the result is returned asynchronously in
51 // OnResetCredentialsCompleted() function.
52 bool ResetCredentialsInternal(SecurityLevel security_level
);
54 // The MediaDrmBridge object used to perform the credential reset.
55 scoped_ptr
<media::MediaDrmBridge
> media_drm_bridge_
;
57 // The callback provided by the caller.
58 ResetCredentialsCB reset_credentials_cb_
;
60 DISALLOW_COPY_AND_ASSIGN(MediaDrmCredentialManager
);
63 } // namespace content
65 #endif // CONTENT_BROWSER_MEDIA_ANDROID_MEDIA_DRM_CREDENTIAL_MANAGER_H_