Add in GeminiThreadSpecifics fields and proto conversions

Bug: 476335087, 479207460
Change-Id: Ia31b470b472dca5dbe5d5a18cee837963d3150c3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/7518392
Reviewed-by: Ankush Singh <ankushkush@google.com>
Commit-Queue: David Maunder <davidjm@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1575422}
diff --git a/components/sync/protocol/gemini_thread_specifics.proto b/components/sync/protocol/gemini_thread_specifics.proto
index 343f845..a199667 100644
--- a/components/sync/protocol/gemini_thread_specifics.proto
+++ b/components/sync/protocol/gemini_thread_specifics.proto
@@ -15,5 +15,9 @@
 package sync_pb;
 
 message GeminiThreadSpecifics {
-  // TODO(crbug.com/476335087) Add in proto fields
+  // A server-generated unique identifier for the conversation.
+  optional string conversation_id = 1;
+
+  // The title of the chat.
+  optional string title = 2;
 }
diff --git a/components/sync/protocol/proto_value_conversions.cc b/components/sync/protocol/proto_value_conversions.cc
index 3ac1df4a..33d70ea 100644
--- a/components/sync/protocol/proto_value_conversions.cc
+++ b/components/sync/protocol/proto_value_conversions.cc
@@ -31,6 +31,7 @@
 #include "components/sync/protocol/entity_specifics.pb.h"
 #include "components/sync/protocol/extension_setting_specifics.pb.h"
 #include "components/sync/protocol/extension_specifics.pb.h"
+#include "components/sync/protocol/gemini_thread_specifics.pb.h"
 #include "components/sync/protocol/history_delete_directive_specifics.pb.h"
 #include "components/sync/protocol/history_specifics.pb.h"
 #include "components/sync/protocol/nigori_specifics.pb.h"
@@ -368,6 +369,7 @@
 IMPLEMENT_PROTO_TO_VALUE(ExtensionSettingSpecifics)
 IMPLEMENT_PROTO_TO_VALUE(ExtensionSpecifics)
 IMPLEMENT_PROTO_TO_VALUE(GlobalIdDirective)
+IMPLEMENT_PROTO_TO_VALUE(GeminiThreadSpecifics)
 IMPLEMENT_PROTO_TO_VALUE(HistoryDeleteDirectiveSpecifics)
 IMPLEMENT_PROTO_TO_VALUE(HistorySpecifics)
 IMPLEMENT_PROTO_TO_VALUE(IncomingPasswordSharingInvitationSpecifics)
diff --git a/components/sync/protocol/proto_value_conversions.h b/components/sync/protocol/proto_value_conversions.h
index bfa7b73..db04ba4 100644
--- a/components/sync/protocol/proto_value_conversions.h
+++ b/components/sync/protocol/proto_value_conversions.h
@@ -43,6 +43,7 @@
 class EwalletDetails;
 class ExtensionSettingSpecifics;
 class ExtensionSpecifics;
+class GeminiThreadSpecifics;
 class HistoryDeleteDirectiveSpecifics;
 class HistorySpecifics;
 class IncomingPasswordSharingInvitationSpecifics;
@@ -191,6 +192,9 @@
 base::Value ExtensionSpecificsToValue(
     const sync_pb::ExtensionSpecifics& extension_specifics);
 
+base::Value GeminiThreadSpecificsToValue(
+    const sync_pb::GeminiThreadSpecifics& gemini_specifics);
+
 base::Value HistoryDeleteDirectiveSpecificsToValue(
     const sync_pb::HistoryDeleteDirectiveSpecifics&
         history_delete_directive_specifics);
diff --git a/components/sync/protocol/proto_value_conversions_unittest.cc b/components/sync/protocol/proto_value_conversions_unittest.cc
index b157a2f..db36f23 100644
--- a/components/sync/protocol/proto_value_conversions_unittest.cc
+++ b/components/sync/protocol/proto_value_conversions_unittest.cc
@@ -26,6 +26,7 @@
 #include "components/sync/protocol/entity_specifics.pb.h"
 #include "components/sync/protocol/extension_setting_specifics.pb.h"
 #include "components/sync/protocol/extension_specifics.pb.h"
+#include "components/sync/protocol/gemini_thread_specifics.pb.h"
 #include "components/sync/protocol/managed_user_setting_specifics.pb.h"
 #include "components/sync/protocol/nigori_specifics.pb.h"
 #include "components/sync/protocol/os_preference_specifics.pb.h"
@@ -396,5 +397,19 @@
                (*data_list)[1].GetDict().FindString("url")->c_str());
 }
 
+TEST(ProtoValueConversionsTest, GeminiThreadSpecificsToValue) {
+  sync_pb::GeminiThreadSpecifics gemini_specifics;
+  gemini_specifics.set_conversation_id("my_id");
+  gemini_specifics.set_title("my_title");
+
+  base::Value::Dict value =
+      GeminiThreadSpecificsToValue(gemini_specifics).TakeDict();
+  EXPECT_FALSE(value.empty());
+  EXPECT_THAT(value.FindString("conversation_id"),
+              ::testing::Pointee(testing::Eq("my_id")));
+  EXPECT_THAT(value.FindString("title"),
+              ::testing::Pointee(testing::Eq("my_title")));
+}
+
 }  // namespace
 }  // namespace syncer
diff --git a/components/sync/protocol/proto_visitors.h b/components/sync/protocol/proto_visitors.h
index ccf00cd..f260db8 100644
--- a/components/sync/protocol/proto_visitors.h
+++ b/components/sync/protocol/proto_visitors.h
@@ -2198,7 +2198,8 @@
 }
 
 VISIT_PROTO_FIELDS(const sync_pb::GeminiThreadSpecifics& proto) {
-  // TODO(crbug.com/476335087): In CL #2, VISIT fields added to specifics.
+  VISIT(conversation_id);
+  VISIT(title);
 }
 
 VISIT_PROTO_FIELDS(const sync_pb::AiThreadSpecifics& proto) {