OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/browser/extensions/extension_management_api.h" | 5 #include "chrome/browser/extensions/extension_management_api.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 } | 94 } |
95 info->Set("icons", icon_list); | 95 info->Set("icons", icon_list); |
96 } | 96 } |
97 | 97 |
98 const std::set<std::string> perms = | 98 const std::set<std::string> perms = |
99 extension.GetActivePermissions()->GetAPIsAsStrings(); | 99 extension.GetActivePermissions()->GetAPIsAsStrings(); |
100 ListValue* permission_list = new ListValue(); | 100 ListValue* permission_list = new ListValue(); |
101 if (!perms.empty()) { | 101 if (!perms.empty()) { |
102 std::set<std::string>::const_iterator perms_iter; | 102 std::set<std::string>::const_iterator perms_iter; |
103 for (perms_iter = perms.begin(); perms_iter != perms.end(); ++perms_iter) { | 103 for (perms_iter = perms.begin(); perms_iter != perms.end(); ++perms_iter) { |
104 StringValue* permission_name = new StringValue(*perms_iter); | 104 StringValue* permission_name = base::StringValue::New(*perms_iter); |
105 permission_list->Append(permission_name); | 105 permission_list->Append(permission_name); |
106 } | 106 } |
107 } | 107 } |
108 info->Set("permissions", permission_list); | 108 info->Set("permissions", permission_list); |
109 | 109 |
110 ListValue* host_permission_list = new ListValue(); | 110 ListValue* host_permission_list = new ListValue(); |
111 if (!extension.is_hosted_app()) { | 111 if (!extension.is_hosted_app()) { |
112 // Skip host permissions for hosted apps. | 112 // Skip host permissions for hosted apps. |
113 const URLPatternSet host_perms = | 113 const URLPatternSet host_perms = |
114 extension.GetActivePermissions()->explicit_hosts(); | 114 extension.GetActivePermissions()->explicit_hosts(); |
115 if (!host_perms.is_empty()) { | 115 if (!host_perms.is_empty()) { |
116 URLPatternSet::const_iterator host_perms_iter; | 116 URLPatternSet::const_iterator host_perms_iter; |
117 for (host_perms_iter = host_perms.begin(); | 117 for (host_perms_iter = host_perms.begin(); |
118 host_perms_iter != host_perms.end(); | 118 host_perms_iter != host_perms.end(); |
119 ++host_perms_iter) { | 119 ++host_perms_iter) { |
120 StringValue* name = new StringValue(host_perms_iter->GetAsString()); | 120 StringValue* name = |
| 121 base::StringValue::New(host_perms_iter->GetAsString()); |
121 host_permission_list->Append(name); | 122 host_permission_list->Append(name); |
122 } | 123 } |
123 } | 124 } |
124 } | 125 } |
125 info->Set("hostPermissions", host_permission_list); | 126 info->Set("hostPermissions", host_permission_list); |
126 | 127 |
127 return info; | 128 return info; |
128 } | 129 } |
129 | 130 |
130 static void AddExtensionInfo(ListValue* list, | 131 static void AddExtensionInfo(ListValue* list, |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
175 if (!extension) { | 176 if (!extension) { |
176 error_ = ExtensionErrorUtils::FormatErrorMessage(kNoExtensionError, | 177 error_ = ExtensionErrorUtils::FormatErrorMessage(kNoExtensionError, |
177 ext_id); | 178 ext_id); |
178 return false; | 179 return false; |
179 } | 180 } |
180 | 181 |
181 ExtensionPermissionMessages warnings = extension->GetPermissionMessages(); | 182 ExtensionPermissionMessages warnings = extension->GetPermissionMessages(); |
182 ListValue* result = new ListValue(); | 183 ListValue* result = new ListValue(); |
183 for (ExtensionPermissionMessages::const_iterator i = warnings.begin(); | 184 for (ExtensionPermissionMessages::const_iterator i = warnings.begin(); |
184 i < warnings.end(); ++i) | 185 i < warnings.end(); ++i) |
185 result->Append(Value::CreateStringValue(i->message())); | 186 result->Append(base::StringValue::New(i->message())); |
186 result_.reset(result); | 187 result_.reset(result); |
187 return true; | 188 return true; |
188 } | 189 } |
189 | 190 |
190 namespace { | 191 namespace { |
191 | 192 |
192 // This class helps GetPermissionWarningsByManifestFunction manage | 193 // This class helps GetPermissionWarningsByManifestFunction manage |
193 // sending manifest JSON strings to the utility process for parsing. | 194 // sending manifest JSON strings to the utility process for parsing. |
194 class SafeManifestJSONParser : public UtilityProcessHost::Client { | 195 class SafeManifestJSONParser : public UtilityProcessHost::Client { |
195 public: | 196 public: |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
301 Extension::STRICT_ERROR_CHECKS, &error_); | 302 Extension::STRICT_ERROR_CHECKS, &error_); |
302 if (!extension.get()) { | 303 if (!extension.get()) { |
303 OnParseFailure(kExtensionCreateError); | 304 OnParseFailure(kExtensionCreateError); |
304 return; | 305 return; |
305 } | 306 } |
306 | 307 |
307 ExtensionPermissionMessages warnings = extension->GetPermissionMessages(); | 308 ExtensionPermissionMessages warnings = extension->GetPermissionMessages(); |
308 ListValue* result = new ListValue(); | 309 ListValue* result = new ListValue(); |
309 for (ExtensionPermissionMessages::const_iterator i = warnings.begin(); | 310 for (ExtensionPermissionMessages::const_iterator i = warnings.begin(); |
310 i < warnings.end(); ++i) | 311 i < warnings.end(); ++i) |
311 result->Append(Value::CreateStringValue(i->message())); | 312 result->Append(base::StringValue::New(i->message())); |
312 result_.reset(result); | 313 result_.reset(result); |
313 SendResponse(true); | 314 SendResponse(true); |
314 | 315 |
315 // Matched with AddRef() in RunImpl(). | 316 // Matched with AddRef() in RunImpl(). |
316 Release(); | 317 Release(); |
317 } | 318 } |
318 | 319 |
319 void GetPermissionWarningsByManifestFunction::OnParseFailure( | 320 void GetPermissionWarningsByManifestFunction::OnParseFailure( |
320 const std::string& error) { | 321 const std::string& error) { |
321 error_ = error; | 322 error_ = error; |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
453 break; | 454 break; |
454 default: | 455 default: |
455 NOTREACHED(); | 456 NOTREACHED(); |
456 return; | 457 return; |
457 } | 458 } |
458 | 459 |
459 ListValue args; | 460 ListValue args; |
460 if (event_name == events::kOnExtensionUninstalled) { | 461 if (event_name == events::kOnExtensionUninstalled) { |
461 const std::string& extension_id = | 462 const std::string& extension_id = |
462 Details<UninstalledExtensionInfo>(details).ptr()->extension_id; | 463 Details<UninstalledExtensionInfo>(details).ptr()->extension_id; |
463 args.Append(Value::CreateStringValue(extension_id)); | 464 args.Append(base::StringValue::New(extension_id)); |
464 } else { | 465 } else { |
465 const Extension* extension = NULL; | 466 const Extension* extension = NULL; |
466 if (event_name == events::kOnExtensionDisabled) { | 467 if (event_name == events::kOnExtensionDisabled) { |
467 extension = Details<UnloadedExtensionInfo>(details)->extension; | 468 extension = Details<UnloadedExtensionInfo>(details)->extension; |
468 } else { | 469 } else { |
469 extension = Details<const Extension>(details).ptr(); | 470 extension = Details<const Extension>(details).ptr(); |
470 } | 471 } |
471 CHECK(extension); | 472 CHECK(extension); |
472 ExtensionService* service = profile->GetExtensionService(); | 473 ExtensionService* service = profile->GetExtensionService(); |
473 bool enabled = service->GetExtensionById(extension->id(), false) != NULL; | 474 bool enabled = service->GetExtensionById(extension->id(), false) != NULL; |
474 args.Append(CreateExtensionInfo(*extension, enabled)); | 475 args.Append(CreateExtensionInfo(*extension, enabled)); |
475 } | 476 } |
476 | 477 |
477 std::string args_json; | 478 std::string args_json; |
478 base::JSONWriter::Write(&args, false /* pretty_print */, &args_json); | 479 base::JSONWriter::Write(&args, false /* pretty_print */, &args_json); |
479 | 480 |
480 profile->GetExtensionEventRouter()->DispatchEventToRenderers( | 481 profile->GetExtensionEventRouter()->DispatchEventToRenderers( |
481 event_name, args_json, NULL, GURL()); | 482 event_name, args_json, NULL, GURL()); |
482 } | 483 } |
OLD | NEW |