| 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 kClearKeyCdmDisplayName[] = "Clear Key CDM"; |
| 16 |
| 17 const char kClearKeyCdmAdapterFileName[] = |
| 18 #if defined(OS_MACOSX) |
| 19 "clearkeycdmadapter.plugin"; |
| 20 #elif defined(OS_WIN) |
| 21 "clearkeycdmadapter.dll"; |
| 22 #elif defined(OS_POSIX) |
| 23 "libclearkeycdmadapter.so"; |
| 24 #endif |
| 25 |
| 26 const char kClearKeyCdmPepperMimeType[] = "application/x-ppapi-clearkey-cdm"; |
| 27 |
| 28 base::FilePath::StringType BuildPepperCdmRegistration( |
| 29 const std::string& adapter_file_name, |
| 30 const std::string& display_name, |
| 31 const std::string& mime_type, |
| 32 bool expect_adapter_exists) { |
| 33 base::FilePath adapter_path; |
| 34 PathService::Get(base::DIR_MODULE, &adapter_path); |
| 35 adapter_path = adapter_path.AppendASCII(adapter_file_name); |
| 36 DCHECK_EQ(expect_adapter_exists, base::PathExists(adapter_path)); |
| 37 |
| 38 base::FilePath::StringType pepper_cdm_registration = adapter_path.value(); |
| 39 |
| 40 std::string string_to_append = "#"; |
| 41 string_to_append.append(display_name); |
| 42 string_to_append.append("#CDM#0.1.0.0;"); |
| 43 string_to_append.append(mime_type); |
| 44 |
| 45 #if defined(OS_WIN) |
| 46 pepper_cdm_registration.append(base::ASCIIToUTF16(string_to_append)); |
| 47 #else |
| 48 pepper_cdm_registration.append(string_to_append); |
| 49 #endif |
| 50 |
| 51 return pepper_cdm_registration; |
| 52 } |
| 53 |
| 54 void RegisterPepperCdm(base::CommandLine* command_line, |
| 55 const std::string& adapter_file_name, |
| 56 const std::string& display_name, |
| 57 const std::string& mime_type, |
| 58 bool expect_adapter_exists) { |
| 59 base::FilePath::StringType pepper_cdm_registration = |
| 60 BuildPepperCdmRegistration(adapter_file_name, display_name, mime_type, |
| 61 expect_adapter_exists); |
| 62 |
| 63 // Append the switch to register the CDM Adapter. |
| 64 command_line->AppendSwitchNative(switches::kRegisterPepperPlugins, |
| 65 pepper_cdm_registration); |
| 66 } |
| OLD | NEW |