diff --git a/app/brave_main_delegate.cc b/app/brave_main_delegate.cc index 645e464089e5..b186f9f36bf2 100644 --- a/app/brave_main_delegate.cc +++ b/app/brave_main_delegate.cc @@ -177,9 +177,9 @@ bool BraveMainDelegate::BasicStartupComplete(int* exit_code) { bool ret = ChromeMainDelegate::BasicStartupComplete(exit_code); #if BUILDFLAG(BUNDLE_WIDEVINE_CDM) - // Override chrome::FILE_WIDEVINE_CDM path because we install it in user data - // dir. Must call after ChromeMainDelegate::BasicStartupComplete() to use - // chrome paths. + // Override chrome::DIR_BUNDLED_WIDEVINE_CDM path because we install it in + // user data dir. Must call after ChromeMainDelegate::BasicStartupComplete() + // to use chrome paths. brave::OverridePath(); #endif diff --git a/browser/widevine/BUILD.gn b/browser/widevine/BUILD.gn index 17d780d7d492..94c6c7b878f7 100644 --- a/browser/widevine/BUILD.gn +++ b/browser/widevine/BUILD.gn @@ -33,6 +33,7 @@ source_set("widevine") { "//components/prefs", "//components/pref_registry", "//components/services/unzip/public/cpp", + "//media/cdm:cdm_paths", "//services/network/public/cpp", "//services/service_manager/public/cpp", "//third_party/widevine/cdm:headers", diff --git a/browser/widevine/brave_widevine_bundle_unzipper.cc b/browser/widevine/brave_widevine_bundle_unzipper.cc index 514dbb3727a0..644c419672b0 100644 --- a/browser/widevine/brave_widevine_bundle_unzipper.cc +++ b/browser/widevine/brave_widevine_bundle_unzipper.cc @@ -5,6 +5,7 @@ #include "brave/browser/widevine/brave_widevine_bundle_unzipper.h" +#include #include #include "base/bind.h" @@ -14,6 +15,7 @@ #include "components/services/unzip/content/unzip_service.h" #include "components/services/unzip/public/cpp/unzip.h" #include "content/public/browser/browser_thread.h" +#include "media/cdm/cdm_paths.h" #include "third_party/widevine/cdm/widevine_cdm_common.h" namespace { @@ -22,8 +24,10 @@ namespace { bool IsWidevineCdmFile(const base::FilePath& file_path) { CHECK(!file_path.IsAbsolute()); return base::FilePath::CompareEqualIgnoreCase( - file_path.value(), - base::GetNativeLibraryName(kWidevineCdmLibraryName)); + file_path.value(), + base::GetNativeLibraryName(kWidevineCdmLibraryName)) || + base::FilePath::CompareEqualIgnoreCase(file_path.value(), + "manifest.json"); } base::Optional GetTempDirForUnzip() { @@ -106,16 +110,30 @@ void BraveWidevineBundleUnzipper::OnUnzippedInTempDir(bool status) { } std::string BraveWidevineBundleUnzipper::MoveUnzippedLibFromTempToTargetDir() { - const base::FilePath source = temp_unzip_dir_.AppendASCII( - base::GetNativeLibraryName(kWidevineCdmLibraryName)); - DCHECK(base::PathExists(source)); - - const base::FilePath target = target_unzip_dir_.AppendASCII( - base::GetNativeLibraryName(kWidevineCdmLibraryName)); + // Lib should go into the platform specific directory, whereas the manifest + // goes to the top directory. + const base::FilePath widevine_lib_dir = + media::GetPlatformSpecificDirectory(target_unzip_dir_); + base::CreateDirectory(widevine_lib_dir); + const std::string widevine_lib_name = + base::GetNativeLibraryName(kWidevineCdmLibraryName); + + const std::map files = { + {widevine_lib_name, widevine_lib_dir}, + {"manifest.json", target_unzip_dir_}}; std::string error; - if (!base::Move(source, target)) - error = "widevine lib move failed"; + for (auto const& file : files) { + const base::FilePath source = temp_unzip_dir_.AppendASCII(file.first); + DCHECK(base::PathExists(source)); + const base::FilePath target = file.second.AppendASCII(file.first); + + if (!base::Move(source, target)) { + error = std::string("widevine lib failed to move: ") + + source.value() + " to " + target.value(); + break; + } + } base::DeleteFile(temp_unzip_dir_, true); diff --git a/browser/widevine/widevine_permission_request.cc b/browser/widevine/widevine_permission_request.cc index cf081ad1849f..eb4a9e9afb49 100644 --- a/browser/widevine/widevine_permission_request.cc +++ b/browser/widevine/widevine_permission_request.cc @@ -33,7 +33,7 @@ GURL WidevinePermissionRequest::GetOrigin() const { } void WidevinePermissionRequest::PermissionGranted() { -#if BUILDFLAG(ENABLE_WIDEVINE_CDM_COMPONENT) +#if BUILDFLAG(ENABLE_WIDEVINE_CDM_COMPONENT) && !defined(OS_LINUX) EnableWidevineCdmComponent(web_contents_); #endif diff --git a/browser/widevine/widevine_permission_request_browsertest.cc b/browser/widevine/widevine_permission_request_browsertest.cc index e9f96f6bfffb..4b5fcc0e009e 100644 --- a/browser/widevine/widevine_permission_request_browsertest.cc +++ b/browser/widevine/widevine_permission_request_browsertest.cc @@ -147,7 +147,7 @@ IN_PROC_BROWSER_TEST_F(WidevinePermissionRequestBrowserTest, BubbleTest) { // OptedInPref of bundling tests are done by // BraveWidevineBundleManagerBrowserTest. -#if BUILDFLAG(ENABLE_WIDEVINE_CDM_COMPONENT) +#if BUILDFLAG(ENABLE_WIDEVINE_CDM_COMPONENT) && !defined(OS_LINUX) IN_PROC_BROWSER_TEST_F(WidevinePermissionRequestBrowserTest, CheckOptedInPrefStateForComponent) { PrefService* prefs = ProfileManager::GetActiveUserProfile()->GetPrefs(); diff --git a/browser/widevine/widevine_utils.cc b/browser/widevine/widevine_utils.cc index 4683d176357e..8dc3fd109741 100644 --- a/browser/widevine/widevine_utils.cc +++ b/browser/widevine/widevine_utils.cc @@ -26,7 +26,7 @@ #include "chrome/browser/ui/tabs/tab_strip_model.h" #endif -#if BUILDFLAG(ENABLE_WIDEVINE_CDM_COMPONENT) +#if BUILDFLAG(ENABLE_WIDEVINE_CDM_COMPONENT) && !defined(OS_LINUX) #include "chrome/browser/component_updater/widevine_cdm_component_installer.h" #include "chrome/browser/profiles/profile_manager.h" #endif @@ -67,7 +67,7 @@ void OnWidevineInstallDone(const std::string& error) { int GetWidevinePermissionRequestTextFrangmentResourceId() { int message_id = -1; -#if BUILDFLAG(ENABLE_WIDEVINE_CDM_COMPONENT) +#if BUILDFLAG(ENABLE_WIDEVINE_CDM_COMPONENT) && !defined(OS_LINUX) message_id = IDS_WIDEVINE_PERMISSION_REQUEST_TEXT_FRAGMENT; #endif @@ -85,7 +85,7 @@ void RequestWidevinePermission(content::WebContents* web_contents) { new WidevinePermissionRequest(web_contents)); } -#if BUILDFLAG(ENABLE_WIDEVINE_CDM_COMPONENT) +#if BUILDFLAG(ENABLE_WIDEVINE_CDM_COMPONENT) && !defined(OS_LINUX) void EnableWidevineCdmComponent(content::WebContents* web_contents) { DCHECK(web_contents); diff --git a/browser/widevine/widevine_utils.h b/browser/widevine/widevine_utils.h index dfef84e25eb7..dc294c09ba17 100644 --- a/browser/widevine/widevine_utils.h +++ b/browser/widevine/widevine_utils.h @@ -19,7 +19,7 @@ void RequestWidevinePermission(content::WebContents* web_contents); void InstallBundleOrRestartBrowser(); #endif -#if BUILDFLAG(ENABLE_WIDEVINE_CDM_COMPONENT) +#if BUILDFLAG(ENABLE_WIDEVINE_CDM_COMPONENT) && !defined(OS_LINUX) void EnableWidevineCdmComponent(content::WebContents* web_contents); #endif diff --git a/common/brave_paths.cc b/common/brave_paths.cc index 1d1a46eecdff..9c3c061d5ec2 100644 --- a/common/brave_paths.cc +++ b/common/brave_paths.cc @@ -49,16 +49,13 @@ void RegisterPathProvider() { void OverridePath() { #if BUILDFLAG(BUNDLE_WIDEVINE_CDM) // Brave downloads cdm lib to user dir when user accepts instead of shippig by - // default. So, override |FILE_WIDEVINE_CDM| to new path in user dir. + // default. So, override |DIR_BUNDLED_WIDEVINE_CDM| to new path in user dir. base::FilePath widevine_cdm_path; if (base::PathService::Get(chrome::DIR_USER_DATA, &widevine_cdm_path)) { widevine_cdm_path = - widevine_cdm_path.AppendASCII(kWidevineCdmBaseDirectory) - .AppendASCII(base::GetNativeLibraryName(kWidevineCdmLibraryName)); - base::PathService::OverrideAndCreateIfNeeded(chrome::FILE_WIDEVINE_CDM, - widevine_cdm_path, - true, - false); + widevine_cdm_path.AppendASCII(kWidevineCdmBaseDirectory); + base::PathService::OverrideAndCreateIfNeeded( + chrome::DIR_BUNDLED_WIDEVINE_CDM, widevine_cdm_path, true, false); } #endif }