This repository has been archived by the owner on Jan 4, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 109
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,20 +10,26 @@ | |
#include "atom/common/atom_version.h" | ||
#include "atom/common/options_switches.h" | ||
#include "atom/common/pepper_flash_util.h" | ||
#include "base/base_paths.h" | ||
#include "base/command_line.h" | ||
#include "base/debug/crash_logging.h" | ||
#include "base/files/file_path.h" | ||
#include "base/files/file_util.h" | ||
#include "base/mac/bundle_locations.h" | ||
#include "base/memory/ptr_util.h" | ||
#include "base/path_service.h" | ||
#include "base/strings/string16.h" | ||
#include "base/strings/string_number_conversions.h" | ||
#include "base/strings/string_split.h" | ||
#include "base/strings/string_util.h" | ||
#include "base/strings/stringprintf.h" | ||
#include "base/strings/utf_string_conversions.h" | ||
#include "chrome/common/chrome_constants.h" | ||
#include "chrome/common/chrome_version.h" | ||
#include "chrome/common/crash_keys.h" | ||
#include "chrome/common/extensions/extension_process_policy.h" | ||
#include "chrome/common/secure_origin_whitelist.h" | ||
#include "content/public/common/cdm_info.h" | ||
#include "content/public/common/content_constants.h" | ||
#include "content/public/common/pepper_plugin_info.h" | ||
#include "content/public/common/user_agent.h" | ||
|
@@ -41,6 +47,52 @@ | |
#include "extensions/common/features/feature_util.h" | ||
#endif | ||
|
||
#if defined(WIDEVINE_CDM_AVAILABLE) && BUILDFLAG(ENABLE_PEPPER_CDMS) && \ | ||
!defined(WIDEVINE_CDM_IS_COMPONENT) | ||
#define WIDEVINE_CDM_AVAILABLE_NOT_COMPONENT | ||
#include "chrome/common/widevine_cdm_constants.h" | ||
#endif | ||
|
||
#if BUILDFLAG(ENABLE_CDM_HOST_VERIFICATION) | ||
#include "chrome/common/media/cdm_host_file_path.h" | ||
#endif | ||
|
||
#if defined(WIDEVINE_CDM_AVAILABLE_NOT_COMPONENT) | ||
bool IsWidevineAvailable(base::FilePath* adapter_path, | ||
base::FilePath* cdm_path, | ||
std::vector<std::string>* codecs_supported) { | ||
static enum { | ||
NOT_CHECKED, | ||
FOUND, | ||
NOT_FOUND, | ||
} widevine_cdm_file_check = NOT_CHECKED; | ||
// TODO(jrummell): We should add a new path for DIR_WIDEVINE_CDM and use that | ||
// to locate the CDM and the CDM adapter. | ||
if (PathService::Get(chrome::FILE_WIDEVINE_CDM_ADAPTER, adapter_path)) { | ||
*cdm_path = adapter_path->DirName().AppendASCII( | ||
base::GetNativeLibraryName(kWidevineCdmLibraryName)); | ||
if (widevine_cdm_file_check == NOT_CHECKED) { | ||
widevine_cdm_file_check = | ||
(base::PathExists(*adapter_path) && base::PathExists(*cdm_path)) | ||
? FOUND | ||
: NOT_FOUND; | ||
} | ||
if (widevine_cdm_file_check == FOUND) { | ||
// Add the supported codecs as if they came from the component manifest. | ||
// This list must match the CDM that is being bundled with Chrome. | ||
codecs_supported->push_back(kCdmSupportedCodecVp8); | ||
codecs_supported->push_back(kCdmSupportedCodecVp9); | ||
#if BUILDFLAG(USE_PROPRIETARY_CODECS) | ||
codecs_supported->push_back(kCdmSupportedCodecAvc1); | ||
#endif // BUILDFLAG(USE_PROPRIETARY_CODECS) | ||
return true; | ||
} | ||
} | ||
|
||
return false; | ||
} | ||
#endif // defined(WIDEVINE_CDM_AVAILABLE_NOT_COMPONENT) | ||
|
||
namespace atom { | ||
|
||
namespace { | ||
|
@@ -142,4 +194,78 @@ void AtomContentClient::AddPepperPlugins( | |
AddPepperFlashFromCommandLine(plugins); | ||
} | ||
|
||
// TODO(xhwang): Move this to a common place if needed. | ||
const base::FilePath::CharType kSignatureFileExtension[] = | ||
FILE_PATH_LITERAL(".sig"); | ||
|
||
// Returns the signature file path given the |file_path|. This function should | ||
// only be used when the signature file and the file are located in the same | ||
// directory. | ||
base::FilePath GetSigFilePath(const base::FilePath& file_path) { | ||
return file_path.AddExtension(kSignatureFileExtension); | ||
} | ||
|
||
void AtomContentClient::AddContentDecryptionModules( | ||
std::vector<content::CdmInfo>* cdms, | ||
std::vector<content::CdmHostFilePath>* cdm_host_file_paths) { | ||
if (cdms) { | ||
// TODO(jrummell): Need to have a better flag to indicate systems Widevine | ||
// is available on. For now we continue to use ENABLE_PEPPER_CDMS so that | ||
// we can experiment between pepper and mojo. | ||
#if defined(WIDEVINE_CDM_AVAILABLE_NOT_COMPONENT) | ||
base::FilePath adapter_path; | ||
base::FilePath cdm_path; | ||
std::vector<std::string> codecs_supported; | ||
if (IsWidevineAvailable(&adapter_path, &cdm_path, &codecs_supported)) { | ||
// CdmInfo needs |path| to be the actual Widevine library, | ||
// not the adapter, so adjust as necessary. It will be in the | ||
// same directory as the installed adapter. | ||
const base::Version version(WIDEVINE_CDM_VERSION_STRING); | ||
DCHECK(version.IsValid()); | ||
cdms->push_back(content::CdmInfo(kWidevineCdmType, version, cdm_path, | ||
codecs_supported)); | ||
} | ||
#endif // defined(WIDEVINE_CDM_AVAILABLE_NOT_COMPONENT) | ||
|
||
// TODO(jrummell): Add External Clear Key CDM for testing, if it's | ||
// available. | ||
} | ||
|
||
#if BUILDFLAG(ENABLE_CDM_HOST_VERIFICATION) | ||
if (cdm_host_file_paths) { | ||
#if defined(OS_WIN) | ||
static const base::FilePath::CharType* const kUnversionedFiles[] = { | ||
FILE_PATH_LITERAL("brave.exe")}; | ||
base::FilePath brave_exe_dir; | ||
if (!PathService::Get(base::DIR_EXE, &brave_exe_dir)) | ||
NOTREACHED(); | ||
cdm_host_file_paths->reserve(arraysize(kUnversionedFiles)); | ||
|
||
// Signature files are always in the version directory. | ||
for (size_t i = 0; i < arraysize(kUnversionedFiles); ++i) { | ||
base::FilePath file_path = brave_exe_dir.Append(kUnversionedFiles[i]); | ||
base::FilePath sig_path = | ||
GetSigFilePath(brave_exe_dir.Append(kUnversionedFiles[i])); | ||
VLOG(1) << __func__ << ": unversioned file " << i << " at " | ||
<< file_path.value() << ", signature file " << sig_path.value(); | ||
cdm_host_file_paths->push_back( | ||
content::CdmHostFilePath(file_path, sig_path)); | ||
} | ||
#elif defined(OS_MACOSX) | ||
base::FilePath brave_framework_path = | ||
base::mac::FrameworkBundlePath().Append(chrome::kFrameworkExecutableName); | ||
|
||
base::FilePath brave_framework_sig_path = GetSigFilePath( | ||
brave_framework_path.Append(chrome::kFrameworkExecutableName)); | ||
|
||
VLOG(1) << __func__ | ||
<< ": brave_framework_path=" << brave_framework_path.value() | ||
<< ", signature_path=" << brave_framework_sig_path.value(); | ||
cdm_host_file_paths->push_back( | ||
content::CdmHostFilePath(brave_framework_path, brave_framework_sig_path)); | ||
#endif | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @posix4e you'll need something here for linux |
||
} | ||
#endif | ||
} | ||
|
||
} // namespace atom |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use
base::FILE_EXE
instead of hard-coding brave.exe with the path