Store SharingInfo in DeviceInfo

- Added DeviceInfoSyncClient::GetLocalSharingInfo and returns nullopt until
  SharingSyncPreference is change is ready.

Bug: 991971
Change-Id: Ie1c29c6140afe83d6f08fc5d4d8d6bc469e2770b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1825219
Commit-Queue: Alex Chau <[email protected]>
Reviewed-by: Ramya Nagarajan <[email protected]>
Reviewed-by: Marc Treib <[email protected]>
Reviewed-by: Mikel Astiz <[email protected]>
Cr-Commit-Position: refs/heads/master@{#701160}
diff --git a/components/sync_device_info/device_info.h b/components/sync_device_info/device_info.h
index e4a2c9a..3e17461 100644
--- a/components/sync_device_info/device_info.h
+++ b/components/sync_device_info/device_info.h
@@ -6,10 +6,12 @@
 #define COMPONENTS_SYNC_DEVICE_INFO_DEVICE_INFO_H_
 
 #include <memory>
+#include <set>
 #include <string>
 
 #include "base/callback.h"
 #include "base/macros.h"
+#include "base/optional.h"
 #include "base/time/time.h"
 #include "components/sync/protocol/sync.pb.h"
 
@@ -22,6 +24,32 @@
 // A class that holds information regarding the properties of a device.
 class DeviceInfo {
  public:
+  struct SharingInfo {
+    SharingInfo(std::string fcm_token,
+                std::string p256dh,
+                std::string auth_secret,
+                std::set<sync_pb::SharingSpecificFields::EnabledFeatures>
+                    enabled_features);
+    SharingInfo(const SharingInfo& other);
+    SharingInfo(SharingInfo&& other);
+    SharingInfo& operator=(const SharingInfo& other);
+    ~SharingInfo();
+
+    // FCM registration token of device for sending Sharing messages.
+    std::string fcm_token;
+
+    // Subscription public key required for Sharing message encryption[RFC8291].
+    std::string p256dh;
+
+    // Auth secret key required for Sharing message encryption[RFC8291].
+    std::string auth_secret;
+
+    // Set of Sharing features enabled on the device.
+    std::set<sync_pb::SharingSpecificFields::EnabledFeatures> enabled_features;
+
+    bool operator==(const SharingInfo& other) const;
+  };
+
   DeviceInfo(const std::string& guid,
              const std::string& client_name,
              const std::string& chrome_version,
@@ -29,7 +57,8 @@
              const sync_pb::SyncEnums::DeviceType device_type,
              const std::string& signin_scoped_device_id,
              base::Time last_updated_timestamp,
-             bool send_tab_to_self_receiving_enabled);
+             bool send_tab_to_self_receiving_enabled,
+             const base::Optional<SharingInfo>& sharing_info);
   ~DeviceInfo();
 
   // Sync specific unique identifier for the device. Note if a device
@@ -65,6 +94,9 @@
   // Whether the receiving side of the SendTabToSelf feature is enabled.
   bool send_tab_to_self_receiving_enabled() const;
 
+  // Returns Sharing related info of the device.
+  const base::Optional<SharingInfo>& sharing_info() const;
+
   // Gets the OS in string form.
   std::string GetOSString() const;
 
@@ -82,6 +114,8 @@
 
   void set_send_tab_to_self_receiving_enabled(bool new_value);
 
+  void set_sharing_info(const base::Optional<SharingInfo>& sharing_info);
+
   // Converts the |DeviceInfo| values to a JS friendly DictionaryValue,
   // which extension APIs can expose to third party apps.
   std::unique_ptr<base::DictionaryValue> ToValue();
@@ -109,6 +143,8 @@
 
   bool send_tab_to_self_receiving_enabled_;
 
+  base::Optional<SharingInfo> sharing_info_;
+
   DISALLOW_COPY_AND_ASSIGN(DeviceInfo);
 };