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
...@@ -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