Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(179)

Side by Side Diff: chrome/browser/media/android/cdm/media_drm_storage_factory.cc

Issue 2765343003: media: Add MediaDrmStorage (Closed)
Patch Set: media: Add MediaDrmStorage Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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 <utility>
8
9 #include "base/logging.h"
10 #include "base/memory/ptr_util.h"
11 #include "chrome/browser/profiles/profile.h"
12 #include "components/cdm/browser/media_drm_storage_impl.h"
13 #include "components/prefs/pref_service.h"
14 #include "content/public/browser/browser_context.h"
15 #include "content/public/browser/browser_thread.h"
16 #include "content/public/browser/render_frame_host.h"
17 #include "content/public/browser/web_contents.h"
18 #include "mojo/public/cpp/bindings/strong_binding.h"
19
20 namespace chrome {
21
22 void CreateMediaDrmStorage(content::RenderFrameHost* render_frame_host,
23 media::mojom::MediaDrmStorageRequest request) {
24 DVLOG(1) << __func__;
25 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
26 DCHECK(render_frame_host);
27
28 content::WebContents* web_contents =
29 content::WebContents::FromRenderFrameHost(render_frame_host);
30 if (!web_contents) {
31 DVLOG(1) << __func__ << ": WebContents not available.";
32 return;
33 }
34
35 content::BrowserContext* browser_context = web_contents->GetBrowserContext();
36 if (!browser_context) {
37 DVLOG(1) << __func__ << ": BrowserContext not available.";
38 return;
39 }
40
41 Profile* profile = Profile::FromBrowserContext(browser_context);
42 if (!profile) {
43 DVLOG(1) << __func__ << ": Profile not available.";
dcheng 2017/03/31 18:01:56 Per chromium-dev, I think we should be DCHECKing t
xhwang 2017/03/31 18:25:36 Thanks for starting that discussion. Done!
44 return;
45 }
46
47 PrefService* pref_service = profile->GetPrefs();
48 if (!pref_service) {
dcheng 2017/03/31 18:01:56 I strongly suspect this one should be a DCHECK as
xhwang 2017/03/31 18:25:36 Done.
49 DVLOG(1) << __func__ << ": PrefService not available.";
50 return;
51 }
52
53 url::Origin origin = render_frame_host->GetLastCommittedOrigin();
54 if (origin.unique()) {
55 DVLOG(1) << __func__ << ": Unique origin.";
56 return;
57 }
58
59 // The object will be deleted on connection error, or when the frame navigates
60 // away.
61 new cdm::MediaDrmStorageImpl(render_frame_host, pref_service, origin,
62 std::move(request));
63 }
64
65 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698