OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/cdm/browser_cdm_manager.h" | 5 #include "content/browser/media/cdm/browser_cdm_manager.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <memory> | 9 #include <memory> |
10 #include <string> | 10 #include <string> |
11 #include <utility> | 11 #include <utility> |
12 | 12 |
13 #include "base/bind.h" | 13 #include "base/bind.h" |
14 #include "base/bind_helpers.h" | 14 #include "base/bind_helpers.h" |
15 #include "base/lazy_instance.h" | 15 #include "base/lazy_instance.h" |
16 #include "base/task_runner.h" | 16 #include "base/task_runner.h" |
17 #include "build/build_config.h" | 17 #include "build/build_config.h" |
18 #include "content/public/browser/browser_context.h" | 18 #include "content/public/browser/browser_context.h" |
19 #include "content/public/browser/browser_thread.h" | 19 #include "content/public/browser/browser_thread.h" |
20 #include "content/public/browser/content_browser_client.h" | 20 #include "content/public/browser/content_browser_client.h" |
21 #include "content/public/browser/permission_manager.h" | 21 #include "content/public/browser/permission_manager.h" |
22 #include "content/public/browser/permission_type.h" | 22 #include "content/public/browser/permission_type.h" |
23 #include "content/public/browser/render_frame_host.h" | 23 #include "content/public/browser/render_frame_host.h" |
24 #include "content/public/browser/render_process_host.h" | 24 #include "content/public/browser/render_process_host.h" |
25 #include "content/public/browser/render_process_host_observer.h" | 25 #include "content/public/browser/render_process_host_observer.h" |
| 26 #include "content/public/browser/storage_partition.h" |
26 #include "content/public/browser/web_contents.h" | 27 #include "content/public/browser/web_contents.h" |
27 #include "media/base/cdm_config.h" | 28 #include "media/base/cdm_config.h" |
28 #include "media/base/cdm_factory.h" | 29 #include "media/base/cdm_factory.h" |
29 #include "media/base/cdm_promise.h" | 30 #include "media/base/cdm_promise.h" |
30 #include "media/base/limits.h" | 31 #include "media/base/limits.h" |
31 | 32 |
32 #if defined(OS_ANDROID) | 33 #if defined(OS_ANDROID) |
33 #include "content/public/browser/android/provision_fetcher_factory.h" | 34 #include "content/public/browser/android/provision_fetcher_factory.h" |
34 #include "content/public/common/renderer_preferences.h" | 35 #include "content/public/common/renderer_preferences.h" |
35 #include "media/base/android/android_cdm_factory.h" | 36 #include "media/base/android/android_cdm_factory.h" |
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
284 | 285 |
285 media::CdmFactory* BrowserCdmManager::GetCdmFactory() { | 286 media::CdmFactory* BrowserCdmManager::GetCdmFactory() { |
286 if (!cdm_factory_) { | 287 if (!cdm_factory_) { |
287 // Create a new CdmFactory. | 288 // Create a new CdmFactory. |
288 cdm_factory_ = GetContentClient()->browser()->CreateCdmFactory(); | 289 cdm_factory_ = GetContentClient()->browser()->CreateCdmFactory(); |
289 | 290 |
290 #if defined(OS_ANDROID) | 291 #if defined(OS_ANDROID) |
291 if (!cdm_factory_) { | 292 if (!cdm_factory_) { |
292 // Obtain http request context for the current render process. | 293 // Obtain http request context for the current render process. |
293 net::URLRequestContextGetter* context_getter = | 294 net::URLRequestContextGetter* context_getter = |
294 RenderProcessHost::FromID(render_process_id_) | 295 BrowserContext::GetDefaultStoragePartition( |
295 ->GetBrowserContext() | 296 RenderProcessHost::FromID(render_process_id_)-> |
296 ->GetRequestContext(); | 297 GetBrowserContext())->GetURLRequestContext(); |
297 DCHECK(context_getter); | 298 DCHECK(context_getter); |
298 | 299 |
299 cdm_factory_.reset(new media::AndroidCdmFactory( | 300 cdm_factory_.reset(new media::AndroidCdmFactory( |
300 base::Bind(&CreateProvisionFetcher, context_getter))); | 301 base::Bind(&CreateProvisionFetcher, context_getter))); |
301 } | 302 } |
302 #endif | 303 #endif |
303 } | 304 } |
304 | 305 |
305 return cdm_factory_.get(); | 306 return cdm_factory_.get(); |
306 } | 307 } |
(...skipping 422 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
729 scoped_refptr<MediaKeys> cdm = GetCdm(render_frame_id, cdm_id); | 730 scoped_refptr<MediaKeys> cdm = GetCdm(render_frame_id, cdm_id); |
730 if (!cdm) { | 731 if (!cdm) { |
731 promise->reject(MediaKeys::INVALID_STATE_ERROR, 0, "CDM not found."); | 732 promise->reject(MediaKeys::INVALID_STATE_ERROR, 0, "CDM not found."); |
732 return; | 733 return; |
733 } | 734 } |
734 | 735 |
735 cdm->LoadSession(session_type, session_id, std::move(promise)); | 736 cdm->LoadSession(session_type, session_id, std::move(promise)); |
736 } | 737 } |
737 | 738 |
738 } // namespace content | 739 } // namespace content |
OLD | NEW |