| 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 "content/common/plugin_list.h" | 5 #include "content/common/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 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 | 123 |
| 124 return PluginList::ReadWebPluginInfo(filename, info); | 124 return PluginList::ReadWebPluginInfo(filename, info); |
| 125 } | 125 } |
| 126 | 126 |
| 127 // static | 127 // static |
| 128 bool PluginList::ParseMimeTypes( | 128 bool PluginList::ParseMimeTypes( |
| 129 const std::string& mime_types_str, | 129 const std::string& mime_types_str, |
| 130 const std::string& file_extensions_str, | 130 const std::string& file_extensions_str, |
| 131 const base::string16& mime_type_descriptions_str, | 131 const base::string16& mime_type_descriptions_str, |
| 132 std::vector<WebPluginMimeType>* parsed_mime_types) { | 132 std::vector<WebPluginMimeType>* parsed_mime_types) { |
| 133 std::vector<std::string> mime_types, file_extensions; | 133 std::vector<std::string> mime_types = base::SplitString( |
| 134 std::vector<base::string16> descriptions; | 134 mime_types_str, "|", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); |
| 135 base::SplitString(mime_types_str, '|', &mime_types); | 135 std::vector<std::string> file_extensions = base::SplitString( |
| 136 base::SplitString(file_extensions_str, '|', &file_extensions); | 136 file_extensions_str, "|", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); |
| 137 base::SplitString(mime_type_descriptions_str, '|', &descriptions); | 137 std::vector<base::string16> descriptions = base::SplitString( |
| 138 mime_type_descriptions_str, base::string16(1, '|'), base::TRIM_WHITESPACE, |
| 139 base::SPLIT_WANT_ALL); |
| 138 | 140 |
| 139 parsed_mime_types->clear(); | 141 parsed_mime_types->clear(); |
| 140 | 142 |
| 141 if (mime_types.empty()) | 143 if (mime_types.empty()) |
| 142 return false; | 144 return false; |
| 143 | 145 |
| 144 for (size_t i = 0; i < mime_types.size(); ++i) { | 146 for (size_t i = 0; i < mime_types.size(); ++i) { |
| 145 WebPluginMimeType mime_type; | 147 WebPluginMimeType mime_type; |
| 146 mime_type.mime_type = base::StringToLowerASCII(mime_types[i]); | 148 mime_type.mime_type = base::StringToLowerASCII(mime_types[i]); |
| 147 if (file_extensions.size() > i) | 149 if (file_extensions.size() > i) { |
| 148 base::SplitString(file_extensions[i], ',', &mime_type.file_extensions); | 150 mime_type.file_extensions = base::SplitString( |
| 151 file_extensions[i], ",", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); |
| 152 } |
| 149 | 153 |
| 150 if (descriptions.size() > i) { | 154 if (descriptions.size() > i) { |
| 151 mime_type.description = descriptions[i]; | 155 mime_type.description = descriptions[i]; |
| 152 | 156 |
| 153 // On Windows, the description likely has a list of file extensions | 157 // On Windows, the description likely has a list of file extensions |
| 154 // embedded in it (e.g. "SurfWriter file (*.swr)"). Remove an extension | 158 // embedded in it (e.g. "SurfWriter file (*.swr)"). Remove an extension |
| 155 // list from the description if it is present. | 159 // list from the description if it is present. |
| 156 size_t ext = mime_type.description.find(base::ASCIIToUTF16("(*")); | 160 size_t ext = mime_type.description.find(base::ASCIIToUTF16("(*")); |
| 157 if (ext != base::string16::npos) { | 161 if (ext != base::string16::npos) { |
| 158 if (ext > 1 && mime_type.description[ext - 1] == ' ') | 162 if (ext > 1 && mime_type.description[ext - 1] == ' ') |
| (...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 406 plugin_path); | 410 plugin_path); |
| 407 if (it != extra_plugin_paths_.end()) | 411 if (it != extra_plugin_paths_.end()) |
| 408 extra_plugin_paths_.erase(it); | 412 extra_plugin_paths_.erase(it); |
| 409 } | 413 } |
| 410 | 414 |
| 411 PluginList::~PluginList() { | 415 PluginList::~PluginList() { |
| 412 } | 416 } |
| 413 | 417 |
| 414 | 418 |
| 415 } // namespace content | 419 } // namespace content |
| OLD | NEW |