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

Omnibox UI Experiments: Steady state elisions - reelide on blur

For steady state elisions, we currently unelide when the user places
the caret in the URL or makes a partial selection. This restores hidden
schemes and hides the security chip.

However, we don't re-elide in any circumstances currently, even if the
user has made no edits.

This CL re-elides on blur if the user has not made any edits, and
also restores the security chip.

One more note: This CL subtly changes the behavior even with steady
state elisions off. It will revert and re-show the security chip on
blur if the user adds and then deletes a character to the URL
(restoring the original URL). This seems like a harmless and slightly
beneficial change.

Bug: 797354
Change-Id: I87966e388034ed0573756e9f7985540dc4315c83
Reviewed-on: https://chromium-review.googlesource.com/993696
Commit-Queue: Peter Kasting <pkasting@chromium.org>
Reviewed-by: default avatarPeter Kasting <pkasting@chromium.org>
Cr-Commit-Position: refs/heads/master@{#547970}
parent cbb1ce22
...@@ -922,6 +922,13 @@ void OmniboxViewViews::OnBlur() { ...@@ -922,6 +922,13 @@ void OmniboxViewViews::OnBlur() {
// Save the user's existing selection to restore it later. // Save the user's existing selection to restore it later.
saved_selection_for_focus_change_ = GetSelectedRange(); saved_selection_for_focus_change_ = GetSelectedRange();
// Revert the URL if the user has not made any changes. If steady-state
// elisions is on, this will also re-elide the URL.
if (model()->user_input_in_progress() &&
text() == model()->GetCurrentPermanentUrlText()) {
RevertAll();
}
views::Textfield::OnBlur(); views::Textfield::OnBlur();
model()->OnWillKillFocus(); model()->OnWillKillFocus();
......
...@@ -181,6 +181,7 @@ class OmniboxViewViewsTest : public ChromeViewsTestBase { ...@@ -181,6 +181,7 @@ class OmniboxViewViewsTest : public ChromeViewsTestBase {
public: public:
OmniboxViewViewsTest(); OmniboxViewViewsTest();
TestToolbarModel* toolbar_model() { return &toolbar_model_; }
TestingOmniboxView* omnibox_view() { return omnibox_view_.get(); } TestingOmniboxView* omnibox_view() { return omnibox_view_.get(); }
views::Textfield* omnibox_textfield() { return omnibox_view(); } views::Textfield* omnibox_textfield() { return omnibox_view(); }
ui::TextEditCommand scheduled_text_edit_command() const { ui::TextEditCommand scheduled_text_edit_command() const {
...@@ -387,3 +388,30 @@ TEST_F(OmniboxViewViewsTest, Emphasis) { ...@@ -387,3 +388,30 @@ TEST_F(OmniboxViewViewsTest, Emphasis) {
} }
} }
} }
TEST_F(OmniboxViewViewsTest, RevertOnBlur) {
toolbar_model()->set_text(base::ASCIIToUTF16("permanent text"));
omnibox_view()->model()->ResetDisplayUrls();
omnibox_view()->RevertAll();
EXPECT_EQ(base::ASCIIToUTF16("permanent text"), omnibox_view()->text());
EXPECT_FALSE(omnibox_view()->model()->user_input_in_progress());
omnibox_view()->SetUserText(base::ASCIIToUTF16("user text"));
EXPECT_EQ(base::ASCIIToUTF16("user text"), omnibox_view()->text());
EXPECT_TRUE(omnibox_view()->model()->user_input_in_progress());
// Expect that on blur, if the text has been edited, stay in user input mode.
omnibox_textfield()->OnBlur();
EXPECT_EQ(base::ASCIIToUTF16("user text"), omnibox_view()->text());
EXPECT_TRUE(omnibox_view()->model()->user_input_in_progress());
// Expect that on blur, if the text is the same as the permanent text, exit
// user input mode.
omnibox_view()->SetUserText(base::ASCIIToUTF16("permanent text"));
EXPECT_TRUE(omnibox_view()->model()->user_input_in_progress());
omnibox_textfield()->OnBlur();
EXPECT_EQ(base::ASCIIToUTF16("permanent text"), omnibox_view()->text());
EXPECT_FALSE(omnibox_view()->model()->user_input_in_progress());
}
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