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" | |
27 #include "content/public/browser/web_contents.h" | 26 #include "content/public/browser/web_contents.h" |
28 #include "media/base/cdm_config.h" | 27 #include "media/base/cdm_config.h" |
29 #include "media/base/cdm_factory.h" | 28 #include "media/base/cdm_factory.h" |
30 #include "media/base/cdm_promise.h" | 29 #include "media/base/cdm_promise.h" |
31 #include "media/base/limits.h" | 30 #include "media/base/limits.h" |
32 | 31 |
33 #if defined(OS_ANDROID) | 32 #if defined(OS_ANDROID) |
34 #include "content/public/browser/android/provision_fetcher_factory.h" | 33 #include "content/public/browser/android/provision_fetcher_factory.h" |
35 #include "content/public/common/renderer_preferences.h" | 34 #include "content/public/common/renderer_preferences.h" |
36 #include "media/base/android/android_cdm_factory.h" | 35 #include "media/base/android/android_cdm_factory.h" |
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
285 | 284 |
286 media::CdmFactory* BrowserCdmManager::GetCdmFactory() { | 285 media::CdmFactory* BrowserCdmManager::GetCdmFactory() { |
287 if (!cdm_factory_) { | 286 if (!cdm_factory_) { |
288 // Create a new CdmFactory. | 287 // Create a new CdmFactory. |
289 cdm_factory_ = GetContentClient()->browser()->CreateCdmFactory(); | 288 cdm_factory_ = GetContentClient()->browser()->CreateCdmFactory(); |
290 | 289 |
291 #if defined(OS_ANDROID) | 290 #if defined(OS_ANDROID) |
292 if (!cdm_factory_) { | 291 if (!cdm_factory_) { |
293 // Obtain http request context for the current render process. | 292 // Obtain http request context for the current render process. |
294 net::URLRequestContextGetter* context_getter = | 293 net::URLRequestContextGetter* context_getter = |
295 BrowserContext::GetDefaultStoragePartition( | 294 RenderProcessHost::FromID(render_process_id_) |
296 RenderProcessHost::FromID(render_process_id_)-> | 295 ->GetBrowserContext() |
297 GetBrowserContext())->GetURLRequestContext(); | 296 ->GetRequestContext(); |
298 DCHECK(context_getter); | 297 DCHECK(context_getter); |
299 | 298 |
300 cdm_factory_.reset(new media::AndroidCdmFactory( | 299 cdm_factory_.reset(new media::AndroidCdmFactory( |
301 base::Bind(&CreateProvisionFetcher, context_getter))); | 300 base::Bind(&CreateProvisionFetcher, context_getter))); |
302 } | 301 } |
303 #endif | 302 #endif |
304 } | 303 } |
305 | 304 |
306 return cdm_factory_.get(); | 305 return cdm_factory_.get(); |
307 } | 306 } |
(...skipping 422 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
730 scoped_refptr<MediaKeys> cdm = GetCdm(render_frame_id, cdm_id); | 729 scoped_refptr<MediaKeys> cdm = GetCdm(render_frame_id, cdm_id); |
731 if (!cdm) { | 730 if (!cdm) { |
732 promise->reject(MediaKeys::INVALID_STATE_ERROR, 0, "CDM not found."); | 731 promise->reject(MediaKeys::INVALID_STATE_ERROR, 0, "CDM not found."); |
733 return; | 732 return; |
734 } | 733 } |
735 | 734 |
736 cdm->LoadSession(session_type, session_id, std::move(promise)); | 735 cdm->LoadSession(session_type, session_id, std::move(promise)); |
737 } | 736 } |
738 | 737 |
739 } // namespace content | 738 } // namespace content |
OLD | NEW |