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

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

Issue 448853002: Move StringToLowerASCII to base namespace (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 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 | Annotate | Revision Log
« no previous file with comments | « content/child/npapi/webplugin_delegate_impl_win.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 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 base::SplitString(file_extensions_str, '|', &file_extensions); 136 base::SplitString(file_extensions_str, '|', &file_extensions);
137 base::SplitString(mime_type_descriptions_str, '|', &descriptions); 137 base::SplitString(mime_type_descriptions_str, '|', &descriptions);
138 138
139 parsed_mime_types->clear(); 139 parsed_mime_types->clear();
140 140
141 if (mime_types.empty()) 141 if (mime_types.empty())
142 return false; 142 return false;
143 143
144 for (size_t i = 0; i < mime_types.size(); ++i) { 144 for (size_t i = 0; i < mime_types.size(); ++i) {
145 WebPluginMimeType mime_type; 145 WebPluginMimeType mime_type;
146 mime_type.mime_type = StringToLowerASCII(mime_types[i]); 146 mime_type.mime_type = base::StringToLowerASCII(mime_types[i]);
147 if (file_extensions.size() > i) 147 if (file_extensions.size() > i)
148 base::SplitString(file_extensions[i], ',', &mime_type.file_extensions); 148 base::SplitString(file_extensions[i], ',', &mime_type.file_extensions);
149 149
150 if (descriptions.size() > i) { 150 if (descriptions.size() > i) {
151 mime_type.description = descriptions[i]; 151 mime_type.description = descriptions[i];
152 152
153 // On Windows, the description likely has a list of file extensions 153 // On Windows, the description likely has a list of file extensions
154 // embedded in it (e.g. "SurfWriter file (*.swr)"). Remove an extension 154 // embedded in it (e.g. "SurfWriter file (*.swr)"). Remove an extension
155 // list from the description if it is present. 155 // list from the description if it is present.
156 size_t ext = mime_type.description.find(base::ASCIIToUTF16("(*")); 156 size_t ext = mime_type.description.find(base::ASCIIToUTF16("(*"));
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 } 306 }
307 307
308 void PluginList::GetPluginInfoArray( 308 void PluginList::GetPluginInfoArray(
309 const GURL& url, 309 const GURL& url,
310 const std::string& mime_type, 310 const std::string& mime_type,
311 bool allow_wildcard, 311 bool allow_wildcard,
312 bool* use_stale, 312 bool* use_stale,
313 bool include_npapi, 313 bool include_npapi,
314 std::vector<WebPluginInfo>* info, 314 std::vector<WebPluginInfo>* info,
315 std::vector<std::string>* actual_mime_types) { 315 std::vector<std::string>* actual_mime_types) {
316 DCHECK(mime_type == StringToLowerASCII(mime_type)); 316 DCHECK(mime_type == base::StringToLowerASCII(mime_type));
317 DCHECK(info); 317 DCHECK(info);
318 318
319 if (!use_stale) 319 if (!use_stale)
320 LoadPlugins(include_npapi); 320 LoadPlugins(include_npapi);
321 base::AutoLock lock(lock_); 321 base::AutoLock lock(lock_);
322 if (use_stale) 322 if (use_stale)
323 *use_stale = (loading_state_ != LOADING_STATE_UP_TO_DATE); 323 *use_stale = (loading_state_ != LOADING_STATE_UP_TO_DATE);
324 info->clear(); 324 info->clear();
325 if (actual_mime_types) 325 if (actual_mime_types)
326 actual_mime_types->clear(); 326 actual_mime_types->clear();
(...skipping 14 matching lines...) Expand all
341 341
342 // Add in plugins by url. 342 // Add in plugins by url.
343 // We do not permit URL-sniff based plug-in MIME type overrides aside from 343 // We do not permit URL-sniff based plug-in MIME type overrides aside from
344 // the case where the "type" was initially missing. 344 // the case where the "type" was initially missing.
345 // We collected stats to determine this approach isn't a major compat issue, 345 // We collected stats to determine this approach isn't a major compat issue,
346 // and we defend against content confusion attacks in various cases, such 346 // and we defend against content confusion attacks in various cases, such
347 // as when the user doesn't have the Flash plug-in enabled. 347 // as when the user doesn't have the Flash plug-in enabled.
348 std::string path = url.path(); 348 std::string path = url.path();
349 std::string::size_type last_dot = path.rfind('.'); 349 std::string::size_type last_dot = path.rfind('.');
350 if (last_dot != std::string::npos && mime_type.empty()) { 350 if (last_dot != std::string::npos && mime_type.empty()) {
351 std::string extension = StringToLowerASCII(std::string(path, last_dot+1)); 351 std::string extension =
352 base::StringToLowerASCII(std::string(path, last_dot+1));
352 std::string actual_mime_type; 353 std::string actual_mime_type;
353 for (size_t i = 0; i < plugins_list_.size(); ++i) { 354 for (size_t i = 0; i < plugins_list_.size(); ++i) {
354 if (SupportsExtension(plugins_list_[i], extension, &actual_mime_type)) { 355 if (SupportsExtension(plugins_list_[i], extension, &actual_mime_type)) {
355 base::FilePath path = plugins_list_[i].path; 356 base::FilePath path = plugins_list_[i].path;
356 if (visited_plugins.insert(path).second) { 357 if (visited_plugins.insert(path).second) {
357 info->push_back(plugins_list_[i]); 358 info->push_back(plugins_list_[i]);
358 if (actual_mime_types) 359 if (actual_mime_types)
359 actual_mime_types->push_back(actual_mime_type); 360 actual_mime_types->push_back(actual_mime_type);
360 } 361 }
361 } 362 }
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
405 plugin_path); 406 plugin_path);
406 if (it != extra_plugin_paths_.end()) 407 if (it != extra_plugin_paths_.end())
407 extra_plugin_paths_.erase(it); 408 extra_plugin_paths_.erase(it);
408 } 409 }
409 410
410 PluginList::~PluginList() { 411 PluginList::~PluginList() {
411 } 412 }
412 413
413 414
414 } // namespace content 415 } // namespace content
OLDNEW
« no previous file with comments | « content/child/npapi/webplugin_delegate_impl_win.cc ('k') | content/common/plugin_list_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698