Commit 2fe411a4 authored by Yuchen Liu's avatar Yuchen Liu Committed by Commit Bot

[Chromecast] Temporarily allow sync mojo API to get cdm origin

The origin is used for storage isolation. Now the CDM service should
call a sync mojo API to get the origin from browser process.

Merge-With: eureka-internal/413835
Bug: internal b/159179276
Test: EME on x86
Change-Id: I0dc1292a207b7e05d204436e0f4d45a95857bb34
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2252636Reviewed-by: default avatarYuchen Liu <yucliu@chromium.org>
Reviewed-by: default avatarDaniel Cheng <dcheng@chromium.org>
Reviewed-by: default avatarSean Topping <seantopping@chromium.org>
Reviewed-by: default avatarKen Rockot <rockot@google.com>
Reviewed-by: default avatarXiaohan Wang <xhwang@chromium.org>
Commit-Queue: Yuchen Liu <yucliu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#780398}
parent 681b9b2f
......@@ -177,6 +177,7 @@ cast_source_set("browser") {
"//chromecast/media:libcast_media",
"//chromecast/media/base:media_codec_support",
"//chromecast/media/base:video_plane_controller",
"//chromecast/media/cdm:cdm_origin_provider",
"//chromecast/media/service",
"//chromecast/media/service/mojom",
"//chromecast/net",
......
......@@ -53,6 +53,7 @@
#include "chromecast/media/audio/cast_audio_manager.h"
#include "chromecast/media/base/media_resource_tracker.h"
#include "chromecast/media/cdm/cast_cdm_factory.h"
#include "chromecast/media/cdm/cast_cdm_origin_provider.h"
#include "chromecast/media/cma/backend/cma_backend_factory_impl.h"
#include "chromecast/media/cma/backend/media_pipeline_backend_manager.h"
#include "chromecast/media/service/cast_renderer.h"
......@@ -303,7 +304,7 @@ bool CastContentBrowserClient::OverridesAudioManager() {
std::unique_ptr<::media::CdmFactory> CastContentBrowserClient::CreateCdmFactory(
::media::mojom::FrameInterfaceFactory* frame_interfaces) {
url::Origin cdm_origin;
if(!frame_interfaces->GetCdmOrigin(&cdm_origin))
if (!CastCdmOriginProvider::GetCdmOrigin(frame_interfaces, &cdm_origin))
return nullptr;
return std::make_unique<media::CastCdmFactory>(
......
......@@ -41,9 +41,9 @@ class CastMediaBlockerBrowserTest : public CastBrowserTest {
query_params.push_back(std::make_pair(tag, media_file));
query_params.push_back(std::make_pair("loop", "true"));
std::string query = media::GetURLQueryString(query_params);
std::string query = ::media::GetURLQueryString(query_params);
GURL gurl = content::GetFileUrlWithQuery(
media::GetTestDataFilePath("player.html"), query);
::media::GetTestDataFilePath("player.html"), query);
web_contents_ = NavigateToURL(gurl);
WaitForLoadStop(web_contents_);
......
......@@ -30,7 +30,7 @@ class CastNavigationBrowserTest : public CastBrowserTest {
void SetUpOnMainThread() override {
embedded_test_server()->ServeFilesFromSourceDirectory(
media::GetTestDataPath());
::media::GetTestDataPath());
ASSERT_TRUE(embedded_test_server()->Start());
}
......@@ -70,7 +70,7 @@ class CastNavigationBrowserTest : public CastBrowserTest {
void RunMediaTestPage(const std::string& html_page,
const base::StringPairs& query_params,
const std::string& expected_title) {
std::string query = media::GetURLQueryString(query_params);
std::string query = ::media::GetURLQueryString(query_params);
GURL gurl = embedded_test_server()->GetURL("/" + html_page + "?" + query);
std::string final_title = RunTest(gurl, expected_title);
EXPECT_EQ(expected_title, final_title);
......
......@@ -10,6 +10,7 @@ include_rules = [
"+media/base",
"+media/cdm",
"+media/filters",
"+media/mojo/mojom",
"+mojo/core/embedder/embedder.h",
"+mojo/public/cpp/bindings",
"+ui/gfx/geometry",
......
......@@ -33,3 +33,15 @@ cast_source_set("cdm") {
]
}
}
cast_source_set("cdm_origin_provider") {
sources = [
"cast_cdm_origin_provider.cc",
"cast_cdm_origin_provider.h",
]
deps = [
"//media/mojo/mojom",
"//mojo/public/cpp/bindings",
]
}
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chromecast/media/cdm/cast_cdm_origin_provider.h"
#include "media/mojo/mojom/frame_interface_factory.mojom.h"
#include "mojo/public/cpp/bindings/sync_call_restrictions.h"
namespace chromecast {
// static
bool CastCdmOriginProvider::GetCdmOrigin(
::media::mojom::FrameInterfaceFactory* interfaces,
url::Origin* cdm_origin) {
mojo::SyncCallRestrictions::ScopedAllowSyncCall allow_sync_call;
return interfaces->GetCdmOrigin(cdm_origin);
}
} // namespace chromecast
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROMECAST_MEDIA_CDM_CAST_CDM_ORIGIN_PROVIDER_H_
#define CHROMECAST_MEDIA_CDM_CAST_CDM_ORIGIN_PROVIDER_H_
namespace media {
namespace mojom {
class FrameInterfaceFactory;
} // namespace mojom
} // namespace media
namespace url {
class Origin;
} // namespace url
namespace chromecast {
class CastCdmOriginProvider {
public:
// Util function to call sync mojo API to get cdm origin.
// TODO(159346933) Remove once the origin isolation logic is moved outside of
// media service.
static bool GetCdmOrigin(::media::mojom::FrameInterfaceFactory* interfaces,
url::Origin* cdm_origin);
};
} // namespace chromecast
#endif // CHROMECAST_MEDIA_CDM_CAST_CDM_ORIGIN_PROVIDER_H_
......@@ -15,6 +15,10 @@
#define ENABLE_SYNC_CALL_RESTRICTIONS 0
#endif
namespace chromecast {
class CastCdmOriginProvider;
} // namespace chromecast
namespace sync_preferences {
class PrefServiceSyncable;
}
......@@ -82,6 +86,11 @@ class COMPONENT_EXPORT(MOJO_CPP_BINDINGS) SyncCallRestrictions {
// For preventing frame swaps of wrong size during resize on Windows.
// (https://crbug.com/811945)
friend class ui::Compositor;
// For calling sync mojo API to get cdm origin. The service and the client are
// running in the same process, so it won't block anything.
// TODO(159346933) Remove once the origin isolation logic is moved outside of
// cast media service.
friend class chromecast::CastCdmOriginProvider;
// END ALLOWED USAGE.
#if ENABLE_SYNC_CALL_RESTRICTIONS
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment