Commit c6657b44 authored by Tommy C. Li's avatar Tommy C. Li Committed by Commit Bot

[omnibox] Make Android use LocationBarModel::GetPageClassification

Currently, Android Chrome has its own page classification logic within
autocomplete_controller_android.cc.

This duplicates logic that now lives within LocationBarModel. This CL
makes the Android Autocomplete system re-use the LocationBarModel
version, which handles Query in Omnibox correctly.

Bug: 963680, 912722
Change-Id: I0dd14b6d6f4ab34a52c9629d3511baef111c73cb
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1627896
Commit-Queue: Tommy Li <tommycli@chromium.org>
Reviewed-by: default avatarTommy Li <tommycli@chromium.org>
Reviewed-by: default avatarTed Choc <tedchoc@chromium.org>
Cr-Commit-Position: refs/heads/master@{#665305}
parent 7c2a18ec
......@@ -97,15 +97,14 @@ public class AutocompleteController {
*
* @param profile The profile to use for starting the AutocompleteController
* @param url The URL of the current tab, used to suggest query refinements.
* @param pageClassification The page classification of the current tab.
* @param text The text to query autocomplete suggestions for.
* @param cursorPosition The position of the cursor within the text. Set to -1 if the cursor is
* not focused on the text.
* @param preventInlineAutocomplete Whether autocomplete suggestions should be prevented.
* @param focusedFromFakebox Whether the user entered the omnibox by tapping the fakebox on the
* native NTP. This should be false on all other pages.
*/
public void start(Profile profile, String url, String text, int cursorPosition,
boolean preventInlineAutocomplete, boolean focusedFromFakebox) {
public void start(Profile profile, String url, int pageClassification, String text,
int cursorPosition, boolean preventInlineAutocomplete) {
// crbug.com/764749
Log.w(TAG, "starting autocomplete controller..[%b][%b]", profile == null,
TextUtils.isEmpty(url));
......@@ -115,7 +114,7 @@ public class AutocompleteController {
// Initializing the native counterpart might still fail.
if (mNativeAutocompleteControllerAndroid != 0) {
nativeStart(mNativeAutocompleteControllerAndroid, text, cursorPosition, null, url,
preventInlineAutocomplete, false, false, true, focusedFromFakebox);
pageClassification, preventInlineAutocomplete, false, false, true);
mWaitingForSuggestionsToCache = false;
}
}
......@@ -148,12 +147,11 @@ public class AutocompleteController {
* @param profile The profile to use for starting the AutocompleteController.
* @param omniboxText The text displayed in the omnibox.
* @param url The url of the currently loaded web page.
* @param pageClassification The page classification of the current tab.
* @param title The title of the currently loaded web page.
* @param focusedFromFakebox Whether the user entered the omnibox by tapping the fakebox on the
* native NTP. This should be false on all other pages.
*/
public void startZeroSuggest(Profile profile, String omniboxText, String url, String title,
boolean focusedFromFakebox) {
public void startZeroSuggest(
Profile profile, String omniboxText, String url, int pageClassification, String title) {
if (profile == null || TextUtils.isEmpty(url)) return;
if (!NewTabPage.isNTPUrl(url)) {
......@@ -164,8 +162,8 @@ public class AutocompleteController {
mNativeAutocompleteControllerAndroid = nativeInit(profile);
if (mNativeAutocompleteControllerAndroid != 0) {
if (mUseCachedZeroSuggestResults) mWaitingForSuggestionsToCache = true;
nativeOnOmniboxFocused(mNativeAutocompleteControllerAndroid, omniboxText, url, title,
focusedFromFakebox);
nativeOnOmniboxFocused(mNativeAutocompleteControllerAndroid, omniboxText, url,
pageClassification, title);
}
}
......@@ -252,21 +250,20 @@ public class AutocompleteController {
* @param selectedIndex The index of the suggestion that was selected.
* @param type The type of the selected suggestion.
* @param currentPageUrl The URL of the current page.
* @param focusedFromFakebox Whether the user entered the omnibox by tapping the fakebox on the
* native NTP. This should be false on all other pages.
* @param pageClassification The page classification of the current tab.
* @param elapsedTimeSinceModified The number of ms that passed between the user first
* modifying text in the omnibox and selecting a suggestion.
* @param completedLength The length of the default match's inline autocompletion if any.
* @param webContents The web contents for the tab where the selected suggestion will be shown.
*/
public void onSuggestionSelected(int selectedIndex, int hashCode, int type,
String currentPageUrl, boolean focusedFromFakebox, long elapsedTimeSinceModified,
String currentPageUrl, int pageClassification, long elapsedTimeSinceModified,
int completedLength, WebContents webContents) {
assert mNativeAutocompleteControllerAndroid != 0;
// Don't natively log voice suggestion results as we add them in Java.
if (type == OmniboxSuggestionType.VOICE_SUGGEST) return;
nativeOnSuggestionSelected(mNativeAutocompleteControllerAndroid, selectedIndex, hashCode,
currentPageUrl, focusedFromFakebox, elapsedTimeSinceModified, completedLength,
currentPageUrl, pageClassification, elapsedTimeSinceModified, completedLength,
webContents);
}
......@@ -349,19 +346,18 @@ public class AutocompleteController {
@VisibleForTesting
protected native long nativeInit(Profile profile);
private native void nativeStart(long nativeAutocompleteControllerAndroid, String text,
int cursorPosition, String desiredTld, String currentUrl,
int cursorPosition, String desiredTld, String currentUrl, int pageClassification,
boolean preventInlineAutocomplete, boolean preferKeyword,
boolean allowExactKeywordMatch, boolean wantAsynchronousMatches,
boolean focusedFromFakebox);
boolean allowExactKeywordMatch, boolean wantAsynchronousMatches);
private native OmniboxSuggestion nativeClassify(
long nativeAutocompleteControllerAndroid, String text, boolean focusedFromFakebox);
private native void nativeStop(long nativeAutocompleteControllerAndroid, boolean clearResults);
private native void nativeResetSession(long nativeAutocompleteControllerAndroid);
private native void nativeOnSuggestionSelected(long nativeAutocompleteControllerAndroid,
int selectedIndex, int hashCode, String currentPageUrl, boolean focusedFromFakebox,
int selectedIndex, int hashCode, String currentPageUrl, int pageClassification,
long elapsedTimeSinceModified, int completedLength, WebContents webContents);
private native void nativeOnOmniboxFocused(long nativeAutocompleteControllerAndroid,
String omniboxText, String currentUrl, String currentTitle, boolean focusedFromFakebox);
String omniboxText, String currentUrl, int pageClassification, String currentTitle);
private native void nativeDeleteSuggestion(
long nativeAutocompleteControllerAndroid, int selectedIndex, int hashCode);
private native String nativeUpdateMatchDestinationURLWithQueryFormulationTime(
......
......@@ -693,8 +693,10 @@ class AutocompleteMediator
// position. Hence, there's no need to check for -1 here explicitly.
cursorPosition = mUrlBarEditingTextProvider.getSelectionStart();
}
mAutocomplete.start(profile, mDataProvider.getCurrentUrl(), textWithoutAutocomplete,
cursorPosition, preventAutocomplete, mDelegate.didFocusUrlFromFakebox());
int pageClassification =
mDataProvider.getPageClassification(mDelegate.didFocusUrlFromFakebox());
mAutocomplete.start(profile, mDataProvider.getCurrentUrl(), pageClassification,
textWithoutAutocomplete, cursorPosition, preventAutocomplete);
};
if (mNativeInitialized) {
mHandler.postDelayed(mRequestSuggestions, OMNIBOX_SUGGESTION_START_DELAY_MS);
......@@ -860,8 +862,10 @@ class AutocompleteMediator
if (!shouldSkipNativeLog) {
int autocompleteLength = mUrlBarEditingTextProvider.getTextWithAutocomplete().length()
- mUrlBarEditingTextProvider.getTextWithoutAutocomplete().length();
int pageClassification =
mDataProvider.getPageClassification(mDelegate.didFocusUrlFromFakebox());
mAutocomplete.onSuggestionSelected(matchPosition, suggestion.hashCode(), type,
currentPageUrl, mDelegate.didFocusUrlFromFakebox(), elapsedTimeSinceModified,
currentPageUrl, pageClassification, elapsedTimeSinceModified,
autocompleteLength, webContents);
}
if (((transition & PageTransition.CORE_MASK) == PageTransition.TYPED)
......@@ -900,10 +904,11 @@ class AutocompleteMediator
mHasStartedNewOmniboxEditSession = false;
mNewOmniboxEditSessionTimestamp = -1;
if (mNativeInitialized && mDelegate.isUrlBarFocused() && mDataProvider.hasTab()) {
int pageClassification =
mDataProvider.getPageClassification(mDelegate.didFocusUrlFromFakebox());
mAutocomplete.startZeroSuggest(mDataProvider.getProfile(),
mUrlBarEditingTextProvider.getTextWithAutocomplete(),
mDataProvider.getCurrentUrl(), mDataProvider.getTitle(),
mDelegate.didFocusUrlFromFakebox());
mDataProvider.getCurrentUrl(), pageClassification, mDataProvider.getTitle());
}
}
......@@ -969,8 +974,8 @@ class AutocompleteMediator
void startAutocompleteForQuery(String query) {
stopAutocomplete(false);
if (mDataProvider.hasTab()) {
mAutocomplete.start(mDataProvider.getProfile(), mDataProvider.getCurrentUrl(), query,
-1, false, false);
mAutocomplete.start(mDataProvider.getProfile(), mDataProvider.getCurrentUrl(),
mDataProvider.getPageClassification(false), query, -1, false);
}
}
......
......@@ -351,6 +351,12 @@ public class LocationBarModel implements ToolbarDataProvider {
return getSecurityLevel(tab, isOfflinePage(), TrustedCdn.getPublisherUrl(tab));
}
@Override
public int getPageClassification(boolean isFocusedFromFakebox) {
if (mNativeLocationBarModelAndroid == 0) return 0;
return nativeGetPageClassification(mNativeLocationBarModelAndroid, isFocusedFromFakebox);
}
@Override
public int getSecurityIconResource(boolean isTablet) {
// If we're showing a query in the omnibox, and the security level is high enough to show
......@@ -486,4 +492,6 @@ public class LocationBarModel implements ToolbarDataProvider {
private native String nativeGetFormattedFullURL(long nativeLocationBarModelAndroid);
private native String nativeGetURLForDisplay(long nativeLocationBarModelAndroid);
private native String nativeGetDisplaySearchTerms(long nativeLocationBarModelAndroid);
private native int nativeGetPageClassification(
long nativeLocationBarModelAndroid, boolean isFocusedFromFakebox);
}
......@@ -101,6 +101,14 @@ public interface ToolbarDataProvider {
@ConnectionSecurityLevel
int getSecurityLevel();
/**
* @param isFocusedFromFakebox If the omnibox focus originated from the fakebox.
* @return The current page classification.
*/
default int getPageClassification(boolean isFocusedFromFakebox) {
return 0;
}
/**
* @return The resource ID of the icon that should be displayed or 0 if no icon should be shown.
*/
......
......@@ -157,11 +157,11 @@ void AutocompleteControllerAndroid::Start(JNIEnv* env,
jint j_cursor_pos,
const JavaRef<jstring>& j_desired_tld,
const JavaRef<jstring>& j_current_url,
jint j_page_classification,
bool prevent_inline_autocomplete,
bool prefer_keyword,
bool allow_exact_keyword_match,
bool want_asynchronous_matches,
bool focused_from_fakebox) {
bool want_asynchronous_matches) {
if (!autocomplete_controller_)
return;
......@@ -172,11 +172,11 @@ void AutocompleteControllerAndroid::Start(JNIEnv* env,
if (!j_desired_tld.is_null())
desired_tld = base::android::ConvertJavaStringToUTF8(env, j_desired_tld);
base::string16 text = ConvertJavaStringToUTF16(env, j_text);
OmniboxEventProto::PageClassification page_classification =
ClassifyPage(current_url, focused_from_fakebox);
size_t cursor_pos = j_cursor_pos == -1 ? base::string16::npos : j_cursor_pos;
input_ = AutocompleteInput(text, cursor_pos, desired_tld, page_classification,
ChromeAutocompleteSchemeClassifier(profile_));
input_ = AutocompleteInput(
text, cursor_pos, desired_tld,
OmniboxEventProto::PageClassification(j_page_classification),
ChromeAutocompleteSchemeClassifier(profile_));
input_.set_current_url(current_url);
input_.set_prevent_inline_autocomplete(prevent_inline_autocomplete);
input_.set_prefer_keyword(prefer_keyword);
......@@ -198,8 +198,8 @@ void AutocompleteControllerAndroid::OnOmniboxFocused(
const JavaParamRef<jobject>& obj,
const JavaParamRef<jstring>& j_omnibox_text,
const JavaParamRef<jstring>& j_current_url,
const JavaParamRef<jstring>& j_current_title,
jboolean focused_from_fakebox) {
jint j_page_classification,
const JavaParamRef<jstring>& j_current_title) {
if (!autocomplete_controller_)
return;
......@@ -220,9 +220,10 @@ void AutocompleteControllerAndroid::OnOmniboxFocused(
!current_url.SchemeIs(chrome::kChromeUINativeScheme))
omnibox_text = url;
input_ = AutocompleteInput(omnibox_text,
ClassifyPage(current_url, focused_from_fakebox),
ChromeAutocompleteSchemeClassifier(profile_));
input_ = AutocompleteInput(
omnibox_text,
OmniboxEventProto::PageClassification(j_page_classification),
ChromeAutocompleteSchemeClassifier(profile_));
input_.set_current_url(current_url);
input_.set_current_title(current_title);
input_.set_from_omnibox_focus(true);
......@@ -249,7 +250,7 @@ void AutocompleteControllerAndroid::OnSuggestionSelected(
jint selected_index,
jint hash_code,
const JavaParamRef<jstring>& j_current_url,
jboolean focused_from_fakebox,
jint j_page_classification,
jlong elapsed_time_since_first_modified,
jint completed_length,
const JavaParamRef<jobject>& j_web_contents) {
......@@ -258,8 +259,6 @@ void AutocompleteControllerAndroid::OnSuggestionSelected(
base::string16 url = ConvertJavaStringToUTF16(env, j_current_url);
const GURL current_url = GURL(url);
OmniboxEventProto::PageClassification current_page_classification =
ClassifyPage(current_url, focused_from_fakebox);
const base::TimeTicks& now(base::TimeTicks::Now());
content::WebContents* web_contents =
content::WebContents::FromJavaWebContents(j_web_contents);
......@@ -280,16 +279,12 @@ void AutocompleteControllerAndroid::OnSuggestionSelected(
// For zero suggest, record an empty input string instead of the
// current URL.
input_.from_omnibox_focus() ? base::string16() : input_.text(),
false, /* don't know */
input_.type(),
false, /* not keyword mode */
OmniboxEventProto::INVALID,
true,
selected_index,
WindowOpenDisposition::CURRENT_TAB,
false,
false, /* don't know */
input_.type(), false, /* not keyword mode */
OmniboxEventProto::INVALID, true, selected_index,
WindowOpenDisposition::CURRENT_TAB, false,
SessionTabHelper::IdForTab(web_contents),
current_page_classification,
OmniboxEventProto::PageClassification(j_page_classification),
base::TimeDelta::FromMilliseconds(elapsed_time_since_first_modified),
completed_length,
now - autocomplete_controller_->last_time_default_match_changed(),
......@@ -431,49 +426,6 @@ void AutocompleteControllerAndroid::NotifySuggestionsReceived(
j_autocomplete_result);
}
OmniboxEventProto::PageClassification
AutocompleteControllerAndroid::ClassifyPage(const GURL& gurl,
bool focused_from_fakebox) const {
if (!gurl.is_valid())
return OmniboxEventProto::INVALID_SPEC;
const std::string& url = gurl.spec();
if (gurl.SchemeIs(content::kChromeUIScheme) &&
gurl.host_piece() == chrome::kChromeUINewTabHost) {
return OmniboxEventProto::NTP;
}
if (url == chrome::kChromeUINativeNewTabURL) {
// On phones, the omnibox is not initially shown on the NTP. In this case,
// treat the fakebox like the omnibox.
if (ui::GetDeviceFormFactor() == ui::DEVICE_FORM_FACTOR_PHONE)
return OmniboxEventProto::INSTANT_NTP_WITH_OMNIBOX_AS_STARTING_FOCUS;
// On tablets, the user can choose to focus either the fakebox or the
// omnibox. Chrome distinguishes between the two in order to apply URL
// demotion when the user focuses the fakebox (which looks more like a
// search box) but not when they focus the omnibox (which looks more
// like a URL bar).
return focused_from_fakebox ?
OmniboxEventProto::INSTANT_NTP_WITH_FAKEBOX_AS_STARTING_FOCUS :
OmniboxEventProto::INSTANT_NTP_WITH_OMNIBOX_AS_STARTING_FOCUS;
}
if (url == url::kAboutBlankURL)
return OmniboxEventProto::BLANK;
if (url == profile_->GetPrefs()->GetString(prefs::kHomePage))
return OmniboxEventProto::HOME_PAGE;
bool is_search_url = TemplateURLServiceFactory::GetForProfile(profile_)->
IsSearchResultsPageFromDefaultSearchProvider(gurl);
if (is_search_url)
return OmniboxEventProto::SEARCH_RESULT_PAGE_NO_SEARCH_TERM_REPLACEMENT;
return OmniboxEventProto::OTHER;
}
namespace {
// Updates the formatting of Android omnibox suggestions where we intentionally
......
......@@ -38,11 +38,11 @@ class AutocompleteControllerAndroid : public AutocompleteControllerDelegate,
jint j_cursor_pos,
const base::android::JavaRef<jstring>& j_desired_tld,
const base::android::JavaRef<jstring>& j_current_url,
jint j_page_classification,
bool prevent_inline_autocomplete,
bool prefer_keyword,
bool allow_exact_keyword_match,
bool want_asynchronous_matches,
bool focused_from_fakebox);
bool want_asynchronous_matches);
base::android::ScopedJavaLocalRef<jobject> Classify(
JNIEnv* env,
const base::android::JavaParamRef<jobject>& obj,
......@@ -53,8 +53,8 @@ class AutocompleteControllerAndroid : public AutocompleteControllerDelegate,
const base::android::JavaParamRef<jobject>& obj,
const base::android::JavaParamRef<jstring>& j_omnibox_text,
const base::android::JavaParamRef<jstring>& j_current_url,
const base::android::JavaParamRef<jstring>& j_current_title,
jboolean focused_from_fakebox);
jint j_page_classification,
const base::android::JavaParamRef<jstring>& j_current_title);
void Stop(JNIEnv* env,
const base::android::JavaParamRef<jobject>& obj,
bool clear_result);
......@@ -66,7 +66,7 @@ class AutocompleteControllerAndroid : public AutocompleteControllerDelegate,
jint selected_index,
jint hash_code,
const base::android::JavaParamRef<jstring>& j_current_url,
jboolean focused_from_fakebox,
jint j_page_classification,
jlong elapsed_time_since_first_modified,
jint completed_length,
const base::android::JavaParamRef<jobject>& j_web_contents);
......@@ -120,11 +120,6 @@ class AutocompleteControllerAndroid : public AutocompleteControllerDelegate,
void NotifySuggestionsReceived(
const AutocompleteResult& autocomplete_result);
// Classifies the type of page we are on.
metrics::OmniboxEventProto::PageClassification ClassifyPage(
const GURL& gurl,
bool focused_from_fakebox) const;
base::android::ScopedJavaLocalRef<jobject> BuildOmniboxSuggestion(
JNIEnv* env, const AutocompleteMatch& match);
......
......@@ -5,12 +5,15 @@
#include "chrome/browser/ui/android/toolbar/location_bar_model_android.h"
#include "base/android/jni_string.h"
#include "chrome/common/url_constants.h"
#include "chrome/common/webui_url_constants.h"
#include "components/omnibox/browser/location_bar_model_impl.h"
#include "content/public/browser/navigation_entry.h"
#include "content/public/browser/ssl_status.h"
#include "content/public/browser/web_contents.h"
#include "content/public/common/content_constants.h"
#include "jni/LocationBarModel_jni.h"
#include "ui/base/device_form_factor.h"
using base::android::JavaParamRef;
using base::android::JavaRef;
......@@ -54,6 +57,29 @@ ScopedJavaLocalRef<jstring> LocationBarModelAndroid::GetDisplaySearchTerms(
return base::android::ConvertUTF16ToJavaString(env, result);
}
jint LocationBarModelAndroid::GetPageClassification(
JNIEnv* env,
const base::android::JavaParamRef<jobject>& obj,
bool is_focused_from_fakebox) {
// On phones, the omnibox is not initially shown on the NTP. In this case,
// treat the fakebox like the omnibox.
if (ui::GetDeviceFormFactor() == ui::DEVICE_FORM_FACTOR_PHONE)
is_focused_from_fakebox = false;
// On tablets, the user can choose to focus either the fakebox or the
// omnibox. Chrome distinguishes between the two in order to apply URL
// demotion when the user focuses the fakebox (which looks more like a
// search box) but not when they focus the omnibox (which looks more
// like a URL bar).
OmniboxFocusSource source = is_focused_from_fakebox
? OmniboxFocusSource::FAKEBOX
: OmniboxFocusSource::OMNIBOX;
// TODO: Android does not save the homepage to the native pref, so we will
// never get the HOME_PAGE classification. Fix this by overriding IsHomePage.
return location_bar_model_->GetPageClassification(source);
}
content::WebContents* LocationBarModelAndroid::GetActiveWebContents() const {
JNIEnv* env = base::android::AttachCurrentThread();
ScopedJavaLocalRef<jobject> jweb_contents =
......@@ -61,6 +87,20 @@ content::WebContents* LocationBarModelAndroid::GetActiveWebContents() const {
return content::WebContents::FromJavaWebContents(jweb_contents);
}
bool LocationBarModelAndroid::IsInstantNTP() const {
GURL url;
if (!GetURL(&url))
return false;
// Android Chrome has its own Instant NTP page implementation.
if (url.SchemeIs(chrome::kChromeNativeScheme) &&
url.host_piece() == chrome::kChromeUINewTabHost) {
return true;
}
return false;
}
// static
jlong JNI_LocationBarModel_Init(JNIEnv* env, const JavaParamRef<jobject>& obj) {
return reinterpret_cast<intptr_t>(new LocationBarModelAndroid(env, obj));
......
......@@ -34,9 +34,13 @@ class LocationBarModelAndroid : public ChromeLocationBarModelDelegate {
base::android::ScopedJavaLocalRef<jstring> GetDisplaySearchTerms(
JNIEnv* env,
const base::android::JavaParamRef<jobject>& obj);
jint GetPageClassification(JNIEnv* env,
const base::android::JavaParamRef<jobject>& obj,
bool is_focused_from_fakebox);
// ChromeLocationBarModelDelegate:
content::WebContents* GetActiveWebContents() const override;
bool IsInstantNTP() const override;
private:
std::unique_ptr<LocationBarModel> location_bar_model_;
......
// Copyright 2019 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.
#include "chrome/browser/ui/android/toolbar/location_bar_model_android.h"
#include "chrome/common/webui_url_constants.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace {
class TestLocationBarModelAndroid : public LocationBarModelAndroid {
public:
TestLocationBarModelAndroid()
: LocationBarModelAndroid(nullptr, base::android::JavaRef<jobject>()) {}
~TestLocationBarModelAndroid() override = default;
// LocationBarModelDelegate:
bool GetURL(GURL* url) const override {
*url = url_;
return true;
}
void SetURL(const GURL& url) { url_ = url; }
private:
GURL url_;
};
} // namespace
TEST(LocationBarModelAndroidTest, ClassifyAndroidNativeNewTabPage) {
TestLocationBarModelAndroid location_bar_model_android;
location_bar_model_android.SetURL(GURL(chrome::kChromeUINativeNewTabURL));
EXPECT_EQ(
metrics::OmniboxEventProto::INSTANT_NTP_WITH_OMNIBOX_AS_STARTING_FOCUS,
location_bar_model_android.GetPageClassification(
nullptr, base::android::JavaParamRef<jobject>(nullptr), false));
std::string ntp_with_path_and_query =
std::string(chrome::kChromeUINativeNewTabURL) + "foopath?foo=bar";
location_bar_model_android.SetURL(GURL(ntp_with_path_and_query));
EXPECT_EQ(
metrics::OmniboxEventProto::INSTANT_NTP_WITH_OMNIBOX_AS_STARTING_FOCUS,
location_bar_model_android.GetPageClassification(
nullptr, base::android::JavaParamRef<jobject>(nullptr), false));
}
......@@ -27,20 +27,11 @@ class ChromeLocationBarModelDelegate : public LocationBarModelDelegate {
bool ShouldPreventElision() const override;
// LocationBarModelDelegate:
bool ShouldDisplayURL() const override;
protected:
ChromeLocationBarModelDelegate();
~ChromeLocationBarModelDelegate() override;
// Helper method to get the navigation entry from the navigation controller.
content::NavigationEntry* GetNavigationEntry() const;
private:
base::string16 FormattedStringWithEquivalentMeaning(
const GURL& url,
const base::string16& formatted_url) const override;
bool GetURL(GURL* url) const override;
bool ShouldDisplayURL() const override;
security_state::SecurityLevel GetSecurityLevel() const override;
std::unique_ptr<security_state::VisibleSecurityState>
GetVisibleSecurityState() const override;
......@@ -53,6 +44,14 @@ class ChromeLocationBarModelDelegate : public LocationBarModelDelegate {
AutocompleteClassifier* GetAutocompleteClassifier() override;
TemplateURLService* GetTemplateURLService() override;
protected:
ChromeLocationBarModelDelegate();
~ChromeLocationBarModelDelegate() override;
// Helper method to get the navigation entry from the navigation controller.
content::NavigationEntry* GetNavigationEntry() const;
private:
// Returns the navigation controller used to retrieve the navigation entry
// from which the states are retrieved. If this returns null, default values
// are used.
......
......@@ -3014,6 +3014,7 @@ test("unit_tests") {
"../browser/translate/translate_service_unittest.cc",
"../browser/ui/android/tab_model/tab_model_list_unittest.cc",
"../browser/ui/android/tab_model/tab_model_unittest.cc",
"../browser/ui/android/toolbar/location_bar_model_android_unittest.cc",
"../browser/ui/autofill/autofill_popup_layout_model_unittest.cc",
"../browser/ui/autofill/popup_view_common_unittest.cc",
"../browser/ui/autofill/popup_view_test_helpers.cc",
......
......@@ -144,8 +144,8 @@ public class OmniboxTestUtils {
}
@Override
public void start(Profile profile, String url, final String text, int cursorPosition,
boolean preventInlineAutocomplete, boolean focusedFromFakebox) {
public void start(Profile profile, String url, int pageClassification, final String text,
int cursorPosition, boolean preventInlineAutocomplete) {
mStartAutocompleteCalled = true;
mSuggestionsDispatcher = new Runnable() {
@Override
......@@ -166,8 +166,8 @@ public class OmniboxTestUtils {
}
@Override
public void startZeroSuggest(Profile profile, String omniboxText, String url, String title,
boolean focusedFromFakebox) {
public void startZeroSuggest(Profile profile, String omniboxText, String url,
int pageClassification, String title) {
mZeroSuggestCalledCount++;
}
......@@ -209,12 +209,12 @@ public class OmniboxTestUtils {
}
@Override
public void start(Profile profile, String url, String text, int cursorPosition,
boolean preventInlineAutocomplete, boolean focusedFromFakebox) {}
public void start(Profile profile, String url, int pageClassification, String text,
int cursorPosition, boolean preventInlineAutocomplete) {}
@Override
public void startZeroSuggest(Profile profile, String omniboxText, String url, String title,
boolean focusedFromFakebox) {}
public void startZeroSuggest(Profile profile, String omniboxText, String url,
int pageClassification, String title) {}
@Override
public void stop(boolean clear) {}
......
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