| Index: chrome/browser/extensions/api/signedin_devices/signedin_devices_api.cc
|
| diff --git a/chrome/browser/extensions/api/signedin_devices/signedin_devices_api.cc b/chrome/browser/extensions/api/signedin_devices/signedin_devices_api.cc
|
| index 47a132b87126f615d2428d66e3b525766df06d7b..513895991b4db9d4e3791e3095e1c1a5b9ab543f 100644
|
| --- a/chrome/browser/extensions/api/signedin_devices/signedin_devices_api.cc
|
| +++ b/chrome/browser/extensions/api/signedin_devices/signedin_devices_api.cc
|
| @@ -13,6 +13,7 @@
|
| #include "chrome/browser/sync/glue/device_info.h"
|
| #include "chrome/browser/sync/profile_sync_service.h"
|
| #include "chrome/browser/sync/profile_sync_service_factory.h"
|
| +#include "chrome/common/extensions/api/signedin_devices.h"
|
|
|
| using base::DictionaryValue;
|
| using browser_sync::DeviceInfo;
|
| @@ -47,11 +48,11 @@ const base::DictionaryValue* GetIdMappingDictionary(
|
| // Helper routine to get all signed in devices. The helper takes in
|
| // the pointers for |ProfileSyncService| and |Extensionprefs|. This
|
| // makes it easier to test by passing mock values for these pointers.
|
| -ScopedVector<DeviceInfo> GetAllSignedInDevices(
|
| +ScopedVector<DeviceInfo> GetAllSignedinDevices(
|
| const std::string& extension_id,
|
| ProfileSyncService* pss,
|
| ExtensionPrefs* extension_prefs) {
|
| - ScopedVector<DeviceInfo> devices = pss->GetAllSignedInDevices();
|
| + ScopedVector<DeviceInfo> devices = pss->GetAllSignedinDevices();
|
| const DictionaryValue* mapping_dictionary = GetIdMappingDictionary(
|
| extension_prefs,
|
| extension_id);
|
| @@ -72,7 +73,7 @@ ScopedVector<DeviceInfo> GetAllSignedInDevices(
|
| return devices.Pass();
|
| }
|
|
|
| -ScopedVector<DeviceInfo> GetAllSignedInDevices(
|
| +ScopedVector<DeviceInfo> GetAllSignedinDevices(
|
| const std::string& extension_id,
|
| Profile* profile) {
|
| // Get the profile sync service and extension prefs pointers
|
| @@ -80,10 +81,39 @@ ScopedVector<DeviceInfo> GetAllSignedInDevices(
|
| ProfileSyncService* pss = ProfileSyncServiceFactory::GetForProfile(profile);
|
| ExtensionPrefs* extension_prefs = ExtensionPrefs::Get(profile);
|
|
|
| - return GetAllSignedInDevices(extension_id,
|
| + return GetAllSignedinDevices(extension_id,
|
| pss,
|
| extension_prefs);
|
| }
|
|
|
| +bool SignedinDevicesGetFunction::RunImpl() {
|
| + scoped_ptr<api::signedin_devices::Get::Params> params(
|
| + api::signedin_devices::Get::Params::Create(*args_));
|
| + EXTENSION_FUNCTION_VALIDATE(params.get());
|
| +
|
| + bool is_local = params->is_local.get() ? *params->is_local : false;
|
| +
|
| + if (is_local) {
|
| + // TODO(lipalani): Set the device info for local device.
|
| + base::ListValue* result = new base::ListValue();
|
| + SetResult(result);
|
| + return true;
|
| + }
|
| +
|
| + ScopedVector<DeviceInfo> devices = GetAllSignedinDevices(extension_id(),
|
| + profile());
|
| +
|
| + scoped_ptr<base::ListValue> result(new base::ListValue());
|
| +
|
| + for (ScopedVector<DeviceInfo>::const_iterator it = devices.begin();
|
| + it != devices.end();
|
| + ++it) {
|
| + result->Append((*it)->ToValue());
|
| + }
|
| +
|
| + SetResult(result.release());
|
| + return true;
|
| +}
|
| +
|
| } // namespace extensions
|
|
|
|
|