Commit e726ec7d authored by Tomasz Wiszkowski's avatar Tomasz Wiszkowski Committed by Commit Bot

Allocate Page Class for Search widget

This change introduces PageClassification for SearchActivity
and brings back the SearchActivity suggestions.

The unique ID allocated to Search Activity will help us
clear up any inconsistencies in offered suggestions,
address SA directly and eliminate the use of the
INVALID_SPEC PageClassification (currently reported by SA).

Bug: 1143557
Change-Id: I3f48074079a9046d7aea25af9f5f2dc1f84ba268
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2516970Reviewed-by: default avatarJustin Donnelly <jdonnelly@chromium.org>
Reviewed-by: default avatarSteven Holte <holte@chromium.org>
Reviewed-by: default avatarFilip Gorski <fgorski@chromium.org>
Reviewed-by: default avatarTed Choc <tedchoc@chromium.org>
Commit-Queue: Tomasz Wiszkowski <ender@google.com>
Cr-Commit-Position: refs/heads/master@{#824686}
parent 76508378
...@@ -521,6 +521,7 @@ android_library("chrome_java") { ...@@ -521,6 +521,7 @@ android_library("chrome_java") {
"//third_party/blink/public/mojom:mojom_platform_java", "//third_party/blink/public/mojom:mojom_platform_java",
"//third_party/gif_player:gif_player_java", "//third_party/gif_player:gif_player_java",
"//third_party/google_android_play_core:com_google_android_play_core_java", "//third_party/google_android_play_core:com_google_android_play_core_java",
"//third_party/metrics_proto:metrics_proto_java",
"//ui/android:ui_java", "//ui/android:ui_java",
"//ui/base/mojom:mojom_java", "//ui/base/mojom:mojom_java",
"//ui/gfx/geometry/mojom:mojom_java", "//ui/gfx/geometry/mojom:mojom_java",
...@@ -1216,6 +1217,7 @@ android_library("chrome_test_java") { ...@@ -1216,6 +1217,7 @@ android_library("chrome_test_java") {
"//third_party/blink/public/mojom:mojom_platform_java", "//third_party/blink/public/mojom:mojom_platform_java",
"//third_party/hamcrest:hamcrest_java", "//third_party/hamcrest:hamcrest_java",
"//third_party/junit", "//third_party/junit",
"//third_party/metrics_proto:metrics_proto_java",
"//third_party/mockito:mockito_java", "//third_party/mockito:mockito_java",
"//third_party/ub-uiautomator:ub_uiautomator_java", "//third_party/ub-uiautomator:ub_uiautomator_java",
"//ui/android:clipboard_java_test_support", "//ui/android:clipboard_java_test_support",
......
...@@ -109,10 +109,9 @@ public interface LocationBarDataProvider { ...@@ -109,10 +109,9 @@ public interface LocationBarDataProvider {
/** /**
* Returns the current page classification. * Returns the current page classification.
* @param isFocusedFromFakebox If the omnibox focus originated from the fakebox. * @param isFocusedFromFakebox If the omnibox focus originated from the fakebox.
* @return Integer value representing the OmniboxEventProto.PageClassification.
*/ */
default int getPageClassification(boolean isFocusedFromFakebox) { int getPageClassification(boolean isFocusedFromFakebox);
return 0;
}
/** /**
* Returns the resource ID of the icon that should be displayed or 0 if no icon should be shown. * Returns the resource ID of the icon that should be displayed or 0 if no icon should be shown.
......
...@@ -16,6 +16,7 @@ import org.chromium.chrome.browser.profiles.Profile; ...@@ -16,6 +16,7 @@ import org.chromium.chrome.browser.profiles.Profile;
import org.chromium.chrome.browser.tab.Tab; import org.chromium.chrome.browser.tab.Tab;
import org.chromium.chrome.browser.toolbar.NewTabPageDelegate; import org.chromium.chrome.browser.toolbar.NewTabPageDelegate;
import org.chromium.components.browser_ui.styles.ChromeColors; import org.chromium.components.browser_ui.styles.ChromeColors;
import org.chromium.components.metrics.OmniboxEventProtos.OmniboxEventProto.PageClassification;
import org.chromium.components.security_state.ConnectionSecurityLevel; import org.chromium.components.security_state.ConnectionSecurityLevel;
class SearchBoxDataProvider implements LocationBarDataProvider { class SearchBoxDataProvider implements LocationBarDataProvider {
...@@ -125,6 +126,11 @@ class SearchBoxDataProvider implements LocationBarDataProvider { ...@@ -125,6 +126,11 @@ class SearchBoxDataProvider implements LocationBarDataProvider {
return ConnectionSecurityLevel.NONE; return ConnectionSecurityLevel.NONE;
} }
@Override
public int getPageClassification(boolean isFocusedFromFakebox) {
return PageClassification.ANDROID_SEARCH_WIDGET_VALUE;
}
@Override @Override
public int getSecurityIconResource(boolean isTablet) { public int getSecurityIconResource(boolean isTablet) {
return 0; return 0;
......
...@@ -38,6 +38,7 @@ import org.chromium.components.browser_ui.styles.ChromeColors; ...@@ -38,6 +38,7 @@ import org.chromium.components.browser_ui.styles.ChromeColors;
import org.chromium.components.dom_distiller.core.DomDistillerUrlUtils; import org.chromium.components.dom_distiller.core.DomDistillerUrlUtils;
import org.chromium.components.embedder_support.util.UrlConstants; import org.chromium.components.embedder_support.util.UrlConstants;
import org.chromium.components.embedder_support.util.UrlUtilities; import org.chromium.components.embedder_support.util.UrlUtilities;
import org.chromium.components.metrics.OmniboxEventProtos.OmniboxEventProto.PageClassification;
import org.chromium.components.omnibox.OmniboxUrlEmphasizer; import org.chromium.components.omnibox.OmniboxUrlEmphasizer;
import org.chromium.components.omnibox.SecurityStatusIcon; import org.chromium.components.omnibox.SecurityStatusIcon;
import org.chromium.components.security_state.ConnectionSecurityLevel; import org.chromium.components.security_state.ConnectionSecurityLevel;
...@@ -385,11 +386,11 @@ public class LocationBarModel implements ToolbarDataProvider, LocationBarDataPro ...@@ -385,11 +386,11 @@ public class LocationBarModel implements ToolbarDataProvider, LocationBarDataPro
@Override @Override
public int getPageClassification(boolean isFocusedFromFakebox) { public int getPageClassification(boolean isFocusedFromFakebox) {
if (mNativeLocationBarModelAndroid == 0) return 0; if (mNativeLocationBarModelAndroid == 0) return PageClassification.INVALID_SPEC_VALUE;
// Provide (NTP=1) as page class in overview mode (when Start Surface is enabled). No call // Provide NTP as page class in overview mode (when Start Surface is enabled). No call
// to the backend necessary or possible, since there is no tab or navigation entry. // to the backend necessary or possible, since there is no tab or navigation entry.
if (isInOverviewAndShowingOmnibox()) return 1; if (isInOverviewAndShowingOmnibox()) return PageClassification.NTP_VALUE;
return LocationBarModelJni.get().getPageClassification( return LocationBarModelJni.get().getPageClassification(
mNativeLocationBarModelAndroid, LocationBarModel.this, isFocusedFromFakebox); mNativeLocationBarModelAndroid, LocationBarModel.this, isFocusedFromFakebox);
......
...@@ -50,6 +50,7 @@ import org.chromium.chrome.browser.profiles.Profile; ...@@ -50,6 +50,7 @@ import org.chromium.chrome.browser.profiles.Profile;
import org.chromium.chrome.test.util.browser.Features; import org.chromium.chrome.test.util.browser.Features;
import org.chromium.chrome.test.util.browser.Features.DisableFeatures; import org.chromium.chrome.test.util.browser.Features.DisableFeatures;
import org.chromium.chrome.test.util.browser.Features.EnableFeatures; import org.chromium.chrome.test.util.browser.Features.EnableFeatures;
import org.chromium.components.metrics.OmniboxEventProtos.OmniboxEventProto.PageClassification;
import org.chromium.content_public.browser.test.NativeLibraryTestUtils; import org.chromium.content_public.browser.test.NativeLibraryTestUtils;
import org.chromium.ui.modelutil.MVCListAdapter.ModelList; import org.chromium.ui.modelutil.MVCListAdapter.ModelList;
import org.chromium.ui.modelutil.PropertyModel; import org.chromium.ui.modelutil.PropertyModel;
...@@ -339,7 +340,7 @@ public class AutocompleteMediatorUnitTest { ...@@ -339,7 +340,7 @@ public class AutocompleteMediatorUnitTest {
Profile profile = Mockito.mock(Profile.class); Profile profile = Mockito.mock(Profile.class);
String url = "http://www.example.com"; String url = "http://www.example.com";
String title = "Title"; String title = "Title";
int pageClassification = 2; int pageClassification = PageClassification.BLANK_VALUE;
when(mLocationBarDataProvider.getProfile()).thenReturn(profile); when(mLocationBarDataProvider.getProfile()).thenReturn(profile);
when(mLocationBarDataProvider.getCurrentUrl()).thenReturn(url); when(mLocationBarDataProvider.getCurrentUrl()).thenReturn(url);
when(mLocationBarDataProvider.getTitle()).thenReturn(title); when(mLocationBarDataProvider.getTitle()).thenReturn(title);
...@@ -361,7 +362,7 @@ public class AutocompleteMediatorUnitTest { ...@@ -361,7 +362,7 @@ public class AutocompleteMediatorUnitTest {
public void onTextChanged_nonEmptyTextTriggersSuggestions() { public void onTextChanged_nonEmptyTextTriggersSuggestions() {
Profile profile = Mockito.mock(Profile.class); Profile profile = Mockito.mock(Profile.class);
String url = "http://www.example.com"; String url = "http://www.example.com";
int pageClassification = 2; int pageClassification = PageClassification.BLANK_VALUE;
when(mLocationBarDataProvider.getProfile()).thenReturn(profile); when(mLocationBarDataProvider.getProfile()).thenReturn(profile);
when(mLocationBarDataProvider.getCurrentUrl()).thenReturn(url); when(mLocationBarDataProvider.getCurrentUrl()).thenReturn(url);
when(mLocationBarDataProvider.hasTab()).thenReturn(true); when(mLocationBarDataProvider.hasTab()).thenReturn(true);
...@@ -384,7 +385,7 @@ public class AutocompleteMediatorUnitTest { ...@@ -384,7 +385,7 @@ public class AutocompleteMediatorUnitTest {
public void onTextChanged_cancelsPendingRequests() { public void onTextChanged_cancelsPendingRequests() {
Profile profile = Mockito.mock(Profile.class); Profile profile = Mockito.mock(Profile.class);
String url = "http://www.example.com"; String url = "http://www.example.com";
int pageClassification = 2; int pageClassification = PageClassification.BLANK_VALUE;
when(mLocationBarDataProvider.getProfile()).thenReturn(profile); when(mLocationBarDataProvider.getProfile()).thenReturn(profile);
when(mLocationBarDataProvider.getCurrentUrl()).thenReturn(url); when(mLocationBarDataProvider.getCurrentUrl()).thenReturn(url);
when(mLocationBarDataProvider.hasTab()).thenReturn(true); when(mLocationBarDataProvider.hasTab()).thenReturn(true);
...@@ -473,7 +474,7 @@ public class AutocompleteMediatorUnitTest { ...@@ -473,7 +474,7 @@ public class AutocompleteMediatorUnitTest {
Profile profile = Mockito.mock(Profile.class); Profile profile = Mockito.mock(Profile.class);
String url = "http://www.example.com"; String url = "http://www.example.com";
String title = "Title"; String title = "Title";
int pageClassification = 2; int pageClassification = PageClassification.BLANK_VALUE;
when(mLocationBarDataProvider.getProfile()).thenReturn(profile); when(mLocationBarDataProvider.getProfile()).thenReturn(profile);
when(mLocationBarDataProvider.getCurrentUrl()).thenReturn(url); when(mLocationBarDataProvider.getCurrentUrl()).thenReturn(url);
when(mLocationBarDataProvider.getTitle()).thenReturn(title); when(mLocationBarDataProvider.getTitle()).thenReturn(title);
...@@ -499,7 +500,7 @@ public class AutocompleteMediatorUnitTest { ...@@ -499,7 +500,7 @@ public class AutocompleteMediatorUnitTest {
Profile profile = Mockito.mock(Profile.class); Profile profile = Mockito.mock(Profile.class);
String url = "http://www.example.com"; String url = "http://www.example.com";
String title = "Title"; String title = "Title";
int pageClassification = 2; int pageClassification = PageClassification.BLANK_VALUE;
when(mLocationBarDataProvider.getProfile()).thenReturn(profile); when(mLocationBarDataProvider.getProfile()).thenReturn(profile);
when(mLocationBarDataProvider.getCurrentUrl()).thenReturn(url); when(mLocationBarDataProvider.getCurrentUrl()).thenReturn(url);
when(mLocationBarDataProvider.getTitle()).thenReturn(title); when(mLocationBarDataProvider.getTitle()).thenReturn(title);
......
...@@ -51,6 +51,7 @@ import org.chromium.chrome.browser.toolbar.ToolbarDataProvider; ...@@ -51,6 +51,7 @@ import org.chromium.chrome.browser.toolbar.ToolbarDataProvider;
import org.chromium.chrome.test.ChromeJUnit4ClassRunner; import org.chromium.chrome.test.ChromeJUnit4ClassRunner;
import org.chromium.chrome.test.ChromeTabbedActivityTestRule; import org.chromium.chrome.test.ChromeTabbedActivityTestRule;
import org.chromium.chrome.test.util.browser.Features.EnableFeatures; import org.chromium.chrome.test.util.browser.Features.EnableFeatures;
import org.chromium.components.metrics.OmniboxEventProtos.OmniboxEventProto.PageClassification;
import org.chromium.content_public.browser.test.util.TestThreadUtils; import org.chromium.content_public.browser.test.util.TestThreadUtils;
import org.chromium.ui.base.ActivityWindowAndroid; import org.chromium.ui.base.ActivityWindowAndroid;
import org.chromium.ui.base.AndroidPermissionDelegate; import org.chromium.ui.base.AndroidPermissionDelegate;
...@@ -280,6 +281,11 @@ public class VoiceRecognitionHandlerTest { ...@@ -280,6 +281,11 @@ public class VoiceRecognitionHandlerTest {
return 0; return 0;
} }
@Override
public int getPageClassification(boolean isFocusedFromFakebox) {
return PageClassification.NTP_VALUE;
}
@Override @Override
public int getSecurityIconResource(boolean isTablet) { public int getSecurityIconResource(boolean isTablet) {
return 0; return 0;
......
...@@ -88,19 +88,20 @@ ...@@ -88,19 +88,20 @@
title="Mostly useful when zero-suggest is enabled, but may also affect clipboard and search providers."> title="Mostly useful when zero-suggest is enabled, but may also affect clipboard and search providers.">
<select id="page-classification" class="row" accesskey="o"> <select id="page-classification" class="row" accesskey="o">
<option value="0">Invalid spec</option> <option value="0">Invalid spec</option>
<option value="1">(OBSOLETE) new tab page</option>
<option value="2">about:blank</option> <option value="2">about:blank</option>
<option value="3">user's home page</option> <option value="3">user's home page</option>
<option value="4" selected>arbitrary URL</option> <option value="4" selected>arbitrary URL</option>
<option value="6"> <option value="6">
search result page doing search term replacement search result page doing search term replacement
</option> </option>
<option value="7">new tab page omnibox</option>
<option value="8">new tab page fakebox</option>
<option value="9"> <option value="9">
search result page not doing search term replacement search result page not doing search term replacement
</option> </option>
<option value="7">new tab page omnibox</option>
<option value="8">new tab page fakebox</option>
<option value="15">new tab page realbox</option> <option value="15">new tab page realbox</option>
<option value="1">(OBSOLETE) new tab page</option> <option value="16">search widget (Android)</option>
</select> </select>
</div> </div>
......
...@@ -122,8 +122,10 @@ bool MostVisitedSitesProvider::AllowMostVisitedSitesSuggestions( ...@@ -122,8 +122,10 @@ bool MostVisitedSitesProvider::AllowMostVisitedSitesSuggestions(
return false; return false;
// Only serve Most Visited suggestions when the current context is page visit. // Only serve Most Visited suggestions when the current context is page visit.
if (page_class != metrics::OmniboxEventProto::OTHER) if (page_class != metrics::OmniboxEventProto::OTHER &&
page_class != metrics::OmniboxEventProto::ANDROID_SEARCH_WIDGET) {
return false; return false;
}
// When omnibox contains pre-populated content, only show zero suggest for // When omnibox contains pre-populated content, only show zero suggest for
// pages with URLs the user will recognize. // pages with URLs the user will recognize.
......
...@@ -27,6 +27,7 @@ bool IsVerbatimMatchEligible( ...@@ -27,6 +27,7 @@ bool IsVerbatimMatchEligible(
SEARCH_RESULT_PAGE_NO_SEARCH_TERM_REPLACEMENT: SEARCH_RESULT_PAGE_NO_SEARCH_TERM_REPLACEMENT:
return base::FeatureList::IsEnabled( return base::FeatureList::IsEnabled(
omnibox::kOmniboxSearchReadyIncognito); omnibox::kOmniboxSearchReadyIncognito);
case metrics::OmniboxEventProto::ANDROID_SEARCH_WIDGET:
case metrics::OmniboxEventProto::OTHER: case metrics::OmniboxEventProto::OTHER:
return true; return true;
default: default:
......
Name: Metrics Protos Name: Metrics Protos
Short Name: metrics_proto Short Name: metrics_proto
URL: This is the canonical public repository URL: This is the canonical public repository
Version: 338697903 Version: 340693871
Date: 2020/10/23 UTC Date: 2020/11/04 UTC
License: BSD License: BSD
Security Critical: Yes Security Critical: Yes
......
...@@ -161,6 +161,9 @@ message OmniboxEventProto { ...@@ -161,6 +161,9 @@ message OmniboxEventProto {
// having focus in the realbox. // having focus in the realbox.
NTP_REALBOX = 15; NTP_REALBOX = 15;
// Android's Search Widget started directly from Launcher.
ANDROID_SEARCH_WIDGET = 16;
// When adding new classifications, please consider adding them in // When adding new classifications, please consider adding them in
// chromium's chrome/browser/resources/omnibox/omnibox.html // chromium's chrome/browser/resources/omnibox/omnibox.html
// so that these new options are displayed on about:omnibox. // so that these new options are displayed on about:omnibox.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment