Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(438)

Side by Side Diff: extensions/browser/api/system_display/system_display_api.cc

Issue 2638903003: Updates touch calibration API and plumbs through the native touch calibration method (Closed)
Patch Set: Resolving Comments Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "extensions/browser/api/system_display/system_display_api.h" 5 #include "extensions/browser/api/system_display/system_display_api.h"
6 6
7 #include <map> 7 #include <map>
8 #include <memory> 8 #include <memory>
9 #include <set> 9 #include <set>
10 #include <string> 10 #include <string>
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 display::OverscanCalibrationComplete::Params::Create(*args_)); 260 display::OverscanCalibrationComplete::Params::Create(*args_));
261 if (!DisplayInfoProvider::Get()->OverscanCalibrationComplete(params->id)) { 261 if (!DisplayInfoProvider::Get()->OverscanCalibrationComplete(params->id)) {
262 return RespondNow( 262 return RespondNow(
263 Error("Calibration not started for display ID: " + params->id)); 263 Error("Calibration not started for display ID: " + params->id));
264 } 264 }
265 OverscanTracker::RemoveDisplay(GetSenderWebContents(), params->id); 265 OverscanTracker::RemoveDisplay(GetSenderWebContents(), params->id);
266 return RespondNow(NoArguments()); 266 return RespondNow(NoArguments());
267 } 267 }
268 268
269 ExtensionFunction::ResponseAction 269 ExtensionFunction::ResponseAction
270 SystemDisplayTouchCalibrationStartFunction::Run() { 270 SystemDisplayShowNativeTouchCalibrationFunction::Run() {
271 std::unique_ptr<display::TouchCalibrationStart::Params> params( 271 std::unique_ptr<display::ShowNativeTouchCalibration::Params> params(
272 display::TouchCalibrationStart::Params::Create(*args_)); 272 display::ShowNativeTouchCalibration::Params::Create(*args_));
273 273
274 std::string error; 274 std::string error;
275 if (DisplayInfoProvider::Get()->IsTouchCalibrationActive(&error)) 275 if (DisplayInfoProvider::Get()->IsNativeTouchCalibrationActive(&error))
276 return RespondNow(Error(error)); 276 return RespondNow(Error(error));
277 277
278 if (!DisplayInfoProvider::Get()->TouchCalibrationStart(params->id)) 278 if (!DisplayInfoProvider::Get()->ShowNativeTouchCalibration(
279 return RespondNow(Error("Invalid display ID: " + params->id)); 279 params->id, &error,
280 base::Bind(&SystemDisplayShowNativeTouchCalibrationFunction::
281 OnCalibrationComplete,
282 this))) {
283 return RespondNow(Error(error));
284 }
285 return RespondLater();
286 }
287
288 void SystemDisplayShowNativeTouchCalibrationFunction::OnCalibrationComplete(
289 bool success) {
290 Respond(OneArgument(base::MakeUnique<base::FundamentalValue>(success)));
291 }
292
293 ExtensionFunction::ResponseAction
294 SystemDisplayStartCustomTouchCalibrationFunction::Run() {
295 std::unique_ptr<display::StartCustomTouchCalibration::Params> params(
296 display::StartCustomTouchCalibration::Params::Create(*args_));
297
298 std::string error;
299 if (DisplayInfoProvider::Get()->IsNativeTouchCalibrationActive(&error))
300 return RespondNow(Error(error));
301
302 if (!DisplayInfoProvider::Get()->StartCustomTouchCalibration(params->id,
303 &error))
304 return RespondNow(Error(error));
280 return RespondNow(NoArguments()); 305 return RespondNow(NoArguments());
281 } 306 }
282 307
283 ExtensionFunction::ResponseAction 308 ExtensionFunction::ResponseAction
284 SystemDisplayTouchCalibrationSetFunction::Run() { 309 SystemDisplayCompleteCustomTouchCalibrationFunction::Run() {
285 std::unique_ptr<display::TouchCalibrationSet::Params> params( 310 std::unique_ptr<display::CompleteCustomTouchCalibration::Params> params(
286 display::TouchCalibrationSet::Params::Create(*args_)); 311 display::CompleteCustomTouchCalibration::Params::Create(*args_));
287 312
288 std::string error; 313 std::string error;
289 if (DisplayInfoProvider::Get()->IsTouchCalibrationActive(&error)) 314 if (DisplayInfoProvider::Get()->IsNativeTouchCalibrationActive(&error))
290 return RespondNow(Error(error)); 315 return RespondNow(Error(error));
291 316
292 if (!DisplayInfoProvider::Get()->TouchCalibrationSet( 317 if (!DisplayInfoProvider::Get()->CompleteCustomTouchCalibration(
293 params->id, params->pairs, params->bounds, &error)) { 318 params->pairs, params->bounds, &error)) {
294 return RespondNow(Error(error)); 319 return RespondNow(Error(error));
295 } 320 }
296 return RespondNow(NoArguments()); 321 return RespondNow(NoArguments());
297 } 322 }
298 323
299 ExtensionFunction::ResponseAction 324 ExtensionFunction::ResponseAction
300 SystemDisplayTouchCalibrationResetFunction::Run() { 325 SystemDisplayResetTouchCalibrationFunction::Run() {
301 std::unique_ptr<display::TouchCalibrationReset::Params> params( 326 std::unique_ptr<display::ResetTouchCalibration::Params> params(
302 display::TouchCalibrationReset::Params::Create(*args_)); 327 display::ResetTouchCalibration::Params::Create(*args_));
303 328
304 std::string error; 329 std::string error;
305 if (DisplayInfoProvider::Get()->IsTouchCalibrationActive(&error)) 330 if (DisplayInfoProvider::Get()->IsNativeTouchCalibrationActive(&error))
306 return RespondNow(Error(error)); 331 return RespondNow(Error(error));
307 332
308 if (!DisplayInfoProvider::Get()->TouchCalibrationReset(params->id, &error)) 333 if (!DisplayInfoProvider::Get()->ResetTouchCalibration(params->id, &error))
309 return RespondNow(Error(error)); 334 return RespondNow(Error(error));
310 return RespondNow(NoArguments()); 335 return RespondNow(NoArguments());
311 } 336 }
312 337
313 } // namespace extensions 338 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698