| 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/id_mapping_helper.h" | 5 #include "chrome/browser/extensions/api/signed_in_devices/id_mapping_helper.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/rand_util.h" | 9 #include "base/rand_util.h" |
| 10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
| 11 #include "base/values.h" | 11 #include "base/values.h" |
| 12 #include "chrome/browser/extensions/api/signed_in_devices/signed_in_devices_api.
h" | 12 #include "chrome/browser/extensions/api/signed_in_devices/signed_in_devices_api.
h" |
| 13 #include "chrome/browser/profiles/profile.h" | 13 #include "chrome/browser/profiles/profile.h" |
| 14 #include "chrome/browser/sync/glue/device_info.h" | 14 #include "chrome/browser/sync/glue/device_info.h" |
| 15 #include "extensions/common/extension.h" | 15 #include "components/crx_file/id_util.h" |
| 16 | 16 |
| 17 using base::DictionaryValue; | 17 using base::DictionaryValue; |
| 18 using base::Value; | 18 using base::Value; |
| 19 using browser_sync::DeviceInfo; | 19 using browser_sync::DeviceInfo; |
| 20 | 20 |
| 21 namespace extensions { | 21 namespace extensions { |
| 22 | 22 |
| 23 std::string GetPublicIdFromGUID( | 23 std::string GetPublicIdFromGUID( |
| 24 const base::DictionaryValue& id_mapping, | 24 const base::DictionaryValue& id_mapping, |
| 25 const std::string& guid) { | 25 const std::string& guid) { |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 value->SetString(local_id, device->guid()); | 81 value->SetString(local_id, device->guid()); |
| 82 } | 82 } |
| 83 device->set_public_id(local_id); | 83 device->set_public_id(local_id); |
| 84 } | 84 } |
| 85 } | 85 } |
| 86 | 86 |
| 87 scoped_ptr<DeviceInfo> GetDeviceInfoForClientId( | 87 scoped_ptr<DeviceInfo> GetDeviceInfoForClientId( |
| 88 const std::string& client_id, | 88 const std::string& client_id, |
| 89 const std::string& extension_id, | 89 const std::string& extension_id, |
| 90 Profile* profile) { | 90 Profile* profile) { |
| 91 DCHECK(Extension::IdIsValid(extension_id)) << extension_id | 91 DCHECK(crx_file::id_util::IdIsValid(extension_id)) << extension_id |
| 92 << " is not valid"; | 92 << " is not valid"; |
| 93 ScopedVector<DeviceInfo> devices = GetAllSignedInDevices(extension_id, | 93 ScopedVector<DeviceInfo> devices = GetAllSignedInDevices(extension_id, |
| 94 profile); | 94 profile); |
| 95 for (ScopedVector<DeviceInfo>::iterator it = devices.begin(); | 95 for (ScopedVector<DeviceInfo>::iterator it = devices.begin(); |
| 96 it != devices.end(); | 96 it != devices.end(); |
| 97 ++it) { | 97 ++it) { |
| 98 if ((*it)->guid() == client_id) { | 98 if ((*it)->guid() == client_id) { |
| 99 scoped_ptr<DeviceInfo> device(*it); | 99 scoped_ptr<DeviceInfo> device(*it); |
| 100 devices.weak_erase(it); | 100 devices.weak_erase(it); |
| 101 return device.Pass(); | 101 return device.Pass(); |
| 102 } | 102 } |
| 103 } | 103 } |
| 104 return scoped_ptr<DeviceInfo>(); | 104 return scoped_ptr<DeviceInfo>(); |
| 105 } | 105 } |
| 106 | 106 |
| 107 } // namespace extensions | 107 } // namespace extensions |
| OLD | NEW |