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 { ...@@ -49,6 +49,12 @@ public interface LocationBar extends UrlBarDelegate {
*/ */
void setAutocompleteProfile(Profile profile); 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 * Call to force the UI to update the state of various buttons based on whether or not the
* current tab is incognito. * current tab is incognito.
......
...@@ -355,6 +355,11 @@ public class LocationBarLayout extends FrameLayout ...@@ -355,6 +355,11 @@ public class LocationBarLayout extends FrameLayout
mOmniboxPrerender.initializeForProfile(profile); mOmniboxPrerender.initializeForProfile(profile);
} }
@Override
public void setShowIconsWhenUrlFocused(boolean showIcon) {
mStatusViewCoordinator.setShowIconsWhenUrlFocused(showIcon);
}
/** Focuses the current page. */ /** Focuses the current page. */
private void focusCurrentTab() { private void focusCurrentTab() {
if (mToolbarDataProvider.hasTab()) getCurrentTab().requestFocus(); if (mToolbarDataProvider.hasTab()) getCurrentTab().requestFocus();
......
...@@ -65,7 +65,7 @@ public class LocationBarPhone extends LocationBarLayout { ...@@ -65,7 +65,7 @@ public class LocationBarPhone extends LocationBarLayout {
if (mShouldShowSearchEngineLogo) { if (mShouldShowSearchEngineLogo) {
mFirstVisibleFocusedView = findViewById(R.id.location_bar_status); mFirstVisibleFocusedView = findViewById(R.id.location_bar_status);
} }
mStatusViewCoordinator.setShowIconsWhenUrlFocused(shouldShowSearchEngineLogo); setShowIconsWhenUrlFocused(shouldShowSearchEngineLogo);
} }
/** /**
......
...@@ -13,6 +13,7 @@ import android.text.TextUtils; ...@@ -13,6 +13,7 @@ import android.text.TextUtils;
import org.chromium.base.Callback; import org.chromium.base.Callback;
import org.chromium.base.VisibleForTesting; import org.chromium.base.VisibleForTesting;
import org.chromium.base.library_loader.LibraryProcessType;
import org.chromium.chrome.R; import org.chromium.chrome.R;
import org.chromium.chrome.browser.ChromeFeatureList; import org.chromium.chrome.browser.ChromeFeatureList;
import org.chromium.chrome.browser.favicon.FaviconHelper; import org.chromium.chrome.browser.favicon.FaviconHelper;
...@@ -21,6 +22,7 @@ import org.chromium.chrome.browser.profiles.Profile; ...@@ -21,6 +22,7 @@ import org.chromium.chrome.browser.profiles.Profile;
import org.chromium.chrome.browser.search_engines.TemplateUrlServiceFactory; import org.chromium.chrome.browser.search_engines.TemplateUrlServiceFactory;
import org.chromium.chrome.browser.util.UrlUtilities; import org.chromium.chrome.browser.util.UrlUtilities;
import org.chromium.chrome.browser.widget.RoundedIconGenerator; import org.chromium.chrome.browser.widget.RoundedIconGenerator;
import org.chromium.content_public.browser.BrowserStartupController;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
...@@ -49,7 +51,11 @@ public class SearchEngineLogoUtils { ...@@ -49,7 +51,11 @@ public class SearchEngineLogoUtils {
public static boolean shouldShowSearchEngineLogo() { public static boolean shouldShowSearchEngineLogo() {
return !LocaleManager.getInstance().needToCheckForSearchEnginePromo() return !LocaleManager.getInstance().needToCheckForSearchEnginePromo()
&& ChromeFeatureList.isInitialized() && 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() { public static boolean shouldRoundedSearchEngineLogo() {
......
...@@ -37,7 +37,6 @@ class StatusMediator { ...@@ -37,7 +37,6 @@ class StatusMediator {
private boolean mPageIsOffline; private boolean mPageIsOffline;
private boolean mShowStatusIconWhenUrlFocused; private boolean mShowStatusIconWhenUrlFocused;
private boolean mIsSecurityButtonShown; private boolean mIsSecurityButtonShown;
private boolean mShouldShowSearchEngineLogo;
private boolean mIsSearchEngineGoogle; private boolean mIsSearchEngineGoogle;
private boolean mShouldCancelCustomFavicon; private boolean mShouldCancelCustomFavicon;
...@@ -305,7 +304,6 @@ class StatusMediator { ...@@ -305,7 +304,6 @@ class StatusMediator {
mModel.set(StatusProperties.STATUS_ICON_TINT_RES, 0); mModel.set(StatusProperties.STATUS_ICON_TINT_RES, 0);
mIsSearchEngineGoogle = isSearchEngineGoogle; mIsSearchEngineGoogle = isSearchEngineGoogle;
mShouldShowSearchEngineLogo = shouldShowSearchEngineLogo;
updateLocationBarIcon(); updateLocationBarIcon();
} }
...@@ -337,7 +335,7 @@ class StatusMediator { ...@@ -337,7 +335,7 @@ class StatusMediator {
&& mToolbarCommonPropertiesModel.getDisplaySearchTerms() != null && mToolbarCommonPropertiesModel.getDisplaySearchTerms() != null
&& SearchEngineLogoUtils.doesUrlMatchDefaultSearchEngine( && SearchEngineLogoUtils.doesUrlMatchDefaultSearchEngine(
mToolbarCommonPropertiesModel.getCurrentUrl()); mToolbarCommonPropertiesModel.getCurrentUrl());
if (mShouldShowSearchEngineLogo if (SearchEngineLogoUtils.shouldShowSearchEngineLogo()
&& (showFocused || showUnfocusedNewTabPage || showUnfocusedSearchResultsPage)) { && (showFocused || showUnfocusedNewTabPage || showUnfocusedSearchResultsPage)) {
mShouldCancelCustomFavicon = false; mShouldCancelCustomFavicon = false;
mModel.set(StatusProperties.STATUS_ICON_TINT_RES, /* no tint */ 0); mModel.set(StatusProperties.STATUS_ICON_TINT_RES, /* no tint */ 0);
......
...@@ -1872,6 +1872,8 @@ public class ToolbarManager implements ScrimObserver, ToolbarTabController, UrlF ...@@ -1872,6 +1872,8 @@ public class ToolbarManager implements ScrimObserver, ToolbarTabController, UrlF
mAppMenuPropertiesDelegate.setBookmarkBridge(mBookmarkBridge); mAppMenuPropertiesDelegate.setBookmarkBridge(mBookmarkBridge);
} }
mLocationBar.setAutocompleteProfile(profile); mLocationBar.setAutocompleteProfile(profile);
mLocationBar.setShowIconsWhenUrlFocused(
SearchEngineLogoUtils.shouldShowSearchEngineLogo());
} }
mCurrentProfile = profile; mCurrentProfile = profile;
} }
......
...@@ -828,6 +828,9 @@ public class CustomTabToolbar extends ToolbarLayout implements View.OnLongClickL ...@@ -828,6 +828,9 @@ public class CustomTabToolbar extends ToolbarLayout implements View.OnLongClickL
@Override @Override
public void setAutocompleteProfile(Profile profile) {} public void setAutocompleteProfile(Profile profile) {}
@Override
public void setShowIconsWhenUrlFocused(boolean showIcon) {}
@Override @Override
public int getUrlContainerMarginEnd() { public int getUrlContainerMarginEnd() {
return 0; 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