OLD | NEW |
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 <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
(...skipping 549 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
560 EasyUnlockPrivateSetRemoteDevicesFunction:: | 560 EasyUnlockPrivateSetRemoteDevicesFunction:: |
561 ~EasyUnlockPrivateSetRemoteDevicesFunction() { | 561 ~EasyUnlockPrivateSetRemoteDevicesFunction() { |
562 } | 562 } |
563 | 563 |
564 bool EasyUnlockPrivateSetRemoteDevicesFunction::RunSync() { | 564 bool EasyUnlockPrivateSetRemoteDevicesFunction::RunSync() { |
565 scoped_ptr<easy_unlock_private::SetRemoteDevices::Params> params( | 565 scoped_ptr<easy_unlock_private::SetRemoteDevices::Params> params( |
566 easy_unlock_private::SetRemoteDevices::Params::Create(*args_)); | 566 easy_unlock_private::SetRemoteDevices::Params::Create(*args_)); |
567 EXTENSION_FUNCTION_VALIDATE(params.get()); | 567 EXTENSION_FUNCTION_VALIDATE(params.get()); |
568 | 568 |
569 Profile* profile = Profile::FromBrowserContext(browser_context()); | 569 Profile* profile = Profile::FromBrowserContext(browser_context()); |
570 base::ListValue devices; | 570 if (params->devices.empty()) { |
571 for (size_t i = 0; i < params->devices.size(); ++i) { | 571 EasyUnlockService::Get(profile)->ClearRemoteDevices(); |
572 devices.Append(params->devices[i]->ToValue().release()); | 572 } else { |
| 573 base::ListValue devices; |
| 574 for (size_t i = 0; i < params->devices.size(); ++i) { |
| 575 devices.Append(params->devices[i]->ToValue().release()); |
| 576 } |
| 577 EasyUnlockService::Get(profile)->SetRemoteDevices(devices); |
573 } | 578 } |
574 EasyUnlockService::Get(profile)->SetRemoteDevices(devices); | |
575 | 579 |
576 return true; | 580 return true; |
577 } | 581 } |
578 | 582 |
579 EasyUnlockPrivateGetRemoteDevicesFunction:: | 583 EasyUnlockPrivateGetRemoteDevicesFunction:: |
580 EasyUnlockPrivateGetRemoteDevicesFunction() { | 584 EasyUnlockPrivateGetRemoteDevicesFunction() { |
581 } | 585 } |
582 | 586 |
583 EasyUnlockPrivateGetRemoteDevicesFunction:: | 587 EasyUnlockPrivateGetRemoteDevicesFunction:: |
584 ~EasyUnlockPrivateGetRemoteDevicesFunction() { | 588 ~EasyUnlockPrivateGetRemoteDevicesFunction() { |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
706 // TODO(tengs): Find a way to get the profile picture for non-ChromeOS | 710 // TODO(tengs): Find a way to get the profile picture for non-ChromeOS |
707 // devices. | 711 // devices. |
708 results_ = easy_unlock_private::GetUserImage::Results::Create(""); | 712 results_ = easy_unlock_private::GetUserImage::Results::Create(""); |
709 SetError("Not supported on non-ChromeOS platforms."); | 713 SetError("Not supported on non-ChromeOS platforms."); |
710 #endif | 714 #endif |
711 return true; | 715 return true; |
712 } | 716 } |
713 | 717 |
714 } // namespace api | 718 } // namespace api |
715 } // namespace extensions | 719 } // namespace extensions |
OLD | NEW |