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