diff --git a/chrome/browser/resources/memories/BUILD.gn b/chrome/browser/resources/memories/BUILD.gn index 2221663379538c..d42c9938a15cbc 100644 --- a/chrome/browser/resources/memories/BUILD.gn +++ b/chrome/browser/resources/memories/BUILD.gn @@ -18,9 +18,8 @@ ts_library("build_ts") { in_files = [ "app.ts", "browser_proxy.ts", - "chrome/browser/ui/webui/history_clusters/history_clusters.mojom-webui.js", "cluster.ts", - "components/history_clusters/core/history_clusters.mojom-webui.js", + "history_clusters.mojom-webui.js", "history_clusters.ts", "page_favicon.ts", "router.ts", @@ -30,42 +29,24 @@ ts_library("build_ts") { "top_visit.ts", "visit_row.ts", ] - path_mappings = [ - "/chrome/browser/ui/webui/history_clusters/*|" + - rebase_path( - "$preprocess_folder/chrome/browser/ui/webui/history_clusters/*", - target_gen_dir), - "/components/history_clusters/core/*|" + - rebase_path("$preprocess_folder/components/history_clusters/core/*", - target_gen_dir), - ] deps = [ "//third_party/polymer/v3_0:library", "//ui/webui/resources:library", "//ui/webui/resources/mojo:library", ] extra_deps = [ - ":copy_history_clusters_api_mojom", - ":copy_history_clusters_definitions_mojom", + ":copy_history_clusters_mojom", ":preprocess", ":preprocess_generated", ] } -copy("copy_history_clusters_api_mojom") { +copy("copy_history_clusters_mojom") { sources = [ "$root_gen_dir/mojom-webui/chrome/browser/ui/webui/history_clusters/history_clusters.mojom-webui.js" ] - outputs = [ "$preprocess_folder/chrome/browser/ui/webui/history_clusters/{{source_file_part}}" ] + outputs = [ "$preprocess_folder/{{source_file_part}}" ] deps = [ "//chrome/browser/ui/webui/history_clusters:mojo_bindings_webui_js" ] } -copy("copy_history_clusters_definitions_mojom") { - sources = [ "$root_gen_dir/mojom-webui/components/history_clusters/core/history_clusters.mojom-webui.js" ] - outputs = [ - "$preprocess_folder/components/history_clusters/core/{{source_file_part}}", - ] - deps = [ "//components/history_clusters/core:mojo_bindings_webui_js" ] -} - html_to_js("web_components_local") { js_files = [ "app.ts", diff --git a/chrome/browser/resources/memories/app.ts b/chrome/browser/resources/memories/app.ts index 9f8c83e1a85066..dbf7356f870bd4 100644 --- a/chrome/browser/resources/memories/app.ts +++ b/chrome/browser/resources/memories/app.ts @@ -22,8 +22,7 @@ import {IronScrollThresholdElement} from 'chrome://resources/polymer/v3_0/iron-s import {html, PolymerElement} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js'; import {BrowserProxy} from './browser_proxy.js'; -import {PageCallbackRouter, PageHandlerRemote, QueryParams, QueryResult} from './chrome/browser/ui/webui/history_clusters/history_clusters.mojom-webui.js'; -import {URLVisit} from './components/history_clusters/core/history_clusters.mojom-webui.js'; +import {PageCallbackRouter, PageHandlerRemote, QueryParams, QueryResult, URLVisit} from './history_clusters.mojom-webui.js'; /** * @fileoverview This file provides the root custom element for the Clusters @@ -163,8 +162,8 @@ class HistoryClustersAppElement extends PolymerElement { this.onBrowserIdle_().then(() => { this.queryClusters_({ query: this.query_.trim(), - maxTime: undefined, maxCount: this.result_.clusters.length, + endTime: undefined, }); }); } @@ -213,11 +212,11 @@ class HistoryClustersAppElement extends PolymerElement { private onScrolledToBottom_() { this.$.scrollThreshold.clearTriggers(); - if (this.result_ && this.result_.continuationMaxTime) { + if (this.result_ && this.result_.continuationEndTime) { this.queryClusters_({ query: this.result_.query, - maxTime: this.result_.continuationMaxTime, maxCount: RESULTS_PER_PAGE, + endTime: this.result_.continuationEndTime, }); } } @@ -252,7 +251,7 @@ class HistoryClustersAppElement extends PolymerElement { // Do not replace the existing result. `result` contains a partial set of // Clusters that should be appended to the existing ones. this.push('result_.clusters', ...result.clusters); - this.result_.continuationMaxTime = result.continuationMaxTime; + this.result_.continuationEndTime = result.continuationEndTime; } else { this.result_ = result; } @@ -269,8 +268,8 @@ class HistoryClustersAppElement extends PolymerElement { // Request up to `RESULTS_PER_PAGE` of the freshest Clusters until now. this.queryClusters_({ query: this.query_.trim(), - maxTime: undefined, maxCount: RESULTS_PER_PAGE, + endTime: undefined, }); // Scroll to the top when the results change due to query change. this.$.container.scrollTop = 0; @@ -285,11 +284,11 @@ class HistoryClustersAppElement extends PolymerElement { } private queryClusters_(queryParams: QueryParams) { - // Invalidate the existing `continuationMaxTime`, if any, in order to + // Invalidate the existing `continuationEndTime`, if any, in order to // prevent sending additional requests while a request is in-flight. A new - // `continuationMaxTime` will be supplied with the new set of results. + // `continuationEndTime` will be supplied with the new set of results. if (this.result_) { - this.result_.continuationMaxTime = undefined; + this.result_.continuationEndTime = undefined; } this.pageHandler_.queryClusters(queryParams); } diff --git a/chrome/browser/resources/memories/browser_proxy.ts b/chrome/browser/resources/memories/browser_proxy.ts index b75bf25249d3f3..0003f174b31b41 100644 --- a/chrome/browser/resources/memories/browser_proxy.ts +++ b/chrome/browser/resources/memories/browser_proxy.ts @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -import {PageCallbackRouter, PageHandler, PageHandlerRemote} from './chrome/browser/ui/webui/history_clusters/history_clusters.mojom-webui.js'; +import {PageCallbackRouter, PageHandler, PageHandlerRemote} from './history_clusters.mojom-webui.js'; /** * @fileoverview This file provides a singleton class that exposes the Mojo diff --git a/chrome/browser/resources/memories/cluster.ts b/chrome/browser/resources/memories/cluster.ts index 4ce41c7a009f96..92b7526218da98 100644 --- a/chrome/browser/resources/memories/cluster.ts +++ b/chrome/browser/resources/memories/cluster.ts @@ -10,8 +10,7 @@ import {assert} from 'chrome://resources/js/assert.m.js'; import {html, PolymerElement} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js'; import {BrowserProxy} from './browser_proxy.js'; -import {PageCallbackRouter} from './chrome/browser/ui/webui/history_clusters/history_clusters.mojom-webui.js'; -import {Cluster, URLVisit} from './components/history_clusters/core/history_clusters.mojom-webui.js'; +import {Cluster, PageCallbackRouter, URLVisit} from './history_clusters.mojom-webui.js'; /** * @fileoverview This file provides a custom element displaying a Cluster. diff --git a/chrome/browser/resources/memories/search_query.ts b/chrome/browser/resources/memories/search_query.ts index 0df7835792f9a7..459189daf47ea2 100644 --- a/chrome/browser/resources/memories/search_query.ts +++ b/chrome/browser/resources/memories/search_query.ts @@ -6,7 +6,7 @@ import './shared_style.js'; import {html, PolymerElement} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js'; -import {SearchQuery} from './components/history_clusters/core/history_clusters.mojom-webui.js'; +import {SearchQuery} from './history_clusters.mojom-webui.js'; /** * @fileoverview This file provides a custom element displaying a search query. diff --git a/chrome/browser/resources/memories/top_visit.ts b/chrome/browser/resources/memories/top_visit.ts index 3d543e5bebeeb6..bb0a75bd8f0062 100644 --- a/chrome/browser/resources/memories/top_visit.ts +++ b/chrome/browser/resources/memories/top_visit.ts @@ -11,7 +11,7 @@ import 'chrome://resources/polymer/v3_0/iron-collapse/iron-collapse.js'; import {loadTimeData} from 'chrome://resources/js/load_time_data.m.js'; import {html, PolymerElement} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js'; -import {URLVisit} from './components/history_clusters/core/history_clusters.mojom-webui.js'; +import {URLVisit} from './history_clusters.mojom-webui.js'; /** * @fileoverview This file provides a custom element displaying a top visit diff --git a/chrome/browser/resources/memories/visit_row.ts b/chrome/browser/resources/memories/visit_row.ts index b3dfb63eaf19b6..c3ee38b3023acc 100644 --- a/chrome/browser/resources/memories/visit_row.ts +++ b/chrome/browser/resources/memories/visit_row.ts @@ -13,7 +13,7 @@ import {loadTimeData} from 'chrome://resources/js/load_time_data.m.js'; import {Url} from 'chrome://resources/mojo/url/mojom/url.mojom-webui.js'; import {html, PolymerElement} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js'; -import {Annotation, URLVisit} from './components/history_clusters/core/history_clusters.mojom-webui.js'; +import {Annotation, URLVisit} from './history_clusters.mojom-webui.js'; /** * @fileoverview This file provides a custom element displaying a visit to a diff --git a/chrome/browser/ui/webui/history_clusters/BUILD.gn b/chrome/browser/ui/webui/history_clusters/BUILD.gn index f647f098f90290..65eaec0a956008 100644 --- a/chrome/browser/ui/webui/history_clusters/BUILD.gn +++ b/chrome/browser/ui/webui/history_clusters/BUILD.gn @@ -8,7 +8,6 @@ mojom("mojo_bindings") { sources = [ "history_clusters.mojom" ] webui_module_path = "/chrome/browser/ui/webui/history_clusters" public_deps = [ - "//components/history_clusters/core:mojo_bindings", "//mojo/public/mojom/base", "//url/mojom:url_mojom_gurl", ] diff --git a/chrome/browser/ui/webui/history_clusters/history_clusters.mojom b/chrome/browser/ui/webui/history_clusters/history_clusters.mojom index 6ec61eb23f1fde..6cfcb1d0d1b27c 100644 --- a/chrome/browser/ui/webui/history_clusters/history_clusters.mojom +++ b/chrome/browser/ui/webui/history_clusters/history_clusters.mojom @@ -4,10 +4,93 @@ module history_clusters.mojom; -import "components/history_clusters/core/history_clusters.mojom"; import "mojo/public/mojom/base/time.mojom"; import "url/mojom/url.mojom"; +// Represents a search query related to a visit to the search results page. +struct SearchQuery { + // Text of the search query. + string query; + // URL of the search query page. + url.mojom.Url url; +}; + +// Available annotations for a visit. +enum Annotation { + // Indicates that the visited URL was added to the bookmarks or was already + // bookmarked. + kBookmarked, + // Indicates that the visited URL was added to a tab group or was already in a + // tab group. + kTabGrouped, + // Indicates that the visited URL was the search results page of the default + // search provider. + kSearchResultsPage, +}; + +// Represents the most recent visit to a URL within a Cluster. Visits for which +// there are more recent visits to the same (or a qualifying near-duplicate) URL +// within the Cluster are omitted. +// However, the time of the least recent visit as well as the raw URLs of those +// duplicative visits are preserved for deletion purposes. +struct URLVisit { + // Normalized URL of the visited webpage. Only Search Results Page urls will + // be normalized for now; This is because SRP visits for the same search terms + // have slightly different URLs due to various query params such as the AQS. + url.mojom.Url normalized_url; + + // Title of the visited webpage. + string page_title; + + // Time of the most recent visit in the Cluster to the same (or a qualifying + // near-duplicate) URL. + mojo_base.mojom.Time last_visit_time; + + // Time of the least recent visit in the Cluster to the same (or a qualifying + // near-duplicate) URL. Equals `last_visit_time` if there is only one visit in + // the Cluster to the same (or a qualifying near-duplicate) URL. + mojo_base.mojom.Time first_visit_time; + + // List of raw visited URLs for `normalized_url`. + array raw_urls; + + // Localized string of approximate `last_visit_time`, e.g., "2 days ago". + string relative_date; + + // Annotations for this visit. + array annotations; + + // Search queries related to this visit or one of its related visits, if + // applicable; typically the highest scoring one. + array related_searches; + + // Related visits to this visit; starting with the highest scoring one, if + // applicable. Only prominently featured visits have related visits. + array related_visits; + + // Whether a related visit is initially hidden. Calculated based on `score`. + bool below_the_fold; + + // A calculated score (i.e., calculated based on how long the tab was in + // foreground etc). + double score; +}; + +// Represents a cluster of visits generated from device history by the browser +// and displayed in the chrome://memories WebUI. Contains cluster-level metadata +// (e.g., last_visit_time) derived from the metadata of constituent visits. +struct Cluster { + // Cluster identifier. See //components/history/core/browser/history_types.h + int64 id; + + // Prominently featured constituent visits; typically the highest scoring + // one(s). + array visits; + + // Time of the most recent visit in the Cluster. Used for extracting Clusters. + mojo_base.mojom.Time last_visit_time; +}; + // Parameters used to query the browser for Clusters in reverse chronological // order. struct QueryParams { @@ -20,9 +103,9 @@ struct QueryParams { uint32 max_count; // The optional time threshold (exclusive) for how recent the Clusters can be. - // If specified, Clusters before `max_time` and if missing, Clusters until the + // If specified, Clusters before `end_time` and if missing, Clusters until the // present time that match the other criteria are returned. - mojo_base.mojom.Time? max_time; + mojo_base.mojom.Time? end_time; }; // Represents a set of Clusters returned by the browser in response to a request @@ -42,7 +125,7 @@ struct QueryResult { // The optional time threshold (exclusive) to be supplied in the follow-up UI // request to load older Clusters. Typically set to `last_visit_time` of the // last cluster in `clusters` if the backend supports paging. - mojo_base.mojom.Time? continuation_max_time; + mojo_base.mojom.Time? continuation_end_time; }; // Browser-side handler for requests from WebUI page. diff --git a/chrome/browser/ui/webui/history_clusters/history_clusters_handler.cc b/chrome/browser/ui/webui/history_clusters/history_clusters_handler.cc index 48e59258e7ebc6..8a96692ba0e850 100644 --- a/chrome/browser/ui/webui/history_clusters/history_clusters_handler.cc +++ b/chrome/browser/ui/webui/history_clusters/history_clusters_handler.cc @@ -11,7 +11,6 @@ #include "chrome/browser/history_clusters/history_clusters_service_factory.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/ui/browser.h" -#include "components/history_clusters/core/history_clusters.mojom.h" #include "content/public/browser/render_frame_host.h" #include "content/public/browser/web_contents.h" #include "url/gurl.h" @@ -113,7 +112,7 @@ void HistoryClustersHandler::SetPage( void HistoryClustersHandler::QueryClusters(mojom::QueryParamsPtr query_params) { const std::string& query = query_params->query; const size_t max_count = query_params->max_count; - base::Time end_time = query_params->max_time.value_or(base::Time()); + base::Time end_time = query_params->end_time.value_or(base::Time()); auto result_callback = base::BindOnce(&HistoryClustersHandler::OnClustersQueryResult, weak_ptr_factory_.GetWeakPtr(), std::move(query_params)); @@ -123,8 +122,8 @@ void HistoryClustersHandler::QueryClusters(mojom::QueryParamsPtr query_params) { query_task_tracker_.TryCancelAll(); auto* history_clusters_service = HistoryClustersServiceFactory::GetForBrowserContext(profile_); - // TODO(crbug.com/1220765): Supply `continuation_max_time` in - // `result_callback` once the service supports paging. + // TODO(crbug.com/1220765): Supply `continuation_end_time` in + // `result_callback` once the service supports paging. history_clusters_service->QueryClusters( query, end_time, max_count, base::BindOnce(&ClustersToMojom) @@ -186,13 +185,13 @@ void HistoryClustersHandler::OnMemoriesDebugMessage( void HistoryClustersHandler::OnClustersQueryResult( mojom::QueryParamsPtr original_query_params, - const absl::optional& continuation_max_time, + const absl::optional& continuation_end_time, std::vector cluster_mojoms) { auto result_mojom = mojom::QueryResult::New(); result_mojom->query = original_query_params->query; - // Continuation queries have a value for `max_time`. Mark the result as such. - result_mojom->is_continuation = original_query_params->max_time.has_value(); - result_mojom->continuation_max_time = continuation_max_time; + // Continuation queries have a value for `end_time`. Mark the result as such. + result_mojom->is_continuation = original_query_params->end_time.has_value(); + result_mojom->continuation_end_time = continuation_end_time; result_mojom->clusters = std::move(cluster_mojoms); page_->OnClustersQueryResult(std::move(result_mojom)); } @@ -205,14 +204,14 @@ void HistoryClustersHandler::OnVisitsRemoved( #if !defined(CHROME_BRANDED) void HistoryClustersHandler::QueryHistoryService( const std::string& query, - base::Time max_time, + base::Time end_time, size_t max_count, std::vector cluster_mojoms, QueryResultsCallback callback) { if (max_count > 0 && cluster_mojoms.size() == max_count) { // Enough clusters have been created. Run the callback with those Clusters // along with the continuation max time threshold. - std::move(callback).Run(max_time, std::move(cluster_mojoms)); + std::move(callback).Run(end_time, std::move(cluster_mojoms)); return; } @@ -221,21 +220,21 @@ void HistoryClustersHandler::QueryHistoryService( ServiceAccessType::EXPLICIT_ACCESS); history::QueryOptions query_options; query_options.duplicate_policy = history::QueryOptions::KEEP_ALL_DUPLICATES; - query_options.end_time = max_time; + query_options.end_time = end_time; // Make sure to look back far enough to find some visits. query_options.begin_time = query_options.end_time.LocalMidnight() - base::TimeDelta::FromDays(90); history_service->QueryHistory( base::UTF8ToUTF16(query), query_options, base::BindOnce(&HistoryClustersHandler::OnHistoryQueryResults, - weak_ptr_factory_.GetWeakPtr(), query, max_time, max_count, + weak_ptr_factory_.GetWeakPtr(), query, end_time, max_count, std::move(cluster_mojoms), std::move(callback)), &query_task_tracker_); } void HistoryClustersHandler::OnHistoryQueryResults( const std::string& query, - base::Time max_time, + base::Time end_time, size_t max_count, std::vector cluster_mojoms, QueryResultsCallback callback, @@ -243,7 +242,7 @@ void HistoryClustersHandler::OnHistoryQueryResults( if (results.empty()) { // No more results to create Clusters from. Run the callback with the // Clusters created so far. - std::move(callback).Run(max_time, std::move(cluster_mojoms)); + std::move(callback).Run(end_time, std::move(cluster_mojoms)); return; } @@ -400,10 +399,10 @@ void HistoryClustersHandler::OnHistoryQueryResults( // Continue to extract Clusters from 11:59:59pm of the day before the // Cluster's `last_visit_time`. - max_time = cluster_mojom->last_visit_time.LocalMidnight() - + end_time = cluster_mojom->last_visit_time.LocalMidnight() - base::TimeDelta::FromSeconds(1); cluster_mojoms.push_back(std::move(cluster_mojom)); - QueryHistoryService(query, max_time, max_count, std::move(cluster_mojoms), + QueryHistoryService(query, end_time, max_count, std::move(cluster_mojoms), std::move(callback)); } #endif diff --git a/chrome/browser/ui/webui/history_clusters/history_clusters_handler.h b/chrome/browser/ui/webui/history_clusters/history_clusters_handler.h index 625e3ea2b2b161..18e84bc788dea5 100644 --- a/chrome/browser/ui/webui/history_clusters/history_clusters_handler.h +++ b/chrome/browser/ui/webui/history_clusters/history_clusters_handler.h @@ -13,7 +13,6 @@ #include "base/task/cancelable_task_tracker.h" #include "chrome/browser/ui/webui/history_clusters/history_clusters.mojom.h" #include "components/history/core/browser/history_types.h" -#include "components/history_clusters/core/history_clusters.mojom-forward.h" #include "components/history_clusters/core/history_clusters_service.h" #include "mojo/public/cpp/bindings/pending_receiver.h" #include "mojo/public/cpp/bindings/pending_remote.h" @@ -57,13 +56,13 @@ class HistoryClustersHandler : public mojom::PageHandler, void OnMemoriesDebugMessage(const std::string& message) override; private: - // Called with the original `query_params`, `continuation_max_time` which is + // Called with the original `query_params`, `continuation_end_time` which is // created in anticipation of the next query, and `cluster_mojoms` when the // results of querying the HistoryClustersService are available. Subsequently // creates a QueryResult instance using the parameters and sends it to the JS. void OnClustersQueryResult( mojom::QueryParamsPtr original_query_params, - const absl::optional& continuation_max_time, + const absl::optional& continuation_end_time, std::vector cluster_mojoms); // Called with the set of removed visits. Subsequently, `visits` is sent to // the JS to update the UI. @@ -74,12 +73,12 @@ class HistoryClustersHandler : public mojom::PageHandler, base::OnceCallback&, std::vector)>; void QueryHistoryService(const std::string& query, - base::Time max_time, + base::Time end_time, size_t max_count, std::vector cluster_mojoms, QueryResultsCallback callback); void OnHistoryQueryResults(const std::string& query, - base::Time max_time, + base::Time end_time, size_t max_count, std::vector cluster_mojoms, QueryResultsCallback callback, diff --git a/components/history_clusters/core/BUILD.gn b/components/history_clusters/core/BUILD.gn index 733e0d5909fbd7..f75c75c19fda0d 100644 --- a/components/history_clusters/core/BUILD.gn +++ b/components/history_clusters/core/BUILD.gn @@ -33,7 +33,6 @@ static_library("core") { deps = [ ":clustering_backend", ":history_clusters_buildflags", - ":mojo_bindings", "//base", "//components/history/core/browser", "//components/history_clusters/core/proto", @@ -58,15 +57,6 @@ source_set("clustering_backend") { ] } -mojom("mojo_bindings") { - sources = [ "history_clusters.mojom" ] - webui_module_path = "/components/history_clusters/core" - public_deps = [ - "//mojo/public/mojom/base", - "//url/mojom:url_mojom_gurl", - ] -} - source_set("unit_tests") { testonly = true sources = [ @@ -80,7 +70,6 @@ source_set("unit_tests") { "//base/test:test_support", "//components/history/core/browser", "//components/history/core/test", - "//components/history_clusters/core:mojo_bindings", "//components/history_clusters/core/proto", "//services/network:test_support", "//testing/gtest", diff --git a/components/history_clusters/core/OWNERS b/components/history_clusters/core/OWNERS deleted file mode 100644 index 08850f421205f8..00000000000000 --- a/components/history_clusters/core/OWNERS +++ /dev/null @@ -1,2 +0,0 @@ -per-file *.mojom=set noparent -per-file *.mojom=file://ipc/SECURITY_OWNERS diff --git a/components/history_clusters/core/history_clusters.mojom b/components/history_clusters/core/history_clusters.mojom deleted file mode 100644 index 6daf466d48c8d3..00000000000000 --- a/components/history_clusters/core/history_clusters.mojom +++ /dev/null @@ -1,99 +0,0 @@ -// Copyright 2021 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -module history_clusters.mojom; - -import "mojo/public/mojom/base/string16.mojom"; -import "mojo/public/mojom/base/time.mojom"; -import "url/mojom/url.mojom"; - -// Represents a search query related to a visit to the search results page. -struct SearchQuery { - // Text of the search query. - string query; - // URL of the search query page. - url.mojom.Url url; -}; - -// Available annotations for a visit. -enum Annotation { - // Indicates that the visited URL was added to the bookmarks or was already - // bookmarked. - kBookmarked, - // Indicates that the visited URL was added to a tab group or was already in a - // tab group. - kTabGrouped, - // Indicates that the visited URL was the search results page of the default - // search provider. - kSearchResultsPage, -}; - -// Represents the most recent visit to a URL within a Cluster. Visits for which -// there are more recent visits to the same (or a qualifying near-duplicate) URL -// within the Cluster are omitted. -// However, the time of the least recent visit as well as the raw URLs of those -// duplicative visits are preserved for deletion purposes. -struct URLVisit { - // Normalized URL of the visited webpage. Only Search Results Page urls will - // be normalized for now; This is because SRP visits for the same search terms - // have slightly different URLs due to various query params such as the AQS. - url.mojom.Url normalized_url; - - // Title of the visited webpage. - string page_title; - - // Time of the most recent visit in the Cluster to the same (or a qualifying - // near-duplicate) URL. - mojo_base.mojom.Time last_visit_time; - - // Time of the least recent visit in the Cluster to the same (or a qualifying - // near-duplicate) URL. Equals `last_visit_time` if there is only one visit in - // the Cluster to the same (or a qualifying near-duplicate) URL. - mojo_base.mojom.Time first_visit_time; - - // List of raw visited URLs for `normalized_url`. - array raw_urls; - - // Localized string of approximate `last_visit_time`, e.g., "2 days ago". - string relative_date; - - // Annotations for this visit. - array annotations; - - // Search queries related to this visit or one of its related visits, if - // applicable; typically the highest scoring one. - array related_searches; - - // Related visits to this visit; starting with the highest scoring one, if - // applicable. Only prominently featured visits have related visits. - array related_visits; - - // Whether a related visit is initially hidden. Calculated based on `score`. - bool below_the_fold; - - // A calculated score (i.e., calculated based on how long the tab was in - // foreground etc). - double score; -}; - -// Represents a cluster of visits generated from device history by the browser -// and displayed in the chrome://memories WebUI. Contains cluster-level metadata -// (e.g., keywords) derived from the metadata of constituent visits. -struct Cluster { - // Cluster identifier. See //components/history/core/browser/history_types.h - int64 id; - - // Prominently featured constituent visits; typically the highest scoring - // one(s). - array visits; - - // Time of the most recent visit in the Cluster. Used for extracting Clusters. - mojo_base.mojom.Time last_visit_time; - - // The content "topics", or keywords, that the memory contains/is related to. - // These strings should never be exposed to the user directly in case they are - // offensively wrong, but may be queried over with search terms to find - // memories. - array keywords; -};