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