Skip to content

Commit

Permalink
Fix Padlock icon gone during transition from Incognito to website.
Browse files Browse the repository at this point in the history
The change addresses a bug where triggered focus animation would
remove the site padlock.

The change also reduces volume of initiated animations by not
starting animations within the same state, ie. focused->focused or
unfocused->unfocused.

The change fixes a parameter passed to triggerUrlFocusAnimation that
needs to indicate whether URL is focused; the parameter being passed
right now suggests that URL is focused when it isn't.

(cherry picked from commit 929250d)

Bug: 1182133, 1183250
Change-Id: I84f9e6cdb603fdcac4a73afab85efde973c77da6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2724973
Commit-Queue: Tomasz Wiszkowski <ender@google.com>
Reviewed-by: Xi Han <hanxi@chromium.org>
Reviewed-by: Patrick Noland <pnoland@chromium.org>
Reviewed-by: Filip Gorski <fgorski@chromium.org>
Cr-Original-Commit-Position: refs/heads/master@{#859842}
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2739202
Reviewed-by: Krishna Govind <govind@chromium.org>
Commit-Queue: Krishna Govind <govind@chromium.org>
Cr-Commit-Position: refs/branch-heads/4430@{#174}
Cr-Branched-From: e5ce7dc-refs/heads/master@{#857950}
  • Loading branch information
tomasz-wiszkowski authored and Chromium LUCI CQ committed Mar 5, 2021
1 parent 1613c10 commit e43b72c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1804,7 +1804,7 @@ public void testNewSurfaceFromHomeButton(){
.perform(pressKey(KeyEvent.KEYCODE_ENTER));
hideWatcher.waitForBehavior();
TabUiTestHelper.verifyTabModelTabCount(mActivityTestRule.getActivity(), 2, 0);
onView(withId(R.id.home_button)).perform(click());
pressHomePageButton();

// MV tiles and carousel tab switcher should not show anymore.
onViewWaiting(allOf(withId(R.id.start_tab_switcher_button), isDisplayed()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ public class ToolbarPhone extends ToolbarLayout implements OnClickListener, TabC
protected int mUnfocusedLocationBarLayoutLeft;
protected int mUnfocusedLocationBarLayoutRight;
private boolean mUnfocusedLocationBarUsesTransparentBg;
private boolean mCurrentUrlFocusState;

private int mLocationBarBackgroundAlpha = 255;
private float mNtpSearchBoxScrollFraction = UNINITIALIZED_FRACTION;
Expand Down Expand Up @@ -1872,14 +1873,10 @@ private boolean handleOmniboxInOverviewMode(boolean inTabSwitcherMode) {
// possible that this function is called before native initialization when Instant Start
// is enabled. Keyboard shouldn't be shown here.
if (isNativeLibraryReady()) {
boolean hasFocus = inTabSwitcherMode && !urlHasFocus();
boolean shouldShowKeyboard = false;
boolean hasFocus = urlHasFocus();
// When switching out of the tab switcher and the url has got focused, we don't clear
// the focus.
if (!inTabSwitcherMode && urlHasFocus()) {
hasFocus = true;
shouldShowKeyboard = true;
}
boolean shouldShowKeyboard = hasFocus && !inTabSwitcherMode;
triggerUrlFocusAnimation(hasFocus, shouldShowKeyboard);
} else {
mPendingTriggerUrlFocusRequest = true;
Expand Down Expand Up @@ -2100,7 +2097,10 @@ public void onUrlFocusChange(final boolean hasFocus) {

if (getToolbarDataProvider().isInOverviewAndShowingOmnibox()) {
mUrlBar.setText("");
if (!hasFocus) return;
if (!hasFocus) {
mCurrentUrlFocusState = false;
return;
}
}

triggerUrlFocusAnimation(hasFocus, /* shouldShowKeyboard= */ hasFocus);
Expand All @@ -2112,6 +2112,14 @@ public void onUrlFocusChange(final boolean hasFocus) {
* as hasFocus by default.
*/
private void triggerUrlFocusAnimation(final boolean hasFocus, boolean shouldShowKeyboard) {
// Check if we need to run animation. If not, jump directly to target desired state.
if (mCurrentUrlFocusState == hasFocus) {
mLocationBar.finishUrlFocusChange(hasFocus, shouldShowKeyboard,
getToolbarDataProvider().shouldShowLocationBarInOverviewMode());
return;
}

mCurrentUrlFocusState = hasFocus;
TraceEvent.begin("ToolbarPhone.triggerUrlFocusAnimation");
if (mUrlFocusLayoutAnimator != null && mUrlFocusLayoutAnimator.isRunning()) {
mUrlFocusLayoutAnimator.cancel();
Expand Down

0 comments on commit e43b72c

Please sign in to comment.