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

Side by Side Diff: chrome/browser/extensions/api/easy_unlock_private/easy_unlock_private_api.cc

Issue 475483003: Wire easy unlock settings UI (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 4 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "chrome/browser/extensions/api/easy_unlock_private/easy_unlock_private_ api.h" 5 #include "chrome/browser/extensions/api/easy_unlock_private/easy_unlock_private_ api.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/lazy_instance.h" 8 #include "base/lazy_instance.h"
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "base/values.h" 10 #include "base/values.h"
(...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after
417 if (screenlock_state_handler) { 417 if (screenlock_state_handler) {
418 screenlock_state_handler->ChangeState( 418 screenlock_state_handler->ChangeState(
419 ToScreenlockStateHandlerState(params->state)); 419 ToScreenlockStateHandlerState(params->state));
420 return true; 420 return true;
421 } 421 }
422 422
423 SetError("Not allowed"); 423 SetError("Not allowed");
424 return false; 424 return false;
425 } 425 }
426 426
427 EasyUnlockPrivateSetPermitAccessFunction::
428 EasyUnlockPrivateSetPermitAccessFunction() {
429 }
430
431 EasyUnlockPrivateSetPermitAccessFunction::
432 ~EasyUnlockPrivateSetPermitAccessFunction() {
433 }
434
435 bool EasyUnlockPrivateSetPermitAccessFunction::RunSync() {
436 scoped_ptr<easy_unlock_private::SetPermitAccess::Params> params(
437 easy_unlock_private::SetPermitAccess::Params::Create(*args_));
438 EXTENSION_FUNCTION_VALIDATE(params.get());
439
440 Profile* profile = Profile::FromBrowserContext(browser_context());
441 EasyUnlockService::Get(profile)
442 ->SetPermitAccess(*params->permit_access.ToValue());
443
444 return true;
445 }
446
447 EasyUnlockPrivateGetPermitAccessFunction::
448 EasyUnlockPrivateGetPermitAccessFunction() {
449 }
450
451 EasyUnlockPrivateGetPermitAccessFunction::
452 ~EasyUnlockPrivateGetPermitAccessFunction() {
453 }
454
455 bool EasyUnlockPrivateGetPermitAccessFunction::RunSync() {
456 Profile* profile = Profile::FromBrowserContext(browser_context());
457 const base::DictionaryValue* permit_value =
458 EasyUnlockService::Get(profile)->GetPermitAccess();
459 if (permit_value) {
460 scoped_ptr<easy_unlock_private::PermitRecord> permit =
461 easy_unlock_private::PermitRecord::FromValue(*permit_value);
462 results_ = easy_unlock_private::GetPermitAccess::Results::Create(*permit);
463 }
464
465 return true;
466 }
467
468 EasyUnlockPrivateClearPermitAccessFunction::
469 EasyUnlockPrivateClearPermitAccessFunction() {
470 }
471
472 EasyUnlockPrivateClearPermitAccessFunction::
473 ~EasyUnlockPrivateClearPermitAccessFunction() {
474 }
475
476 bool EasyUnlockPrivateClearPermitAccessFunction::RunSync() {
477 Profile* profile = Profile::FromBrowserContext(browser_context());
478 EasyUnlockService::Get(profile)->ClearPermitAccess();
479 return true;
480 }
481
482 EasyUnlockPrivateSetRemoteDevicesFunction::
483 EasyUnlockPrivateSetRemoteDevicesFunction() {
484 }
485
486 EasyUnlockPrivateSetRemoteDevicesFunction::
487 ~EasyUnlockPrivateSetRemoteDevicesFunction() {
488 }
489
490 bool EasyUnlockPrivateSetRemoteDevicesFunction::RunSync() {
491 scoped_ptr<easy_unlock_private::SetRemoteDevices::Params> params(
492 easy_unlock_private::SetRemoteDevices::Params::Create(*args_));
493 EXTENSION_FUNCTION_VALIDATE(params.get());
494
495 Profile* profile = Profile::FromBrowserContext(browser_context());
496 if (params->devices.empty()) {
497 EasyUnlockService::Get(profile)->ClearRemoteDevices();
498 } else {
499 base::ListValue devices;
500 for (size_t i = 0; i < params->devices.size(); ++i) {
501 devices.Append(params->devices[i]->ToValue().release());
502 }
503 EasyUnlockService::Get(profile)->SetRemoteDevices(devices);
504 }
505
506 return true;
507 }
508
509 EasyUnlockPrivateGetRemoteDevicesFunction::
510 EasyUnlockPrivateGetRemoteDevicesFunction() {
511 }
512
513 EasyUnlockPrivateGetRemoteDevicesFunction::
514 ~EasyUnlockPrivateGetRemoteDevicesFunction() {
515 }
516
517 bool EasyUnlockPrivateGetRemoteDevicesFunction::RunSync() {
518 Profile* profile = Profile::FromBrowserContext(browser_context());
519 const base::ListValue* devices =
520 EasyUnlockService::Get(profile)->GetRemoteDevices();
521 SetResult(devices ? devices->DeepCopy() : new base::ListValue());
522 return true;
523 }
524
427 } // namespace api 525 } // namespace api
428 } // namespace extensions 526 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698