Commit 1d6b1a0c authored by Emily Stark's avatar Emily Stark Committed by Commit Bot

Simplified domains: don't elide on autofocusing form fields

In the simplified domains hide-on-interaction field trial, we elide
the URL to the simplified domain (the most security-critical
information) when the user focuses a text form field, which can be a
moment where the user is making a security decision. However, this can
lead to a weird experience when webpages autofocus input fields
without user interaction. Therefore, this CL only elides the URL when
the user specifically clicks a form field to focus it. (Focusing by
keypress will already cause the URL to elide all keypresses trigger
elision via DidGetUserInteraction()).

Bug: 1104280
Change-Id: I016aa5df5ce34bf71ccec86401f9ed192f6d9ef8
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2377322
Commit-Queue: Emily Stark <estark@chromium.org>
Reviewed-by: default avatarTommy Li <tommycli@chromium.org>
Cr-Commit-Position: refs/heads/master@{#802413}
parent e31eca1d
...@@ -2040,8 +2040,17 @@ void OmniboxViewViews::DidGetUserInteraction( ...@@ -2040,8 +2040,17 @@ void OmniboxViewViews::DidGetUserInteraction(
void OmniboxViewViews::OnFocusChangedInPage( void OmniboxViewViews::OnFocusChangedInPage(
content::FocusedNodeDetails* details) { content::FocusedNodeDetails* details) {
if (details->is_editable_node) // Elide the URL to the simplified domain (the most security-critical
// information) when the user focuses a form text field, which is a key moment
// for making security decisions. Ignore the focus event if it didn't come
// from a mouse click/tap. Focus via keyboard will trigger elision from
// DidGetUserInteraction(), and we want to ignore focuses that aren't from an
// explicit user action (e.g., input fields that are autofocused on page
// load).
if (details->is_editable_node &&
details->focus_type == blink::mojom::FocusType::kMouse) {
MaybeElideURLWithAnimationFromInteraction(); MaybeElideURLWithAnimationFromInteraction();
}
} }
base::string16 OmniboxViewViews::GetSelectionClipboardText() const { base::string16 OmniboxViewViews::GetSelectionClipboardText() const {
......
...@@ -2232,13 +2232,33 @@ TEST_P(OmniboxViewViewsHideOnInteractionAndRevealOnHoverTest, ...@@ -2232,13 +2232,33 @@ TEST_P(OmniboxViewViewsHideOnInteractionAndRevealOnHoverTest,
// Focusing a non-editable node should not run the fade-out animation. // Focusing a non-editable node should not run the fade-out animation.
content::FocusedNodeDetails details; content::FocusedNodeDetails details;
details.is_editable_node = false; details.is_editable_node = false;
details.focus_type = blink::mojom::FocusType::kMouse;
omnibox_view()->OnFocusChangedInPage(&details); omnibox_view()->OnFocusChangedInPage(&details);
OmniboxViewViews::ElideAnimation* elide_animation = OmniboxViewViews::ElideAnimation* elide_animation =
omnibox_view()->GetElideAfterInteractionAnimationForTesting(); omnibox_view()->GetElideAfterInteractionAnimationForTesting();
EXPECT_FALSE(elide_animation); EXPECT_FALSE(elide_animation);
// Focusing via keypress should not run the fade-out animation.
details.is_editable_node = true;
details.focus_type = blink::mojom::FocusType::kForward;
omnibox_view()->OnFocusChangedInPage(&details);
elide_animation =
omnibox_view()->GetElideAfterInteractionAnimationForTesting();
EXPECT_FALSE(elide_animation);
// Other ways that an element can be focused, such as element.focus() in
// JavaScript, have a focus type of kNone and should not run the fade-out
// animation.
details.is_editable_node = true;
details.focus_type = blink::mojom::FocusType::kNone;
omnibox_view()->OnFocusChangedInPage(&details);
elide_animation =
omnibox_view()->GetElideAfterInteractionAnimationForTesting();
EXPECT_FALSE(elide_animation);
// Focusing an editable node should run the fade-out animation. // Focusing an editable node should run the fade-out animation.
details.is_editable_node = true; details.is_editable_node = true;
details.focus_type = blink::mojom::FocusType::kMouse;
omnibox_view()->OnFocusChangedInPage(&details); omnibox_view()->OnFocusChangedInPage(&details);
elide_animation = elide_animation =
omnibox_view()->GetElideAfterInteractionAnimationForTesting(); omnibox_view()->GetElideAfterInteractionAnimationForTesting();
......
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