Supervised user import: Listen for profile creation/deletion
[chromium-blink-merge.git] / content / browser / media / android / media_drm_credential_manager.h
blobcf16cea9528f3edcfe53cdf747bea8668c86d6a0
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_
8 #include <jni.h>
9 #include <string>
11 #include "base/callback.h"
12 #include "base/memory/singleton.h"
13 #include "media/base/android/media_drm_bridge.h"
15 namespace content {
17 // This class manages the media DRM credentials on Android.
18 class MediaDrmCredentialManager {
19 public:
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);
37 private:
38 friend struct DefaultSingletonTraits<MediaDrmCredentialManager>;
39 friend class Singleton<MediaDrmCredentialManager>;
40 typedef media::MediaDrmBridge::SecurityLevel SecurityLevel;
42 MediaDrmCredentialManager();
43 ~MediaDrmCredentialManager();
45 // Callback function passed to MediaDrmBridge. It is called when credentials
46 // reset is completed.
47 void OnResetCredentialsCompleted(SecurityLevel security_level, bool success);
49 // Resets DRM credentials for a particular |security_level|. Returns false if
50 // we fail to create the MediaDrmBridge at all, in which case we cannot reset
51 // the credentials. Otherwise, the result is returned asynchronously in
52 // OnResetCredentialsCompleted() function.
53 bool ResetCredentialsInternal(SecurityLevel security_level);
55 // The MediaDrmBridge object used to perform the credential reset.
56 scoped_ptr<media::MediaDrmBridge> media_drm_bridge_;
58 // The callback provided by the caller.
59 ResetCredentialsCB reset_credentials_cb_;
61 DISALLOW_COPY_AND_ASSIGN(MediaDrmCredentialManager);
64 } // namespace content
66 #endif // CONTENT_BROWSER_MEDIA_ANDROID_MEDIA_DRM_CREDENTIAL_MANAGER_H_