Commit 687201f2 authored by Lei Zhang's avatar Lei Zhang Committed by Commit Bot

Change ExtensionFunction::TwoArguments() to take base::Value.

Instead of std::unique_ptr<base::Value>.

Bug: 1139221
Change-Id: Ie28bd486e0eed75cdb4287c3efd778aceac32f13
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2496034Reviewed-by: default avatarDavid Bertoni <dbertoni@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
Cr-Commit-Position: refs/heads/master@{#820863}
parent 735a9e9e
......@@ -814,8 +814,9 @@ FileManagerPrivateInternalGetCrostiniSharedPathsFunction::Run() {
entry->SetBoolean("fileIsDirectory", true);
entries->Append(std::move(entry));
}
return RespondNow(TwoArguments(
std::move(entries), std::make_unique<base::Value>(first_for_session)));
return RespondNow(
TwoArguments(base::Value::FromUniquePtrValue(std::move(entries)),
base::Value(first_for_session)));
}
ExtensionFunction::ResponseAction
......
......@@ -901,6 +901,6 @@ void WallpaperPrivateGetSurpriseMeImageFunction::OnSurpriseMeImageFetched(
extensions::api::wallpaper_private::ImageInfo image_info;
ParseImageInfo(image, &image_info);
Respond(TwoArguments(image_info.ToValue(),
std::make_unique<Value>(next_resume_token)));
Respond(TwoArguments(Value::FromUniquePtrValue(image_info.ToValue()),
Value(next_resume_token)));
}
......@@ -346,8 +346,9 @@ void IdentityGetAuthTokenFunction::CompleteFunctionWithResult(
for (const auto& scope : granted_scopes)
granted_scopes_value->Append(scope);
CompleteAsyncRun(TwoArguments(std::make_unique<base::Value>(access_token),
std::move(granted_scopes_value)));
CompleteAsyncRun(TwoArguments(
base::Value(access_token),
base::Value::FromUniquePtrValue(std::move(granted_scopes_value))));
} else {
CompleteAsyncRun(OneArgument(base::Value(access_token)));
}
......
......@@ -414,11 +414,10 @@ void FeedbackPrivateSendFeedbackFunction::OnAllLogsFetched(
void FeedbackPrivateSendFeedbackFunction::OnCompleted(
api::feedback_private::LandingPageType type,
bool success) {
Respond(TwoArguments(
std::make_unique<base::Value>(feedback_private::ToString(
success ? feedback_private::STATUS_SUCCESS
: feedback_private::STATUS_DELAYED)),
std::make_unique<base::Value>(feedback_private::ToString(type))));
Respond(TwoArguments(base::Value(feedback_private::ToString(
success ? feedback_private::STATUS_SUCCESS
: feedback_private::STATUS_DELAYED)),
base::Value(feedback_private::ToString(type))));
if (!success) {
ExtensionsAPIClient::Get()
->GetFeedbackPrivateDelegate()
......
......@@ -260,8 +260,7 @@ void HidReceiveFunction::OnFinished(
const base::Optional<std::vector<uint8_t>>& buffer) {
if (success) {
DCHECK(buffer);
Respond(TwoArguments(std::make_unique<base::Value>(report_id),
base::Value::ToUniquePtrValue(base::Value(*buffer))));
Respond(TwoArguments(base::Value(report_id), base::Value(*buffer)));
} else {
Respond(Error(kErrorTransfer));
}
......
......@@ -657,8 +657,8 @@ void RuntimeRequestUpdateCheckFunction::CheckComplete(
if (result.success) {
std::unique_ptr<base::DictionaryValue> details(new base::DictionaryValue);
details->SetString("version", result.version);
Respond(TwoArguments(std::make_unique<base::Value>(result.response),
std::move(details)));
Respond(TwoArguments(base::Value(result.response),
base::Value::FromUniquePtrValue(std::move(details))));
} else {
// HMM(kalman): Why does !success not imply Error()?
Respond(OneArgument(base::Value(result.response)));
......
......@@ -536,11 +536,11 @@ ExtensionFunction::ResponseValue ExtensionFunction::OneArgument(
}
ExtensionFunction::ResponseValue ExtensionFunction::TwoArguments(
std::unique_ptr<base::Value> arg1,
std::unique_ptr<base::Value> arg2) {
base::Value arg1,
base::Value arg2) {
base::Value args(base::Value::Type::LIST);
args.Append(base::Value::FromUniquePtrValue(std::move(arg1)));
args.Append(base::Value::FromUniquePtrValue(std::move(arg2)));
args.Append(std::move(arg1));
args.Append(std::move(arg2));
return ResponseValue(new ArgumentListResponseValue(this, std::move(args)));
}
......
......@@ -370,8 +370,7 @@ class ExtensionFunction : public base::RefCountedThreadSafe<
// Success, two arguments |arg1| and |arg2| to pass to caller.
// Note that use of this function may imply you
// should be using the generated Result struct and ArgumentList.
ResponseValue TwoArguments(std::unique_ptr<base::Value> arg1,
std::unique_ptr<base::Value> arg2);
ResponseValue TwoArguments(base::Value arg1, base::Value arg2);
// Success, a list of arguments |results| to pass to caller.
// - a std::unique_ptr<> for convenience, since callers usually get this from
// the result of a Create(...) call on the generated Results struct. For
......
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