Commit f25e9c98 authored by Evan Stade's avatar Evan Stade Committed by Commit Bot

Immersive mode: reveal top view on Ctrl+K.

Move the immersive reveal lock into OmniboxViewViews::SetFocus so more
codepaths will use it.

Bug: 337689
Change-Id: I16546969e99eae5493da60df5454ebac9a4d1292
Reviewed-on: https://chromium-review.googlesource.com/c/1287303Reviewed-by: default avatarMichael Wasserman <msw@chromium.org>
Commit-Queue: Evan Stade <estade@chromium.org>
Cr-Commit-Position: refs/heads/master@{#600853}
parent e1e8394f
...@@ -1086,19 +1086,9 @@ void BrowserView::SetFocusToLocationBar(bool select_all) { ...@@ -1086,19 +1086,9 @@ void BrowserView::SetFocusToLocationBar(bool select_all) {
return; return;
#endif #endif
// Temporarily reveal the top-of-window views (if not already revealed) so
// that the location bar view is visible and is considered focusable. If the
// location bar view gains focus, |immersive_mode_controller_| will keep the
// top-of-window views revealed.
std::unique_ptr<ImmersiveRevealedLock> focus_reveal_lock(
immersive_mode_controller_->GetRevealedLock(
ImmersiveModeController::ANIMATE_REVEAL_YES));
LocationBarView* location_bar = GetLocationBarView(); LocationBarView* location_bar = GetLocationBarView();
if (location_bar->omnibox_view()->IsFocusable()) { location_bar->FocusLocation(select_all);
// Location bar got focus. if (!location_bar->omnibox_view()->HasFocus()) {
location_bar->FocusLocation(select_all);
} else {
// If none of location bar got focus, then clear focus. // If none of location bar got focus, then clear focus.
views::FocusManager* focus_manager = GetFocusManager(); views::FocusManager* focus_manager = GetFocusManager();
DCHECK(focus_manager); DCHECK(focus_manager);
......
...@@ -1149,11 +1149,18 @@ const char* LocationBarView::GetClassName() const { ...@@ -1149,11 +1149,18 @@ const char* LocationBarView::GetClassName() const {
} }
void LocationBarView::OnBoundsChanged(const gfx::Rect& previous_bounds) { void LocationBarView::OnBoundsChanged(const gfx::Rect& previous_bounds) {
RefreshBackground();
RefreshFocusRing();
}
bool LocationBarView::GetNeedsNotificationWhenVisibleBoundsChange() const {
return true;
}
void LocationBarView::OnVisibleBoundsChanged() {
OmniboxPopupView* popup = GetOmniboxPopupView(); OmniboxPopupView* popup = GetOmniboxPopupView();
if (popup->IsOpen()) if (popup->IsOpen())
popup->UpdatePopupAppearance(); popup->UpdatePopupAppearance();
RefreshBackground();
RefreshFocusRing();
} }
void LocationBarView::OnFocus() { void LocationBarView::OnFocus() {
......
...@@ -262,6 +262,8 @@ class LocationBarView : public LocationBar, ...@@ -262,6 +262,8 @@ class LocationBarView : public LocationBar,
// |is_hovering| should be true when mouse is in omnibox; false when exited. // |is_hovering| should be true when mouse is in omnibox; false when exited.
void OnOmniboxHovered(bool is_hovering); void OnOmniboxHovered(bool is_hovering);
Browser* browser() { return browser_; }
private: private:
FRIEND_TEST_ALL_PREFIXES(SecurityIndicatorTest, CheckIndicatorText); FRIEND_TEST_ALL_PREFIXES(SecurityIndicatorTest, CheckIndicatorText);
FRIEND_TEST_ALL_PREFIXES(TouchLocationBarViewBrowserTest, FRIEND_TEST_ALL_PREFIXES(TouchLocationBarViewBrowserTest,
...@@ -357,6 +359,8 @@ class LocationBarView : public LocationBar, ...@@ -357,6 +359,8 @@ class LocationBarView : public LocationBar,
// views::View: // views::View:
const char* GetClassName() const override; const char* GetClassName() const override;
void OnBoundsChanged(const gfx::Rect& previous_bounds) override; void OnBoundsChanged(const gfx::Rect& previous_bounds) override;
bool GetNeedsNotificationWhenVisibleBoundsChange() const override;
void OnVisibleBoundsChanged() override;
void OnFocus() override; void OnFocus() override;
void OnPaintBorder(gfx::Canvas* canvas) override; void OnPaintBorder(gfx::Canvas* canvas) override;
......
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
#include "chrome/browser/ui/omnibox/omnibox_theme.h" #include "chrome/browser/ui/omnibox/omnibox_theme.h"
#include "chrome/browser/ui/view_ids.h" #include "chrome/browser/ui/view_ids.h"
#include "chrome/browser/ui/views/chrome_layout_provider.h" #include "chrome/browser/ui/views/chrome_layout_provider.h"
#include "chrome/browser/ui/views/frame/browser_view.h"
#include "chrome/browser/ui/views/location_bar/location_bar_view.h" #include "chrome/browser/ui/views/location_bar/location_bar_view.h"
#include "chrome/browser/ui/views/omnibox/omnibox_popup_contents_view.h" #include "chrome/browser/ui/views/omnibox/omnibox_popup_contents_view.h"
#include "chrome/grit/generated_resources.h" #include "chrome/grit/generated_resources.h"
...@@ -314,6 +315,15 @@ void OmniboxViewViews::RevertAll() { ...@@ -314,6 +315,15 @@ void OmniboxViewViews::RevertAll() {
} }
void OmniboxViewViews::SetFocus() { void OmniboxViewViews::SetFocus() {
// 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
// keep it revealed.
std::unique_ptr<ImmersiveRevealedLock> focus_reveal_lock(
BrowserView::GetBrowserViewForBrowser(location_bar_view_->browser())
->immersive_mode_controller()
->GetRevealedLock(ImmersiveModeController::ANIMATE_REVEAL_YES));
RequestFocus(); RequestFocus();
// Restore caret visibility if focus is explicitly requested. This is // Restore caret visibility if focus is explicitly requested. This is
// necessary because if we already have invisible focus, the RequestFocus() // necessary because if we already have invisible focus, the RequestFocus()
......
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