| 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 "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/signed_in_devices/id_mapping_helper.h" | 10 #include "chrome/browser/extensions/api/signed_in_devices/id_mapping_helper.h" |
| 11 #include "chrome/browser/profiles/profile.h" | 11 #include "chrome/browser/profiles/profile.h" |
| 12 #include "chrome/browser/sync/glue/device_info.h" | 12 #include "chrome/browser/sync/glue/device_info.h" |
| 13 #include "chrome/browser/sync/glue/local_device_info_provider.h" | |
| 14 #include "chrome/browser/sync/profile_sync_service.h" | 13 #include "chrome/browser/sync/profile_sync_service.h" |
| 15 #include "chrome/browser/sync/profile_sync_service_factory.h" | 14 #include "chrome/browser/sync/profile_sync_service_factory.h" |
| 16 #include "chrome/common/extensions/api/signed_in_devices.h" | 15 #include "chrome/common/extensions/api/signed_in_devices.h" |
| 17 #include "extensions/browser/extension_prefs.h" | 16 #include "extensions/browser/extension_prefs.h" |
| 18 | 17 |
| 19 using base::DictionaryValue; | 18 using base::DictionaryValue; |
| 20 using browser_sync::DeviceInfo; | 19 using browser_sync::DeviceInfo; |
| 21 using browser_sync::LocalDeviceInfoProvider; | |
| 22 | 20 |
| 23 namespace extensions { | 21 namespace extensions { |
| 24 | 22 |
| 25 static const char kPrefStringForIdMapping[] = "id_mapping_dictioanry"; | 23 static const char kPrefStringForIdMapping[] = "id_mapping_dictioanry"; |
| 26 | 24 |
| 27 // 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 |
| 28 // in the |ExtensionPrefs|. | 26 // in the |ExtensionPrefs|. |
| 29 const base::DictionaryValue* GetIdMappingDictionary( | 27 const base::DictionaryValue* GetIdMappingDictionary( |
| 30 ExtensionPrefs* extension_prefs, | 28 ExtensionPrefs* extension_prefs, |
| 31 const std::string& extension_id) { | 29 const std::string& extension_id) { |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 pss, | 85 pss, |
| 88 extension_prefs); | 86 extension_prefs); |
| 89 } | 87 } |
| 90 | 88 |
| 91 scoped_ptr<DeviceInfo> GetLocalDeviceInfo(const std::string& extension_id, | 89 scoped_ptr<DeviceInfo> GetLocalDeviceInfo(const std::string& extension_id, |
| 92 Profile* profile) { | 90 Profile* profile) { |
| 93 ProfileSyncService* pss = ProfileSyncServiceFactory::GetForProfile(profile); | 91 ProfileSyncService* pss = ProfileSyncServiceFactory::GetForProfile(profile); |
| 94 if (!pss) { | 92 if (!pss) { |
| 95 return scoped_ptr<DeviceInfo>(); | 93 return scoped_ptr<DeviceInfo>(); |
| 96 } | 94 } |
| 97 | 95 std::string guid = pss->GetLocalSyncCacheGUID(); |
| 98 LocalDeviceInfoProvider* local_device = pss->GetLocalDeviceInfoProvider(); | |
| 99 DCHECK(local_device); | |
| 100 std::string guid = local_device->GetLocalSyncCacheGUID(); | |
| 101 scoped_ptr<DeviceInfo> device = GetDeviceInfoForClientId(guid, | 96 scoped_ptr<DeviceInfo> device = GetDeviceInfoForClientId(guid, |
| 102 extension_id, | 97 extension_id, |
| 103 profile); | 98 profile); |
| 104 return device.Pass(); | 99 return device.Pass(); |
| 105 } | 100 } |
| 106 | 101 |
| 107 bool SignedInDevicesGetFunction::RunSync() { | 102 bool SignedInDevicesGetFunction::RunSync() { |
| 108 scoped_ptr<api::signed_in_devices::Get::Params> params( | 103 scoped_ptr<api::signed_in_devices::Get::Params> params( |
| 109 api::signed_in_devices::Get::Params::Create(*args_)); | 104 api::signed_in_devices::Get::Params::Create(*args_)); |
| 110 EXTENSION_FUNCTION_VALIDATE(params.get()); | 105 EXTENSION_FUNCTION_VALIDATE(params.get()); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 132 ++it) { | 127 ++it) { |
| 133 result->Append((*it)->ToValue()); | 128 result->Append((*it)->ToValue()); |
| 134 } | 129 } |
| 135 | 130 |
| 136 SetResult(result.release()); | 131 SetResult(result.release()); |
| 137 return true; | 132 return true; |
| 138 } | 133 } |
| 139 | 134 |
| 140 } // namespace extensions | 135 } // namespace extensions |
| 141 | 136 |
| OLD | NEW |