Chromium Code Reviews| 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/single_thread_task_runner.h" | 12 #include "base/single_thread_task_runner.h" |
| 13 #include "base/thread_task_runner_handle.h" | 13 #include "base/thread_task_runner_handle.h" |
| 14 #include "jni/MediaDrmCredentialManager_jni.h" | 14 #include "jni/MediaDrmCredentialManager_jni.h" |
| 15 #include "media/base/android/media_drm_bridge.h" | 15 #include "media/base/android/media_drm_bridge.h" |
| 16 #include "media/base/android/provision_fetcher.h" | |
| 16 #include "url/gurl.h" | 17 #include "url/gurl.h" |
| 17 | 18 |
| 18 #include "widevine_cdm_version.h" // In SHARED_INTERMEDIATE_DIR. | 19 #include "widevine_cdm_version.h" // In SHARED_INTERMEDIATE_DIR. |
| 19 | 20 |
| 20 using base::android::ScopedJavaGlobalRef; | 21 using base::android::ScopedJavaGlobalRef; |
| 21 | 22 |
| 22 namespace { | 23 namespace { |
| 23 | 24 |
| 24 void MediaDrmCredentialManagerCallback( | 25 void MediaDrmCredentialManagerCallback( |
| 25 const ScopedJavaGlobalRef<jobject>& j_media_drm_credential_manager_callback, | 26 const ScopedJavaGlobalRef<jobject>& j_media_drm_credential_manager_callback, |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 84 success = false; | 85 success = false; |
| 85 } | 86 } |
| 86 | 87 |
| 87 base::ResetAndReturn(&reset_credentials_cb_).Run(success); | 88 base::ResetAndReturn(&reset_credentials_cb_).Run(success); |
| 88 media_drm_bridge_.reset(); | 89 media_drm_bridge_.reset(); |
| 89 } | 90 } |
| 90 | 91 |
| 91 // TODO(ddorwin): The key system should be passed in. http://crbug.com/459400 | 92 // TODO(ddorwin): The key system should be passed in. http://crbug.com/459400 |
| 92 bool MediaDrmCredentialManager::ResetCredentialsInternal( | 93 bool MediaDrmCredentialManager::ResetCredentialsInternal( |
| 93 SecurityLevel security_level) { | 94 SecurityLevel security_level) { |
| 94 media_drm_bridge_ = | 95 scoped_ptr<media::ProvisionFetcher> provision_fetcher = |
| 95 media::MediaDrmBridge::CreateWithoutSessionSupport(kWidevineKeySystem); | 96 media::ProvisionFetcher::GetFactory()->CreateFetcher(); |
| 97 | |
| 98 media_drm_bridge_ = media::MediaDrmBridge::CreateWithoutSessionSupport( | |
| 99 kWidevineKeySystem, provision_fetcher.Pass()); | |
|
xhwang
2015/11/02 20:37:04
Can we create the ProvisionFetcher directly in MDB
Tima Vaisburd
2015/11/05 02:24:07
Done for this path, but not for the other.
| |
| 96 if (!media_drm_bridge_) | 100 if (!media_drm_bridge_) |
| 97 return false; | 101 return false; |
| 98 | 102 |
| 99 ResetCredentialsCB reset_credentials_cb = | 103 ResetCredentialsCB reset_credentials_cb = |
| 100 base::Bind(&MediaDrmCredentialManager::OnResetCredentialsCompleted, | 104 base::Bind(&MediaDrmCredentialManager::OnResetCredentialsCompleted, |
| 101 base::Unretained(this), security_level); | 105 base::Unretained(this), security_level); |
| 102 | 106 |
| 103 if (!media_drm_bridge_->SetSecurityLevel(security_level)) { | 107 if (!media_drm_bridge_->SetSecurityLevel(security_level)) { |
| 104 // No need to reset credentials for unsupported |security_level|. | 108 // No need to reset credentials for unsupported |security_level|. |
| 105 base::ThreadTaskRunnerHandle::Get()->PostTask( | 109 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 106 FROM_HERE, base::Bind(reset_credentials_cb, true)); | 110 FROM_HERE, base::Bind(reset_credentials_cb, true)); |
| 107 return true; | 111 return true; |
| 108 } | 112 } |
| 109 | 113 |
| 110 media_drm_bridge_->ResetDeviceCredentials(reset_credentials_cb); | 114 media_drm_bridge_->ResetDeviceCredentials(reset_credentials_cb); |
| 111 return true; | 115 return true; |
| 112 } | 116 } |
| 113 | 117 |
| 114 // static | 118 // static |
| 115 bool MediaDrmCredentialManager::RegisterMediaDrmCredentialManager(JNIEnv* env) { | 119 bool MediaDrmCredentialManager::RegisterMediaDrmCredentialManager(JNIEnv* env) { |
| 116 return RegisterNativesImpl(env); | 120 return RegisterNativesImpl(env); |
| 117 } | 121 } |
| 118 | 122 |
| 119 } // namespace content | 123 } // namespace content |
| OLD | NEW |