Commit 108b8b22 authored by Steven Bennetts's avatar Steven Bennetts Committed by Commit Bot

Implement DisplayInfoProviderChromeos using cros_display_config.mojom

Bug: 682402
Change-Id: I6502a46e7dfa5293e8e5b29fefd44b3c3034db2c
Reviewed-on: https://chromium-review.googlesource.com/1011547
Commit-Queue: Steven Bennetts <stevenjb@chromium.org>
Reviewed-by: default avatarToni Barzic <tbarzic@chromium.org>
Reviewed-by: default avatarAhmed Fakhry <afakhry@chromium.org>
Cr-Commit-Position: refs/heads/master@{#555280}
parent e5e7dc37
...@@ -8,19 +8,20 @@ ...@@ -8,19 +8,20 @@
#include <map> #include <map>
#include <memory> #include <memory>
#include "ash/public/interfaces/cros_display_config.mojom.h"
#include "base/macros.h" #include "base/macros.h"
#include "base/memory/weak_ptr.h"
#include "extensions/browser/api/system_display/display_info_provider.h" #include "extensions/browser/api/system_display/display_info_provider.h"
namespace ash { namespace service_manager {
class OverscanCalibrator; class Connector;
class TouchCalibratorController; }
} // namespace ash
namespace extensions { namespace extensions {
class DisplayInfoProviderChromeOS : public DisplayInfoProvider { class DisplayInfoProviderChromeOS : public DisplayInfoProvider {
public: public:
DisplayInfoProviderChromeOS(); explicit DisplayInfoProviderChromeOS(service_manager::Connector* connector);
~DisplayInfoProviderChromeOS() override; ~DisplayInfoProviderChromeOS() override;
// DisplayInfoProvider implementation. // DisplayInfoProvider implementation.
...@@ -44,31 +45,30 @@ class DisplayInfoProviderChromeOS : public DisplayInfoProvider { ...@@ -44,31 +45,30 @@ class DisplayInfoProviderChromeOS : public DisplayInfoProvider {
bool OverscanCalibrationComplete(const std::string& id) override; bool OverscanCalibrationComplete(const std::string& id) override;
void ShowNativeTouchCalibration(const std::string& id, void ShowNativeTouchCalibration(const std::string& id,
ErrorCallback callback) override; ErrorCallback callback) override;
bool IsNativeTouchCalibrationActive() override;
bool StartCustomTouchCalibration(const std::string& id) override; bool StartCustomTouchCalibration(const std::string& id) override;
bool CompleteCustomTouchCalibration( bool CompleteCustomTouchCalibration(
const api::system_display::TouchCalibrationPairQuad& pairs, const api::system_display::TouchCalibrationPairQuad& pairs,
const api::system_display::Bounds& bounds) override; const api::system_display::Bounds& bounds) override;
bool ClearTouchCalibration(const std::string& id) override; bool ClearTouchCalibration(const std::string& id) override;
bool IsCustomTouchCalibrationActive() override;
void SetMirrorMode(const api::system_display::MirrorModeInfo& info, void SetMirrorMode(const api::system_display::MirrorModeInfo& info,
ErrorCallback callback) override; ErrorCallback callback) override;
void UpdateDisplayUnitInfoForPlatform(
const display::Display& display,
api::system_display::DisplayUnitInfo* unit) override;
private: private:
ash::TouchCalibratorController* GetTouchCalibrator(); void CallSetDisplayLayoutInfo(ash::mojom::DisplayLayoutInfoPtr layout_info,
ErrorCallback callback,
ash::OverscanCalibrator* GetOverscanCalibrator(const std::string& id); ash::mojom::DisplayLayoutInfoPtr cur_info);
void CallGetDisplayUnitInfoList(
std::map<std::string, std::unique_ptr<ash::OverscanCalibrator>> bool single_unified,
overscan_calibrators_; base::OnceCallback<void(DisplayUnitInfoList result)> callback,
ash::mojom::DisplayLayoutInfoPtr layout);
std::unique_ptr<ash::TouchCalibratorController> touch_calibrator_; void CallTouchCalibration(const std::string& id,
ash::mojom::DisplayConfigOperation op,
ash::mojom::TouchCalibrationPtr calibration,
ErrorCallback callback);
ash::mojom::CrosDisplayConfigControllerPtr cros_display_config_;
std::string touch_calibration_target_id_; std::string touch_calibration_target_id_;
bool custom_touch_calibration_active_ = false; base::WeakPtrFactory<DisplayInfoProviderChromeOS> weak_ptr_factory_;
DISALLOW_COPY_AND_ASSIGN(DisplayInfoProviderChromeOS); DISALLOW_COPY_AND_ASSIGN(DisplayInfoProviderChromeOS);
}; };
......
...@@ -48,15 +48,9 @@ DisplayInfoProvider* DisplayInfoProvider::Get() { ...@@ -48,15 +48,9 @@ DisplayInfoProvider* DisplayInfoProvider::Get() {
// static // static
void DisplayInfoProvider::InitializeForTesting( void DisplayInfoProvider::InitializeForTesting(
DisplayInfoProvider* display_info_provider) { DisplayInfoProvider* display_info_provider) {
DCHECK(display_info_provider);
g_display_info_provider = display_info_provider;
}
// static
void DisplayInfoProvider::ResetForTesting() {
if (g_display_info_provider) if (g_display_info_provider)
delete g_display_info_provider; delete g_display_info_provider;
g_display_info_provider = nullptr; g_display_info_provider = display_info_provider;
} }
// static // static
...@@ -150,10 +144,6 @@ void DisplayInfoProvider::ShowNativeTouchCalibration(const std::string& id, ...@@ -150,10 +144,6 @@ void DisplayInfoProvider::ShowNativeTouchCalibration(const std::string& id,
NOTREACHED(); // Implemented on Chrome OS only in override. NOTREACHED(); // Implemented on Chrome OS only in override.
} }
bool DisplayInfoProvider::IsNativeTouchCalibrationActive() {
return false;
}
bool DisplayInfoProvider::StartCustomTouchCalibration(const std::string& id) { bool DisplayInfoProvider::StartCustomTouchCalibration(const std::string& id) {
NOTREACHED(); // Implemented on Chrome OS only in override. NOTREACHED(); // Implemented on Chrome OS only in override.
return false; return false;
...@@ -171,10 +161,6 @@ bool DisplayInfoProvider::ClearTouchCalibration(const std::string& id) { ...@@ -171,10 +161,6 @@ bool DisplayInfoProvider::ClearTouchCalibration(const std::string& id) {
return false; return false;
} }
bool DisplayInfoProvider::IsCustomTouchCalibrationActive() {
return false;
}
void DisplayInfoProvider::SetMirrorMode( void DisplayInfoProvider::SetMirrorMode(
const api::system_display::MirrorModeInfo& info, const api::system_display::MirrorModeInfo& info,
ErrorCallback callback) { ErrorCallback callback) {
......
...@@ -96,8 +96,6 @@ class DisplayInfoProvider { ...@@ -96,8 +96,6 @@ class DisplayInfoProvider {
// calibration has completed. // calibration has completed.
virtual void ShowNativeTouchCalibration(const std::string& id, virtual void ShowNativeTouchCalibration(const std::string& id,
ErrorCallback callback); ErrorCallback callback);
// Returns true if native touch calibration is in progress.
virtual bool IsNativeTouchCalibrationActive();
// These methods implement custom touch calibration. They will return false // These methods implement custom touch calibration. They will return false
// if |id| is invalid or if the operation is invalid. // if |id| is invalid or if the operation is invalid.
...@@ -106,8 +104,6 @@ class DisplayInfoProvider { ...@@ -106,8 +104,6 @@ class DisplayInfoProvider {
const api::system_display::TouchCalibrationPairQuad& pairs, const api::system_display::TouchCalibrationPairQuad& pairs,
const api::system_display::Bounds& bounds); const api::system_display::Bounds& bounds);
virtual bool ClearTouchCalibration(const std::string& id); virtual bool ClearTouchCalibration(const std::string& id);
// Returns true if custom touch calibration is in progress.
virtual bool IsCustomTouchCalibrationActive();
// Sets the display mode to the specified mirror mode. See system_display.idl. // Sets the display mode to the specified mirror mode. See system_display.idl.
// |info|: Mirror mode properties to apply. // |info|: Mirror mode properties to apply.
......
...@@ -317,13 +317,6 @@ ExtensionFunction::ResponseAction ...@@ -317,13 +317,6 @@ ExtensionFunction::ResponseAction
SystemDisplayShowNativeTouchCalibrationFunction::Run() { SystemDisplayShowNativeTouchCalibrationFunction::Run() {
std::unique_ptr<display::ShowNativeTouchCalibration::Params> params( std::unique_ptr<display::ShowNativeTouchCalibration::Params> params(
display::ShowNativeTouchCalibration::Params::Create(*args_)); display::ShowNativeTouchCalibration::Params::Create(*args_));
if (DisplayInfoProvider::Get()->IsNativeTouchCalibrationActive())
return RespondNow(Error("Native touch calibration already active."));
if (DisplayInfoProvider::Get()->IsCustomTouchCalibrationActive())
return RespondNow(Error("Custom touch calibration is active."));
DisplayInfoProvider::Get()->ShowNativeTouchCalibration( DisplayInfoProvider::Get()->ShowNativeTouchCalibration(
params->id, params->id,
base::BindOnce(&SystemDisplayShowNativeTouchCalibrationFunction:: base::BindOnce(&SystemDisplayShowNativeTouchCalibrationFunction::
...@@ -342,10 +335,6 @@ ExtensionFunction::ResponseAction ...@@ -342,10 +335,6 @@ ExtensionFunction::ResponseAction
SystemDisplayStartCustomTouchCalibrationFunction::Run() { SystemDisplayStartCustomTouchCalibrationFunction::Run() {
std::unique_ptr<display::StartCustomTouchCalibration::Params> params( std::unique_ptr<display::StartCustomTouchCalibration::Params> params(
display::StartCustomTouchCalibration::Params::Create(*args_)); display::StartCustomTouchCalibration::Params::Create(*args_));
if (DisplayInfoProvider::Get()->IsNativeTouchCalibrationActive())
return RespondNow(Error("Native touch calibration is active."));
if (!DisplayInfoProvider::Get()->StartCustomTouchCalibration(params->id)) { if (!DisplayInfoProvider::Get()->StartCustomTouchCalibration(params->id)) {
return RespondNow( return RespondNow(
Error("Custom touch calibration not available for display.")); Error("Custom touch calibration not available for display."));
...@@ -357,13 +346,6 @@ ExtensionFunction::ResponseAction ...@@ -357,13 +346,6 @@ ExtensionFunction::ResponseAction
SystemDisplayCompleteCustomTouchCalibrationFunction::Run() { SystemDisplayCompleteCustomTouchCalibrationFunction::Run() {
std::unique_ptr<display::CompleteCustomTouchCalibration::Params> params( std::unique_ptr<display::CompleteCustomTouchCalibration::Params> params(
display::CompleteCustomTouchCalibration::Params::Create(*args_)); display::CompleteCustomTouchCalibration::Params::Create(*args_));
if (DisplayInfoProvider::Get()->IsNativeTouchCalibrationActive())
return RespondNow(Error("Native touch calibration is active."));
if (!DisplayInfoProvider::Get()->IsCustomTouchCalibrationActive())
return RespondNow(Error("Custom touch calibration is not active."));
if (!DisplayInfoProvider::Get()->CompleteCustomTouchCalibration( if (!DisplayInfoProvider::Get()->CompleteCustomTouchCalibration(
params->pairs, params->bounds)) { params->pairs, params->bounds)) {
return RespondNow(Error("Custom touch calibration completion failed.")); return RespondNow(Error("Custom touch calibration completion failed."));
...@@ -375,14 +357,6 @@ ExtensionFunction::ResponseAction ...@@ -375,14 +357,6 @@ ExtensionFunction::ResponseAction
SystemDisplayClearTouchCalibrationFunction::Run() { SystemDisplayClearTouchCalibrationFunction::Run() {
std::unique_ptr<display::ClearTouchCalibration::Params> params( std::unique_ptr<display::ClearTouchCalibration::Params> params(
display::ClearTouchCalibration::Params::Create(*args_)); display::ClearTouchCalibration::Params::Create(*args_));
if (DisplayInfoProvider::Get()->IsNativeTouchCalibrationActive())
return RespondNow(Error("Native touch calibration is active."));
// TODO(malaykeshav@): Document and test whether
// IsCustomTouchCalibrationActive() should be true or false and enforce in
// DisplayInfoProvider::ClearTouchCalibration.
if (!DisplayInfoProvider::Get()->ClearTouchCalibration(params->id)) if (!DisplayInfoProvider::Get()->ClearTouchCalibration(params->id))
return RespondNow(Error("Failed to clear custom touch calibration data.")); return RespondNow(Error("Failed to clear custom touch calibration data."));
return RespondNow(NoArguments()); return RespondNow(NoArguments());
......
...@@ -218,15 +218,15 @@ namespace system.display { ...@@ -218,15 +218,15 @@ namespace system.display {
// desktop (see $(ref:enableUnifiedDesktop) for details). If set to false, // desktop (see $(ref:enableUnifiedDesktop) for details). If set to false,
// unified desktop mode will be disabled. This is only valid for the // unified desktop mode will be disabled. This is only valid for the
// primary display. If provided, mirroringSourceId must not be provided and // primary display. If provided, mirroringSourceId must not be provided and
// other properties may not apply. This is has no effect if not provided. // other properties will be ignored. This is has no effect if not provided.
boolean? isUnified; boolean? isUnified;
// Deprecated. Please use $(ref:setMirrorMode) instead. // Chrome OS only. If set and not empty, enables mirroring for this display
// Chrome OS only. If set and not empty, enables mirroring for this display. // only. Otherwise disables mirroring for all displays. This value should
// Otherwise disables mirroring for this display. This value should indicate // indicate the id of the source display to mirror, which must not be the
// the id of the source display to mirror, which must not be the same as the // same as the id passed to setDisplayProperties. If set, no other property
// id passed to setDisplayProperties. If set, no other property may be set. // may be set.
DOMString? mirroringSourceId; [deprecated="Use $(ref:setMirrorMode)."] DOMString? mirroringSourceId;
// If set to true, makes the display primary. No-op if set to false. // If set to true, makes the display primary. No-op if set to false.
// Note: If set, the display is considered primary for all other properties // Note: If set, the display is considered primary for all other properties
......
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