Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2016 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/browser/media/pepper_cdm_test_helper.h" | |
| 6 | |
| 7 #include "base/command_line.h" | |
| 8 #include "base/files/file_util.h" | |
| 9 #include "base/path_service.h" | |
| 10 #include "base/strings/utf_string_conversions.h" | |
| 11 #include "content/public/common/content_switches.h" | |
| 12 | |
| 13 #include "widevine_cdm_version.h" // In SHARED_INTERMEDIATE_DIR. | |
| 14 | |
| 15 const char kClearKeyCdmAdapterFileName[] = | |
| 16 #if defined(OS_MACOSX) | |
| 17 "clearkeycdmadapter.plugin"; | |
| 18 #elif defined(OS_WIN) | |
| 19 "clearkeycdmadapter.dll"; | |
| 20 #elif defined(OS_POSIX) | |
| 21 "libclearkeycdmadapter.so"; | |
| 22 #endif | |
| 23 | |
| 24 const char kClearKeyCdmPepperMimeType[] = "application/x-ppapi-clearkey-cdm"; | |
| 25 | |
| 26 base::FilePath::StringType BuildPepperCdmRegistration( | |
| 27 const std::string& adapter_file_name, | |
| 28 const std::string& mime_type, | |
| 29 bool expect_adapter_exists) { | |
| 30 base::FilePath adapter_path; | |
| 31 DCHECK(PathService::Get(base::DIR_MODULE, &adapter_path)); | |
|
Lei Zhang
2016/05/18 00:53:11
Can't put this in a DCHECK. It won't run in releas
xhwang
2016/05/18 02:08:10
Good catch. It's really not interesting to check t
| |
| 32 adapter_path = adapter_path.AppendASCII(adapter_file_name); | |
| 33 DCHECK_EQ(expect_adapter_exists, base::PathExists(adapter_path)); | |
| 34 | |
| 35 base::FilePath::StringType pepper_cdm_registration = adapter_path.value(); | |
|
Lei Zhang
2016/05/18 00:53:11
If this is just a base::FilePath, then you can use
xhwang
2016/05/18 02:08:10
The registration is a string. AppendASCII will add
| |
| 36 pepper_cdm_registration.append(FILE_PATH_LITERAL("#CDM#0.1.0.0;")); | |
| 37 | |
| 38 #if defined(OS_WIN) | |
| 39 pepper_cdm_registration.append(base::ASCIIToUTF16(mime_type)); | |
| 40 #else | |
| 41 pepper_cdm_registration.append(mime_type); | |
| 42 #endif | |
| 43 | |
| 44 return pepper_cdm_registration; | |
| 45 } | |
| 46 | |
| 47 void RegisterPepperCdm(base::CommandLine* command_line, | |
| 48 const std::string& adapter_file_name, | |
| 49 const std::string& mime_type, | |
| 50 bool expect_adapter_exists) { | |
| 51 base::FilePath::StringType pepper_cdm_registration = | |
| 52 BuildPepperCdmRegistration(adapter_file_name, mime_type, | |
| 53 expect_adapter_exists); | |
| 54 | |
| 55 // Append the switch to register the CDM Adapter. | |
| 56 command_line->AppendSwitchNative(switches::kRegisterPepperPlugins, | |
| 57 pepper_cdm_registration); | |
| 58 } | |
| OLD | NEW |