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

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

Issue 2481923002: [WIP] make GURL::path() return a StringPiece (Closed)
Patch Set: thanks asan Created 4 years, 1 month 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
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 <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 10
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 } 229 }
230 } 230 }
231 } 231 }
232 232
233 // Add in plugins by url. 233 // Add in plugins by url.
234 // We do not permit URL-sniff based plugin MIME type overrides aside from 234 // We do not permit URL-sniff based plugin MIME type overrides aside from
235 // the case where the "type" was initially missing. 235 // the case where the "type" was initially missing.
236 // We collected stats to determine this approach isn't a major compat issue, 236 // We collected stats to determine this approach isn't a major compat issue,
237 // and we defend against content confusion attacks in various cases, such 237 // and we defend against content confusion attacks in various cases, such
238 // as when the user doesn't have the Flash plugin enabled. 238 // as when the user doesn't have the Flash plugin enabled.
239 std::string path = url.path(); 239 base::StringPiece path = url.path();
240 std::string::size_type last_dot = path.rfind('.'); 240 std::string::size_type last_dot = path.rfind('.');
241 if (last_dot != std::string::npos && mime_type.empty()) { 241 if (last_dot != std::string::npos && mime_type.empty()) {
242 std::string extension = 242 std::string extension = base::ToLowerASCII(path.substr(last_dot + 1));
243 base::ToLowerASCII(base::StringPiece(path).substr(last_dot + 1));
244 std::string actual_mime_type; 243 std::string actual_mime_type;
245 for (size_t i = 0; i < plugins_list_.size(); ++i) { 244 for (size_t i = 0; i < plugins_list_.size(); ++i) {
246 if (SupportsExtension(plugins_list_[i], extension, &actual_mime_type)) { 245 if (SupportsExtension(plugins_list_[i], extension, &actual_mime_type)) {
247 base::FilePath path = plugins_list_[i].path; 246 base::FilePath path = plugins_list_[i].path;
248 if (visited_plugins.insert(path).second) { 247 if (visited_plugins.insert(path).second) {
249 info->push_back(plugins_list_[i]); 248 info->push_back(plugins_list_[i]);
250 if (actual_mime_types) 249 if (actual_mime_types)
251 actual_mime_types->push_back(actual_mime_type); 250 actual_mime_types->push_back(actual_mime_type);
252 } 251 }
253 } 252 }
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
297 plugin_path); 296 plugin_path);
298 if (it != extra_plugin_paths_.end()) 297 if (it != extra_plugin_paths_.end())
299 extra_plugin_paths_.erase(it); 298 extra_plugin_paths_.erase(it);
300 } 299 }
301 300
302 PluginList::~PluginList() { 301 PluginList::~PluginList() {
303 } 302 }
304 303
305 304
306 } // namespace content 305 } // namespace content
OLDNEW
« no previous file with comments | « content/child/ftp_directory_listing_response_delegate.cc ('k') | content/common/service_worker/service_worker_utils.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698