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