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

Side by Side Diff: webkit/glue/plugins/plugin_list.cc

Issue 3750001: base: Move SplitString functions into the base namespace and update the callers. (Closed) Base URL: git://git.chromium.org/chromium.git
Patch Set: brett review, reverted changes in o3d due to it's using an old base revision Created 10 years, 2 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 | « webkit/glue/plugins/plugin_lib_posix.cc ('k') | webkit/glue/plugins/plugin_list_posix.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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 "webkit/glue/plugins/plugin_list.h" 5 #include "webkit/glue/plugins/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 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 // Not an internal plugin. 109 // Not an internal plugin.
110 *entry_points = NULL; 110 *entry_points = NULL;
111 111
112 return PluginLib::ReadWebPluginInfo(filename, info); 112 return PluginLib::ReadWebPluginInfo(filename, info);
113 } 113 }
114 114
115 bool PluginList::CreateWebPluginInfo(const PluginVersionInfo& pvi, 115 bool PluginList::CreateWebPluginInfo(const PluginVersionInfo& pvi,
116 WebPluginInfo* info) { 116 WebPluginInfo* info) {
117 std::vector<std::string> mime_types, file_extensions; 117 std::vector<std::string> mime_types, file_extensions;
118 std::vector<string16> descriptions; 118 std::vector<string16> descriptions;
119 SplitString(WideToUTF8(pvi.mime_types), '|', &mime_types); 119 base::SplitString(WideToUTF8(pvi.mime_types), '|', &mime_types);
120 SplitString(WideToUTF8(pvi.file_extensions), '|', &file_extensions); 120 base::SplitString(WideToUTF8(pvi.file_extensions), '|', &file_extensions);
121 SplitString(WideToUTF16(pvi.type_descriptions), '|', &descriptions); 121 base::SplitString(WideToUTF16(pvi.type_descriptions), '|', &descriptions);
122 122
123 info->mime_types.clear(); 123 info->mime_types.clear();
124 124
125 if (mime_types.empty()) { 125 if (mime_types.empty()) {
126 LOG_IF(ERROR, PluginList::DebugPluginLoading()) 126 LOG_IF(ERROR, PluginList::DebugPluginLoading())
127 << "Plugin " << pvi.product_name << " has no MIME types, skipping"; 127 << "Plugin " << pvi.product_name << " has no MIME types, skipping";
128 return false; 128 return false;
129 } 129 }
130 130
131 info->name = WideToUTF16(pvi.product_name); 131 info->name = WideToUTF16(pvi.product_name);
132 info->desc = WideToUTF16(pvi.file_description); 132 info->desc = WideToUTF16(pvi.file_description);
133 info->version = WideToUTF16(pvi.file_version); 133 info->version = WideToUTF16(pvi.file_version);
134 info->path = pvi.path; 134 info->path = pvi.path;
135 info->enabled = true; 135 info->enabled = true;
136 136
137 for (size_t i = 0; i < mime_types.size(); ++i) { 137 for (size_t i = 0; i < mime_types.size(); ++i) {
138 WebPluginMimeType mime_type; 138 WebPluginMimeType mime_type;
139 mime_type.mime_type = StringToLowerASCII(mime_types[i]); 139 mime_type.mime_type = StringToLowerASCII(mime_types[i]);
140 if (file_extensions.size() > i) 140 if (file_extensions.size() > i)
141 SplitString(file_extensions[i], ',', &mime_type.file_extensions); 141 base::SplitString(file_extensions[i], ',', &mime_type.file_extensions);
142 142
143 if (descriptions.size() > i) { 143 if (descriptions.size() > i) {
144 mime_type.description = descriptions[i]; 144 mime_type.description = descriptions[i];
145 145
146 // On Windows, the description likely has a list of file extensions 146 // On Windows, the description likely has a list of file extensions
147 // embedded in it (e.g. "SurfWriter file (*.swr)"). Remove an extension 147 // embedded in it (e.g. "SurfWriter file (*.swr)"). Remove an extension
148 // list from the description if it is present. 148 // list from the description if it is present.
149 size_t ext = mime_type.description.find(ASCIIToUTF16("(*")); 149 size_t ext = mime_type.description.find(ASCIIToUTF16("(*"));
150 if (ext != string16::npos) { 150 if (ext != string16::npos) {
151 if (ext > 1 && mime_type.description[ext -1] == ' ') 151 if (ext > 1 && mime_type.description[ext -1] == ' ')
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
362 ++it) { 362 ++it) {
363 if (it->enabled) 363 if (it->enabled)
364 plugins->push_back(*it); 364 plugins->push_back(*it);
365 } 365 }
366 } 366 }
367 367
368 void PluginList::GetPluginInfoArray(const GURL& url, 368 void PluginList::GetPluginInfoArray(const GURL& url,
369 const std::string& mime_type, 369 const std::string& mime_type,
370 bool allow_wildcard, 370 bool allow_wildcard,
371 std::vector<WebPluginInfo>* info, 371 std::vector<WebPluginInfo>* info,
372 std::vector<std::string>* actual_mime_types) { 372 std::vector<std::string>* actual_mime_types)
373 {
373 DCHECK(mime_type == StringToLowerASCII(mime_type)); 374 DCHECK(mime_type == StringToLowerASCII(mime_type));
374 DCHECK(info); 375 DCHECK(info);
375 376
376 LoadPlugins(false); 377 LoadPlugins(false);
377 AutoLock lock(lock_); 378 AutoLock lock(lock_);
378 info->clear(); 379 info->clear();
379 if (actual_mime_types) 380 if (actual_mime_types)
380 actual_mime_types->clear(); 381 actual_mime_types->clear();
381 382
382 std::set<FilePath> visited_plugins; 383 std::set<FilePath> visited_plugins;
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
447 bool allow_wildcard, 448 bool allow_wildcard,
448 WebPluginInfo* info, 449 WebPluginInfo* info,
449 std::string* actual_mime_type) { 450 std::string* actual_mime_type) {
450 DCHECK(info); 451 DCHECK(info);
451 std::vector<WebPluginInfo> info_list; 452 std::vector<WebPluginInfo> info_list;
452 453
453 // GetPluginInfoArray has slightly less work to do if we can pass 454 // GetPluginInfoArray has slightly less work to do if we can pass
454 // NULL for the mime type list... 455 // NULL for the mime type list...
455 if (actual_mime_type) { 456 if (actual_mime_type) {
456 std::vector<std::string> mime_type_list; 457 std::vector<std::string> mime_type_list;
457 GetPluginInfoArray(url, mime_type, allow_wildcard, &info_list, &mime_type_li st); 458 GetPluginInfoArray(
459 url, mime_type, allow_wildcard, &info_list, &mime_type_list);
458 if (!info_list.empty()) { 460 if (!info_list.empty()) {
459 *info = info_list[0]; 461 *info = info_list[0];
460 *actual_mime_type = mime_type_list[0]; 462 *actual_mime_type = mime_type_list[0];
461 return true; 463 return true;
462 } 464 }
463 } else { 465 } else {
464 GetPluginInfoArray(url, mime_type, allow_wildcard, &info_list, NULL); 466 GetPluginInfoArray(url, mime_type, allow_wildcard, &info_list, NULL);
465 if (!info_list.empty()) { 467 if (!info_list.empty()) {
466 *info = info_list[0]; 468 *info = info_list[0];
467 return true; 469 return true;
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
612 } 614 }
613 615
614 PluginList::~PluginList() { 616 PluginList::~PluginList() {
615 } 617 }
616 618
617 void PluginList::Shutdown() { 619 void PluginList::Shutdown() {
618 // TODO 620 // TODO
619 } 621 }
620 622
621 } // namespace NPAPI 623 } // namespace NPAPI
OLDNEW
« no previous file with comments | « webkit/glue/plugins/plugin_lib_posix.cc ('k') | webkit/glue/plugins/plugin_list_posix.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698