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