OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "chrome/common/pepper_plugin_registry.h" | 5 #include "chrome/common/pepper_plugin_registry.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
9 #include "base/native_library.h" | 9 #include "base/native_library.h" |
10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 base::NativeLibrary library = base::LoadNativeLibrary(plugins[i].path); | 47 base::NativeLibrary library = base::LoadNativeLibrary(plugins[i].path); |
48 LOG_IF(WARNING, !library) << "Unable to load plugin " | 48 LOG_IF(WARNING, !library) << "Unable to load plugin " |
49 << plugins[i].path.value(); | 49 << plugins[i].path.value(); |
50 } | 50 } |
51 } | 51 } |
52 } | 52 } |
53 | 53 |
54 // static | 54 // static |
55 void PepperPluginRegistry::GetPluginInfoFromSwitch( | 55 void PepperPluginRegistry::GetPluginInfoFromSwitch( |
56 std::vector<PepperPluginInfo>* plugins) { | 56 std::vector<PepperPluginInfo>* plugins) { |
57 const std::wstring& value = CommandLine::ForCurrentProcess()->GetSwitchValue( | 57 const std::string value = |
58 switches::kRegisterPepperPlugins); | 58 CommandLine::ForCurrentProcess()->GetSwitchValueASCII( |
| 59 switches::kRegisterPepperPlugins); |
59 if (value.empty()) | 60 if (value.empty()) |
60 return; | 61 return; |
61 | 62 |
62 // FORMAT: | 63 // FORMAT: |
63 // command-line = <plugin-entry> + *( LWS + "," + LWS + <plugin-entry> ) | 64 // command-line = <plugin-entry> + *( LWS + "," + LWS + <plugin-entry> ) |
64 // plugin-entry = <file-path> + ["#" + <name> + ["#" + <description>]] + | 65 // plugin-entry = <file-path> + ["#" + <name> + ["#" + <description>]] + |
65 // *1( LWS + ";" + LWS + <mime-type> ) | 66 // *1( LWS + ";" + LWS + <mime-type> ) |
66 | 67 |
67 std::vector<std::wstring> modules; | 68 std::vector<std::string> modules; |
68 SplitString(value, ',', &modules); | 69 SplitString(value, ',', &modules); |
69 for (size_t i = 0; i < modules.size(); ++i) { | 70 for (size_t i = 0; i < modules.size(); ++i) { |
70 std::vector<std::wstring> parts; | 71 std::vector<std::string> parts; |
71 SplitString(modules[i], ';', &parts); | 72 SplitString(modules[i], ';', &parts); |
72 if (parts.size() < 2) { | 73 if (parts.size() < 2) { |
73 DLOG(ERROR) << "Required mime-type not found"; | 74 DLOG(ERROR) << "Required mime-type not found"; |
74 continue; | 75 continue; |
75 } | 76 } |
76 | 77 |
77 std::vector<std::wstring> name_parts; | 78 std::vector<std::string> name_parts; |
78 SplitString(parts[0], '#', &name_parts); | 79 SplitString(parts[0], '#', &name_parts); |
79 | 80 |
80 PepperPluginInfo plugin; | 81 PepperPluginInfo plugin; |
81 plugin.path = FilePath::FromWStringHack(name_parts[0]); | 82 #if defined(OS_WIN) |
| 83 // This means we can't provide plugins from non-ASCII paths, but |
| 84 // since this switch is only for development I don't think that's |
| 85 // too awful. |
| 86 plugin.path = FilePath(ASCIIToUTF16(name_parts[0])); |
| 87 #else |
| 88 plugin.path = FilePath(name_parts[0]); |
| 89 #endif |
82 if (name_parts.size() > 1) | 90 if (name_parts.size() > 1) |
83 plugin.name = WideToUTF8(name_parts[1]); | 91 plugin.name = name_parts[1]; |
84 if (name_parts.size() > 2) | 92 if (name_parts.size() > 2) |
85 plugin.type_descriptions = WideToUTF8(name_parts[2]); | 93 plugin.type_descriptions = name_parts[2]; |
86 for (size_t j = 1; j < parts.size(); ++j) | 94 for (size_t j = 1; j < parts.size(); ++j) |
87 plugin.mime_types.push_back(WideToASCII(parts[j])); | 95 plugin.mime_types.push_back(parts[j]); |
88 | 96 |
89 plugins->push_back(plugin); | 97 plugins->push_back(plugin); |
90 } | 98 } |
91 } | 99 } |
92 | 100 |
93 // static | 101 // static |
94 void PepperPluginRegistry::GetExtraPlugins( | 102 void PepperPluginRegistry::GetExtraPlugins( |
95 std::vector<PepperPluginInfo>* plugins) { | 103 std::vector<PepperPluginInfo>* plugins) { |
96 FilePath path; | 104 FilePath path; |
97 // We can't check for path existance here, since we are in the sandbox. | 105 // We can't check for path existance here, since we are in the sandbox. |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 for (size_t i = 0; i < plugins.size(); ++i) { | 186 for (size_t i = 0; i < plugins.size(); ++i) { |
179 const FilePath& path = plugins[i].path; | 187 const FilePath& path = plugins[i].path; |
180 ModuleHandle module = pepper::PluginModule::CreateModule(path); | 188 ModuleHandle module = pepper::PluginModule::CreateModule(path); |
181 if (!module) { | 189 if (!module) { |
182 DLOG(ERROR) << "Failed to load pepper module: " << path.value(); | 190 DLOG(ERROR) << "Failed to load pepper module: " << path.value(); |
183 continue; | 191 continue; |
184 } | 192 } |
185 modules_[path] = module; | 193 modules_[path] = module; |
186 } | 194 } |
187 } | 195 } |
OLD | NEW |