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 #ifndef CHROME_BROWSER_EXTENSIONS_API_SIGNED_IN_DEVICES_ID_MAPPING_HELPER_H__ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_SIGNED_IN_DEVICES_ID_MAPPING_HELPER_H__ |
6 #define CHROME_BROWSER_EXTENSIONS_API_SIGNED_IN_DEVICES_ID_MAPPING_HELPER_H__ | 6 #define CHROME_BROWSER_EXTENSIONS_API_SIGNED_IN_DEVICES_ID_MAPPING_HELPER_H__ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 | 12 |
13 namespace base { | 13 namespace base { |
14 class DictionaryValue; | 14 class DictionaryValue; |
15 } // namespace base | 15 } // namespace base |
16 | 16 |
17 namespace sync_driver { | 17 namespace syncer { |
18 class DeviceInfo; | 18 class DeviceInfo; |
19 } // namespace sync_driver | 19 } // namespace syncer |
20 | 20 |
21 class Profile; | 21 class Profile; |
22 | 22 |
23 namespace extensions { | 23 namespace extensions { |
24 | 24 |
25 // In order to not expose unique GUIDs for devices to third pary apps, | 25 // In order to not expose unique GUIDs for devices to third pary apps, |
26 // the unique GUIDs are mapped to local ids and local ids are exposed to apps. | 26 // the unique GUIDs are mapped to local ids and local ids are exposed to apps. |
27 // The functions in this file are helper routines to do the mapping. | 27 // The functions in this file are helper routines to do the mapping. |
28 | 28 |
29 // Gets public id from GUID, given a dictionary that has the mapping. | 29 // Gets public id from GUID, given a dictionary that has the mapping. |
30 // If it cannot find the GUID the public id returned will be empty. | 30 // If it cannot find the GUID the public id returned will be empty. |
31 std::string GetPublicIdFromGUID( | 31 std::string GetPublicIdFromGUID( |
32 const base::DictionaryValue& id_mapping, | 32 const base::DictionaryValue& id_mapping, |
33 const std::string& guid); | 33 const std::string& guid); |
34 | 34 |
35 // Gets the GUID from public id given a dictionary that has the mapping. | 35 // Gets the GUID from public id given a dictionary that has the mapping. |
36 // If it cannot find the public id, the GUID returned will be empty. | 36 // If it cannot find the public id, the GUID returned will be empty. |
37 std::string GetGUIDFromPublicId( | 37 std::string GetGUIDFromPublicId( |
38 const base::DictionaryValue& id_mapping, | 38 const base::DictionaryValue& id_mapping, |
39 const std::string& id); | 39 const std::string& id); |
40 | 40 |
41 // Creates public id for devices that don't have a public id. To create mappings | 41 // Creates public id for devices that don't have a public id. To create mappings |
42 // from scratch an empty dictionary must be passed. The dictionary will be | 42 // from scratch an empty dictionary must be passed. The dictionary will be |
43 // updated with the mappings. The |device_info| objects will also be updated | 43 // updated with the mappings. The |device_info| objects will also be updated |
44 // with the public ids. | 44 // with the public ids. |
45 // The dictionary would have the public id as the key and the | 45 // The dictionary would have the public id as the key and the |
46 // device guid as the value. | 46 // device guid as the value. |
47 void CreateMappingForUnmappedDevices( | 47 void CreateMappingForUnmappedDevices( |
48 const std::vector<std::unique_ptr<sync_driver::DeviceInfo>>& device_info, | 48 const std::vector<std::unique_ptr<syncer::DeviceInfo>>& device_info, |
49 base::DictionaryValue* value); | 49 base::DictionaryValue* value); |
50 | 50 |
51 // Gets the device info for a given client id. If the device is not found | 51 // Gets the device info for a given client id. If the device is not found |
52 // the returned pointer would be null. | 52 // the returned pointer would be null. |
53 std::unique_ptr<sync_driver::DeviceInfo> GetDeviceInfoForClientId( | 53 std::unique_ptr<syncer::DeviceInfo> GetDeviceInfoForClientId( |
54 const std::string& client_id, | 54 const std::string& client_id, |
55 const std::string& extension_id, | 55 const std::string& extension_id, |
56 Profile* profile); | 56 Profile* profile); |
57 | 57 |
58 } // namespace extensions | 58 } // namespace extensions |
59 | 59 |
60 #endif // CHROME_BROWSER_EXTENSIONS_API_SIGNED_IN_DEVICES_ID_MAPPING_HELPER_H__ | 60 #endif // CHROME_BROWSER_EXTENSIONS_API_SIGNED_IN_DEVICES_ID_MAPPING_HELPER_H__ |
OLD | NEW |