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

Side by Side Diff: chrome/browser/extensions/extension_management_api.cc

Issue 10694106: Added support for multiple parameters to Extension API callbacks. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Synced. Created 8 years, 5 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
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 "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 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 155
156 if (extension.location() == Extension::COMPONENT) 156 if (extension.location() == Extension::COMPONENT)
157 continue; // Skip built-in extensions. 157 continue; // Skip built-in extensions.
158 158
159 list->Append(CreateExtensionInfo(extension, service)); 159 list->Append(CreateExtensionInfo(extension, service));
160 } 160 }
161 } 161 }
162 162
163 bool GetAllExtensionsFunction::RunImpl() { 163 bool GetAllExtensionsFunction::RunImpl() {
164 ListValue* result = new ListValue(); 164 ListValue* result = new ListValue();
165 result_.reset(result); 165 SetResult(result);
166 166
167 AddExtensionInfo(result, *service()->extensions(), service()); 167 AddExtensionInfo(result, *service()->extensions(), service());
168 AddExtensionInfo(result, *service()->disabled_extensions(), service()); 168 AddExtensionInfo(result, *service()->disabled_extensions(), service());
169 169
170 return true; 170 return true;
171 } 171 }
172 172
173 bool GetExtensionByIdFunction::RunImpl() { 173 bool GetExtensionByIdFunction::RunImpl() {
174 std::string extension_id; 174 std::string extension_id;
175 EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &extension_id)); 175 EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &extension_id));
176 const Extension* extension = service()->GetExtensionById(extension_id, true); 176 const Extension* extension = service()->GetExtensionById(extension_id, true);
177 if (!extension) { 177 if (!extension) {
178 error_ = ExtensionErrorUtils::FormatErrorMessage(keys::kNoExtensionError, 178 error_ = ExtensionErrorUtils::FormatErrorMessage(keys::kNoExtensionError,
179 extension_id); 179 extension_id);
180 return false; 180 return false;
181 } 181 }
182 DictionaryValue* result = CreateExtensionInfo(*extension, service()); 182 DictionaryValue* result = CreateExtensionInfo(*extension, service());
183 result_.reset(result); 183 SetResult(result);
184 184
185 return true; 185 return true;
186 } 186 }
187 187
188 bool GetPermissionWarningsByIdFunction::RunImpl() { 188 bool GetPermissionWarningsByIdFunction::RunImpl() {
189 std::string ext_id; 189 std::string ext_id;
190 EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &ext_id)); 190 EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &ext_id));
191 191
192 const Extension* extension = service()->GetExtensionById(ext_id, true); 192 const Extension* extension = service()->GetExtensionById(ext_id, true);
193 if (!extension) { 193 if (!extension) {
194 error_ = ExtensionErrorUtils::FormatErrorMessage(keys::kNoExtensionError, 194 error_ = ExtensionErrorUtils::FormatErrorMessage(keys::kNoExtensionError,
195 ext_id); 195 ext_id);
196 return false; 196 return false;
197 } 197 }
198 198
199 PermissionMessages warnings = extension->GetPermissionMessages(); 199 PermissionMessages warnings = extension->GetPermissionMessages();
200 ListValue* result = new ListValue(); 200 ListValue* result = new ListValue();
201 for (PermissionMessages::const_iterator i = warnings.begin(); 201 for (PermissionMessages::const_iterator i = warnings.begin();
202 i < warnings.end(); ++i) 202 i < warnings.end(); ++i)
203 result->Append(Value::CreateStringValue(i->message())); 203 result->Append(Value::CreateStringValue(i->message()));
204 result_.reset(result); 204 SetResult(result);
205 return true; 205 return true;
206 } 206 }
207 207
208 namespace { 208 namespace {
209 209
210 // This class helps GetPermissionWarningsByManifestFunction manage 210 // This class helps GetPermissionWarningsByManifestFunction manage
211 // sending manifest JSON strings to the utility process for parsing. 211 // sending manifest JSON strings to the utility process for parsing.
212 class SafeManifestJSONParser : public UtilityProcessHostClient { 212 class SafeManifestJSONParser : public UtilityProcessHostClient {
213 public: 213 public:
214 SafeManifestJSONParser(GetPermissionWarningsByManifestFunction* client, 214 SafeManifestJSONParser(GetPermissionWarningsByManifestFunction* client,
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
318 if (!extension.get()) { 318 if (!extension.get()) {
319 OnParseFailure(keys::kExtensionCreateError); 319 OnParseFailure(keys::kExtensionCreateError);
320 return; 320 return;
321 } 321 }
322 322
323 PermissionMessages warnings = extension->GetPermissionMessages(); 323 PermissionMessages warnings = extension->GetPermissionMessages();
324 ListValue* result = new ListValue(); 324 ListValue* result = new ListValue();
325 for (PermissionMessages::const_iterator i = warnings.begin(); 325 for (PermissionMessages::const_iterator i = warnings.begin();
326 i < warnings.end(); ++i) 326 i < warnings.end(); ++i)
327 result->Append(Value::CreateStringValue(i->message())); 327 result->Append(Value::CreateStringValue(i->message()));
328 result_.reset(result); 328 SetResult(result);
329 SendResponse(true); 329 SendResponse(true);
330 330
331 // Matched with AddRef() in RunImpl(). 331 // Matched with AddRef() in RunImpl().
332 Release(); 332 Release();
333 } 333 }
334 334
335 void GetPermissionWarningsByManifestFunction::OnParseFailure( 335 void GetPermissionWarningsByManifestFunction::OnParseFailure(
336 const std::string& error) { 336 const std::string& error) {
337 error_ = error; 337 error_ = error;
338 SendResponse(false); 338 SendResponse(false);
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
585 ExtensionService* service = profile->GetExtensionService(); 585 ExtensionService* service = profile->GetExtensionService();
586 args.Append(CreateExtensionInfo(*extension, service)); 586 args.Append(CreateExtensionInfo(*extension, service));
587 } 587 }
588 588
589 std::string args_json; 589 std::string args_json;
590 base::JSONWriter::Write(&args, &args_json); 590 base::JSONWriter::Write(&args, &args_json);
591 591
592 profile->GetExtensionEventRouter()->DispatchEventToRenderers( 592 profile->GetExtensionEventRouter()->DispatchEventToRenderers(
593 event_name, args_json, NULL, GURL(), extensions::EventFilteringInfo()); 593 event_name, args_json, NULL, GURL(), extensions::EventFilteringInfo());
594 } 594 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698