Commit 5c084cb2 authored by Brandon Wylie's avatar Brandon Wylie Committed by Commit Bot

Hide the search engine icon when incognito

Bug: 986585
Change-Id: Iabfdebc44bcad6a7008627ed4dab043618aea31d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1766354
Commit-Queue: Brandon Wylie <wylieb@chromium.org>
Reviewed-by: default avatarTheresa  <twellington@chromium.org>
Reviewed-by: default avatarPatrick Noland <pnoland@chromium.org>
Cr-Commit-Position: refs/heads/master@{#691917}
parent 95007315
......@@ -49,6 +49,12 @@ public interface LocationBar extends UrlBarDelegate {
*/
void setAutocompleteProfile(Profile profile);
/**
* Specify whether location bar should present icons when focused.
* @param showIcon True if we should show the icons when the url is focused.
*/
void setShowIconsWhenUrlFocused(boolean showIcon);
/**
* Call to force the UI to update the state of various buttons based on whether or not the
* current tab is incognito.
......
......@@ -355,6 +355,11 @@ public class LocationBarLayout extends FrameLayout
mOmniboxPrerender.initializeForProfile(profile);
}
@Override
public void setShowIconsWhenUrlFocused(boolean showIcon) {
mStatusViewCoordinator.setShowIconsWhenUrlFocused(showIcon);
}
/** Focuses the current page. */
private void focusCurrentTab() {
if (mToolbarDataProvider.hasTab()) getCurrentTab().requestFocus();
......
......@@ -65,7 +65,7 @@ public class LocationBarPhone extends LocationBarLayout {
if (mShouldShowSearchEngineLogo) {
mFirstVisibleFocusedView = findViewById(R.id.location_bar_status);
}
mStatusViewCoordinator.setShowIconsWhenUrlFocused(shouldShowSearchEngineLogo);
setShowIconsWhenUrlFocused(shouldShowSearchEngineLogo);
}
/**
......
......@@ -13,6 +13,7 @@ import android.text.TextUtils;
import org.chromium.base.Callback;
import org.chromium.base.VisibleForTesting;
import org.chromium.base.library_loader.LibraryProcessType;
import org.chromium.chrome.R;
import org.chromium.chrome.browser.ChromeFeatureList;
import org.chromium.chrome.browser.favicon.FaviconHelper;
......@@ -21,6 +22,7 @@ import org.chromium.chrome.browser.profiles.Profile;
import org.chromium.chrome.browser.search_engines.TemplateUrlServiceFactory;
import org.chromium.chrome.browser.util.UrlUtilities;
import org.chromium.chrome.browser.widget.RoundedIconGenerator;
import org.chromium.content_public.browser.BrowserStartupController;
import java.util.HashMap;
import java.util.Map;
......@@ -49,7 +51,11 @@ public class SearchEngineLogoUtils {
public static boolean shouldShowSearchEngineLogo() {
return !LocaleManager.getInstance().needToCheckForSearchEnginePromo()
&& ChromeFeatureList.isInitialized()
&& ChromeFeatureList.isEnabled(ChromeFeatureList.OMNIBOX_SEARCH_ENGINE_LOGO);
&& ChromeFeatureList.isEnabled(ChromeFeatureList.OMNIBOX_SEARCH_ENGINE_LOGO)
// Using the profile now, so we need to pay attention to browser initialization.
&& BrowserStartupController.get(LibraryProcessType.PROCESS_BROWSER)
.isFullBrowserStarted()
&& !Profile.getLastUsedProfile().isOffTheRecord();
}
public static boolean shouldRoundedSearchEngineLogo() {
......
......@@ -37,7 +37,6 @@ class StatusMediator {
private boolean mPageIsOffline;
private boolean mShowStatusIconWhenUrlFocused;
private boolean mIsSecurityButtonShown;
private boolean mShouldShowSearchEngineLogo;
private boolean mIsSearchEngineGoogle;
private boolean mShouldCancelCustomFavicon;
......@@ -305,7 +304,6 @@ class StatusMediator {
mModel.set(StatusProperties.STATUS_ICON_TINT_RES, 0);
mIsSearchEngineGoogle = isSearchEngineGoogle;
mShouldShowSearchEngineLogo = shouldShowSearchEngineLogo;
updateLocationBarIcon();
}
......@@ -337,7 +335,7 @@ class StatusMediator {
&& mToolbarCommonPropertiesModel.getDisplaySearchTerms() != null
&& SearchEngineLogoUtils.doesUrlMatchDefaultSearchEngine(
mToolbarCommonPropertiesModel.getCurrentUrl());
if (mShouldShowSearchEngineLogo
if (SearchEngineLogoUtils.shouldShowSearchEngineLogo()
&& (showFocused || showUnfocusedNewTabPage || showUnfocusedSearchResultsPage)) {
mShouldCancelCustomFavicon = false;
mModel.set(StatusProperties.STATUS_ICON_TINT_RES, /* no tint */ 0);
......
......@@ -1872,6 +1872,8 @@ public class ToolbarManager implements ScrimObserver, ToolbarTabController, UrlF
mAppMenuPropertiesDelegate.setBookmarkBridge(mBookmarkBridge);
}
mLocationBar.setAutocompleteProfile(profile);
mLocationBar.setShowIconsWhenUrlFocused(
SearchEngineLogoUtils.shouldShowSearchEngineLogo());
}
mCurrentProfile = profile;
}
......
......@@ -828,6 +828,9 @@ public class CustomTabToolbar extends ToolbarLayout implements View.OnLongClickL
@Override
public void setAutocompleteProfile(Profile profile) {}
@Override
public void setShowIconsWhenUrlFocused(boolean showIcon) {}
@Override
public int getUrlContainerMarginEnd() {
return 0;
......
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