Commit df253752 authored by Tommy Li's avatar Tommy Li Committed by Commit Bot

[omnibox] Clean up LocationBarView / OmniboxViewViews SetFocus code

For historic reasons, LocationBarView "dug into" OmniboxViewViews and
triggered some additional actions on focus.

This CL moves those actions into OmniboxViewViews to reduce the need
for LocationBarView to be concerned with OmniboxViewViews' behavior.

Also this CL deletes a feature flag that's been Enabled by default for
a long time, and exists just as an unused killswitch.

Bug: NONE
Change-Id: Id29abca060b5e8b7f1cd8b31b6c202833303a849
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1937773Reviewed-by: default avatarmanuk hovanesian <manukh@chromium.org>
Commit-Queue: Tommy Li <tommycli@chromium.org>
Cr-Commit-Position: refs/heads/master@{#719628}
parent e5cb8f10
......@@ -126,12 +126,6 @@
namespace {
// This feature shows the full URL when the user focuses the omnibox via
// keyboard shortcut. This feature flag only exists so we have a remote
// killswitch for this behavior.
base::Feature kOmniboxShowFullUrlOnKeyboardShortcut{
"OmniboxShowFullUrlOnKeyboardShortcut", base::FEATURE_ENABLED_BY_DEFAULT};
int IncrementalMinimumWidth(const views::View* view) {
return (view && view->GetVisible()) ? view->GetMinimumSize().width() : 0;
}
......@@ -369,24 +363,7 @@ void LocationBarView::SelectAll() {
// LocationBarView, public LocationBar implementation:
void LocationBarView::FocusLocation(bool is_user_initiated) {
const bool omnibox_already_focused = omnibox_view_->HasFocus();
omnibox_view_->SetFocus(is_user_initiated);
if (omnibox_already_focused)
omnibox_view()->model()->ClearKeyword();
// TODO(tommycli): Since we are now passing the |is_user_initiated| parameter
// onto OmniboxView, we can likely move the below code into SetFocus().
if (!is_user_initiated)
return;
omnibox_view_->SelectAll(true);
// Only exit Query in Omnibox mode on focus command if the location bar was
// already focused to begin with, i.e. user presses Ctrl+L twice.
if (base::FeatureList::IsEnabled(kOmniboxShowFullUrlOnKeyboardShortcut))
omnibox_view()->model()->Unelide(omnibox_already_focused);
}
void LocationBarView::Revert() {
......
......@@ -420,6 +420,8 @@ void OmniboxViewViews::RevertAll() {
}
void OmniboxViewViews::SetFocus(bool is_user_initiated) {
const bool already_focused = HasFocus();
// Temporarily reveal the top-of-window views (if not already revealed) so
// that the location bar view is visible and is considered focusable. When it
// actually receives focus, ImmersiveFocusWatcher will add another lock to
......@@ -447,6 +449,17 @@ void OmniboxViewViews::SetFocus(bool is_user_initiated) {
// re-pressed. This occurs even if the omnibox is already focused and we
// re-request focus (e.g. pressing ctrl-l twice).
model()->ConsumeCtrlKey();
if (already_focused)
model()->ClearKeyword();
if (is_user_initiated) {
SelectAll(true);
// Only exit Query in Omnibox mode on focus command if the location bar was
// already focused to begin with, i.e. user presses Ctrl+L twice.
model()->Unelide(/*exit_query_in_omnibox=*/already_focused);
}
}
int OmniboxViewViews::GetTextWidth() const {
......
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