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

Side by Side Diff: content/public/test/ppapi_test_utils.cc

Issue 2356053002: [HBD] Only use Plugin Content Settings for Flash. (Closed)
Patch Set: fix prerender tests Created 4 years, 2 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
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 <vector> 7 #include <vector>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/files/file_util.h" 10 #include "base/files/file_util.h"
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "base/path_service.h" 12 #include "base/path_service.h"
13 #include "build/build_config.h" 13 #include "build/build_config.h"
14 #include "content/public/common/content_constants.h"
14 #include "content/public/common/content_switches.h" 15 #include "content/public/common/content_switches.h"
15 #include "ppapi/shared_impl/ppapi_constants.h" 16 #include "ppapi/shared_impl/ppapi_constants.h"
17 #include "ppapi/shared_impl/ppapi_switches.h"
16 18
17 using CharType = base::FilePath::CharType; 19 using CharType = base::FilePath::CharType;
18 using StringType = base::FilePath::StringType; 20 using StringType = base::FilePath::StringType;
19 21
20 namespace ppapi { 22 namespace ppapi {
21 23
22 namespace { 24 namespace {
23 25
24 struct PluginInfo { 26 struct PluginInfo {
25 PluginInfo(const StringType& library_name, 27 PluginInfo(const StringType& library_name,
(...skipping 29 matching lines...) Expand all
55 } 57 }
56 command_line->AppendSwitchNative(switches::kRegisterPepperPlugins, args); 58 command_line->AppendSwitchNative(switches::kRegisterPepperPlugins, args);
57 return true; 59 return true;
58 } 60 }
59 61
60 bool RegisterPluginWithDefaultMimeType( 62 bool RegisterPluginWithDefaultMimeType(
61 base::CommandLine* command_line, 63 base::CommandLine* command_line,
62 const base::FilePath::StringType& library_name, 64 const base::FilePath::StringType& library_name,
63 const base::FilePath::StringType& extra_registration_parameters) { 65 const base::FilePath::StringType& extra_registration_parameters) {
64 std::vector<PluginInfo> plugins; 66 std::vector<PluginInfo> plugins;
65 plugins.push_back(PluginInfo(library_name, extra_registration_parameters, 67 plugins.push_back(PluginInfo(
66 FILE_PATH_LITERAL("application/x-ppapi-tests"))); 68 library_name, extra_registration_parameters,
69 base::FilePath::FromUTF8Unsafe(content::kTestPluginMimeType).value()));
67 return RegisterPlugins(command_line, plugins); 70 return RegisterPlugins(command_line, plugins);
68 } 71 }
69 72
70 } // namespace 73 } // namespace
71 74
72 bool RegisterTestPlugin(base::CommandLine* command_line) { 75 bool RegisterTestPlugin(base::CommandLine* command_line) {
73 return RegisterTestPluginWithExtraParameters(command_line, 76 return RegisterTestPluginWithExtraParameters(command_line,
74 FILE_PATH_LITERAL("")); 77 FILE_PATH_LITERAL(""));
75 } 78 }
76 79
77 bool RegisterTestPluginWithExtraParameters( 80 bool RegisterTestPluginWithExtraParameters(
78 base::CommandLine* command_line, 81 base::CommandLine* command_line,
79 const base::FilePath::StringType& extra_registration_parameters) { 82 const base::FilePath::StringType& extra_registration_parameters) {
80 #if defined(OS_WIN) 83 #if defined(OS_WIN)
81 base::FilePath::StringType plugin_library = L"ppapi_tests.dll"; 84 base::FilePath::StringType plugin_library = L"ppapi_tests.dll";
82 #elif defined(OS_MACOSX) 85 #elif defined(OS_MACOSX)
83 base::FilePath::StringType plugin_library = "ppapi_tests.plugin"; 86 base::FilePath::StringType plugin_library = "ppapi_tests.plugin";
84 #elif defined(OS_POSIX) 87 #elif defined(OS_POSIX)
85 base::FilePath::StringType plugin_library = "libppapi_tests.so"; 88 base::FilePath::StringType plugin_library = "libppapi_tests.so";
86 #endif 89 #endif
87 return RegisterPluginWithDefaultMimeType(command_line, plugin_library, 90 return RegisterPluginWithDefaultMimeType(command_line, plugin_library,
88 extra_registration_parameters); 91 extra_registration_parameters);
89 } 92 }
90 93
91 bool RegisterPowerSaverTestPlugin(base::CommandLine* command_line) { 94 bool RegisterPowerSaverTestPlugin(base::CommandLine* command_line) {
95 // Power Saver plugin requires Pepper testing API.
96 command_line->AppendSwitch(switches::kEnablePepperTesting);
97
92 base::FilePath::StringType library_name = 98 base::FilePath::StringType library_name =
93 base::FilePath::FromUTF8Unsafe(ppapi::kPowerSaverTestPluginName).value(); 99 base::FilePath::FromUTF8Unsafe(ppapi::kPowerSaverTestPluginName).value();
100 // Register a fake Flash with 100.0 version (to avoid outdated checks).
101 base::FilePath::StringType fake_flash_parameter =
102 base::FilePath::FromUTF8Unsafe(
103 std::string("#") + content::kFlashPluginName + "#Description#100.0")
104 .value();
94 return RegisterPluginWithDefaultMimeType(command_line, library_name, 105 return RegisterPluginWithDefaultMimeType(command_line, library_name,
95 FILE_PATH_LITERAL("")); 106 fake_flash_parameter);
96 } 107 }
97 108
98 bool RegisterBlinkTestPlugin(base::CommandLine* command_line) { 109 bool RegisterBlinkTestPlugin(base::CommandLine* command_line) {
99 #if defined(OS_WIN) 110 #if defined(OS_WIN)
100 static const CharType kPluginLibrary[] = L"blink_test_plugin.dll"; 111 static const CharType kPluginLibrary[] = L"blink_test_plugin.dll";
101 static const CharType kDeprecatedPluginLibrary[] = 112 static const CharType kDeprecatedPluginLibrary[] =
102 L"blink_deprecated_test_plugin.dll"; 113 L"blink_deprecated_test_plugin.dll";
103 #elif defined(OS_MACOSX) 114 #elif defined(OS_MACOSX)
104 static const CharType kPluginLibrary[] = "blink_test_plugin.plugin"; 115 static const CharType kPluginLibrary[] = "blink_test_plugin.plugin";
105 static const CharType kDeprecatedPluginLibrary[] = 116 static const CharType kDeprecatedPluginLibrary[] =
(...skipping 14 matching lines...) Expand all
120 FILE_PATH_LITERAL("application/x-blink-test-plugin#blinktestplugin"))); 131 FILE_PATH_LITERAL("application/x-blink-test-plugin#blinktestplugin")));
121 plugins.push_back( 132 plugins.push_back(
122 PluginInfo(kDeprecatedPluginLibrary, kDeprecatedExtraParameters, 133 PluginInfo(kDeprecatedPluginLibrary, kDeprecatedExtraParameters,
123 FILE_PATH_LITERAL("application/" 134 FILE_PATH_LITERAL("application/"
124 "x-blink-deprecated-test-plugin#" 135 "x-blink-deprecated-test-plugin#"
125 "blinkdeprecatedtestplugin"))); 136 "blinkdeprecatedtestplugin")));
126 return RegisterPlugins(command_line, plugins); 137 return RegisterPlugins(command_line, plugins);
127 } 138 }
128 139
129 } // namespace ppapi 140 } // namespace ppapi
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698