| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_SYNC_GLUE_DEVICE_INFO_H_ | 5 #ifndef CHROME_BROWSER_SYNC_GLUE_DEVICE_INFO_H_ |
| 6 #define CHROME_BROWSER_SYNC_GLUE_DEVICE_INFO_H_ | 6 #define CHROME_BROWSER_SYNC_GLUE_DEVICE_INFO_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 | 21 |
| 22 namespace browser_sync { | 22 namespace browser_sync { |
| 23 | 23 |
| 24 // A class that holds information regarding the properties of a device. | 24 // A class that holds information regarding the properties of a device. |
| 25 class DeviceInfo { | 25 class DeviceInfo { |
| 26 public: | 26 public: |
| 27 DeviceInfo(const std::string& guid, | 27 DeviceInfo(const std::string& guid, |
| 28 const std::string& client_name, | 28 const std::string& client_name, |
| 29 const std::string& chrome_version, | 29 const std::string& chrome_version, |
| 30 const std::string& sync_user_agent, | 30 const std::string& sync_user_agent, |
| 31 const sync_pb::SyncEnums::DeviceType device_type, | 31 const sync_pb::SyncEnums::DeviceType device_type); |
| 32 const std::string& signin_scoped_device_id); | |
| 33 ~DeviceInfo(); | 32 ~DeviceInfo(); |
| 34 | 33 |
| 35 // Sync specific unique identifier for the device. Note if a device | 34 // Sync specific unique identifier for the device. Note if a device |
| 36 // is wiped and sync is set up again this id WILL be different. | 35 // is wiped and sync is set up again this id WILL be different. |
| 37 // The same device might have more than 1 guid if the device has multiple | 36 // The same device might have more than 1 guid if the device has multiple |
| 38 // accounts syncing. | 37 // accounts syncing. |
| 39 const std::string& guid() const; | 38 const std::string& guid() const; |
| 40 | 39 |
| 41 // The host name for the client. | 40 // The host name for the client. |
| 42 const std::string& client_name() const; | 41 const std::string& client_name() const; |
| 43 | 42 |
| 44 // Chrome version string. | 43 // Chrome version string. |
| 45 const std::string& chrome_version() const; | 44 const std::string& chrome_version() const; |
| 46 | 45 |
| 47 // The user agent is the combination of OS type, chrome version and which | 46 // The user agent is the combination of OS type, chrome version and which |
| 48 // channel of chrome(stable or beta). For more information see | 47 // channel of chrome(stable or beta). For more information see |
| 49 // |DeviceInfo::MakeUserAgentForSyncApi|. | 48 // |DeviceInfo::MakeUserAgentForSyncApi|. |
| 50 const std::string& sync_user_agent() const; | 49 const std::string& sync_user_agent() const; |
| 51 | 50 |
| 52 // Third party visible id for the device. See |public_id_| for more details. | 51 // Third party visible id for the device. See |public_id_| for more details. |
| 53 const std::string& public_id() const; | 52 const std::string& public_id() const; |
| 54 | 53 |
| 55 // Device Type. | 54 // Device Type. |
| 56 sync_pb::SyncEnums::DeviceType device_type() const; | 55 sync_pb::SyncEnums::DeviceType device_type() const; |
| 57 | 56 |
| 58 // Device_id that is stable until user signs out. This device_id is used for | |
| 59 // annotating login scoped refresh token. | |
| 60 const std::string& signin_scoped_device_id() const; | |
| 61 | |
| 62 // Gets the OS in string form. | 57 // Gets the OS in string form. |
| 63 std::string GetOSString() const; | 58 std::string GetOSString() const; |
| 64 | 59 |
| 65 // Gets the device type in string form. | 60 // Gets the device type in string form. |
| 66 std::string GetDeviceTypeString() const; | 61 std::string GetDeviceTypeString() const; |
| 67 | 62 |
| 68 // Compares this object's fields with another's. | 63 // Compares this object's fields with another's. |
| 69 bool Equals(const DeviceInfo& other) const; | 64 bool Equals(const DeviceInfo& other) const; |
| 70 | 65 |
| 71 // Apps can set ids for a device that is meaningful to them but | 66 // Apps can set ids for a device that is meaningful to them but |
| 72 // not unique enough so the user can be tracked. Exposing |guid| | 67 // not unique enough so the user can be tracked. Exposing |guid| |
| 73 // would lead to a stable unique id for a device which can potentially | 68 // would lead to a stable unique id for a device which can potentially |
| 74 // be used for tracking. | 69 // be used for tracking. |
| 75 void set_public_id(std::string id); | 70 void set_public_id(std::string id); |
| 76 | 71 |
| 77 // Converts the |DeviceInfo| values to a JS friendly DictionaryValue, | 72 // Converts the |DeviceInfo| values to a JS friendly DictionaryValue, |
| 78 // which extension APIs can expose to third party apps. | 73 // which extension APIs can expose to third party apps. |
| 79 base::DictionaryValue* ToValue(); | 74 base::DictionaryValue* ToValue(); |
| 80 | 75 |
| 81 static sync_pb::SyncEnums::DeviceType GetLocalDeviceType(); | 76 static sync_pb::SyncEnums::DeviceType GetLocalDeviceType(); |
| 82 | 77 |
| 83 // Creates a |DeviceInfo| object representing the local device and passes | 78 // Creates a |DeviceInfo| object representing the local device and passes |
| 84 // it as parameter to the callback. | 79 // it as parameter to the callback. |
| 85 static void CreateLocalDeviceInfo( | 80 static void CreateLocalDeviceInfo( |
| 86 const std::string& guid, | 81 const std::string& guid, |
| 87 const std::string& signin_scoped_device_id, | |
| 88 base::Callback<void(const DeviceInfo& local_info)> callback); | 82 base::Callback<void(const DeviceInfo& local_info)> callback); |
| 89 | 83 |
| 90 // Gets the local device name and passes it as a parameter to callback. | 84 // Gets the local device name and passes it as a parameter to callback. |
| 91 static void GetClientName( | 85 static void GetClientName( |
| 92 base::Callback<void(const std::string& local_info)> callback); | 86 base::Callback<void(const std::string& local_info)> callback); |
| 93 | 87 |
| 94 // Helper to construct a user agent string (ASCII) suitable for use by | 88 // Helper to construct a user agent string (ASCII) suitable for use by |
| 95 // the syncapi for any HTTP communication. This string is used by the sync | 89 // the syncapi for any HTTP communication. This string is used by the sync |
| 96 // backend for classifying client types when calculating statistics. | 90 // backend for classifying client types when calculating statistics. |
| 97 static std::string MakeUserAgentForSyncApi( | 91 static std::string MakeUserAgentForSyncApi( |
| 98 const chrome::VersionInfo& version_info); | 92 const chrome::VersionInfo& version_info); |
| 99 | 93 |
| 100 private: | 94 private: |
| 101 static void GetClientNameContinuation( | 95 static void GetClientNameContinuation( |
| 102 base::Callback<void(const std::string& local_info)> callback, | 96 base::Callback<void(const std::string& local_info)> callback, |
| 103 const std::string& session_name); | 97 const std::string& session_name); |
| 104 | 98 |
| 105 static void CreateLocalDeviceInfoContinuation( | 99 static void CreateLocalDeviceInfoContinuation( |
| 106 const std::string& guid, | 100 const std::string& guid, |
| 107 const std::string& signin_scoped_device_id, | |
| 108 base::Callback<void(const DeviceInfo& local_info)> callback, | 101 base::Callback<void(const DeviceInfo& local_info)> callback, |
| 109 const std::string& session_name); | 102 const std::string& session_name); |
| 110 | 103 |
| 111 const std::string guid_; | 104 const std::string guid_; |
| 112 | 105 |
| 113 const std::string client_name_; | 106 const std::string client_name_; |
| 114 | 107 |
| 115 const std::string chrome_version_; | 108 const std::string chrome_version_; |
| 116 | 109 |
| 117 const std::string sync_user_agent_; | 110 const std::string sync_user_agent_; |
| 118 | 111 |
| 119 const sync_pb::SyncEnums::DeviceType device_type_; | 112 const sync_pb::SyncEnums::DeviceType device_type_; |
| 120 | 113 |
| 121 std::string signin_scoped_device_id_; | |
| 122 | |
| 123 // Exposing |guid| would lead to a stable unique id for a device which | 114 // Exposing |guid| would lead to a stable unique id for a device which |
| 124 // can potentially be used for tracking. Public ids are privacy safe | 115 // can potentially be used for tracking. Public ids are privacy safe |
| 125 // ids in that the same device will have different id for different apps | 116 // ids in that the same device will have different id for different apps |
| 126 // and they are also reset when app/extension is uninstalled. | 117 // and they are also reset when app/extension is uninstalled. |
| 127 std::string public_id_; | 118 std::string public_id_; |
| 128 | 119 |
| 129 DISALLOW_COPY_AND_ASSIGN(DeviceInfo); | 120 DISALLOW_COPY_AND_ASSIGN(DeviceInfo); |
| 130 }; | 121 }; |
| 131 | 122 |
| 132 } // namespace browser_sync | 123 } // namespace browser_sync |
| 133 | 124 |
| 134 #endif // CHROME_BROWSER_SYNC_GLUE_DEVICE_INFO_H_ | 125 #endif // CHROME_BROWSER_SYNC_GLUE_DEVICE_INFO_H_ |
| OLD | NEW |