OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "content/public/test/ppapi_test_utils.h" | 5 #include "content/public/test/ppapi_test_utils.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/files/file_util.h" | 8 #include "base/files/file_util.h" |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
11 #include "content/public/common/content_switches.h" | 11 #include "content/public/common/content_switches.h" |
12 #include "ppapi/shared_impl/ppapi_constants.h" | 12 #include "ppapi/shared_impl/ppapi_constants.h" |
13 | 13 |
14 namespace ppapi { | 14 namespace ppapi { |
15 | 15 |
16 namespace { | 16 namespace { |
17 | 17 |
18 bool RegisterPlugin( | 18 bool RegisterPlugin( |
19 base::CommandLine* command_line, | 19 base::CommandLine* command_line, |
20 const base::FilePath::StringType& library_name, | 20 const base::FilePath::StringType& library_name, |
21 const base::FilePath::StringType& extra_registration_parameters) { | 21 const base::FilePath::StringType& extra_registration_parameters, |
22 const base::FilePath::StringType& mime_type) { | |
22 base::FilePath plugin_dir; | 23 base::FilePath plugin_dir; |
23 if (!PathService::Get(base::DIR_MODULE, &plugin_dir)) | 24 if (!PathService::Get(base::DIR_MODULE, &plugin_dir)) { |
25 printf("Couldn't look up module path!\n"); | |
Avi (use Gerrit)
2015/12/01 15:01:14
Why doesn't LOG(ERROR) or LOG(FATAL) work here?
dcheng
2015/12/01 19:52:02
It does, but these are temporary debugging lines.
Avi (use Gerrit)
2015/12/01 20:51:54
No ideas offhand, but don't commit debugging code.
| |
24 return false; | 26 return false; |
27 } | |
25 | 28 |
26 base::FilePath plugin_path = plugin_dir.Append(library_name); | 29 base::FilePath plugin_path = plugin_dir.Append(library_name); |
27 | 30 |
31 printf("Looking for plugin in %s\n", plugin_path.value().c_str()); | |
Avi (use Gerrit)
2015/12/01 15:01:14
Is this needed?
| |
28 // Append the switch to register the pepper plugin. | 32 // Append the switch to register the pepper plugin. |
29 if (!base::PathExists(plugin_path)) | 33 if (!base::PathExists(plugin_path)) { |
34 printf("File doesn't exist!\n"); | |
Avi (use Gerrit)
2015/12/01 15:01:14
LOG(FATAL)?
| |
30 return false; | 35 return false; |
36 } | |
31 base::FilePath::StringType pepper_plugin = plugin_path.value(); | 37 base::FilePath::StringType pepper_plugin = plugin_path.value(); |
32 pepper_plugin.append(extra_registration_parameters); | 38 pepper_plugin.append(extra_registration_parameters); |
33 pepper_plugin.append(FILE_PATH_LITERAL(";application/x-ppapi-tests")); | 39 pepper_plugin.append(FILE_PATH_LITERAL(";")); |
40 pepper_plugin.append(mime_type); | |
34 command_line->AppendSwitchNative(switches::kRegisterPepperPlugins, | 41 command_line->AppendSwitchNative(switches::kRegisterPepperPlugins, |
35 pepper_plugin); | 42 pepper_plugin); |
36 return true; | 43 return true; |
37 } | 44 } |
38 | 45 |
46 bool RegisterPluginWithDefaultMimeType( | |
47 base::CommandLine* command_line, | |
48 const base::FilePath::StringType& library_name, | |
49 const base::FilePath::StringType& extra_registration_parameters) { | |
50 return RegisterPlugin(command_line, library_name, | |
51 extra_registration_parameters, | |
52 FILE_PATH_LITERAL("application/x-ppapi-tests")); | |
53 } | |
54 | |
39 } // namespace | 55 } // namespace |
40 | 56 |
41 bool RegisterTestPlugin(base::CommandLine* command_line) { | 57 bool RegisterTestPlugin(base::CommandLine* command_line) { |
42 return RegisterTestPluginWithExtraParameters(command_line, | 58 return RegisterTestPluginWithExtraParameters(command_line, |
43 FILE_PATH_LITERAL("")); | 59 FILE_PATH_LITERAL("")); |
44 } | 60 } |
45 | 61 |
46 bool RegisterTestPluginWithExtraParameters( | 62 bool RegisterTestPluginWithExtraParameters( |
47 base::CommandLine* command_line, | 63 base::CommandLine* command_line, |
48 const base::FilePath::StringType& extra_registration_parameters) { | 64 const base::FilePath::StringType& extra_registration_parameters) { |
49 #if defined(OS_WIN) | 65 #if defined(OS_WIN) |
50 base::FilePath::StringType plugin_library = L"ppapi_tests.dll"; | 66 base::FilePath::StringType plugin_library = L"ppapi_tests.dll"; |
51 #elif defined(OS_MACOSX) | 67 #elif defined(OS_MACOSX) |
52 base::FilePath::StringType plugin_library = "ppapi_tests.plugin"; | 68 base::FilePath::StringType plugin_library = "ppapi_tests.plugin"; |
53 #elif defined(OS_POSIX) | 69 #elif defined(OS_POSIX) |
54 base::FilePath::StringType plugin_library = "libppapi_tests.so"; | 70 base::FilePath::StringType plugin_library = "libppapi_tests.so"; |
55 #endif | 71 #endif |
56 return RegisterPlugin(command_line, plugin_library, | 72 return RegisterPluginWithDefaultMimeType(command_line, plugin_library, |
57 extra_registration_parameters); | 73 extra_registration_parameters); |
58 } | 74 } |
59 | 75 |
60 bool RegisterPowerSaverTestPlugin(base::CommandLine* command_line) { | 76 bool RegisterPowerSaverTestPlugin(base::CommandLine* command_line) { |
61 base::FilePath::StringType library_name = | 77 base::FilePath::StringType library_name = |
62 base::FilePath::FromUTF8Unsafe(ppapi::kPowerSaverTestPluginName).value(); | 78 base::FilePath::FromUTF8Unsafe(ppapi::kPowerSaverTestPluginName).value(); |
63 return RegisterPlugin(command_line, library_name, FILE_PATH_LITERAL("")); | 79 return RegisterPluginWithDefaultMimeType(command_line, library_name, |
80 FILE_PATH_LITERAL("")); | |
64 } | 81 } |
65 | 82 |
83 bool RegisterBlinkTestPlugin(base::CommandLine* command_line) { | |
84 #if defined(OS_WIN) | |
85 static const base::FilePath::CharType kPluginLibrary[] = | |
86 L"blink_test_plugin.dll"; | |
87 #elif defined(OS_MACOSX) | |
88 static const base::FilePath::CharType kPluginLibrary[] = | |
89 "blink_test_plugin.plugin"; | |
90 #elif defined(OS_POSIX) | |
91 static const base::FilePath::CharType kPluginLibrary[] = | |
92 "libblink_test_plugin.so"; | |
93 #endif | |
94 // #name#description#version | |
95 static const base::FilePath::CharType kExtraParameters[] = | |
96 FILE_PATH_LITERAL("#Blink Test Plugin#Interesting description.#0.8"); | |
97 return RegisterPlugin(command_line, kPluginLibrary, kExtraParameters, | |
98 FILE_PATH_LITERAL("application/x-blink-test-plugin")); | |
99 } | |
66 } // namespace ppapi | 100 } // namespace ppapi |
OLD | NEW |