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

Side by Side Diff: chrome/common/media/cdm_host_file_path.cc

Issue 2582463003: media: Verify CDM Host files (Closed)
Patch Set: comments addressed Created 3 years, 11 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/common/media/cdm_host_file_path.h"
6
7 #include "base/files/file_path.h"
8 #include "base/files/file_util.h"
9 #include "base/logging.h"
10 #include "base/macros.h"
11 #include "base/memory/ptr_util.h"
12 #include "base/path_service.h"
13 #include "build/build_config.h"
14 #include "chrome/common/chrome_version.h"
15
16 #if defined(OS_MACOSX)
17 #include "base/mac/bundle_locations.h"
18 #include "chrome/common/chrome_constants.h"
19 #endif
20
21 namespace {
22
23 using content::CdmHostFilePath;
24
25 // TODO(xhwang): Move this to a common place if needed.
26 const base::FilePath::CharType kSignatureFileExtension[] =
27 FILE_PATH_LITERAL(".sig");
28
29 // Returns the signature file path given the |file_path|. This function should
30 // only be used when the signature file and the file are located in the same
31 // directory.
32 base::FilePath GetSigFilePath(const base::FilePath& file_path) {
33 return file_path.AddExtension(kSignatureFileExtension);
34 }
35
36 #if defined(OS_WIN)
37
38 void AddCdmHostFilePathsWin(std::vector<CdmHostFilePath>* cdm_host_file_paths) {
39 static const base::FilePath::CharType* const kUnversionedFiles[] = {
40 FILE_PATH_LITERAL("chrome.exe")};
tinskip1 2017/01/19 03:42:47 Can we get the actual name of the executable to de
xhwang 2017/01/19 08:30:51 It's possible. I thought about using PathService::
tinskip1 2017/01/19 17:36:38 I'm just concerned about getting a bunch of VMP va
xhwang 2017/01/19 17:57:11 In that case do you expect the user also rename th
41 static const base::FilePath::CharType* const kVersionedFiles[] = {
42 FILE_PATH_LITERAL("chrome.dll"), FILE_PATH_LITERAL("chrome_child.dll")};
43
44 // Find where chrome.exe is installed.
45 base::FilePath chrome_exe_dir;
46 if (!PathService::Get(base::DIR_EXE, &chrome_exe_dir))
47 NOTREACHED();
48
49 cdm_host_file_paths->reserve(arraysize(kUnversionedFiles) +
50 arraysize(kVersionedFiles));
51
52 for (size_t i = 0; i < arraysize(kUnversionedFiles); ++i) {
53 base::FilePath file_path = chrome_exe_dir.Append(kUnversionedFiles[i]);
54 DVLOG(2) << __func__ << ": unversioned file " << i << " at "
55 << file_path.value();
56 cdm_host_file_paths->push_back(
57 CdmHostFilePath(file_path, GetSigFilePath(file_path)));
58 }
59
60 base::FilePath version_dir(chrome_exe_dir.AppendASCII(CHROME_VERSION_STRING));
61 for (size_t i = 0; i < arraysize(kVersionedFiles); ++i) {
62 base::FilePath file_path = version_dir.Append(kVersionedFiles[i]);
63 DVLOG(2) << __func__ << ": versioned file " << i << " at "
64 << file_path.value();
65 cdm_host_file_paths->push_back(
66 CdmHostFilePath(file_path, GetSigFilePath(file_path)));
67 }
68 }
69
70 #elif defined(OS_MACOSX)
71
72 void AddCdmHostFilePathsMac(std::vector<CdmHostFilePath>* cdm_host_file_paths) {
73 base::FilePath chrome_framework_path =
74 base::mac::FrameworkBundlePath().Append(chrome::kFrameworkExecutableName);
75
76 DVLOG(2) << __func__
77 << ": chrome_framework_path=" << chrome_framework_path.value();
78 cdm_host_file_paths->push_back(CdmHostFilePath(
79 chrome_framework_path, GetSigFilePath(chrome_framework_path)));
80 }
81
82 #elif defined(OS_LINUX)
83
84 void AddCdmHostFilePathsLinux(
85 std::vector<CdmHostFilePath>* cdm_host_file_paths) {
86 base::FilePath chrome_exe_dir;
87 if (!PathService::Get(base::DIR_EXE, &chrome_exe_dir))
88 NOTREACHED();
89
90 base::FilePath chrome_path =
91 chrome_exe_dir.Append(FILE_PATH_LITERAL("chrome"));
92 DVLOG(2) << __func__ << ": chrome_path=" << chrome_path.value();
93 cdm_host_file_paths->push_back(
94 CdmHostFilePath(chrome_path, GetSigFilePath(chrome_path)));
95 }
96
97 #endif // defined(OS_WIN)
98
99 } // namespace
100
101 void AddCdmHostFilePaths(
102 std::vector<content::CdmHostFilePath>* cdm_host_file_paths) {
103 DVLOG(1) << __func__;
104 DCHECK(cdm_host_file_paths);
105 DCHECK(cdm_host_file_paths->empty());
106
107 #if defined(OS_WIN)
108 AddCdmHostFilePathsWin(cdm_host_file_paths);
109 #elif defined(OS_MACOSX)
110 AddCdmHostFilePathsMac(cdm_host_file_paths);
111 #elif defined(OS_LINUX)
112 AddCdmHostFilePathsLinux(cdm_host_file_paths);
113 #endif // defined(OS_WIN)
114 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698