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

Side by Side Diff: content/common/plugin_list.cc

Issue 1274123003: Update SplitString calls to new form (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: no media changes Created 5 years, 4 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
« no previous file with comments | « content/common/pepper_plugin_list.cc ('k') | content/common/plugin_list_win.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
OLDNEW
« no previous file with comments | « content/common/pepper_plugin_list.cc ('k') | content/common/plugin_list_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698