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 <memory> |
| 8 |
8 #include "base/memory/scoped_vector.h" | 9 #include "base/memory/scoped_vector.h" |
9 #include "base/rand_util.h" | 10 #include "base/rand_util.h" |
10 #include "base/strings/string_number_conversions.h" | 11 #include "base/strings/string_number_conversions.h" |
11 #include "base/values.h" | 12 #include "base/values.h" |
12 #include "chrome/browser/extensions/api/signed_in_devices/signed_in_devices_api.
h" | 13 #include "chrome/browser/extensions/api/signed_in_devices/signed_in_devices_api.
h" |
13 #include "chrome/browser/profiles/profile.h" | 14 #include "chrome/browser/profiles/profile.h" |
14 #include "components/crx_file/id_util.h" | 15 #include "components/crx_file/id_util.h" |
15 #include "components/sync_driver/device_info.h" | 16 #include "components/sync_driver/device_info.h" |
16 | 17 |
17 using base::DictionaryValue; | 18 using base::DictionaryValue; |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 | 78 |
78 // If the device does not have a local id, set one. | 79 // If the device does not have a local id, set one. |
79 if (local_id.empty()) { | 80 if (local_id.empty()) { |
80 local_id = GetRandomId(*value, device_info->size()); | 81 local_id = GetRandomId(*value, device_info->size()); |
81 value->SetString(local_id, device->guid()); | 82 value->SetString(local_id, device->guid()); |
82 } | 83 } |
83 device->set_public_id(local_id); | 84 device->set_public_id(local_id); |
84 } | 85 } |
85 } | 86 } |
86 | 87 |
87 scoped_ptr<DeviceInfo> GetDeviceInfoForClientId( | 88 std::unique_ptr<DeviceInfo> GetDeviceInfoForClientId( |
88 const std::string& client_id, | 89 const std::string& client_id, |
89 const std::string& extension_id, | 90 const std::string& extension_id, |
90 Profile* profile) { | 91 Profile* profile) { |
91 DCHECK(crx_file::id_util::IdIsValid(extension_id)) << extension_id | 92 DCHECK(crx_file::id_util::IdIsValid(extension_id)) << extension_id |
92 << " is not valid"; | 93 << " is not valid"; |
93 ScopedVector<DeviceInfo> devices = GetAllSignedInDevices(extension_id, | 94 ScopedVector<DeviceInfo> devices = GetAllSignedInDevices(extension_id, |
94 profile); | 95 profile); |
95 for (ScopedVector<DeviceInfo>::iterator it = devices.begin(); | 96 for (ScopedVector<DeviceInfo>::iterator it = devices.begin(); |
96 it != devices.end(); | 97 it != devices.end(); |
97 ++it) { | 98 ++it) { |
98 if ((*it)->guid() == client_id) { | 99 if ((*it)->guid() == client_id) { |
99 scoped_ptr<DeviceInfo> device(*it); | 100 std::unique_ptr<DeviceInfo> device(*it); |
100 devices.weak_erase(it); | 101 devices.weak_erase(it); |
101 return device; | 102 return device; |
102 } | 103 } |
103 } | 104 } |
104 return scoped_ptr<DeviceInfo>(); | 105 return std::unique_ptr<DeviceInfo>(); |
105 } | 106 } |
106 | 107 |
107 } // namespace extensions | 108 } // namespace extensions |
OLD | NEW |