| 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 03adfd7e8664463ac90abf7c5d484ba603864d3a..2b09bad50bcd88c0cb5771da2772fb3a04223ff4 100644
|
| --- a/extensions/browser/api/system_display/system_display_api.cc
|
| +++ b/extensions/browser/api/system_display/system_display_api.cc
|
| @@ -17,9 +17,7 @@
|
|
|
| namespace extensions {
|
|
|
| -using api::system_display::DisplayUnitInfo;
|
| -
|
| -namespace SetDisplayProperties = api::system_display::SetDisplayProperties;
|
| +namespace system_display = api::system_display;
|
|
|
| const char SystemDisplayFunction::kCrosOnlyError[] =
|
| "Function available only on ChromeOS.";
|
| @@ -38,12 +36,24 @@ bool SystemDisplayFunction::CheckValidExtension() {
|
| }
|
|
|
| bool SystemDisplayGetInfoFunction::RunSync() {
|
| - DisplayUnitInfoList all_displays_info =
|
| + DisplayInfoProvider::DisplayUnitInfoList all_displays_info =
|
| DisplayInfoProvider::Get()->GetAllDisplaysInfo();
|
| - results_ = api::system_display::GetInfo::Results::Create(all_displays_info);
|
| + results_ = system_display::GetInfo::Results::Create(all_displays_info);
|
| return true;
|
| }
|
|
|
| +bool SystemDisplayGetDisplayLayoutFunction::RunSync() {
|
| +#if !defined(OS_CHROMEOS)
|
| + SetError(kCrosOnlyError);
|
| + return false;
|
| +#else
|
| + DisplayInfoProvider::DisplayLayoutList display_layout =
|
| + DisplayInfoProvider::Get()->GetDisplayLayout();
|
| + results_ = system_display::GetDisplayLayout::Results::Create(display_layout);
|
| + return true;
|
| +#endif
|
| +}
|
| +
|
| bool SystemDisplaySetDisplayPropertiesFunction::RunSync() {
|
| #if !defined(OS_CHROMEOS)
|
| SetError(kCrosOnlyError);
|
| @@ -52,8 +62,8 @@ bool SystemDisplaySetDisplayPropertiesFunction::RunSync() {
|
| if (!CheckValidExtension())
|
| return false;
|
| std::string error;
|
| - std::unique_ptr<SetDisplayProperties::Params> params(
|
| - SetDisplayProperties::Params::Create(*args_));
|
| + std::unique_ptr<system_display::SetDisplayProperties::Params> params(
|
| + system_display::SetDisplayProperties::Params::Create(*args_));
|
| bool result =
|
| DisplayInfoProvider::Get()->SetInfo(params->id, params->info, &error);
|
| if (!result)
|
| @@ -62,6 +72,23 @@ bool SystemDisplaySetDisplayPropertiesFunction::RunSync() {
|
| #endif
|
| }
|
|
|
| +bool SystemDisplaySetDisplayLayoutFunction::RunSync() {
|
| +#if !defined(OS_CHROMEOS)
|
| + SetError(kCrosOnlyError);
|
| + return false;
|
| +#else
|
| + if (!CheckValidExtension())
|
| + return false;
|
| + std::unique_ptr<system_display::SetDisplayLayout::Params> params(
|
| + system_display::SetDisplayLayout::Params::Create(*args_));
|
| + if (!DisplayInfoProvider::Get()->SetDisplayLayout(params->layouts)) {
|
| + SetError("Unable to set display layout");
|
| + return false;
|
| + }
|
| + return true;
|
| +#endif
|
| +}
|
| +
|
| bool SystemDisplayEnableUnifiedDesktopFunction::RunSync() {
|
| #if !defined(OS_CHROMEOS)
|
| SetError(kCrosOnlyError);
|
| @@ -69,8 +96,8 @@ bool SystemDisplayEnableUnifiedDesktopFunction::RunSync() {
|
| #else
|
| if (!CheckValidExtension())
|
| return false;
|
| - std::unique_ptr<api::system_display::EnableUnifiedDesktop::Params> params(
|
| - api::system_display::EnableUnifiedDesktop::Params::Create(*args_));
|
| + std::unique_ptr<system_display::EnableUnifiedDesktop::Params> params(
|
| + system_display::EnableUnifiedDesktop::Params::Create(*args_));
|
| DisplayInfoProvider::Get()->EnableUnifiedDesktop(params->enabled);
|
| return true;
|
| #endif
|
| @@ -83,8 +110,8 @@ bool SystemDisplayOverscanCalibrationStartFunction::RunSync() {
|
| #else
|
| if (!CheckValidExtension())
|
| return false;
|
| - std::unique_ptr<api::system_display::OverscanCalibrationStart::Params> params(
|
| - api::system_display::OverscanCalibrationStart::Params::Create(*args_));
|
| + std::unique_ptr<system_display::OverscanCalibrationStart::Params> params(
|
| + system_display::OverscanCalibrationStart::Params::Create(*args_));
|
| if (!DisplayInfoProvider::Get()->OverscanCalibrationStart(params->id)) {
|
| SetError("Invalid display ID: " + params->id);
|
| return false;
|
| @@ -100,9 +127,8 @@ bool SystemDisplayOverscanCalibrationAdjustFunction::RunSync() {
|
| #else
|
| if (!CheckValidExtension())
|
| return false;
|
| - std::unique_ptr<api::system_display::OverscanCalibrationAdjust::Params>
|
| - params(api::system_display::OverscanCalibrationAdjust::Params::Create(
|
| - *args_));
|
| + std::unique_ptr<system_display::OverscanCalibrationAdjust::Params> params(
|
| + system_display::OverscanCalibrationAdjust::Params::Create(*args_));
|
| if (!params) {
|
| SetError("Invalid parameters");
|
| return false;
|
| @@ -123,8 +149,8 @@ bool SystemDisplayOverscanCalibrationResetFunction::RunSync() {
|
| #else
|
| if (!CheckValidExtension())
|
| return false;
|
| - std::unique_ptr<api::system_display::OverscanCalibrationReset::Params> params(
|
| - api::system_display::OverscanCalibrationReset::Params::Create(*args_));
|
| + std::unique_ptr<system_display::OverscanCalibrationReset::Params> params(
|
| + system_display::OverscanCalibrationReset::Params::Create(*args_));
|
| if (!DisplayInfoProvider::Get()->OverscanCalibrationReset(params->id)) {
|
| SetError("Calibration not started for display ID: " + params->id);
|
| return false;
|
| @@ -140,9 +166,8 @@ bool SystemDisplayOverscanCalibrationCompleteFunction::RunSync() {
|
| #else
|
| if (!CheckValidExtension())
|
| return false;
|
| - std::unique_ptr<api::system_display::OverscanCalibrationComplete::Params>
|
| - params(api::system_display::OverscanCalibrationComplete::Params::Create(
|
| - *args_));
|
| + std::unique_ptr<system_display::OverscanCalibrationComplete::Params> params(
|
| + system_display::OverscanCalibrationComplete::Params::Create(*args_));
|
| if (!DisplayInfoProvider::Get()->OverscanCalibrationComplete(params->id)) {
|
| SetError("Calibration not started for display ID: " + params->id);
|
| return false;
|
|
|