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 "chrome/browser/media/android/cdm/media_drm_credential_manager.h" | 5 #include "chrome/browser/media/android/cdm/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 "chrome/browser/profiles/profile.h" | |
15 #include "chrome/browser/profiles/profile_manager.h" | |
16 #include "content/public/browser/android/cdm_provision_fetcher.h" | |
14 #include "jni/MediaDrmCredentialManager_jni.h" | 17 #include "jni/MediaDrmCredentialManager_jni.h" |
15 #include "media/base/android/media_drm_bridge.h" | 18 #include "media/base/android/media_drm_bridge.h" |
19 #include "media/base/android/provision_fetcher.h" | |
16 #include "url/gurl.h" | 20 #include "url/gurl.h" |
17 | 21 |
18 #include "widevine_cdm_version.h" // In SHARED_INTERMEDIATE_DIR. | 22 #include "widevine_cdm_version.h" // In SHARED_INTERMEDIATE_DIR. |
19 | 23 |
20 using base::android::ScopedJavaGlobalRef; | 24 using base::android::ScopedJavaGlobalRef; |
21 | 25 |
22 namespace { | 26 namespace { |
23 | 27 |
24 void MediaDrmCredentialManagerCallback( | 28 void MediaDrmCredentialManagerCallback( |
25 const ScopedJavaGlobalRef<jobject>& j_media_drm_credential_manager_callback, | 29 const ScopedJavaGlobalRef<jobject>& j_media_drm_credential_manager_callback, |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
82 success = false; | 86 success = false; |
83 } | 87 } |
84 | 88 |
85 base::ResetAndReturn(&reset_credentials_cb_).Run(success); | 89 base::ResetAndReturn(&reset_credentials_cb_).Run(success); |
86 media_drm_bridge_ = nullptr; | 90 media_drm_bridge_ = nullptr; |
87 } | 91 } |
88 | 92 |
89 // TODO(ddorwin): The key system should be passed in. http://crbug.com/459400 | 93 // TODO(ddorwin): The key system should be passed in. http://crbug.com/459400 |
90 bool MediaDrmCredentialManager::ResetCredentialsInternal( | 94 bool MediaDrmCredentialManager::ResetCredentialsInternal( |
91 SecurityLevel security_level) { | 95 SecurityLevel security_level) { |
92 media_drm_bridge_ = | 96 // Create media::ProvisionFetcher based on the last used profile. |
93 media::MediaDrmBridge::CreateWithoutSessionSupport(kWidevineKeySystem); | 97 Profile* profile = ProfileManager::GetLastUsedProfile(); |
98 net::URLRequestContextGetter* context = profile->GetRequestContext(); | |
xhwang
2015/11/11 09:53:21
I did some more research... Can we use the Browser
Tima Vaisburd
2015/11/11 23:26:35
Done.
| |
99 | |
100 // new content::URLProfisionFetcher(context); | |
101 scoped_ptr<media::ProvisionFetcher> provision_fetcher = | |
102 content::CDMProvisionFetcher::CreateWithURLContext(context); | |
103 | |
104 media_drm_bridge_ = media::MediaDrmBridge::CreateWithoutSessionSupport( | |
105 kWidevineKeySystem, provision_fetcher.Pass()); | |
94 if (!media_drm_bridge_) | 106 if (!media_drm_bridge_) |
95 return false; | 107 return false; |
96 | 108 |
97 ResetCredentialsCB reset_credentials_cb = | 109 ResetCredentialsCB reset_credentials_cb = |
98 base::Bind(&MediaDrmCredentialManager::OnResetCredentialsCompleted, | 110 base::Bind(&MediaDrmCredentialManager::OnResetCredentialsCompleted, |
99 base::Unretained(this), security_level); | 111 base::Unretained(this), security_level); |
100 | 112 |
101 if (!media_drm_bridge_->SetSecurityLevel(security_level)) { | 113 if (!media_drm_bridge_->SetSecurityLevel(security_level)) { |
102 // No need to reset credentials for unsupported |security_level|. | 114 // No need to reset credentials for unsupported |security_level|. |
103 base::ThreadTaskRunnerHandle::Get()->PostTask( | 115 base::ThreadTaskRunnerHandle::Get()->PostTask( |
104 FROM_HERE, base::Bind(reset_credentials_cb, true)); | 116 FROM_HERE, base::Bind(reset_credentials_cb, true)); |
105 return true; | 117 return true; |
106 } | 118 } |
107 | 119 |
108 media_drm_bridge_->ResetDeviceCredentials(reset_credentials_cb); | 120 media_drm_bridge_->ResetDeviceCredentials(reset_credentials_cb); |
109 return true; | 121 return true; |
110 } | 122 } |
111 | 123 |
112 // static | 124 // static |
113 bool MediaDrmCredentialManager::RegisterMediaDrmCredentialManager(JNIEnv* env) { | 125 bool MediaDrmCredentialManager::RegisterMediaDrmCredentialManager(JNIEnv* env) { |
114 return RegisterNativesImpl(env); | 126 return RegisterNativesImpl(env); |
115 } | 127 } |
OLD | NEW |