Chromium Code Reviews| Index: chrome/browser/chromeos/display/touch_calibrator/touch_calibrator_controller.cc |
| diff --git a/chrome/browser/chromeos/display/touch_calibrator/touch_calibrator_controller.cc b/chrome/browser/chromeos/display/touch_calibrator/touch_calibrator_controller.cc |
| index 542cd271bf496cfca82c719ebe78c9e392bd2d79..1b95f2b35e264e88c98ad92c21ad3e17cbac5165 100644 |
| --- a/chrome/browser/chromeos/display/touch_calibrator/touch_calibrator_controller.cc |
| +++ b/chrome/browser/chromeos/display/touch_calibrator/touch_calibrator_controller.cc |
| @@ -7,6 +7,7 @@ |
| #include "ash/shell.h" |
| #include "ash/touch/ash_touch_transform_controller.h" |
| #include "base/memory/ptr_util.h" |
| +#include "base/threading/thread_task_runner_handle.h" |
| #include "chrome/browser/chromeos/display/touch_calibrator/touch_calibrator_view.h" |
| #include "ui/display/screen.h" |
| #include "ui/events/event.h" |
| @@ -33,8 +34,11 @@ void TouchCalibratorController::OnDisplayConfigurationChanged() { |
| } |
| void TouchCalibratorController::StartCalibration( |
| - const display::Display& target_display) { |
| + const display::Display& target_display, |
| + const TouchCalibratorController::TouchCalibrationCallback& callback) { |
| is_calibrating_ = true; |
| + callback_ = callback; |
| + |
| ash::Shell::GetInstance()->window_tree_host_manager()->AddObserver(this); |
| target_display_ = target_display; |
| @@ -64,6 +68,7 @@ void TouchCalibratorController::StopCalibration() { |
| if (!is_calibrating_) |
| return; |
| is_calibrating_ = false; |
| + |
| ash::Shell::GetInstance()->window_tree_host_manager()->RemoveObserver(this); |
| ash::Shell::GetInstance()->touch_transformer_controller()->SetForCalibration( |
| @@ -76,6 +81,8 @@ void TouchCalibratorController::StopCalibration() { |
| // exit. |
| for (const auto& it : touch_calibrator_views_) |
| it.second->SkipToFinalState(); |
| + |
| + callback_.Reset(); |
|
stevenjb
2017/01/19 17:19:01
Run callback_ with 'false' here instead of line 94
malaykeshav
2017/01/19 23:49:06
Done
|
| } |
| // ui::EventHandler: |
| @@ -83,8 +90,14 @@ void TouchCalibratorController::OnKeyEvent(ui::KeyEvent* key) { |
| if (!is_calibrating_) |
| return; |
| // Detect ESC key press. |
| - if (key->type() == ui::ET_KEY_PRESSED && key->key_code() == ui::VKEY_ESCAPE) |
| + if (key->type() == ui::ET_KEY_PRESSED && key->key_code() == ui::VKEY_ESCAPE) { |
| + if (callback_) { |
| + base::ThreadTaskRunnerHandle::Get()->PostTask( |
| + FROM_HERE, base::Bind(callback_, false)); |
| + callback_.Reset(); |
| + } |
| StopCalibration(); |
| + } |
| key->StopPropagation(); |
| } |
| @@ -104,6 +117,11 @@ void TouchCalibratorController::OnTouchEvent(ui::TouchEvent* touch) { |
| // calibration. |
| if (target_screen_calibration_view->state() == |
| TouchCalibratorView::CALIBRATION_COMPLETE) { |
| + if (callback_) { |
| + base::ThreadTaskRunnerHandle::Get()->PostTask( |
| + FROM_HERE, base::Bind(callback_, true)); |
| + callback_.Reset(); |
| + } |
| StopCalibration(); |
| ash::Shell::GetInstance()->display_manager()->SetTouchCalibrationData( |
| target_display_.id(), touch_point_quad_, |