OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "webkit/plugins/npapi/plugin_list.h" | 5 #include "webkit/plugins/npapi/plugin_list.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 // Not an internal plugin. | 187 // Not an internal plugin. |
188 *entry_points = NULL; | 188 *entry_points = NULL; |
189 | 189 |
190 return PluginLib::ReadWebPluginInfo(filename, info); | 190 return PluginLib::ReadWebPluginInfo(filename, info); |
191 } | 191 } |
192 | 192 |
193 // static | 193 // static |
194 bool PluginList::ParseMimeTypes( | 194 bool PluginList::ParseMimeTypes( |
195 const std::string& mime_types_str, | 195 const std::string& mime_types_str, |
196 const std::string& file_extensions_str, | 196 const std::string& file_extensions_str, |
197 const string16& mime_type_descriptions_str, | 197 const base::string16& mime_type_descriptions_str, |
198 std::vector<webkit::WebPluginMimeType>* parsed_mime_types) { | 198 std::vector<webkit::WebPluginMimeType>* parsed_mime_types) { |
199 std::vector<std::string> mime_types, file_extensions; | 199 std::vector<std::string> mime_types, file_extensions; |
200 std::vector<string16> descriptions; | 200 std::vector<base::string16> descriptions; |
201 base::SplitString(mime_types_str, '|', &mime_types); | 201 base::SplitString(mime_types_str, '|', &mime_types); |
202 base::SplitString(file_extensions_str, '|', &file_extensions); | 202 base::SplitString(file_extensions_str, '|', &file_extensions); |
203 base::SplitString(mime_type_descriptions_str, '|', &descriptions); | 203 base::SplitString(mime_type_descriptions_str, '|', &descriptions); |
204 | 204 |
205 parsed_mime_types->clear(); | 205 parsed_mime_types->clear(); |
206 | 206 |
207 if (mime_types.empty()) | 207 if (mime_types.empty()) |
208 return false; | 208 return false; |
209 | 209 |
210 for (size_t i = 0; i < mime_types.size(); ++i) { | 210 for (size_t i = 0; i < mime_types.size(); ++i) { |
211 WebPluginMimeType mime_type; | 211 WebPluginMimeType mime_type; |
212 mime_type.mime_type = StringToLowerASCII(mime_types[i]); | 212 mime_type.mime_type = StringToLowerASCII(mime_types[i]); |
213 if (file_extensions.size() > i) | 213 if (file_extensions.size() > i) |
214 base::SplitString(file_extensions[i], ',', &mime_type.file_extensions); | 214 base::SplitString(file_extensions[i], ',', &mime_type.file_extensions); |
215 | 215 |
216 if (descriptions.size() > i) { | 216 if (descriptions.size() > i) { |
217 mime_type.description = descriptions[i]; | 217 mime_type.description = descriptions[i]; |
218 | 218 |
219 // On Windows, the description likely has a list of file extensions | 219 // On Windows, the description likely has a list of file extensions |
220 // embedded in it (e.g. "SurfWriter file (*.swr)"). Remove an extension | 220 // embedded in it (e.g. "SurfWriter file (*.swr)"). Remove an extension |
221 // list from the description if it is present. | 221 // list from the description if it is present. |
222 size_t ext = mime_type.description.find(ASCIIToUTF16("(*")); | 222 size_t ext = mime_type.description.find(ASCIIToUTF16("(*")); |
223 if (ext != string16::npos) { | 223 if (ext != base::string16::npos) { |
224 if (ext > 1 && mime_type.description[ext - 1] == ' ') | 224 if (ext > 1 && mime_type.description[ext - 1] == ' ') |
225 ext--; | 225 ext--; |
226 | 226 |
227 mime_type.description.erase(ext); | 227 mime_type.description.erase(ext); |
228 } | 228 } |
229 } | 229 } |
230 | 230 |
231 parsed_mime_types->push_back(mime_type); | 231 parsed_mime_types->push_back(mime_type); |
232 } | 232 } |
233 | 233 |
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
468 } | 468 } |
469 return false; | 469 return false; |
470 } | 470 } |
471 | 471 |
472 PluginList::~PluginList() { | 472 PluginList::~PluginList() { |
473 } | 473 } |
474 | 474 |
475 | 475 |
476 } // namespace npapi | 476 } // namespace npapi |
477 } // namespace webkit | 477 } // namespace webkit |
OLD | NEW |