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

Side by Side Diff: chrome/common/plugin_group.cc

Issue 3033050: Rename DictionaryValue's SetStringFromUTF16() to SetString() (and overload). (Closed)
Patch Set: There shouldn't be wstrings in platform-ind. code. Created 10 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 | « chrome/browser/plugin_updater.cc ('k') | chrome/renderer/blocked_plugin.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 "chrome/common/plugin_group.h" 5 #include "chrome/common/plugin_group.h"
6 6
7 #include "base/string_util.h" 7 #include "base/string_util.h"
8 #include "base/utf_string_conversions.h" 8 #include "base/utf_string_conversions.h"
9 #include "base/values.h" 9 #include "base/values.h"
10 #include "base/version.h" 10 #include "base/version.h"
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 Version::GetVersionFromString(version)); 245 Version::GetVersionFromString(version));
246 if (plugin_version.get() != NULL) { 246 if (plugin_version.get() != NULL) {
247 if (plugin_version->CompareTo(*(max_version_)) > 0) { 247 if (plugin_version->CompareTo(*(max_version_)) > 0) {
248 max_version_.reset(plugin_version.release()); 248 max_version_.reset(plugin_version.release());
249 } 249 }
250 } 250 }
251 } 251 }
252 252
253 DictionaryValue* PluginGroup::GetSummary() const { 253 DictionaryValue* PluginGroup::GetSummary() const {
254 DictionaryValue* result = new DictionaryValue(); 254 DictionaryValue* result = new DictionaryValue();
255 result->SetStringFromUTF16(L"name", group_name_); 255 result->SetString("name", group_name_);
256 result->SetBoolean(L"enabled", enabled_); 256 result->SetBoolean("enabled", enabled_);
257 return result; 257 return result;
258 } 258 }
259 259
260 DictionaryValue* PluginGroup::GetDataForUI() const { 260 DictionaryValue* PluginGroup::GetDataForUI() const {
261 DictionaryValue* result = new DictionaryValue(); 261 DictionaryValue* result = new DictionaryValue();
262 result->SetStringFromUTF16(L"name", group_name_); 262 result->SetString("name", group_name_);
263 result->SetStringFromUTF16(L"description", description_); 263 result->SetString("description", description_);
264 result->SetString(L"version", max_version_->GetString()); 264 result->SetString("version", max_version_->GetString());
265 result->SetString(L"update_url", update_url_); 265 result->SetString("update_url", update_url_);
266 result->SetBoolean(L"critical", IsVulnerable()); 266 result->SetBoolean("critical", IsVulnerable());
267 267
268 bool group_disabled_by_policy = IsPluginNameDisabledByPolicy(group_name_); 268 bool group_disabled_by_policy = IsPluginNameDisabledByPolicy(group_name_);
269 if (group_disabled_by_policy) { 269 if (group_disabled_by_policy) {
270 result->SetString(L"enabledMode", L"disabledByPolicy"); 270 result->SetString("enabledMode", "disabledByPolicy");
271 } else { 271 } else {
272 result->SetString(L"enabledMode", 272 result->SetString("enabledMode", enabled_ ? "enabled" : "disabledByUser");
273 enabled_ ? L"enabled" : L"disabledByUser");
274 } 273 }
275 274
276 ListValue* plugin_files = new ListValue(); 275 ListValue* plugin_files = new ListValue();
277 for (size_t i = 0; i < web_plugin_infos_.size(); ++i) { 276 for (size_t i = 0; i < web_plugin_infos_.size(); ++i) {
278 const WebPluginInfo& web_plugin = web_plugin_infos_[i]; 277 const WebPluginInfo& web_plugin = web_plugin_infos_[i];
279 int priority = web_plugin_positions_[i]; 278 int priority = web_plugin_positions_[i];
280 DictionaryValue* plugin_file = new DictionaryValue(); 279 DictionaryValue* plugin_file = new DictionaryValue();
281 plugin_file->SetStringFromUTF16(L"name", web_plugin.name); 280 plugin_file->SetString("name", web_plugin.name);
282 plugin_file->SetStringFromUTF16(L"description", web_plugin.desc); 281 plugin_file->SetString("description", web_plugin.desc);
283 plugin_file->SetString(L"path", web_plugin.path.value()); 282 plugin_file->SetString("path", web_plugin.path.value());
284 plugin_file->SetStringFromUTF16(L"version", web_plugin.version); 283 plugin_file->SetString("version", web_plugin.version);
285 bool plugin_disabled_by_policy = group_disabled_by_policy || 284 bool plugin_disabled_by_policy = group_disabled_by_policy ||
286 IsPluginNameDisabledByPolicy(web_plugin.name); 285 IsPluginNameDisabledByPolicy(web_plugin.name);
287 if (plugin_disabled_by_policy) { 286 if (plugin_disabled_by_policy) {
288 result->SetString(L"enabledMode", L"disabledByPolicy"); 287 result->SetString("enabledMode", "disabledByPolicy");
289 } else { 288 } else {
290 result->SetString(L"enabledMode", 289 result->SetString("enabledMode",
291 web_plugin.enabled ? L"enabled" : L"disabledByUser"); 290 web_plugin.enabled ? "enabled" : "disabledByUser");
292 } 291 }
293 plugin_file->SetInteger(L"priority", priority); 292 plugin_file->SetInteger("priority", priority);
294 293
295 ListValue* mime_types = new ListValue(); 294 ListValue* mime_types = new ListValue();
296 for (std::vector<WebPluginMimeType>::const_iterator type_it = 295 for (std::vector<WebPluginMimeType>::const_iterator type_it =
297 web_plugin.mime_types.begin(); 296 web_plugin.mime_types.begin();
298 type_it != web_plugin.mime_types.end(); 297 type_it != web_plugin.mime_types.end();
299 ++type_it) { 298 ++type_it) {
300 DictionaryValue* mime_type = new DictionaryValue(); 299 DictionaryValue* mime_type = new DictionaryValue();
301 mime_type->SetString(L"mimeType", type_it->mime_type); 300 mime_type->SetString("mimeType", type_it->mime_type);
302 mime_type->SetStringFromUTF16(L"description", type_it->description); 301 mime_type->SetString("description", type_it->description);
303 302
304 ListValue* file_extensions = new ListValue(); 303 ListValue* file_extensions = new ListValue();
305 for (std::vector<std::string>::const_iterator ext_it = 304 for (std::vector<std::string>::const_iterator ext_it =
306 type_it->file_extensions.begin(); 305 type_it->file_extensions.begin();
307 ext_it != type_it->file_extensions.end(); 306 ext_it != type_it->file_extensions.end();
308 ++ext_it) { 307 ++ext_it) {
309 file_extensions->Append(new StringValue(*ext_it)); 308 file_extensions->Append(new StringValue(*ext_it));
310 } 309 }
311 mime_type->Set(L"fileExtensions", file_extensions); 310 mime_type->Set("fileExtensions", file_extensions);
312 311
313 mime_types->Append(mime_type); 312 mime_types->Append(mime_type);
314 } 313 }
315 plugin_file->Set(L"mimeTypes", mime_types); 314 plugin_file->Set("mimeTypes", mime_types);
316 315
317 plugin_files->Append(plugin_file); 316 plugin_files->Append(plugin_file);
318 } 317 }
319 result->Set(L"plugin_files", plugin_files); 318 result->Set("plugin_files", plugin_files);
320 319
321 return result; 320 return result;
322 } 321 }
323 322
324 // Returns true if the latest version of this plugin group is vulnerable. 323 // Returns true if the latest version of this plugin group is vulnerable.
325 bool PluginGroup::IsVulnerable() const { 324 bool PluginGroup::IsVulnerable() const {
326 if (min_version_.get() == NULL || max_version_->GetString() == "0") { 325 if (min_version_.get() == NULL || max_version_->GetString() == "0") {
327 return false; 326 return false;
328 } 327 }
329 return max_version_->CompareTo(*min_version_) < 0; 328 return max_version_->CompareTo(*min_version_) < 0;
330 } 329 }
331 330
332 void PluginGroup::Enable(bool enable) { 331 void PluginGroup::Enable(bool enable) {
333 for (std::vector<WebPluginInfo>::const_iterator it = 332 for (std::vector<WebPluginInfo>::const_iterator it =
334 web_plugin_infos_.begin(); 333 web_plugin_infos_.begin();
335 it != web_plugin_infos_.end(); ++it) { 334 it != web_plugin_infos_.end(); ++it) {
336 if (enable && !IsPluginNameDisabledByPolicy(it->name)) { 335 if (enable && !IsPluginNameDisabledByPolicy(it->name)) {
337 NPAPI::PluginList::Singleton()->EnablePlugin(FilePath(it->path)); 336 NPAPI::PluginList::Singleton()->EnablePlugin(FilePath(it->path));
338 } else { 337 } else {
339 NPAPI::PluginList::Singleton()->DisablePlugin(FilePath(it->path)); 338 NPAPI::PluginList::Singleton()->DisablePlugin(FilePath(it->path));
340 } 339 }
341 } 340 }
342 } 341 }
343 342
OLDNEW
« no previous file with comments | « chrome/browser/plugin_updater.cc ('k') | chrome/renderer/blocked_plugin.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698