Skip to content

Commit

Permalink
[omnibox] Exports action_info.proto to Chrome
Browse files Browse the repository at this point in the history
Also moves chrome_searchbox_stats.proto from
//third_party/metrics_proto/ to //third_party/omnibox_proto/ now that
omnibox has a bunch more protos.

Bug: 1418077
Change-Id: Idd3a14573f09cfc5a94a6e0d74383be2c1c5286e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4347796
Reviewed-by: Mark Pearson <mpearson@chromium.org>
Reviewed-by: Tomasz Wiszkowski <ender@google.com>
Commit-Queue: Moe Ahmadi <mahmadi@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1119659}
  • Loading branch information
mhahmadi authored and Chromium LUCI CQ committed Mar 20, 2023
1 parent e44243e commit 0ee4345
Show file tree
Hide file tree
Showing 17 changed files with 110 additions and 71 deletions.
4 changes: 2 additions & 2 deletions components/omnibox/browser/autocomplete_controller.cc
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@
#include "components/search_engines/template_url_starter_pack_data.h"
#include "components/strings/grit/components_strings.h"
#include "third_party/abseil-cpp/absl/types/optional.h"
#include "third_party/metrics_proto/chrome_searchbox_stats.pb.h"
#include "third_party/metrics_proto/omnibox_focus_type.pb.h"
#include "third_party/omnibox_proto/chrome_searchbox_stats.pb.h"
#include "ui/base/device_form_factor.h"
#include "ui/base/l10n/l10n_util.h"

Expand Down Expand Up @@ -1174,7 +1174,7 @@ void AutocompleteController::UpdateAssistedQueryStats(
if (result->empty())
return;

metrics::ChromeSearchboxStats searchbox_stats;
omnibox::metrics::ChromeSearchboxStats searchbox_stats;
searchbox_stats.set_client_name("chrome");

// Build the impressions string (the AQS part after ".").
Expand Down
54 changes: 27 additions & 27 deletions components/omnibox/browser/autocomplete_provider_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ class AutocompleteProviderTest : public testing::Test {
struct AssistedQueryStatsTestData {
const AutocompleteMatch::Type match_type;
const std::string expected_aqs;
const metrics::ChromeSearchboxStats expected_searchbox_stats;
const omnibox::metrics::ChromeSearchboxStats expected_searchbox_stats;
base::flat_set<omnibox::SuggestSubtype> subtypes;
};

Expand Down Expand Up @@ -409,7 +409,7 @@ class AutocompleteProviderTest : public testing::Test {
controller_->input_.current_page_classification_ = classification;
}
void add_zero_suggest_provider_experiment_stats_v2(
const metrics::ChromeSearchboxStats::ExperimentStatsV2&
const omnibox::metrics::ChromeSearchboxStats::ExperimentStatsV2&
experiment_stat_v2) {
auto& experiment_stats_v2s =
const_cast<SearchSuggestionParser::ExperimentStatsV2s&>(
Expand Down Expand Up @@ -1013,7 +1013,7 @@ TEST_F(AutocompleteProviderTest, UpdateAssistedQueryStats) {
ResetControllerWithTestProviders(false, nullptr, nullptr);

{
metrics::ChromeSearchboxStats searchbox_stats;
omnibox::metrics::ChromeSearchboxStats searchbox_stats;
AssistedQueryStatsTestData test_data[] = {
// MSVC doesn't support zero-length arrays, so supply some dummy data.
{AutocompleteMatchType::SEARCH_WHAT_YOU_TYPED, "", searchbox_stats}};
Expand All @@ -1025,7 +1025,7 @@ TEST_F(AutocompleteProviderTest, UpdateAssistedQueryStats) {
// Note: See suggest.proto for the types and subtypes referenced below.

{
metrics::ChromeSearchboxStats searchbox_stats;
omnibox::metrics::ChromeSearchboxStats searchbox_stats;
searchbox_stats.set_client_name("chrome");
searchbox_stats.set_num_zero_prefix_suggestions_shown(0);
searchbox_stats.set_zero_prefix_enabled(false);
Expand All @@ -1042,7 +1042,7 @@ TEST_F(AutocompleteProviderTest, UpdateAssistedQueryStats) {
}

{
metrics::ChromeSearchboxStats searchbox_stats;
omnibox::metrics::ChromeSearchboxStats searchbox_stats;
searchbox_stats.set_client_name("chrome");
searchbox_stats.set_num_zero_prefix_suggestions_shown(0);
searchbox_stats.set_zero_prefix_enabled(false);
Expand All @@ -1063,7 +1063,7 @@ TEST_F(AutocompleteProviderTest, UpdateAssistedQueryStats) {
}

{
metrics::ChromeSearchboxStats searchbox_stats;
omnibox::metrics::ChromeSearchboxStats searchbox_stats;
searchbox_stats.set_client_name("chrome");
searchbox_stats.set_num_zero_prefix_suggestions_shown(2);
searchbox_stats.set_zero_prefix_enabled(true);
Expand Down Expand Up @@ -1095,27 +1095,27 @@ TEST_F(AutocompleteProviderTest, UpdateAssistedQueryStats) {
available_suggestion->add_subtypes(omnibox::SUBTYPE_PERSONAL);
available_suggestion->add_subtypes(omnibox::SUBTYPE_TRENDS);

metrics::ChromeSearchboxStats searchbox_stats_0;
omnibox::metrics::ChromeSearchboxStats searchbox_stats_0;
searchbox_stats_0.MergeFrom(searchbox_stats);
auto* assisted_query_info = searchbox_stats_0.mutable_assisted_query_info();
assisted_query_info->MergeFrom(searchbox_stats.available_suggestions(0));

metrics::ChromeSearchboxStats searchbox_stats_1;
omnibox::metrics::ChromeSearchboxStats searchbox_stats_1;
searchbox_stats_1.MergeFrom(searchbox_stats);
assisted_query_info = searchbox_stats_1.mutable_assisted_query_info();
assisted_query_info->MergeFrom(searchbox_stats.available_suggestions(1));

metrics::ChromeSearchboxStats searchbox_stats_2;
omnibox::metrics::ChromeSearchboxStats searchbox_stats_2;
searchbox_stats_2.MergeFrom(searchbox_stats);
assisted_query_info = searchbox_stats_2.mutable_assisted_query_info();
assisted_query_info->MergeFrom(searchbox_stats.available_suggestions(2));

metrics::ChromeSearchboxStats searchbox_stats_3;
omnibox::metrics::ChromeSearchboxStats searchbox_stats_3;
searchbox_stats_3.MergeFrom(searchbox_stats);
assisted_query_info = searchbox_stats_3.mutable_assisted_query_info();
assisted_query_info->MergeFrom(searchbox_stats.available_suggestions(3));

metrics::ChromeSearchboxStats searchbox_stats_4;
omnibox::metrics::ChromeSearchboxStats searchbox_stats_4;
searchbox_stats_4.MergeFrom(searchbox_stats);
assisted_query_info = searchbox_stats_4.mutable_assisted_query_info();
assisted_query_info->MergeFrom(searchbox_stats.available_suggestions(4));
Expand Down Expand Up @@ -1161,7 +1161,7 @@ TEST_F(AutocompleteProviderTest, UpdateAssistedQueryStats) {
// reported in `assisted_query_info`. And that the count of zero-prefix
// matches coming from the suggest server or the local device are recorded.
{
metrics::ChromeSearchboxStats searchbox_stats;
omnibox::metrics::ChromeSearchboxStats searchbox_stats;
searchbox_stats.set_client_name("chrome");
searchbox_stats.set_num_zero_prefix_suggestions_shown(3);
searchbox_stats.set_zero_prefix_enabled(true);
Expand Down Expand Up @@ -1200,38 +1200,38 @@ TEST_F(AutocompleteProviderTest, UpdateAssistedQueryStats) {
available_suggestion->set_type(omnibox::TYPE_NATIVE_CHROME);
available_suggestion->add_subtypes(omnibox::SUBTYPE_OMNIBOX_HISTORY_SEARCH);

metrics::ChromeSearchboxStats searchbox_stats_0;
omnibox::metrics::ChromeSearchboxStats searchbox_stats_0;
searchbox_stats_0.MergeFrom(searchbox_stats);

metrics::ChromeSearchboxStats searchbox_stats_1;
omnibox::metrics::ChromeSearchboxStats searchbox_stats_1;
searchbox_stats_1.MergeFrom(searchbox_stats);

metrics::ChromeSearchboxStats searchbox_stats_2;
omnibox::metrics::ChromeSearchboxStats searchbox_stats_2;
searchbox_stats_2.MergeFrom(searchbox_stats);
auto* assisted_query_info = searchbox_stats_2.mutable_assisted_query_info();
assisted_query_info->MergeFrom(searchbox_stats.available_suggestions(2));

metrics::ChromeSearchboxStats searchbox_stats_3;
omnibox::metrics::ChromeSearchboxStats searchbox_stats_3;
searchbox_stats_3.MergeFrom(searchbox_stats);
assisted_query_info = searchbox_stats_3.mutable_assisted_query_info();
assisted_query_info->MergeFrom(searchbox_stats.available_suggestions(3));

metrics::ChromeSearchboxStats searchbox_stats_4;
omnibox::metrics::ChromeSearchboxStats searchbox_stats_4;
searchbox_stats_4.MergeFrom(searchbox_stats);
assisted_query_info = searchbox_stats_4.mutable_assisted_query_info();
assisted_query_info->MergeFrom(searchbox_stats.available_suggestions(4));

metrics::ChromeSearchboxStats searchbox_stats_5;
omnibox::metrics::ChromeSearchboxStats searchbox_stats_5;
searchbox_stats_5.MergeFrom(searchbox_stats);
assisted_query_info = searchbox_stats_5.mutable_assisted_query_info();
assisted_query_info->MergeFrom(searchbox_stats.available_suggestions(5));

metrics::ChromeSearchboxStats searchbox_stats_6;
omnibox::metrics::ChromeSearchboxStats searchbox_stats_6;
searchbox_stats_6.MergeFrom(searchbox_stats);
assisted_query_info = searchbox_stats_6.mutable_assisted_query_info();
assisted_query_info->MergeFrom(searchbox_stats.available_suggestions(6));

metrics::ChromeSearchboxStats searchbox_stats_7;
omnibox::metrics::ChromeSearchboxStats searchbox_stats_7;
searchbox_stats_7.MergeFrom(searchbox_stats);
assisted_query_info = searchbox_stats_7.mutable_assisted_query_info();
assisted_query_info->MergeFrom(searchbox_stats.available_suggestions(7));
Expand Down Expand Up @@ -1335,7 +1335,7 @@ TEST_F(AutocompleteProviderTest, GetDestinationURL_AssistedQueryStatsOnly) {
// Test experiment stats set.
match.search_terms_args->assisted_query_stats =
"chrome.0.69i57j69i58j5l2j0l3j69i59";
metrics::ChromeSearchboxStats::ExperimentStatsV2 experiment_stats_v2;
omnibox::metrics::ChromeSearchboxStats::ExperimentStatsV2 experiment_stats_v2;
experiment_stats_v2.set_type_int(10001);
experiment_stats_v2.set_string_value("0:67");
add_zero_suggest_provider_experiment_stats_v2(experiment_stats_v2);
Expand Down Expand Up @@ -1398,7 +1398,7 @@ TEST_F(AutocompleteProviderTest, GetDestinationURL_SearchboxStatsOnly) {
EXPECT_TRUE(base::Base64UrlDecode(
"EgZjaHJvbWXSAQgyNDU2ajBqMA",
base::Base64UrlDecodePolicy::DISALLOW_PADDING, &serialized_proto));
metrics::ChromeSearchboxStats expected;
omnibox::metrics::ChromeSearchboxStats expected;
expected.ParseFromString(serialized_proto);
EXPECT_EQ("chrome", expected.client_name());
}
Expand All @@ -1413,7 +1413,7 @@ TEST_F(AutocompleteProviderTest, GetDestinationURL_SearchboxStatsOnly) {
EXPECT_TRUE(base::Base64UrlDecode(
"EgZjaHJvbWXSAQgyNDU2ajFqMA",
base::Base64UrlDecodePolicy::DISALLOW_PADDING, &serialized_proto));
metrics::ChromeSearchboxStats expected;
omnibox::metrics::ChromeSearchboxStats expected;
expected.ParseFromString(serialized_proto);
EXPECT_EQ("2456j1j0", expected.experiment_stats());
}
Expand All @@ -1429,7 +1429,7 @@ TEST_F(AutocompleteProviderTest, GetDestinationURL_SearchboxStatsOnly) {
EXPECT_TRUE(base::Base64UrlDecode(
"EgZjaHJvbWXSAQgyNDU2ajBqNA",
base::Base64UrlDecodePolicy::DISALLOW_PADDING, &serialized_proto));
metrics::ChromeSearchboxStats expected;
omnibox::metrics::ChromeSearchboxStats expected;
expected.ParseFromString(serialized_proto);
EXPECT_EQ("2456j0j4", expected.experiment_stats());
}
Expand All @@ -1445,13 +1445,13 @@ TEST_F(AutocompleteProviderTest, GetDestinationURL_SearchboxStatsOnly) {
EXPECT_TRUE(base::Base64UrlDecode(
"EgZjaHJvbWXSAQgyNDU2ajFqNA",
base::Base64UrlDecodePolicy::DISALLOW_PADDING, &serialized_proto));
metrics::ChromeSearchboxStats expected;
omnibox::metrics::ChromeSearchboxStats expected;
expected.ParseFromString(serialized_proto);
EXPECT_EQ("2456j1j4", expected.experiment_stats());
}

// Test experiment stats v2 set.
metrics::ChromeSearchboxStats::ExperimentStatsV2 experiment_stats_v2;
omnibox::metrics::ChromeSearchboxStats::ExperimentStatsV2 experiment_stats_v2;
experiment_stats_v2.set_type_int(10001);
experiment_stats_v2.set_string_value("0:67");
add_zero_suggest_provider_experiment_stats_v2(experiment_stats_v2);
Expand All @@ -1464,7 +1464,7 @@ TEST_F(AutocompleteProviderTest, GetDestinationURL_SearchboxStatsOnly) {
EXPECT_TRUE(base::Base64UrlDecode(
"EgZjaHJvbWXSAQgyNDU2ajFqNOIDCRIEMCw2NyCRTg",
base::Base64UrlDecodePolicy::DISALLOW_PADDING, &serialized_proto));
metrics::ChromeSearchboxStats expected;
omnibox::metrics::ChromeSearchboxStats expected;
expected.ParseFromString(serialized_proto);
EXPECT_EQ(1, expected.experiment_stats_v2_size());
EXPECT_EQ(10001, expected.experiment_stats_v2(0).type_int());
Expand Down
13 changes: 7 additions & 6 deletions components/omnibox/browser/page_classification_functions.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
#include "components/omnibox/browser/page_classification_functions.h"

namespace omnibox {
bool IsNTPPage(metrics::OmniboxEventProto::PageClassification classification) {
using OEP = metrics::OmniboxEventProto;
bool IsNTPPage(
::metrics::OmniboxEventProto::PageClassification classification) {
using OEP = ::metrics::OmniboxEventProto;
return (classification == OEP::NTP) ||
(classification == OEP::OBSOLETE_INSTANT_NTP) ||
(classification == OEP::INSTANT_NTP_WITH_FAKEBOX_AS_STARTING_FOCUS) ||
Expand All @@ -16,8 +17,8 @@ bool IsNTPPage(metrics::OmniboxEventProto::PageClassification classification) {
}

bool IsSearchResultsPage(
metrics::OmniboxEventProto::PageClassification classification) {
using OEP = metrics::OmniboxEventProto;
::metrics::OmniboxEventProto::PageClassification classification) {
using OEP = ::metrics::OmniboxEventProto;
return (classification ==
OEP::SEARCH_RESULT_PAGE_NO_SEARCH_TERM_REPLACEMENT) ||
(classification ==
Expand All @@ -26,8 +27,8 @@ bool IsSearchResultsPage(
}

bool IsOtherWebPage(
metrics::OmniboxEventProto::PageClassification classification) {
using OEP = metrics::OmniboxEventProto;
::metrics::OmniboxEventProto::PageClassification classification) {
using OEP = ::metrics::OmniboxEventProto;
return (classification == OEP::OTHER) ||
(classification == OEP::OTHER_ZPS_PREFETCH);
}
Expand Down
12 changes: 9 additions & 3 deletions components/omnibox/browser/page_classification_functions.h
Original file line number Diff line number Diff line change
@@ -1,18 +1,24 @@
// Copyright 2023 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef COMPONENTS_OMNIBOX_BROWSER_PAGE_CLASSIFICATION_FUNCTIONS_H_
#define COMPONENTS_OMNIBOX_BROWSER_PAGE_CLASSIFICATION_FUNCTIONS_H_

#include "third_party/metrics_proto/omnibox_event.pb.h"

namespace omnibox {
// Return true, if supplied page classification is a new tab page.
bool IsNTPPage(metrics::OmniboxEventProto::PageClassification classification);
bool IsNTPPage(::metrics::OmniboxEventProto::PageClassification classification);

// Return true, if supplied page classification is a search results page.
bool IsSearchResultsPage(
metrics::OmniboxEventProto::PageClassification classification);
::metrics::OmniboxEventProto::PageClassification classification);

// Return true, if supplied page classification is neither a new tab page or
// search results page.
bool IsOtherWebPage(
metrics::OmniboxEventProto::PageClassification classification);
::metrics::OmniboxEventProto::PageClassification classification);
} // namespace omnibox

#endif // COMPONENTS_OMNIBOX_BROWSER_PAGE_CLASSIFICATION_FUNCTIONS_H_
3 changes: 2 additions & 1 deletion components/omnibox/browser/search_suggestion_parser.cc
Original file line number Diff line number Diff line change
Expand Up @@ -608,7 +608,8 @@ bool SearchSuggestionParser::ParseSuggestResults(
if (!type_int || !string_value) {
continue;
}
metrics::ChromeSearchboxStats::ExperimentStatsV2 experiment_stats_v2;
omnibox::metrics::ChromeSearchboxStats::ExperimentStatsV2
experiment_stats_v2;
experiment_stats_v2.set_type_int(*type_int);
experiment_stats_v2.set_string_value(*string_value);
results->experiment_stats_v2s.push_back(std::move(experiment_stats_v2));
Expand Down
4 changes: 2 additions & 2 deletions components/omnibox/browser/search_suggestion_parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#include "components/omnibox/browser/suggestion_answer.h"
#include "components/omnibox/browser/suggestion_group_util.h"
#include "third_party/abseil-cpp/absl/types/optional.h"
#include "third_party/metrics_proto/chrome_searchbox_stats.pb.h"
#include "third_party/omnibox_proto/chrome_searchbox_stats.pb.h"
#include "third_party/omnibox_proto/entity_info.pb.h"
#include "third_party/omnibox_proto/types.pb.h"
#include "url/gurl.h"
Expand Down Expand Up @@ -273,7 +273,7 @@ class SearchSuggestionParser {

typedef std::vector<SuggestResult> SuggestResults;
typedef std::vector<NavigationResult> NavigationResults;
typedef std::vector<metrics::ChromeSearchboxStats::ExperimentStatsV2>
typedef std::vector<omnibox::metrics::ChromeSearchboxStats::ExperimentStatsV2>
ExperimentStatsV2s;

// A simple structure bundling most of the information (including
Expand Down
2 changes: 2 additions & 0 deletions components/search_engines/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ static_library("search_engines") {
"//components/sync",
"//components/webdata/common",
"//third_party/metrics_proto",
"//third_party/omnibox_proto",
]

deps = [
Expand All @@ -84,6 +85,7 @@ static_library("search_engines") {
"//services/network/public/mojom",
"//sql",
"//third_party/metrics_proto",
"//third_party/omnibox_proto",
"//ui/base",
"//ui/gfx",
"//ui/gfx/geometry",
Expand Down
1 change: 1 addition & 0 deletions components/search_engines/DEPS
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ include_rules = [
"+services/network/test",
"+sql",
"+third_party/metrics_proto",
"+third_party/omnibox_proto",
"+ui/base",
"+ui/gfx",
]
4 changes: 2 additions & 2 deletions components/search_engines/template_url.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@
#include "components/search_engines/search_terms_data.h"
#include "components/search_engines/template_url_data.h"
#include "components/search_engines/template_url_id.h"
#include "third_party/metrics_proto/chrome_searchbox_stats.pb.h"
#include "third_party/metrics_proto/omnibox_event.pb.h"
#include "third_party/metrics_proto/omnibox_focus_type.pb.h"
#include "third_party/metrics_proto/omnibox_input_type.pb.h"
#include "third_party/omnibox_proto/chrome_searchbox_stats.pb.h"
#include "ui/gfx/geometry/size.h"
#include "url/gurl.h"
#include "url/third_party/mozilla/url_parse.h"
Expand Down Expand Up @@ -204,7 +204,7 @@ class TemplateURLRef {
// For privacy reasons, we require the search provider to support HTTPS
// protocol in order to receive the gs_lcrp param.
// For more details, see go/chrome-suggest-logging-improvement.
metrics::ChromeSearchboxStats searchbox_stats;
omnibox::metrics::ChromeSearchboxStats searchbox_stats;

// TODO: Remove along with "aq" CGI param.
int accepted_suggestion = NO_SUGGESTIONS_AVAILABLE;
Expand Down

0 comments on commit 0ee4345

Please sign in to comment.