| Index: extensions/browser/api/system_display/system_display_api.cc
|
| diff --git a/extensions/browser/api/system_display/system_display_api.cc b/extensions/browser/api/system_display/system_display_api.cc
|
| index b8dc9c38752f35161ee6634e249484db0bf1da85..3c0e9601e17a289af6efb4caba6be1a54692c5d0 100644
|
| --- a/extensions/browser/api/system_display/system_display_api.cc
|
| +++ b/extensions/browser/api/system_display/system_display_api.cc
|
| @@ -21,6 +21,14 @@ using api::system_display::DisplayUnitInfo;
|
|
|
| namespace SetDisplayProperties = api::system_display::SetDisplayProperties;
|
|
|
| +bool SystemDisplayFunction::CheckValidExtension() {
|
| + if (extension() && !KioskModeInfo::IsKioskEnabled(extension())) {
|
| + SetError("The extension needs to be kiosk enabled to use the function.");
|
| + return false;
|
| + }
|
| + return true;
|
| +}
|
| +
|
| bool SystemDisplayGetInfoFunction::RunSync() {
|
| DisplayUnitInfoList all_displays_info =
|
| DisplayInfoProvider::Get()->GetAllDisplaysInfo();
|
| @@ -33,10 +41,8 @@ bool SystemDisplaySetDisplayPropertiesFunction::RunSync() {
|
| SetError("Function available only on ChromeOS.");
|
| return false;
|
| #else
|
| - if (extension() && !KioskModeInfo::IsKioskEnabled(extension())) {
|
| - SetError("The extension needs to be kiosk enabled to use the function.");
|
| + if (!CheckValidExtension())
|
| return false;
|
| - }
|
| std::string error;
|
| std::unique_ptr<SetDisplayProperties::Params> params(
|
| SetDisplayProperties::Params::Create(*args_));
|
| @@ -53,6 +59,8 @@ bool SystemDisplayEnableUnifiedDesktopFunction::RunSync() {
|
| SetError("Function available only on ChromeOS.");
|
| return false;
|
| #else
|
| + if (!CheckValidExtension())
|
| + return false;
|
| std::unique_ptr<api::system_display::EnableUnifiedDesktop::Params> params(
|
| api::system_display::EnableUnifiedDesktop::Params::Create(*args_));
|
| DisplayInfoProvider::Get()->EnableUnifiedDesktop(params->enabled);
|
| @@ -60,4 +68,79 @@ bool SystemDisplayEnableUnifiedDesktopFunction::RunSync() {
|
| #endif
|
| }
|
|
|
| +bool SystemDisplayOverscanCalibrationStartFunction::RunSync() {
|
| +#if !defined(OS_CHROMEOS)
|
| + SetError("Function available only on ChromeOS.");
|
| + return false;
|
| +#else
|
| + if (!CheckValidExtension())
|
| + return false;
|
| + std::unique_ptr<api::system_display::OverscanCalibrationStart::Params> params(
|
| + api::system_display::OverscanCalibrationStart::Params::Create(*args_));
|
| + if (!DisplayInfoProvider::Get()->OverscanCalibrationStart(params->id)) {
|
| + SetError("Invalid display ID: " + params->id);
|
| + return false;
|
| + }
|
| + return true;
|
| +#endif
|
| +}
|
| +
|
| +bool SystemDisplayOverscanCalibrationAdjustFunction::RunSync() {
|
| +#if !defined(OS_CHROMEOS)
|
| + SetError("Function available only on ChromeOS.");
|
| + return false;
|
| +#else
|
| + if (!CheckValidExtension())
|
| + return false;
|
| + std::unique_ptr<api::system_display::OverscanCalibrationAdjust::Params>
|
| + params(api::system_display::OverscanCalibrationAdjust::Params::Create(
|
| + *args_));
|
| + if (!params) {
|
| + SetError("Invalid parameters");
|
| + return false;
|
| + }
|
| + if (!DisplayInfoProvider::Get()->OverscanCalibrationAdjust(params->id,
|
| + params->delta)) {
|
| + SetError("Calibration not started for display ID: " + params->id);
|
| + return false;
|
| + }
|
| + return true;
|
| +#endif
|
| +}
|
| +
|
| +bool SystemDisplayOverscanCalibrationResetFunction::RunSync() {
|
| +#if !defined(OS_CHROMEOS)
|
| + SetError("Function available only on ChromeOS.");
|
| + return false;
|
| +#else
|
| + if (!CheckValidExtension())
|
| + return false;
|
| + std::unique_ptr<api::system_display::OverscanCalibrationReset::Params> params(
|
| + api::system_display::OverscanCalibrationReset::Params::Create(*args_));
|
| + if (!DisplayInfoProvider::Get()->OverscanCalibrationReset(params->id)) {
|
| + SetError("Calibration not started for display ID: " + params->id);
|
| + return false;
|
| + }
|
| + return true;
|
| +#endif
|
| +}
|
| +
|
| +bool SystemDisplayOverscanCalibrationCompleteFunction::RunSync() {
|
| +#if !defined(OS_CHROMEOS)
|
| + SetError("Function available only on ChromeOS.");
|
| + return false;
|
| +#else
|
| + if (!CheckValidExtension())
|
| + return false;
|
| + std::unique_ptr<api::system_display::OverscanCalibrationComplete::Params>
|
| + params(api::system_display::OverscanCalibrationComplete::Params::Create(
|
| + *args_));
|
| + if (!DisplayInfoProvider::Get()->OverscanCalibrationComplete(params->id)) {
|
| + SetError("Calibration not started for display ID: " + params->id);
|
| + return false;
|
| + }
|
| + return true;
|
| +#endif
|
| +}
|
| +
|
| } // namespace extensions
|
|
|