OLD | NEW |
(Empty) | |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "chrome/browser/media/android/cdm/media_drm_storage_factory.h" |
| 6 |
| 7 #include "base/logging.h" |
| 8 #include "base/memory/ptr_util.h" |
| 9 #include "chrome/browser/profiles/profile.h" |
| 10 #include "components/cdm/browser/media_drm_storage_impl.h" |
| 11 #include "components/prefs/pref_service.h" |
| 12 #include "content/public/browser/browser_context.h" |
| 13 #include "content/public/browser/browser_thread.h" |
| 14 #include "content/public/browser/render_frame_host.h" |
| 15 #include "content/public/browser/web_contents.h" |
| 16 #include "mojo/public/cpp/bindings/strong_binding.h" |
| 17 |
| 18 namespace chrome { |
| 19 |
| 20 void CreateMediaDrmStorage(content::RenderFrameHost* render_frame_host, |
| 21 media::mojom::MediaDrmStorageRequest request) { |
| 22 DVLOG(2) << __func__; |
| 23 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 24 DCHECK(render_frame_host); |
| 25 |
| 26 content::WebContents* web_contents = |
| 27 content::WebContents::FromRenderFrameHost(render_frame_host); |
| 28 if (!web_contents) |
| 29 return; |
| 30 |
| 31 content::BrowserContext* browser_context = web_contents->GetBrowserContext(); |
| 32 if (!browser_context) |
| 33 return; |
| 34 |
| 35 Profile* profile = Profile::FromBrowserContext(browser_context); |
| 36 if (!profile) |
| 37 return; |
| 38 |
| 39 PrefService* pref_service = profile->GetPrefs(); |
| 40 if (!pref_service) |
| 41 return; |
| 42 |
| 43 mojo::MakeStrongBinding( |
| 44 base::MakeUnique<cdm::MediaDrmStorageImpl>(pref_service), |
| 45 std::move(request)); |
| 46 } |
| 47 |
| 48 } // namespace chrome |
OLD | NEW |