Chromiun changes: https://source.chromium.org/chromium/chromium/src/+/f0a92a052a1e3b60ce510650fb7f1120ef6ee9ca commit f0a92a052a1e3b60ce510650fb7f1120ef6ee9ca Author: Lei Zhang <thestig@chromium.org> Date: Fri Oct 23 01:00:51 2020 +0000 Add a form of ExtensionFunction::OneArgument() that takes a base::Value. Instead of taking std::unique_ptr<base::Value>. Mechanically convert many callers from OneArgument(std::make_unique<base::Value>(...)) to OneArgument(base::Value(...)). Bug: 1139221 https://source.chromium.org/chromium/chromium/src/+/71dc58d5aa15ff3a94629d8aa9d0b41c18503ffb commit 71dc58d5aa15ff3a94629d8aa9d0b41c18503ffb Author: Lei Zhang <thestig@chromium.org> Date: Mon Oct 26 18:37:05 2020 +0000 Remove deprecated form of ExtensionFunction::OneArgument(). Use base::Value::FromUniquePtrValue() in many case to get a base::Value. Bug: 1139221
38 lines
1.3 KiB
C++
38 lines
1.3 KiB
C++
/* Copyright (c) 2019 The Brave Authors. All rights reserved.
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
|
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
#include "brave/browser/extensions/api/greaselion_api.h"
|
|
|
|
#include <memory>
|
|
|
|
#include "base/values.h"
|
|
#include "brave/browser/greaselion/greaselion_service_factory.h"
|
|
#include "brave/common/extensions/api/greaselion.h"
|
|
#include "brave/components/greaselion/browser/greaselion_service.h"
|
|
#include "chrome/browser/profiles/profile.h"
|
|
|
|
namespace extensions {
|
|
namespace api {
|
|
|
|
ExtensionFunction::ResponseAction
|
|
GreaselionIsGreaselionExtensionFunction::Run() {
|
|
Profile* profile = Profile::FromBrowserContext(browser_context());
|
|
::greaselion::GreaselionService* greaselion_service =
|
|
::greaselion::GreaselionServiceFactory::GetForBrowserContext(profile);
|
|
if (!greaselion_service) {
|
|
return RespondNow(OneArgument(base::Value(false)));
|
|
}
|
|
|
|
std::unique_ptr<greaselion::IsGreaselionExtension::Params> params(
|
|
greaselion::IsGreaselionExtension::Params::Create(*args_));
|
|
EXTENSION_FUNCTION_VALIDATE(params.get());
|
|
|
|
bool result = greaselion_service->IsGreaselionExtension(params->id);
|
|
return RespondNow(OneArgument(base::Value(result)));
|
|
}
|
|
|
|
} // namespace api
|
|
} // namespace extensions
|