| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 "chrome/browser/extensions/api/signed_in_devices/signed_in_devices_api.
h" | 5 #include "chrome/browser/extensions/api/signed_in_devices/signed_in_devices_api.
h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include <utility> |
| 8 | 9 |
| 9 #include "base/memory/scoped_vector.h" | 10 #include "base/memory/scoped_vector.h" |
| 10 #include "base/values.h" | 11 #include "base/values.h" |
| 11 #include "chrome/browser/extensions/api/signed_in_devices/id_mapping_helper.h" | 12 #include "chrome/browser/extensions/api/signed_in_devices/id_mapping_helper.h" |
| 12 #include "chrome/browser/profiles/profile.h" | 13 #include "chrome/browser/profiles/profile.h" |
| 13 #include "chrome/browser/sync/profile_sync_service_factory.h" | 14 #include "chrome/browser/sync/profile_sync_service_factory.h" |
| 14 #include "chrome/common/extensions/api/signed_in_devices.h" | 15 #include "chrome/common/extensions/api/signed_in_devices.h" |
| 15 #include "components/browser_sync/browser/profile_sync_service.h" | 16 #include "components/browser_sync/browser/profile_sync_service.h" |
| 16 #include "components/sync_driver/device_info_tracker.h" | 17 #include "components/sync_driver/device_info_tracker.h" |
| 17 #include "components/sync_driver/local_device_info_provider.h" | 18 #include "components/sync_driver/local_device_info_provider.h" |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 bool SignedInDevicesGetFunction::RunSync() { | 116 bool SignedInDevicesGetFunction::RunSync() { |
| 116 std::unique_ptr<api::signed_in_devices::Get::Params> params( | 117 std::unique_ptr<api::signed_in_devices::Get::Params> params( |
| 117 api::signed_in_devices::Get::Params::Create(*args_)); | 118 api::signed_in_devices::Get::Params::Create(*args_)); |
| 118 EXTENSION_FUNCTION_VALIDATE(params.get()); | 119 EXTENSION_FUNCTION_VALIDATE(params.get()); |
| 119 | 120 |
| 120 bool is_local = params->is_local.get() ? *params->is_local : false; | 121 bool is_local = params->is_local.get() ? *params->is_local : false; |
| 121 | 122 |
| 122 if (is_local) { | 123 if (is_local) { |
| 123 std::unique_ptr<DeviceInfo> device = | 124 std::unique_ptr<DeviceInfo> device = |
| 124 GetLocalDeviceInfo(extension_id(), GetProfile()); | 125 GetLocalDeviceInfo(extension_id(), GetProfile()); |
| 125 base::ListValue* result = new base::ListValue(); | 126 std::unique_ptr<base::ListValue> result(new base::ListValue()); |
| 126 if (device.get()) { | 127 if (device.get()) { |
| 127 result->Append(device->ToValue()); | 128 result->Append(device->ToValue()); |
| 128 } | 129 } |
| 129 SetResult(result); | 130 SetResult(std::move(result)); |
| 130 return true; | 131 return true; |
| 131 } | 132 } |
| 132 | 133 |
| 133 ScopedVector<DeviceInfo> devices = | 134 ScopedVector<DeviceInfo> devices = |
| 134 GetAllSignedInDevices(extension_id(), GetProfile()); | 135 GetAllSignedInDevices(extension_id(), GetProfile()); |
| 135 | 136 |
| 136 std::unique_ptr<base::ListValue> result(new base::ListValue()); | 137 std::unique_ptr<base::ListValue> result(new base::ListValue()); |
| 137 | 138 |
| 138 for (ScopedVector<DeviceInfo>::const_iterator it = devices.begin(); | 139 for (ScopedVector<DeviceInfo>::const_iterator it = devices.begin(); |
| 139 it != devices.end(); | 140 it != devices.end(); |
| 140 ++it) { | 141 ++it) { |
| 141 result->Append((*it)->ToValue()); | 142 result->Append((*it)->ToValue()); |
| 142 } | 143 } |
| 143 | 144 |
| 144 SetResult(result.release()); | 145 SetResult(std::move(result)); |
| 145 return true; | 146 return true; |
| 146 } | 147 } |
| 147 | 148 |
| 148 } // namespace extensions | 149 } // namespace extensions |
| 149 | 150 |
| OLD | NEW |