• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1diff --git chrome/common/media/component_widevine_cdm_hint_file_linux.cc chrome/common/media/component_widevine_cdm_hint_file_linux.cc
2index 44a89a2e7f6e4..447c1a635eadd 100644
3--- chrome/common/media/component_widevine_cdm_hint_file_linux.cc
4+++ chrome/common/media/component_widevine_cdm_hint_file_linux.cc
5@@ -16,6 +16,7 @@
6 #include "base/path_service.h"
7 #include "base/values.h"
8 #include "chrome/common/chrome_paths.h"
9+#include "third_party/widevine/cdm/widevine_cdm_common.h"
10
11 namespace {
12
13@@ -37,14 +38,33 @@ base::FilePath GetPath(const base::Value& dict) {
14   return path;
15 }
16
17+// On Linux the Widevine CDM is loaded into the zygote at startup. When the
18+// component updater runs sometime later and finds a newer version of the
19+// Widevine CDM, don't register it as the newer version can't be used. Instead,
20+// save the path to the new Widevine CDM in this file. Next time at startup this
21+// file will be checked, and if it references a usable Widevine CDM, use this
22+// version instead of the old (potentially bundled) CDM.
23+// Add this method instead of using chrome::FILE_COMPONENT_WIDEVINE_CDM_HINT
24+// because only directories (not files) can be configured via
25+// base::PathService::Override.
26+bool GetHintFilePath(base::FilePath* hint_file_path) {
27+  base::FilePath user_data_dir;
28+  if (!base::PathService::Get(chrome::DIR_USER_DATA, &user_data_dir))
29+    return false;
30+  // Match the file name in chrome/common/chrome_paths.cc
31+  *hint_file_path = user_data_dir
32+      .AppendASCII(kWidevineCdmBaseDirectory)
33+      .Append(FILE_PATH_LITERAL("latest-component-updated-widevine-cdm"));
34+  return true;
35+}
36+
37 }  // namespace
38
39 bool UpdateWidevineCdmHintFile(const base::FilePath& cdm_base_path) {
40   DCHECK(!cdm_base_path.empty());
41
42   base::FilePath hint_file_path;
43-  CHECK(base::PathService::Get(chrome::FILE_COMPONENT_WIDEVINE_CDM_HINT,
44-                               &hint_file_path));
45+  CHECK(GetHintFilePath(&hint_file_path));
46
47   base::Value dict(base::Value::Type::DICTIONARY);
48   dict.SetStringPath(kPath, cdm_base_path.value());
49@@ -62,8 +82,7 @@ bool UpdateWidevineCdmHintFile(const base::FilePath& cdm_base_path) {
50
51 base::FilePath GetLatestComponentUpdatedWidevineCdmDirectory() {
52   base::FilePath hint_file_path;
53-  CHECK(base::PathService::Get(chrome::FILE_COMPONENT_WIDEVINE_CDM_HINT,
54-                               &hint_file_path));
55+  CHECK(GetHintFilePath(&hint_file_path));
56
57   if (!base::PathExists(hint_file_path)) {
58     DVLOG(2) << "CDM hint file at " << hint_file_path << " does not exist.";
59