[history] Add missing search metadata annotations for synced visits

Currently, PageContentAnnotationsService adds some search-related
annotations when visits are created.

This doesn't work for visits we receive via Sync from remote clients.

This CL makes PageContentAnnotationsService a HistoryServiceObserver,
and updates the HistoryServiceObserver a bit to pass through
visit_source, allowing us to annotate those synced visits too.

Bug: 1383309, 1318028
Change-Id: I2a083b48ec70b971588f8a8d2353f98a943a609d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4022468
Commit-Queue: Tommy Li <[email protected]>
Reviewed-by: Yao Xiao <[email protected]>
Reviewed-by: Sophie Chang <[email protected]>
Commit-Queue: Yao Xiao <[email protected]>
Auto-Submit: Tommy Li <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1071358}
diff --git a/components/browsing_topics/browsing_topics_service_impl.cc b/components/browsing_topics/browsing_topics_service_impl.cc
index 12b593dce..5a22ee8c 100644
--- a/components/browsing_topics/browsing_topics_service_impl.cc
+++ b/components/browsing_topics/browsing_topics_service_impl.cc
@@ -8,6 +8,7 @@
 
 #include "base/rand_util.h"
 #include "base/ranges/algorithm.h"
+#include "base/strings/strcat.h"
 #include "base/time/time.h"
 #include "components/browsing_topics/browsing_topics_calculator.h"
 #include "components/browsing_topics/browsing_topics_page_load_data_tracker.h"