Commit 325d8a11 authored by treib's avatar treib Committed by Commit bot

WebstorePrivate extension API cleanup, part 1:

Convert webstorePrivate functions from ChromeAsyncExtensionFunction (which is deprecated) to UIThreadExtensionFunction.

Review URL: https://codereview.chromium.org/885443010

Cr-Commit-Position: refs/heads/master@{#315288}
parent 8b92b6ea
......@@ -26,7 +26,7 @@ var tests = [
chrome.webstorePrivate.beginInstallWithManifest3(
{'id': extensionId,'iconUrl': loadFailureUrl, 'manifest': manifest },
callbackFail("Image decode failed", function(result) {
assertEq(result, "icon_error");
assertEq("icon_error", result);
}));
},
......
......@@ -60,6 +60,25 @@ class ArgumentListResponseValue
const char* title_;
};
class ErrorWithArgumentsResponseValue : public ArgumentListResponseValue {
public:
ErrorWithArgumentsResponseValue(const std::string& function_name,
const char* title,
ExtensionFunction* function,
scoped_ptr<base::ListValue> result,
const std::string& error)
: ArgumentListResponseValue(function_name,
title,
function,
result.Pass()) {
function->SetError(error);
}
~ErrorWithArgumentsResponseValue() override {}
bool Apply() override { return false; }
};
class ErrorResponseValue : public ExtensionFunction::ResponseValueObject {
public:
ErrorResponseValue(ExtensionFunction* function, const std::string& error) {
......@@ -331,6 +350,13 @@ ExtensionFunction::ResponseValue ExtensionFunction::Error(
this, ErrorUtils::FormatErrorMessage(format, s1, s2, s3)));
}
ExtensionFunction::ResponseValue ExtensionFunction::ErrorWithArguments(
scoped_ptr<base::ListValue> args,
const std::string& error) {
return ResponseValue(new ErrorWithArgumentsResponseValue(
name(), "ErrorWithArguments", this, args.Pass(), error));
}
ExtensionFunction::ResponseValue ExtensionFunction::BadMessage() {
return ResponseValue(new BadMessageResponseValue(this));
}
......
......@@ -308,6 +308,12 @@ class ExtensionFunction
const std::string& s1,
const std::string& s2,
const std::string& s3);
// Error with a list of arguments |args| to pass to caller. TAKES OWNERSHIP.
// Using this ResponseValue indicates something is wrong with the API.
// It shouldn't be possible to have both an error *and* some arguments.
// Some legacy APIs do rely on it though, like webstorePrivate.
ResponseValue ErrorWithArguments(scoped_ptr<base::ListValue> args,
const std::string& error);
// Bad message. A ResponseValue equivalent to EXTENSION_FUNCTION_VALIDATE(),
// so this will actually kill the renderer and not respond at all.
ResponseValue BadMessage();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment