Chromium Code Reviews| 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/signedin_devices/signedin_devices_api.h" | 5 #include "chrome/browser/extensions/api/signedin_devices/signedin_devices_api.h" |
| 6 | 6 |
| 7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
| 8 #include "base/memory/scoped_vector.h" | 8 #include "base/memory/scoped_vector.h" |
| 9 #include "base/values.h" | 9 #include "base/values.h" |
| 10 #include "chrome/browser/extensions/api/signedin_devices/id_mapping_helper.h" | 10 #include "chrome/browser/extensions/api/signedin_devices/id_mapping_helper.h" |
| 11 #include "chrome/browser/extensions/extension_prefs.h" | 11 #include "chrome/browser/extensions/extension_prefs.h" |
| 12 #include "chrome/browser/profiles/profile.h" | 12 #include "chrome/browser/profiles/profile.h" |
| 13 #include "chrome/browser/sync/glue/device_info.h" | 13 #include "chrome/browser/sync/glue/device_info.h" |
| 14 #include "chrome/browser/sync/profile_sync_service.h" | 14 #include "chrome/browser/sync/profile_sync_service.h" |
| 15 #include "chrome/browser/sync/profile_sync_service_factory.h" | 15 #include "chrome/browser/sync/profile_sync_service_factory.h" |
| 16 #include "chrome/common/extensions/api/signedin_devices.h" | |
| 16 | 17 |
| 17 using base::DictionaryValue; | 18 using base::DictionaryValue; |
| 18 using browser_sync::DeviceInfo; | 19 using browser_sync::DeviceInfo; |
| 19 | 20 |
| 20 namespace extensions { | 21 namespace extensions { |
| 21 | 22 |
| 22 static const char kPrefStringForIdMapping[] = "id_mapping_dictioanry"; | 23 static const char kPrefStringForIdMapping[] = "id_mapping_dictioanry"; |
| 23 | 24 |
| 24 // Gets the dictionary that stores the id mapping. The dictionary is stored | 25 // Gets the dictionary that stores the id mapping. The dictionary is stored |
| 25 // in the |ExtensionPrefs|. | 26 // in the |ExtensionPrefs|. |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 78 // Get the profile sync service and extension prefs pointers | 79 // Get the profile sync service and extension prefs pointers |
| 79 // and call the helper. | 80 // and call the helper. |
| 80 ProfileSyncService* pss = ProfileSyncServiceFactory::GetForProfile(profile); | 81 ProfileSyncService* pss = ProfileSyncServiceFactory::GetForProfile(profile); |
| 81 ExtensionPrefs* extension_prefs = ExtensionPrefs::Get(profile); | 82 ExtensionPrefs* extension_prefs = ExtensionPrefs::Get(profile); |
| 82 | 83 |
| 83 return GetAllSignedInDevices(extension_id, | 84 return GetAllSignedInDevices(extension_id, |
| 84 pss, | 85 pss, |
| 85 extension_prefs); | 86 extension_prefs); |
| 86 } | 87 } |
| 87 | 88 |
| 89 bool SignedinDevicesGetFunction::RunImpl() { | |
| 90 scoped_ptr<api::signedin_devices::Get::Params> params( | |
| 91 api::signedin_devices::Get::Params::Create(*args_)); | |
| 92 EXTENSION_FUNCTION_VALIDATE(params.get()); | |
| 93 | |
| 94 bool is_local = params->is_local.get() ? *params->is_local : false; | |
| 95 | |
| 96 if (is_local == true) { | |
|
Matt Perry
2013/08/12 22:21:01
don't compare to true/false. just if (is_local)
lipalani1
2013/08/13 22:42:37
Done.
| |
| 97 // TODO(lipalani): Set the device info for local device. | |
| 98 base::ListValue* result = new base::ListValue(); | |
| 99 SetResult(result); | |
| 100 return true; | |
| 101 } | |
| 102 | |
| 103 ScopedVector<DeviceInfo> devices = GetAllSignedInDevices(extension_id(), | |
| 104 profile()); | |
| 105 | |
| 106 scoped_ptr<base::ListValue> result(new base::ListValue()); | |
| 107 | |
| 108 for (ScopedVector<DeviceInfo>::const_iterator it = devices.begin(); | |
| 109 it != devices.end(); | |
| 110 ++it) { | |
| 111 result->Append((*it)->ToValue()); | |
| 112 } | |
| 113 | |
| 114 SetResult(result.release()); | |
| 115 return true; | |
| 116 } | |
| 117 | |
| 88 } // namespace extensions | 118 } // namespace extensions |
| 89 | 119 |
| OLD | NEW |