| 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 #include "content/browser/media/android/media_drm_credential_manager.h" | 5 #include "content/browser/media/android/media_drm_credential_manager.h" |
| 6 | 6 |
| 7 #include "base/android/jni_android.h" | 7 #include "base/android/jni_android.h" |
| 8 #include "base/android/scoped_java_ref.h" | 8 #include "base/android/scoped_java_ref.h" |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/callback_helpers.h" | 10 #include "base/callback_helpers.h" |
| 11 #include "base/location.h" | 11 #include "base/location.h" |
| 12 #include "base/message_loop/message_loop_proxy.h" | 12 #include "base/message_loop/message_loop_proxy.h" |
| 13 #include "jni/MediaDrmCredentialManager_jni.h" | 13 #include "jni/MediaDrmCredentialManager_jni.h" |
| 14 #include "media/base/android/media_drm_bridge.h" | 14 #include "media/base/android/media_drm_bridge.h" |
| 15 #include "url/gurl.h" | 15 #include "url/gurl.h" |
| 16 | 16 |
| 17 #include "widevine_cdm_version.h" // In SHARED_INTERMEDIATE_DIR. |
| 18 |
| 17 using base::android::ScopedJavaGlobalRef; | 19 using base::android::ScopedJavaGlobalRef; |
| 18 | 20 |
| 19 namespace { | 21 namespace { |
| 20 | 22 |
| 21 void MediaDrmCredentialManagerCallback( | 23 void MediaDrmCredentialManagerCallback( |
| 22 const ScopedJavaGlobalRef<jobject>& j_media_drm_credential_manager_callback, | 24 const ScopedJavaGlobalRef<jobject>& j_media_drm_credential_manager_callback, |
| 23 bool succeeded) { | 25 bool succeeded) { |
| 24 JNIEnv* env = base::android::AttachCurrentThread(); | 26 JNIEnv* env = base::android::AttachCurrentThread(); |
| 25 content::Java_MediaDrmCredentialManagerCallback_onCredentialResetFinished( | 27 content::Java_MediaDrmCredentialManagerCallback_onCredentialResetFinished( |
| 26 env, j_media_drm_credential_manager_callback.obj(), succeeded); | 28 env, j_media_drm_credential_manager_callback.obj(), succeeded); |
| 27 } | 29 } |
| 28 | 30 |
| 29 } // namespace | 31 } // namespace |
| 30 | 32 |
| 31 namespace content { | 33 namespace content { |
| 32 | 34 |
| 33 // TODO(qinmin): Move the UUID definition to some common places. | |
| 34 static const uint8 kWidevineUuid[16] = { | |
| 35 0xED, 0xEF, 0x8B, 0xA9, 0x79, 0xD6, 0x4A, 0xCE, | |
| 36 0xA3, 0xC8, 0x27, 0xDC, 0xD5, 0x1D, 0x21, 0xED }; | |
| 37 | |
| 38 MediaDrmCredentialManager::MediaDrmCredentialManager() {}; | 35 MediaDrmCredentialManager::MediaDrmCredentialManager() {}; |
| 39 | 36 |
| 40 MediaDrmCredentialManager::~MediaDrmCredentialManager() {}; | 37 MediaDrmCredentialManager::~MediaDrmCredentialManager() {}; |
| 41 | 38 |
| 42 // static | 39 // static |
| 43 MediaDrmCredentialManager* MediaDrmCredentialManager::GetInstance() { | 40 MediaDrmCredentialManager* MediaDrmCredentialManager::GetInstance() { |
| 44 return Singleton<MediaDrmCredentialManager>::get(); | 41 return Singleton<MediaDrmCredentialManager>::get(); |
| 45 } | 42 } |
| 46 | 43 |
| 47 void MediaDrmCredentialManager::ResetCredentials( | 44 void MediaDrmCredentialManager::ResetCredentials( |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 return; | 82 return; |
| 86 success = false; | 83 success = false; |
| 87 } | 84 } |
| 88 | 85 |
| 89 base::ResetAndReturn(&reset_credentials_cb_).Run(success); | 86 base::ResetAndReturn(&reset_credentials_cb_).Run(success); |
| 90 media_drm_bridge_.reset(); | 87 media_drm_bridge_.reset(); |
| 91 } | 88 } |
| 92 | 89 |
| 93 bool MediaDrmCredentialManager::ResetCredentialsInternal( | 90 bool MediaDrmCredentialManager::ResetCredentialsInternal( |
| 94 SecurityLevel security_level) { | 91 SecurityLevel security_level) { |
| 95 std::vector<uint8> uuid(kWidevineUuid, kWidevineUuid + 16); | 92 media_drm_bridge_ = |
| 96 media_drm_bridge_ = media::MediaDrmBridge::Create(0, uuid, GURL(), NULL); | 93 media::MediaDrmBridge::Create(0, kWidevineKeySystem, GURL(), NULL); |
| 97 if (!media_drm_bridge_) | 94 if (!media_drm_bridge_) |
| 98 return false; | 95 return false; |
| 99 | 96 |
| 100 ResetCredentialsCB reset_credentials_cb = | 97 ResetCredentialsCB reset_credentials_cb = |
| 101 base::Bind(&MediaDrmCredentialManager::OnResetCredentialsCompleted, | 98 base::Bind(&MediaDrmCredentialManager::OnResetCredentialsCompleted, |
| 102 base::Unretained(this), security_level); | 99 base::Unretained(this), security_level); |
| 103 | 100 |
| 104 if (!media_drm_bridge_->SetSecurityLevel(security_level)) { | 101 if (!media_drm_bridge_->SetSecurityLevel(security_level)) { |
| 105 // No need to reset credentials for unsupported |security_level|. | 102 // No need to reset credentials for unsupported |security_level|. |
| 106 base::MessageLoopProxy::current()->PostTask( | 103 base::MessageLoopProxy::current()->PostTask( |
| 107 FROM_HERE, base::Bind(reset_credentials_cb, true)); | 104 FROM_HERE, base::Bind(reset_credentials_cb, true)); |
| 108 return true; | 105 return true; |
| 109 } | 106 } |
| 110 | 107 |
| 111 media_drm_bridge_->ResetDeviceCredentials(reset_credentials_cb); | 108 media_drm_bridge_->ResetDeviceCredentials(reset_credentials_cb); |
| 112 return true; | 109 return true; |
| 113 } | 110 } |
| 114 | 111 |
| 115 // static | 112 // static |
| 116 bool MediaDrmCredentialManager::RegisterMediaDrmCredentialManager(JNIEnv* env) { | 113 bool MediaDrmCredentialManager::RegisterMediaDrmCredentialManager(JNIEnv* env) { |
| 117 return RegisterNativesImpl(env); | 114 return RegisterNativesImpl(env); |
| 118 } | 115 } |
| 119 | 116 |
| 120 } // namespace content | 117 } // namespace content |
| OLD | NEW |