Commit 098a86a5 authored by Achuith Bhandarkar's avatar Achuith Bhandarkar Committed by Commit Bot

autotest_private: Cleanup.

* Get rid of #define OS_CHROMEOS
* Stop using GetActiveUserProfile.
* Separators between functions
* Remove ctors and DISALLOW_COPY_AND_ASSIGN for conciseness.
* Consistency in declarations.
* Consistency in use of DVLOG
* Match order of functions in header and cc.
* Remove kOnlyAvailableOnChromeOSError

BUG=None
TEST=browser tests, vm_sanity

Change-Id: I0b6900886642479a84c70387c69042c51b9ad5ea
Reviewed-on: https://chromium-review.googlesource.com/1251261Reviewed-by: default avatarSteven Bennetts <stevenjb@chromium.org>
Commit-Queue: Achuith Bhandarkar <achuith@chromium.org>
Cr-Commit-Position: refs/heads/master@{#595597}
parent e186dbf7
......@@ -8,6 +8,11 @@
#include <sstream>
#include <utility>
#include "ash/public/interfaces/ash_message_center_controller.mojom.h"
#include "ash/public/interfaces/constants.mojom.h"
#include "ash/shell.h"
#include "base/base64.h"
#include "base/feature_list.h"
#include "base/lazy_instance.h"
#include "base/metrics/histogram_base.h"
#include "base/metrics/histogram_samples.h"
......@@ -16,27 +21,6 @@
#include "base/strings/string_number_conversions.h"
#include "base/values.h"
#include "build/build_config.h"
#include "chrome/browser/extensions/extension_action_manager.h"
#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/lifetime/application_lifetime.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/common/extensions/api/autotest_private.h"
#include "extensions/browser/extension_function_registry.h"
#include "extensions/browser/extension_registry.h"
#include "extensions/browser/extension_system.h"
#include "extensions/browser/extension_util.h"
#include "extensions/common/manifest_handlers/background_info.h"
#include "extensions/common/manifest_handlers/options_page_info.h"
#include "extensions/common/permissions/api_permission_set.h"
#include "extensions/common/permissions/permission_set.h"
#include "extensions/common/permissions/permissions_data.h"
#if defined(OS_CHROMEOS)
#include "ash/public/interfaces/ash_message_center_controller.mojom.h"
#include "ash/public/interfaces/constants.mojom.h"
#include "ash/shell.h"
#include "base/base64.h"
#include "base/feature_list.h"
#include "chrome/browser/chromeos/arc/arc_util.h"
#include "chrome/browser/chromeos/crostini/crostini_manager.h"
#include "chrome/browser/chromeos/crostini/crostini_pref_names.h"
......@@ -44,12 +28,17 @@
#include "chrome/browser/chromeos/login/lock/screen_locker.h"
#include "chrome/browser/chromeos/printing/cups_printers_manager.h"
#include "chrome/browser/chromeos/system/input_device_settings.h"
#include "chrome/browser/extensions/extension_action_manager.h"
#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/lifetime/application_lifetime.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h"
#include "chrome/browser/ui/ash/login_screen_client.h"
#include "chrome/browser/ui/views/crostini/crostini_installer_view.h"
#include "chrome/browser/ui/views/crostini/crostini_uninstaller_view.h"
#include "chrome/common/chrome_features.h"
#include "chrome/common/extensions/api/autotest_private.h"
#include "chromeos/dbus/dbus_thread_manager.h"
#include "chromeos/dbus/session_manager_client.h"
#include "chromeos/printing/printer_configuration.h"
......@@ -57,17 +46,32 @@
#include "components/arc/arc_prefs.h"
#include "components/user_manager/user_manager.h"
#include "content/public/common/service_manager_connection.h"
#include "extensions/browser/extension_function_registry.h"
#include "extensions/browser/extension_registry.h"
#include "extensions/browser/extension_system.h"
#include "extensions/browser/extension_util.h"
#include "extensions/common/manifest_handlers/background_info.h"
#include "extensions/common/manifest_handlers/options_page_info.h"
#include "extensions/common/permissions/api_permission_set.h"
#include "extensions/common/permissions/permission_set.h"
#include "extensions/common/permissions/permissions_data.h"
#include "mojo/public/cpp/bindings/associated_binding.h"
#include "net/base/filename_util.h"
#include "services/service_manager/public/cpp/connector.h"
#include "ui/base/ui_base_features.h"
#include "ui/display/screen.h"
#include "ui/message_center/public/cpp/notification.h"
#endif
namespace extensions {
namespace {
constexpr char kCrostiniNotAvailableForCurrentUserError[] =
"Crostini is not available for the current user";
int AccessArray(const volatile int arr[], const volatile int* index) {
return arr[*index];
}
std::unique_ptr<base::ListValue> GetHostPermissions(const Extension* ext,
bool effective_perm) {
const PermissionsData* permissions_data = ext->permissions_data();
......@@ -99,7 +103,6 @@ bool IsTestMode(content::BrowserContext* context) {
return AutotestPrivateAPI::GetFactoryInstance()->Get(context)->test_mode();
}
#if defined(OS_CHROMEOS)
std::string ConvertToString(message_center::NotificationType type) {
switch (type) {
case message_center::NOTIFICATION_TYPE_SIMPLE:
......@@ -130,17 +133,27 @@ std::unique_ptr<base::DictionaryValue> MakeDictionaryFromNotification(
return result;
}
constexpr char kCrostiniNotAvailableForCurrentUserError[] =
"Crostini is not available for the current user";
#else
constexpr char kOnlyAvailableOnChromeOSError[] = "Only available on ChromeOS";
#endif
std::string GetPrinterType(chromeos::CupsPrintersManager::PrinterClass type) {
switch (type) {
case chromeos::CupsPrintersManager::PrinterClass::kConfigured:
return "configured";
case chromeos::CupsPrintersManager::PrinterClass::kEnterprise:
return "enterprise";
case chromeos::CupsPrintersManager::PrinterClass::kAutomatic:
return "automatic";
case chromeos::CupsPrintersManager::PrinterClass::kDiscovered:
return "discovered";
default:
return "unknown";
}
}
} // namespace
///////////////////////////////////////////////////////////////////////////////
// AutotestPrivateLogoutFunction
///////////////////////////////////////////////////////////////////////////////
AutotestPrivateLogoutFunction::~AutotestPrivateLogoutFunction() = default;
ExtensionFunction::ResponseAction AutotestPrivateLogoutFunction::Run() {
......@@ -150,6 +163,10 @@ ExtensionFunction::ResponseAction AutotestPrivateLogoutFunction::Run() {
return RespondNow(NoArguments());
}
///////////////////////////////////////////////////////////////////////////////
// AutotestPrivateRestartFunction
///////////////////////////////////////////////////////////////////////////////
AutotestPrivateRestartFunction::~AutotestPrivateRestartFunction() = default;
ExtensionFunction::ResponseAction AutotestPrivateRestartFunction::Run() {
......@@ -159,13 +176,16 @@ ExtensionFunction::ResponseAction AutotestPrivateRestartFunction::Run() {
return RespondNow(NoArguments());
}
///////////////////////////////////////////////////////////////////////////////
// AutotestPrivateShutdownFunction
///////////////////////////////////////////////////////////////////////////////
AutotestPrivateShutdownFunction::~AutotestPrivateShutdownFunction() = default;
ExtensionFunction::ResponseAction AutotestPrivateShutdownFunction::Run() {
std::unique_ptr<api::autotest_private::Shutdown::Params> params(
api::autotest_private::Shutdown::Params::Create(*args_));
EXTENSION_FUNCTION_VALIDATE(params.get());
DVLOG(1) << "AutotestPrivateShutdownFunction " << params->force;
if (!IsTestMode(browser_context()))
......@@ -173,22 +193,21 @@ ExtensionFunction::ResponseAction AutotestPrivateShutdownFunction::Run() {
return RespondNow(NoArguments());
}
///////////////////////////////////////////////////////////////////////////////
// AutotestPrivateLoginStatusFunction
///////////////////////////////////////////////////////////////////////////////
AutotestPrivateLoginStatusFunction::~AutotestPrivateLoginStatusFunction() =
default;
ExtensionFunction::ResponseAction AutotestPrivateLoginStatusFunction::Run() {
DVLOG(1) << "AutotestPrivateLoginStatusFunction";
#if defined(OS_CHROMEOS)
LoginScreenClient::Get()->login_screen()->IsReadyForPassword(base::BindOnce(
&AutotestPrivateLoginStatusFunction::OnIsReadyForPassword, this));
return RespondLater();
#else
return RespondNow(OneArgument(std::make_unique<base::DictionaryValue>()));
#endif
}
#if defined(OS_CHROMEOS)
void AutotestPrivateLoginStatusFunction::OnIsReadyForPassword(bool is_ready) {
auto result = std::make_unique<base::DictionaryValue>();
const user_manager::UserManager* user_manager =
......@@ -234,21 +253,27 @@ void AutotestPrivateLoginStatusFunction::OnIsReadyForPassword(bool is_ready) {
}
Respond(OneArgument(std::move(result)));
}
#endif
///////////////////////////////////////////////////////////////////////////////
// AutotestPrivateLockScreenFunction
///////////////////////////////////////////////////////////////////////////////
AutotestPrivateLockScreenFunction::~AutotestPrivateLockScreenFunction() =
default;
ExtensionFunction::ResponseAction AutotestPrivateLockScreenFunction::Run() {
DVLOG(1) << "AutotestPrivateLockScreenFunction";
#if defined(OS_CHROMEOS)
chromeos::DBusThreadManager::Get()
->GetSessionManagerClient()
->RequestLockScreen();
#endif
return RespondNow(NoArguments());
}
///////////////////////////////////////////////////////////////////////////////
// AutotestPrivateGetExtensionsInfoFunction
///////////////////////////////////////////////////////////////////////////////
AutotestPrivateGetExtensionsInfoFunction::
~AutotestPrivateGetExtensionsInfoFunction() = default;
......@@ -311,9 +336,9 @@ AutotestPrivateGetExtensionsInfoFunction::Run() {
return RespondNow(OneArgument(std::move(return_value)));
}
static int AccessArray(const volatile int arr[], const volatile int* index) {
return arr[*index];
}
///////////////////////////////////////////////////////////////////////////////
// AutotestPrivateSimulateAsanMemoryBugFunction
///////////////////////////////////////////////////////////////////////////////
AutotestPrivateSimulateAsanMemoryBugFunction::
~AutotestPrivateSimulateAsanMemoryBugFunction() = default;
......@@ -321,6 +346,7 @@ AutotestPrivateSimulateAsanMemoryBugFunction::
ExtensionFunction::ResponseAction
AutotestPrivateSimulateAsanMemoryBugFunction::Run() {
DVLOG(1) << "AutotestPrivateSimulateAsanMemoryBugFunction";
if (!IsTestMode(browser_context())) {
// This array is volatile not to let compiler optimize us out.
volatile int testarray[3] = {0, 0, 0};
......@@ -332,6 +358,10 @@ AutotestPrivateSimulateAsanMemoryBugFunction::Run() {
return RespondNow(NoArguments());
}
///////////////////////////////////////////////////////////////////////////////
// AutotestPrivateSetTouchpadSensitivityFunction
///////////////////////////////////////////////////////////////////////////////
AutotestPrivateSetTouchpadSensitivityFunction::
~AutotestPrivateSetTouchpadSensitivityFunction() = default;
......@@ -340,16 +370,17 @@ AutotestPrivateSetTouchpadSensitivityFunction::Run() {
std::unique_ptr<api::autotest_private::SetTouchpadSensitivity::Params> params(
api::autotest_private::SetTouchpadSensitivity::Params::Create(*args_));
EXTENSION_FUNCTION_VALIDATE(params.get());
DVLOG(1) << "AutotestPrivateSetTouchpadSensitivityFunction " << params->value;
#if defined(OS_CHROMEOS)
chromeos::system::InputDeviceSettings::Get()->SetTouchpadSensitivity(
params->value);
#endif
return RespondNow(NoArguments());
}
///////////////////////////////////////////////////////////////////////////////
// AutotestPrivateSetTapToClickFunction
///////////////////////////////////////////////////////////////////////////////
AutotestPrivateSetTapToClickFunction::~AutotestPrivateSetTapToClickFunction() =
default;
......@@ -357,15 +388,16 @@ ExtensionFunction::ResponseAction AutotestPrivateSetTapToClickFunction::Run() {
std::unique_ptr<api::autotest_private::SetTapToClick::Params> params(
api::autotest_private::SetTapToClick::Params::Create(*args_));
EXTENSION_FUNCTION_VALIDATE(params.get());
DVLOG(1) << "AutotestPrivateSetTapToClickFunction " << params->enabled;
#if defined(OS_CHROMEOS)
chromeos::system::InputDeviceSettings::Get()->SetTapToClick(params->enabled);
#endif
return RespondNow(NoArguments());
}
///////////////////////////////////////////////////////////////////////////////
// AutotestPrivateSetThreeFingerClickFunction
///////////////////////////////////////////////////////////////////////////////
AutotestPrivateSetThreeFingerClickFunction::
~AutotestPrivateSetThreeFingerClickFunction() = default;
......@@ -374,16 +406,17 @@ AutotestPrivateSetThreeFingerClickFunction::Run() {
std::unique_ptr<api::autotest_private::SetThreeFingerClick::Params> params(
api::autotest_private::SetThreeFingerClick::Params::Create(*args_));
EXTENSION_FUNCTION_VALIDATE(params.get());
DVLOG(1) << "AutotestPrivateSetThreeFingerClickFunction " << params->enabled;
#if defined(OS_CHROMEOS)
chromeos::system::InputDeviceSettings::Get()->SetThreeFingerClick(
params->enabled);
#endif
return RespondNow(NoArguments());
}
///////////////////////////////////////////////////////////////////////////////
// AutotestPrivateSetTapDraggingFunction
///////////////////////////////////////////////////////////////////////////////
AutotestPrivateSetTapDraggingFunction::
~AutotestPrivateSetTapDraggingFunction() = default;
......@@ -391,15 +424,16 @@ ExtensionFunction::ResponseAction AutotestPrivateSetTapDraggingFunction::Run() {
std::unique_ptr<api::autotest_private::SetTapDragging::Params> params(
api::autotest_private::SetTapDragging::Params::Create(*args_));
EXTENSION_FUNCTION_VALIDATE(params.get());
DVLOG(1) << "AutotestPrivateSetTapDraggingFunction " << params->enabled;
#if defined(OS_CHROMEOS)
chromeos::system::InputDeviceSettings::Get()->SetTapDragging(params->enabled);
#endif
return RespondNow(NoArguments());
}
///////////////////////////////////////////////////////////////////////////////
// AutotestPrivateSetNaturalScrollFunction
///////////////////////////////////////////////////////////////////////////////
AutotestPrivateSetNaturalScrollFunction::
~AutotestPrivateSetNaturalScrollFunction() = default;
......@@ -408,16 +442,17 @@ AutotestPrivateSetNaturalScrollFunction::Run() {
std::unique_ptr<api::autotest_private::SetNaturalScroll::Params> params(
api::autotest_private::SetNaturalScroll::Params::Create(*args_));
EXTENSION_FUNCTION_VALIDATE(params.get());
DVLOG(1) << "AutotestPrivateSetNaturalScrollFunction " << params->enabled;
#if defined(OS_CHROMEOS)
chromeos::system::InputDeviceSettings::Get()->SetNaturalScroll(
params->enabled);
#endif
return RespondNow(NoArguments());
}
///////////////////////////////////////////////////////////////////////////////
// AutotestPrivateSetMouseSensitivityFunction
///////////////////////////////////////////////////////////////////////////////
AutotestPrivateSetMouseSensitivityFunction::
~AutotestPrivateSetMouseSensitivityFunction() = default;
......@@ -426,16 +461,17 @@ AutotestPrivateSetMouseSensitivityFunction::Run() {
std::unique_ptr<api::autotest_private::SetMouseSensitivity::Params> params(
api::autotest_private::SetMouseSensitivity::Params::Create(*args_));
EXTENSION_FUNCTION_VALIDATE(params.get());
DVLOG(1) << "AutotestPrivateSetMouseSensitivityFunction " << params->value;
#if defined(OS_CHROMEOS)
chromeos::system::InputDeviceSettings::Get()->SetMouseSensitivity(
params->value);
#endif
return RespondNow(NoArguments());
}
///////////////////////////////////////////////////////////////////////////////
// AutotestPrivateSetPrimaryButtonRightFunction
///////////////////////////////////////////////////////////////////////////////
AutotestPrivateSetPrimaryButtonRightFunction::
~AutotestPrivateSetPrimaryButtonRightFunction() = default;
......@@ -444,16 +480,17 @@ AutotestPrivateSetPrimaryButtonRightFunction::Run() {
std::unique_ptr<api::autotest_private::SetPrimaryButtonRight::Params> params(
api::autotest_private::SetPrimaryButtonRight::Params::Create(*args_));
EXTENSION_FUNCTION_VALIDATE(params.get());
DVLOG(1) << "AutotestPrivateSetPrimaryButtonRightFunction " << params->right;
#if defined(OS_CHROMEOS)
chromeos::system::InputDeviceSettings::Get()->SetPrimaryButtonRight(
params->right);
#endif
return RespondNow(NoArguments());
}
///////////////////////////////////////////////////////////////////////////////
// AutotestPrivateSetMouseReverseScrollFunction
///////////////////////////////////////////////////////////////////////////////
AutotestPrivateSetMouseReverseScrollFunction::
~AutotestPrivateSetMouseReverseScrollFunction() = default;
......@@ -462,17 +499,18 @@ AutotestPrivateSetMouseReverseScrollFunction::Run() {
std::unique_ptr<api::autotest_private::SetMouseReverseScroll::Params> params(
api::autotest_private::SetMouseReverseScroll::Params::Create(*args_));
EXTENSION_FUNCTION_VALIDATE(params.get());
DVLOG(1) << "AutotestPrivateSetMouseReverseScrollFunction "
<< params->enabled;
#if defined(OS_CHROMEOS)
chromeos::system::InputDeviceSettings::Get()->SetMouseReverseScroll(
params->enabled);
#endif
return RespondNow(NoArguments());
}
///////////////////////////////////////////////////////////////////////////////
// AutotestPrivateGetVisibleNotificationsFunction
///////////////////////////////////////////////////////////////////////////////
AutotestPrivateGetVisibleNotificationsFunction::
AutotestPrivateGetVisibleNotificationsFunction() = default;
AutotestPrivateGetVisibleNotificationsFunction::
......@@ -481,7 +519,7 @@ AutotestPrivateGetVisibleNotificationsFunction::
ExtensionFunction::ResponseAction
AutotestPrivateGetVisibleNotificationsFunction::Run() {
DVLOG(1) << "AutotestPrivateGetVisibleNotificationsFunction";
#if defined(OS_CHROMEOS)
auto* connection = content::ServiceManagerConnection::GetForProcess();
connection->GetConnector()->BindInterface(ash::mojom::kServiceName,
&controller_);
......@@ -489,12 +527,8 @@ AutotestPrivateGetVisibleNotificationsFunction::Run() {
&AutotestPrivateGetVisibleNotificationsFunction::OnGotNotifications,
this));
return RespondLater();
#else
return RespondNow(OneArgument(std::make_unique<base::ListValue>()));
#endif
}
#if defined(OS_CHROMEOS)
void AutotestPrivateGetVisibleNotificationsFunction::OnGotNotifications(
const std::vector<message_center::Notification>& notifications) {
auto values = std::make_unique<base::ListValue>();
......@@ -504,109 +538,9 @@ void AutotestPrivateGetVisibleNotificationsFunction::OnGotNotifications(
Respond(OneArgument(std::move(values)));
}
// static
std::string AutotestPrivateGetPrinterListFunction::GetPrinterType(
chromeos::CupsPrintersManager::PrinterClass type) {
switch (type) {
case chromeos::CupsPrintersManager::PrinterClass::kConfigured:
return "configured";
case chromeos::CupsPrintersManager::PrinterClass::kEnterprise:
return "enterprise";
case chromeos::CupsPrintersManager::PrinterClass::kAutomatic:
return "automatic";
case chromeos::CupsPrintersManager::PrinterClass::kDiscovered:
return "discovered";
default:
return "unknown";
}
}
#endif
AutotestPrivateGetPrinterListFunction::
~AutotestPrivateGetPrinterListFunction() = default;
ExtensionFunction::ResponseAction AutotestPrivateGetPrinterListFunction::Run() {
DVLOG(1) << "AutotestPrivateGetPrinterListFunction";
auto values = std::make_unique<base::ListValue>();
#if defined(OS_CHROMEOS)
Profile* profile = ProfileManager::GetActiveUserProfile();
std::unique_ptr<chromeos::CupsPrintersManager> printers_manager =
chromeos::CupsPrintersManager::Create(profile);
std::vector<chromeos::CupsPrintersManager::PrinterClass> printer_type = {
chromeos::CupsPrintersManager::PrinterClass::kConfigured,
chromeos::CupsPrintersManager::PrinterClass::kEnterprise,
chromeos::CupsPrintersManager::PrinterClass::kAutomatic};
for (const auto& type : printer_type) {
std::vector<chromeos::Printer> printer_list =
printers_manager->GetPrinters(type);
for (const auto& printer : printer_list) {
auto result = std::make_unique<base::DictionaryValue>();
result->SetString("printerName", printer.display_name());
result->SetString("printerId", printer.id());
result->SetString("printerType", GetPrinterType(type));
values->Append(std::move(result));
}
}
#endif
return RespondNow(OneArgument(std::move(values)));
}
AutotestPrivateUpdatePrinterFunction::AutotestPrivateUpdatePrinterFunction() =
default;
AutotestPrivateUpdatePrinterFunction::~AutotestPrivateUpdatePrinterFunction() =
default;
ExtensionFunction::ResponseAction AutotestPrivateUpdatePrinterFunction::Run() {
std::unique_ptr<api::autotest_private::UpdatePrinter::Params> params(
api::autotest_private::UpdatePrinter::Params::Create(*args_));
EXTENSION_FUNCTION_VALIDATE(params);
DVLOG(1) << "AutotestPrivateUpdatePrinterFunction";
#if defined(OS_CHROMEOS)
const api::autotest_private::Printer& js_printer = params->printer;
chromeos::Printer printer(js_printer.printer_id ? *js_printer.printer_id
: "");
printer.set_display_name(js_printer.printer_name);
if (js_printer.printer_desc)
printer.set_description(*js_printer.printer_desc);
if (js_printer.printer_make_and_model)
printer.set_make_and_model(*js_printer.printer_make_and_model);
if (js_printer.printer_uri)
printer.set_uri(*js_printer.printer_uri);
if (js_printer.printer_ppd) {
const GURL ppd =
net::FilePathToFileURL(base::FilePath(*js_printer.printer_ppd));
if (ppd.is_valid())
printer.mutable_ppd_reference()->user_supplied_ppd_url = ppd.spec();
else
LOG(ERROR) << "Invalid ppd path: " << *js_printer.printer_ppd;
}
auto printers_manager = chromeos::CupsPrintersManager::Create(
ProfileManager::GetActiveUserProfile());
printers_manager->UpdateConfiguredPrinter(printer);
#endif
return RespondNow(NoArguments());
}
AutotestPrivateRemovePrinterFunction::AutotestPrivateRemovePrinterFunction() =
default;
AutotestPrivateRemovePrinterFunction::~AutotestPrivateRemovePrinterFunction() =
default;
ExtensionFunction::ResponseAction AutotestPrivateRemovePrinterFunction::Run() {
std::unique_ptr<api::autotest_private::RemovePrinter::Params> params(
api::autotest_private::RemovePrinter::Params::Create(*args_));
EXTENSION_FUNCTION_VALIDATE(params);
DVLOG(1) << "AutotestPrivateRemovePrinterFunction";
#if defined(OS_CHROMEOS)
auto printers_manager = chromeos::CupsPrintersManager::Create(
ProfileManager::GetActiveUserProfile());
printers_manager->RemoveConfiguredPrinter(params->printer_id);
#endif
return RespondNow(NoArguments());
}
///////////////////////////////////////////////////////////////////////////////
// AutotestPrivateGetPlayStoreStateFunction
///////////////////////////////////////////////////////////////////////////////
AutotestPrivateGetPlayStoreStateFunction::
~AutotestPrivateGetPlayStoreStateFunction() = default;
......@@ -614,10 +548,10 @@ AutotestPrivateGetPlayStoreStateFunction::
ExtensionFunction::ResponseAction
AutotestPrivateGetPlayStoreStateFunction::Run() {
DVLOG(1) << "AutotestPrivateGetPlayStoreStateFunction";
api::autotest_private::PlayStoreState play_store_state;
play_store_state.allowed = false;
#if defined(OS_CHROMEOS)
Profile* profile = ProfileManager::GetActiveUserProfile();
Profile* profile = Profile::FromBrowserContext(browser_context());
if (arc::IsArcAllowedForProfile(profile)) {
play_store_state.allowed = true;
play_store_state.enabled =
......@@ -625,21 +559,24 @@ AutotestPrivateGetPlayStoreStateFunction::Run() {
play_store_state.managed = std::make_unique<bool>(
arc::IsArcPlayStoreEnabledPreferenceManagedForProfile(profile));
}
#endif
return RespondNow(OneArgument(play_store_state.ToValue()));
}
///////////////////////////////////////////////////////////////////////////////
// AutotestPrivateSetPlayStoreEnabledFunction
///////////////////////////////////////////////////////////////////////////////
AutotestPrivateSetPlayStoreEnabledFunction::
~AutotestPrivateSetPlayStoreEnabledFunction() = default;
ExtensionFunction::ResponseAction
AutotestPrivateSetPlayStoreEnabledFunction::Run() {
DVLOG(1) << "AutotestPrivateSetPlayStoreEnabledFunction";
#if defined(OS_CHROMEOS)
std::unique_ptr<api::autotest_private::SetPlayStoreEnabled::Params> params(
api::autotest_private::SetPlayStoreEnabled::Params::Create(*args_));
EXTENSION_FUNCTION_VALIDATE(params);
Profile* profile = ProfileManager::GetActiveUserProfile();
DVLOG(1) << "AutotestPrivateSetPlayStoreEnabledFunction " << params->enabled;
Profile* profile = Profile::FromBrowserContext(browser_context());
if (arc::IsArcAllowedForProfile(profile)) {
if (!arc::SetArcPlayStoreEnabledForProfile(profile, params->enabled)) {
return RespondNow(
......@@ -651,19 +588,20 @@ AutotestPrivateSetPlayStoreEnabledFunction::Run() {
} else {
return RespondNow(Error("ARC is not available for the current user"));
}
#else
return RespondNow(Error(kOnlyAvailableOnChromeOSError));
#endif
}
///////////////////////////////////////////////////////////////////////////////
// AutotestPrivateGetHistogramFunction
///////////////////////////////////////////////////////////////////////////////
AutotestPrivateGetHistogramFunction::~AutotestPrivateGetHistogramFunction() =
default;
ExtensionFunction::ResponseAction AutotestPrivateGetHistogramFunction::Run() {
DVLOG(1) << "AutotestPrivateGetHistogramFunction";
std::unique_ptr<api::autotest_private::GetHistogram::Params> params(
api::autotest_private::GetHistogram::Params::Create(*args_));
EXTENSION_FUNCTION_VALIDATE(params);
DVLOG(1) << "AutotestPrivateGetHistogramFunction " << params->name;
const base::HistogramBase* histogram =
base::StatisticsRecorder::FindHistogram(params->name);
......@@ -693,15 +631,19 @@ ExtensionFunction::ResponseAction AutotestPrivateGetHistogramFunction::Run() {
return RespondNow(OneArgument(result.ToValue()));
}
///////////////////////////////////////////////////////////////////////////////
// AutotestPrivateIsAppShownFunction
///////////////////////////////////////////////////////////////////////////////
AutotestPrivateIsAppShownFunction::~AutotestPrivateIsAppShownFunction() =
default;
ExtensionFunction::ResponseAction AutotestPrivateIsAppShownFunction::Run() {
DVLOG(1) << "AutotestPrivateIsAppShownFunction";
#if defined(OS_CHROMEOS)
std::unique_ptr<api::autotest_private::IsAppShown::Params> params(
api::autotest_private::IsAppShown::Params::Create(*args_));
EXTENSION_FUNCTION_VALIDATE(params);
DVLOG(1) << "AutotestPrivateIsAppShownFunction " << params->app_id;
ChromeLauncherController* const controller =
ChromeLauncherController::instance();
if (!controller)
......@@ -713,19 +655,20 @@ ExtensionFunction::ResponseAction AutotestPrivateIsAppShownFunction::Run() {
item && item->status == ash::ShelfItemStatus::STATUS_RUNNING;
return RespondNow(
OneArgument(std::make_unique<base::Value>(window_attached)));
#else
return RespondNow(Error(kOnlyAvailableOnChromeOSError));
#endif
}
///////////////////////////////////////////////////////////////////////////////
// AutotestPrivateLaunchAppFunction
///////////////////////////////////////////////////////////////////////////////
AutotestPrivateLaunchAppFunction::~AutotestPrivateLaunchAppFunction() = default;
ExtensionFunction::ResponseAction AutotestPrivateLaunchAppFunction::Run() {
DVLOG(1) << "AutotestPrivateLaunchAppFunction";
#if defined(OS_CHROMEOS)
std::unique_ptr<api::autotest_private::LaunchApp::Params> params(
api::autotest_private::LaunchApp::Params::Create(*args_));
EXTENSION_FUNCTION_VALIDATE(params);
DVLOG(1) << "AutotestPrivateLaunchAppFunction " << params->app_id;
ChromeLauncherController* const controller =
ChromeLauncherController::instance();
if (!controller)
......@@ -735,21 +678,22 @@ ExtensionFunction::ResponseAction AutotestPrivateLaunchAppFunction::Run() {
0, /* event_flags */
display::Screen::GetScreen()->GetPrimaryDisplay().id());
return RespondNow(NoArguments());
#else
return RespondNow(Error(kOnlyAvailableOnChromeOSError));
#endif
}
///////////////////////////////////////////////////////////////////////////////
// AutotestPrivateSetCrostiniEnabledFunction
///////////////////////////////////////////////////////////////////////////////
AutotestPrivateSetCrostiniEnabledFunction::
~AutotestPrivateSetCrostiniEnabledFunction() = default;
ExtensionFunction::ResponseAction
AutotestPrivateSetCrostiniEnabledFunction::Run() {
DVLOG(1) << "AutotestPrivateSetCrostiniEnabledFunction";
#if defined(OS_CHROMEOS)
std::unique_ptr<api::autotest_private::SetCrostiniEnabled::Params> params(
api::autotest_private::SetCrostiniEnabled::Params::Create(*args_));
EXTENSION_FUNCTION_VALIDATE(params);
DVLOG(1) << "AutotestPrivateSetCrostiniEnabledFunction " << params->enabled;
Profile* profile = Profile::FromBrowserContext(browser_context());
if (!IsCrostiniUIAllowedForProfile(profile))
return RespondNow(Error(kCrostiniNotAvailableForCurrentUserError));
......@@ -763,18 +707,19 @@ AutotestPrivateSetCrostiniEnabledFunction::Run() {
crostini::CrostiniManager::GetForProfile(profile);
crostini_manager->set_skip_restart_for_testing();
return RespondNow(NoArguments());
#else
return RespondNow(Error(kOnlyAvailableOnChromeOSError));
#endif
}
///////////////////////////////////////////////////////////////////////////////
// AutotestPrivateRunCrostiniInstallerFunction
///////////////////////////////////////////////////////////////////////////////
AutotestPrivateRunCrostiniInstallerFunction::
~AutotestPrivateRunCrostiniInstallerFunction() = default;
ExtensionFunction::ResponseAction
AutotestPrivateRunCrostiniInstallerFunction::Run() {
DVLOG(1) << "AutotestPrivateInstallCrostiniFunction";
#if defined(OS_CHROMEOS)
Profile* profile = Profile::FromBrowserContext(browser_context());
if (!IsCrostiniUIAllowedForProfile(profile))
return RespondNow(Error(kCrostiniNotAvailableForCurrentUserError));
......@@ -792,12 +737,8 @@ AutotestPrivateRunCrostiniInstallerFunction::Run() {
this));
return RespondLater();
#else
return RespondNow(Error(kOnlyAvailableOnChromeOSError));
#endif
}
#if defined(OS_CHROMEOS)
void AutotestPrivateRunCrostiniInstallerFunction::CrostiniRestarted(
crostini::ConciergeClientResult result) {
if (result == crostini::ConciergeClientResult::SUCCESS) {
......@@ -806,7 +747,10 @@ void AutotestPrivateRunCrostiniInstallerFunction::CrostiniRestarted(
Respond(Error("Error installing crostini"));
}
}
#endif
///////////////////////////////////////////////////////////////////////////////
// AutotestPrivateRunCrostiniUninstallerFunction
///////////////////////////////////////////////////////////////////////////////
AutotestPrivateRunCrostiniUninstallerFunction::
~AutotestPrivateRunCrostiniUninstallerFunction() = default;
......@@ -814,7 +758,7 @@ AutotestPrivateRunCrostiniUninstallerFunction::
ExtensionFunction::ResponseAction
AutotestPrivateRunCrostiniUninstallerFunction::Run() {
DVLOG(1) << "AutotestPrivateRunCrostiniUninstallerFunction";
#if defined(OS_CHROMEOS)
Profile* profile = Profile::FromBrowserContext(browser_context());
if (!IsCrostiniUIAllowedForProfile(profile))
return RespondNow(Error(kCrostiniNotAvailableForCurrentUserError));
......@@ -828,28 +772,25 @@ AutotestPrivateRunCrostiniUninstallerFunction::Run() {
CrostiniUninstallerView::Show(profile);
CrostiniUninstallerView::GetActiveViewForTesting()->Accept();
return RespondLater();
#else
return RespondNow(Error(kOnlyAvailableOnChromeOSError));
#endif
}
#if defined(OS_CHROMEOS)
void AutotestPrivateRunCrostiniUninstallerFunction::CrostiniRemoved(
crostini::ConciergeClientResult result) {
if (result == crostini::ConciergeClientResult::SUCCESS) {
if (result == crostini::ConciergeClientResult::SUCCESS)
Respond(NoArguments());
} else {
else
Respond(Error("Error uninstalling crostini"));
}
}
#endif
///////////////////////////////////////////////////////////////////////////////
// AutotestPrivateTakeScreenshotFunction
///////////////////////////////////////////////////////////////////////////////
AutotestPrivateTakeScreenshotFunction::
~AutotestPrivateTakeScreenshotFunction() = default;
ExtensionFunction::ResponseAction AutotestPrivateTakeScreenshotFunction::Run() {
DVLOG(1) << "AutotestPrivateTakeScreenshotFunction";
#if defined(OS_CHROMEOS)
auto grabber = std::make_unique<ui::ScreenshotGrabber>();
// TODO(mash): Fix for mash, http://crbug.com/557397
aura::Window* primary_root = ash::Shell::GetPrimaryRootWindow();
......@@ -861,12 +802,8 @@ ExtensionFunction::ResponseAction AutotestPrivateTakeScreenshotFunction::Run() {
base::BindOnce(&AutotestPrivateTakeScreenshotFunction::ScreenshotTaken,
this, base::Passed(&grabber)));
return RespondLater();
#else
return RespondNow(Error(kOnlyAvailableOnChromeOSError));
#endif
}
#if defined(OS_CHROMEOS)
void AutotestPrivateTakeScreenshotFunction::ScreenshotTaken(
std::unique_ptr<ui::ScreenshotGrabber> grabber,
ui::ScreenshotResult screenshot_result,
......@@ -883,18 +820,111 @@ void AutotestPrivateTakeScreenshotFunction::ScreenshotTaken(
base::NumberToString(static_cast<int>(screenshot_result))})));
}
}
#endif
AutotestPrivateBootstrapMachineLearningServiceFunction::
~AutotestPrivateBootstrapMachineLearningServiceFunction() = default;
///////////////////////////////////////////////////////////////////////////////
// AutotestPrivateGetPrinterListFunction
///////////////////////////////////////////////////////////////////////////////
AutotestPrivateGetPrinterListFunction::
~AutotestPrivateGetPrinterListFunction() = default;
ExtensionFunction::ResponseAction AutotestPrivateGetPrinterListFunction::Run() {
DVLOG(1) << "AutotestPrivateGetPrinterListFunction";
auto values = std::make_unique<base::ListValue>();
Profile* profile = Profile::FromBrowserContext(browser_context());
std::unique_ptr<chromeos::CupsPrintersManager> printers_manager =
chromeos::CupsPrintersManager::Create(profile);
std::vector<chromeos::CupsPrintersManager::PrinterClass> printer_type = {
chromeos::CupsPrintersManager::PrinterClass::kConfigured,
chromeos::CupsPrintersManager::PrinterClass::kEnterprise,
chromeos::CupsPrintersManager::PrinterClass::kAutomatic};
for (const auto& type : printer_type) {
std::vector<chromeos::Printer> printer_list =
printers_manager->GetPrinters(type);
for (const auto& printer : printer_list) {
auto result = std::make_unique<base::DictionaryValue>();
result->SetString("printerName", printer.display_name());
result->SetString("printerId", printer.id());
result->SetString("printerType", GetPrinterType(type));
values->Append(std::move(result));
}
}
return RespondNow(OneArgument(std::move(values)));
}
///////////////////////////////////////////////////////////////////////////////
// AutotestPrivateUpdatePrinterFunction
///////////////////////////////////////////////////////////////////////////////
AutotestPrivateUpdatePrinterFunction::~AutotestPrivateUpdatePrinterFunction() =
default;
ExtensionFunction::ResponseAction AutotestPrivateUpdatePrinterFunction::Run() {
std::unique_ptr<api::autotest_private::UpdatePrinter::Params> params(
api::autotest_private::UpdatePrinter::Params::Create(*args_));
EXTENSION_FUNCTION_VALIDATE(params);
DVLOG(1) << "AutotestPrivateUpdatePrinterFunction";
const api::autotest_private::Printer& js_printer = params->printer;
chromeos::Printer printer(js_printer.printer_id ? *js_printer.printer_id
: "");
printer.set_display_name(js_printer.printer_name);
if (js_printer.printer_desc)
printer.set_description(*js_printer.printer_desc);
if (js_printer.printer_make_and_model)
printer.set_make_and_model(*js_printer.printer_make_and_model);
if (js_printer.printer_uri)
printer.set_uri(*js_printer.printer_uri);
if (js_printer.printer_ppd) {
const GURL ppd =
net::FilePathToFileURL(base::FilePath(*js_printer.printer_ppd));
if (ppd.is_valid())
printer.mutable_ppd_reference()->user_supplied_ppd_url = ppd.spec();
else
LOG(ERROR) << "Invalid ppd path: " << *js_printer.printer_ppd;
}
auto printers_manager = chromeos::CupsPrintersManager::Create(
Profile::FromBrowserContext(browser_context()));
printers_manager->UpdateConfiguredPrinter(printer);
return RespondNow(NoArguments());
}
///////////////////////////////////////////////////////////////////////////////
// AutotestPrivateRemovePrinterFunction
///////////////////////////////////////////////////////////////////////////////
AutotestPrivateRemovePrinterFunction::~AutotestPrivateRemovePrinterFunction() =
default;
ExtensionFunction::ResponseAction AutotestPrivateRemovePrinterFunction::Run() {
std::unique_ptr<api::autotest_private::RemovePrinter::Params> params(
api::autotest_private::RemovePrinter::Params::Create(*args_));
EXTENSION_FUNCTION_VALIDATE(params);
DVLOG(1) << "AutotestPrivateRemovePrinterFunction " << params->printer_id;
auto printers_manager = chromeos::CupsPrintersManager::Create(
Profile::FromBrowserContext(browser_context()));
printers_manager->RemoveConfiguredPrinter(params->printer_id);
return RespondNow(NoArguments());
}
///////////////////////////////////////////////////////////////////////////////
// AutotestPrivateBootstrapMachineLearningServiceFunction
///////////////////////////////////////////////////////////////////////////////
AutotestPrivateBootstrapMachineLearningServiceFunction::
AutotestPrivateBootstrapMachineLearningServiceFunction() {}
AutotestPrivateBootstrapMachineLearningServiceFunction() = default;
AutotestPrivateBootstrapMachineLearningServiceFunction::
~AutotestPrivateBootstrapMachineLearningServiceFunction() = default;
ExtensionFunction::ResponseAction
AutotestPrivateBootstrapMachineLearningServiceFunction::Run() {
DVLOG(1) << "AutotestPrivateBootstrapMachineLearningServiceFunction";
#if defined(OS_CHROMEOS)
// Load a model. This will first bootstrap the Mojo connection to ML Service.
chromeos::machine_learning::ServiceConnection::GetInstance()->LoadModel(
chromeos::machine_learning::mojom::ModelSpec::New(
......@@ -907,12 +937,8 @@ AutotestPrivateBootstrapMachineLearningServiceFunction::Run() {
&AutotestPrivateBootstrapMachineLearningServiceFunction::ConnectionError,
this));
return RespondLater();
#else
return RespondNow(Error(kOnlyAvailableOnChromeOSError));
#endif
}
#if defined(OS_CHROMEOS)
void AutotestPrivateBootstrapMachineLearningServiceFunction::ModelLoaded(
chromeos::machine_learning::mojom::LoadModelResult result) {
if (result == chromeos::machine_learning::mojom::LoadModelResult::OK) {
......@@ -926,7 +952,10 @@ void AutotestPrivateBootstrapMachineLearningServiceFunction::ModelLoaded(
void AutotestPrivateBootstrapMachineLearningServiceFunction::ConnectionError() {
Respond(Error("ML Service connection error"));
}
#endif
///////////////////////////////////////////////////////////////////////////////
// AutotestPrivateAPI
///////////////////////////////////////////////////////////////////////////////
static base::LazyInstance<BrowserContextKeyedAPIFactory<AutotestPrivateAPI>>::
DestructorAtExit g_autotest_private_api_factory = LAZY_INSTANCE_INITIALIZER;
......@@ -946,6 +975,6 @@ BrowserContextKeyedAPIFactory<AutotestPrivateAPI>::BuildServiceInstanceFor(
AutotestPrivateAPI::AutotestPrivateAPI() : test_mode_(false) {}
AutotestPrivateAPI::~AutotestPrivateAPI() {}
AutotestPrivateAPI::~AutotestPrivateAPI() = default;
} // namespace extensions
......@@ -7,27 +7,22 @@
#include <string>
#include "ash/public/interfaces/ash_message_center_controller.mojom.h"
#include "base/compiler_specific.h"
#include "chrome/browser/chromeos/printing/cups_printers_manager.h"
#include "chrome/browser/extensions/chrome_extension_function.h"
#include "chromeos/services/machine_learning/public/mojom/machine_learning_service.mojom.h"
#include "extensions/browser/browser_context_keyed_api_factory.h"
#include "ui/message_center/public/cpp/notification_types.h"
#if defined(OS_CHROMEOS)
#include "ash/public/interfaces/ash_message_center_controller.mojom.h"
#include "chrome/browser/chromeos/printing/cups_printers_manager.h"
#include "chromeos/services/machine_learning/public/mojom/machine_learning_service.mojom.h"
#include "ui/snapshot/screenshot_grabber.h"
#endif
namespace message_center {
class Notification;
}
#if defined(OS_CHROMEOS)
namespace crostini {
enum class ConciergeClientResult;
}
#endif
namespace extensions {
......@@ -68,9 +63,7 @@ class AutotestPrivateLoginStatusFunction : public UIThreadExtensionFunction {
~AutotestPrivateLoginStatusFunction() override;
ResponseAction Run() override;
#if defined(OS_CHROMEOS)
void OnIsReadyForPassword(bool is_ready);
#endif
};
class AutotestPrivateLockScreenFunction : public UIThreadExtensionFunction {
......@@ -194,21 +187,18 @@ class AutotestPrivateSetMouseReverseScrollFunction
class AutotestPrivateGetVisibleNotificationsFunction
: public UIThreadExtensionFunction {
public:
AutotestPrivateGetVisibleNotificationsFunction();
DECLARE_EXTENSION_FUNCTION("autotestPrivate.getVisibleNotifications",
AUTOTESTPRIVATE_GETVISIBLENOTIFICATIONS)
AutotestPrivateGetVisibleNotificationsFunction();
private:
~AutotestPrivateGetVisibleNotificationsFunction() override;
ResponseAction Run() override;
#if defined(OS_CHROMEOS)
void OnGotNotifications(
const std::vector<message_center::Notification>& notifications);
ash::mojom::AshMessageCenterControllerPtr controller_;
#endif
};
class AutotestPrivateGetPlayStoreStateFunction
......@@ -266,109 +256,82 @@ class AutotestPrivateLaunchAppFunction : public UIThreadExtensionFunction {
class AutotestPrivateSetCrostiniEnabledFunction
: public UIThreadExtensionFunction {
public:
AutotestPrivateSetCrostiniEnabledFunction() = default;
DECLARE_EXTENSION_FUNCTION("autotestPrivate.setCrostiniEnabled",
AUTOTESTPRIVATE_SETCROSTINIENABLED)
private:
~AutotestPrivateSetCrostiniEnabledFunction() override;
ResponseAction Run() override;
DISALLOW_COPY_AND_ASSIGN(AutotestPrivateSetCrostiniEnabledFunction);
};
class AutotestPrivateRunCrostiniInstallerFunction
: public UIThreadExtensionFunction {
public:
AutotestPrivateRunCrostiniInstallerFunction() = default;
DECLARE_EXTENSION_FUNCTION("autotestPrivate.runCrostiniInstaller",
AUTOTESTPRIVATE_RUNCROSTINIINSTALLER)
private:
~AutotestPrivateRunCrostiniInstallerFunction() override;
ResponseAction Run() override;
#if defined(OS_CHROMEOS)
void CrostiniRestarted(crostini::ConciergeClientResult);
#endif
DISALLOW_COPY_AND_ASSIGN(AutotestPrivateRunCrostiniInstallerFunction);
void CrostiniRestarted(crostini::ConciergeClientResult);
};
class AutotestPrivateRunCrostiniUninstallerFunction
: public UIThreadExtensionFunction {
public:
AutotestPrivateRunCrostiniUninstallerFunction() = default;
DECLARE_EXTENSION_FUNCTION("autotestPrivate.runCrostiniUninstaller",
AUTOTESTPRIVATE_RUNCROSTINIUNINSTALLER)
private:
~AutotestPrivateRunCrostiniUninstallerFunction() override;
ResponseAction Run() override;
#if defined(OS_CHROMEOS)
void CrostiniRemoved(crostini::ConciergeClientResult);
#endif
DISALLOW_COPY_AND_ASSIGN(AutotestPrivateRunCrostiniUninstallerFunction);
void CrostiniRemoved(crostini::ConciergeClientResult);
};
class AutotestPrivateTakeScreenshotFunction : public UIThreadExtensionFunction {
public:
AutotestPrivateTakeScreenshotFunction() = default;
DECLARE_EXTENSION_FUNCTION("autotestPrivate.takeScreenshot",
AUTOTESTPRIVATE_TAKESCREENSHOT)
private:
~AutotestPrivateTakeScreenshotFunction() override;
ResponseAction Run() override;
#if defined(OS_CHROMEOS)
void ScreenshotTaken(std::unique_ptr<ui::ScreenshotGrabber> grabber,
ui::ScreenshotResult screenshot_result,
scoped_refptr<base::RefCountedMemory> png_data);
#endif
DISALLOW_COPY_AND_ASSIGN(AutotestPrivateTakeScreenshotFunction);
};
class AutotestPrivateGetPrinterListFunction : public UIThreadExtensionFunction {
public:
AutotestPrivateGetPrinterListFunction() = default;
DECLARE_EXTENSION_FUNCTION("autotestPrivate.getPrinterList",
AUTOTESTPRIVATE_GETPRINTERLIST)
private:
#if defined(OS_CHROMEOS)
static std::string GetPrinterType(
chromeos::CupsPrintersManager::PrinterClass type);
#endif
~AutotestPrivateGetPrinterListFunction() override;
ResponseAction Run() override;
DISALLOW_COPY_AND_ASSIGN(AutotestPrivateGetPrinterListFunction);
};
class AutotestPrivateUpdatePrinterFunction : public UIThreadExtensionFunction {
public:
AutotestPrivateUpdatePrinterFunction();
DECLARE_EXTENSION_FUNCTION("autotestPrivate.updatePrinter",
AUTOTESTPRIVATE_UPDATEPRINTER)
private:
~AutotestPrivateUpdatePrinterFunction() override;
ResponseAction Run() override;
DISALLOW_COPY_AND_ASSIGN(AutotestPrivateUpdatePrinterFunction);
};
class AutotestPrivateRemovePrinterFunction : public UIThreadExtensionFunction {
public:
AutotestPrivateRemovePrinterFunction();
DECLARE_EXTENSION_FUNCTION("autotestPrivate.removePrinter",
AUTOTESTPRIVATE_REMOVEPRINTER)
private:
~AutotestPrivateRemovePrinterFunction() override;
ResponseAction Run() override;
DISALLOW_COPY_AND_ASSIGN(AutotestPrivateRemovePrinterFunction);
};
class AutotestPrivateBootstrapMachineLearningServiceFunction
......@@ -381,21 +344,14 @@ class AutotestPrivateBootstrapMachineLearningServiceFunction
private:
~AutotestPrivateBootstrapMachineLearningServiceFunction() override;
ResponseAction Run() override;
#if defined(OS_CHROMEOS)
// Callbacks for a basic Mojo call to MachineLearningService.LoadModel.
void ModelLoaded(chromeos::machine_learning::mojom::LoadModelResult result);
void ConnectionError();
chromeos::machine_learning::mojom::ModelPtr model_;
#endif
DISALLOW_COPY_AND_ASSIGN(
AutotestPrivateBootstrapMachineLearningServiceFunction);
};
// Don't kill the browser when we're in a browser test.
void SetAutotestPrivateTest();
// The profile-keyed service that manages the autotestPrivate extension API.
class AutotestPrivateAPI : public BrowserContextKeyedAPI {
public:
......
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