Chromium Code Reviews| Index: chrome/browser/extensions/display_info_provider_chromeos.cc |
| diff --git a/chrome/browser/extensions/display_info_provider_chromeos.cc b/chrome/browser/extensions/display_info_provider_chromeos.cc |
| index b8f392453b8ee16f77fa226a4cce1d6fffaa52ff..1aa7fd7bb595debcab1ca3684ec1c26d6ab3ef92 100644 |
| --- a/chrome/browser/extensions/display_info_provider_chromeos.cc |
| +++ b/chrome/browser/extensions/display_info_provider_chromeos.cc |
| @@ -9,6 +9,7 @@ |
| #include "ash/display/display_configuration_controller.h" |
| #include "ash/display/resolution_notification_controller.h" |
| #include "ash/shell.h" |
| +#include "ash/touch/ash_touch_transform_controller.h" |
| #include "base/strings/string_number_conversions.h" |
| #include "chrome/browser/chromeos/display/display_preferences.h" |
| #include "chrome/browser/chromeos/display/overscan_calibrator.h" |
| @@ -660,19 +661,72 @@ bool DisplayInfoProviderChromeOS::OverscanCalibrationComplete( |
| return true; |
| } |
| -bool DisplayInfoProviderChromeOS::TouchCalibrationSet( |
| +bool DisplayInfoProviderChromeOS::ShowNativeTouchCalibration( |
| + const std::string& id, std::string* error, |
| + const DisplayInfoProvider::TouchCalibrationCallback& callback) { |
| + VLOG(1) << "StartNativeTouchCalibration: " << id; |
| + |
| + if (custom_touch_calibration_active_) { |
| + *error = "Please complete the custom touch calibration that is under " |
| + "progress for id - " + touch_calibration_target_id_ + " before " |
| + "calling this method."; |
|
stevenjb
2017/01/19 17:19:01
Declare string constants at top of file.
Also, un
malaykeshav
2017/01/19 23:49:06
Reducing string length and moving to top of file.
|
| + return false; |
| + } |
| + |
| + const display::Display display = GetDisplay(id); |
| + if (!ValidateParamsForTouchCalibration(id, display, GetTouchCalibrator(), |
| + error)) { |
| + return false; |
| + } |
| + |
| + GetTouchCalibrator()->StartCalibration(display, callback); |
| + return true; |
| +} |
| + |
| +bool DisplayInfoProviderChromeOS::StartCustomTouchCalibration( |
| const std::string& id, |
| - const api::system_display::TouchCalibrationPairQuad& pairs, |
| - const api::system_display::Bounds& bounds, |
| std::string* error) { |
| - VLOG(1) << "TouchCalibrationSet: " << id; |
| - |
| + VLOG(1) << "StartCustomTouchCalibration: " << id; |
| const display::Display display = GetDisplay(id); |
| if (!ValidateParamsForTouchCalibration(id, display, GetTouchCalibrator(), |
| error)) { |
| return false; |
| } |
| + touch_calibration_target_id_ = id; |
| + custom_touch_calibration_active_ = true; |
| + |
| + // Enable un-transformed touch input. |
| + ash::Shell::GetInstance()->touch_transformer_controller()->SetForCalibration( |
| + true); |
| + return true; |
| +} |
| + |
| +bool DisplayInfoProviderChromeOS::CompleteCustomTouchCalibration( |
| + const api::system_display::TouchCalibrationPairQuad& pairs, |
| + const api::system_display::Bounds& bounds, |
| + std::string* error) { |
| + VLOG(1) << "CompleteCustomTouchCalibration: " << touch_calibration_target_id_; |
| + |
| + ash::Shell::GetInstance()->touch_transformer_controller()->SetForCalibration( |
| + false); |
| + |
| + const display::Display display = GetDisplay(touch_calibration_target_id_); |
| + touch_calibration_target_id_ = ""; |
|
stevenjb
2017/01/19 17:19:01
nit: touch_calibration_target_id_.clear()
malaykeshav
2017/01/19 23:49:06
Done
|
| + |
| + if (!custom_touch_calibration_active_) { |
| + *error = "Please call system.display.startCustomTouchCalibration before " |
| + "calling this method."; |
|
stevenjb
2017/01/19 17:19:01
Declare string constants at top of file and sumpli
malaykeshav
2017/01/19 23:49:07
Done
|
| + return false; |
| + } |
| + |
| + custom_touch_calibration_active_ = false; |
| + |
| + if (!ValidateParamsForTouchCalibration( |
| + touch_calibration_target_id_, display, GetTouchCalibrator(), error)) { |
| + return false; |
| + } |
| + |
| display::TouchCalibrationData::CalibrationPointPairQuad calibration_points; |
| calibration_points[0] = GetCalibrationPair(pairs.pair1); |
| calibration_points[1] = GetCalibrationPair(pairs.pair2); |
| @@ -710,7 +764,7 @@ bool DisplayInfoProviderChromeOS::TouchCalibrationSet( |
| return true; |
| } |
| -bool DisplayInfoProviderChromeOS::TouchCalibrationReset(const std::string& id, |
| +bool DisplayInfoProviderChromeOS::ResetTouchCalibration(const std::string& id, |
| std::string* error) { |
| const display::Display display = GetDisplay(id); |
| @@ -724,7 +778,8 @@ bool DisplayInfoProviderChromeOS::TouchCalibrationReset(const std::string& id, |
| return true; |
| } |
| -bool DisplayInfoProviderChromeOS::IsTouchCalibrationActive(std::string* error) { |
| +bool DisplayInfoProviderChromeOS::IsNativeTouchCalibrationActive( |
| + std::string* error) { |
| if (GetTouchCalibrator()->is_calibrating()) { |
| *error = "Another touch calibration is already active."; |
| return true; |