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

Create ImmersiveFocusWatcher for use in Chrome in Mash.

This keeps the immersive reveal going when bubbles anchored to the top
container (like the bookmark bubble) are open, when focus in in the top
container, or when transient children (like the bookmark editor) are
open.

ImmersiveFocusWatcherMus is largely copied from
ImmersiveFocusWatcherClassic, but
1. uses aura::client::TransientWindowClient instead of
   ::wm::TransientWindowManager
2. uses WindowTreeClient::FocusSynchronizer instead of
   ::wm::GetActivationClient
3. Appends |->GetRootWindow()| in a couple places.

Bug: 640365
Change-Id: I46cd0c3d66808d726fea484ff13ceea53dcabd5c
Reviewed-on: https://chromium-review.googlesource.com/1187708
Commit-Queue: Evan Stade <estade@chromium.org>
Reviewed-by: default avatarScott Violet <sky@chromium.org>
Cr-Commit-Position: refs/heads/master@{#586323}
parent 7f19d899
...@@ -1899,6 +1899,8 @@ jumbo_split_static_library("ui") { ...@@ -1899,6 +1899,8 @@ jumbo_split_static_library("ui") {
"views/frame/browser_non_client_frame_view_ash.h", "views/frame/browser_non_client_frame_view_ash.h",
"views/frame/immersive_context_mus.cc", "views/frame/immersive_context_mus.cc",
"views/frame/immersive_context_mus.h", "views/frame/immersive_context_mus.h",
"views/frame/immersive_focus_watcher_mus.cc",
"views/frame/immersive_focus_watcher_mus.h",
"views/frame/immersive_handler_factory_mus.cc", "views/frame/immersive_handler_factory_mus.cc",
"views/frame/immersive_handler_factory_mus.h", "views/frame/immersive_handler_factory_mus.h",
"views/frame/immersive_mode_controller_ash.cc", "views/frame/immersive_mode_controller_ash.cc",
......
This diff is collapsed.
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_UI_VIEWS_FRAME_IMMERSIVE_FOCUS_WATCHER_MUS_H_
#define CHROME_BROWSER_UI_VIEWS_FRAME_IMMERSIVE_FOCUS_WATCHER_MUS_H_
#include "ash/public/cpp/immersive/immersive_focus_watcher.h"
#include "ui/aura/client/focus_change_observer.h"
#include "ui/aura/client/transient_window_client_observer.h"
#include "ui/views/focus/focus_manager.h"
#include "ui/wm/public/activation_change_observer.h"
namespace ash {
class ImmersiveFullscreenController;
class ImmersiveRevealedLock;
} // namespace ash
// ImmersiveFocusWatcherMus is responsible for grabbing a reveal lock based on
// activation and/or focus. This implementation grabs a lock if views focus is
// in the top view, a bubble is showing that is anchored to the top view, or
// the focused window is a transient child of the top view's widget.
class ImmersiveFocusWatcherMus
: public ash::ImmersiveFocusWatcher,
public views::FocusChangeListener,
public aura::client::TransientWindowClientObserver,
public ::wm::ActivationChangeObserver {
public:
explicit ImmersiveFocusWatcherMus(
ash::ImmersiveFullscreenController* controller);
~ImmersiveFocusWatcherMus() override;
// ImmersiveFocusWatcher:
void UpdateFocusRevealedLock() override;
void ReleaseLock() override;
private:
class BubbleObserver;
views::Widget* GetWidget();
aura::Window* GetWidgetWindow();
// Recreate |bubble_observer_| and start observing any bubbles anchored to a
// child of |top_container_|.
void RecreateBubbleObserver();
// views::FocusChangeListener overrides:
void OnWillChangeFocus(views::View* focused_before,
views::View* focused_now) override;
void OnDidChangeFocus(views::View* focused_before,
views::View* focused_now) override;
// aura::client::TransientWindowClientObserver overrides:
void OnTransientChildWindowAdded(aura::Window* window,
aura::Window* transient) override;
void OnTransientChildWindowRemoved(aura::Window* window,
aura::Window* transient) override;
// ::wm::ActivationChangeObserver:
void OnWindowActivated(
::wm::ActivationChangeObserver::ActivationReason reason,
aura::Window* gaining_active,
aura::Window* losing_active) override;
ash::ImmersiveFullscreenController* immersive_fullscreen_controller_;
// Lock which keeps the top-of-window views revealed based on the focused view
// and the active widget. Acquiring the lock never triggers a reveal because
// a view is not focusable till a reveal has made it visible.
std::unique_ptr<ash::ImmersiveRevealedLock> lock_;
// Manages bubbles which are anchored to a child of
// |ImmersiveFullscreenController::top_container_|.
std::unique_ptr<BubbleObserver> bubble_observer_;
DISALLOW_COPY_AND_ASSIGN(ImmersiveFocusWatcherMus);
};
#endif // CHROME_BROWSER_UI_VIEWS_FRAME_IMMERSIVE_FOCUS_WATCHER_MUS_H_
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include "ash/public/cpp/immersive/immersive_focus_watcher.h" #include "ash/public/cpp/immersive/immersive_focus_watcher.h"
#include "ash/public/cpp/immersive/immersive_gesture_handler.h" #include "ash/public/cpp/immersive/immersive_gesture_handler.h"
#include "base/logging.h" #include "base/logging.h"
#include "chrome/browser/ui/views/frame/immersive_focus_watcher_mus.h"
ImmersiveHandlerFactoryMus::ImmersiveHandlerFactoryMus() {} ImmersiveHandlerFactoryMus::ImmersiveHandlerFactoryMus() {}
...@@ -15,8 +16,7 @@ ImmersiveHandlerFactoryMus::~ImmersiveHandlerFactoryMus() {} ...@@ -15,8 +16,7 @@ ImmersiveHandlerFactoryMus::~ImmersiveHandlerFactoryMus() {}
std::unique_ptr<ash::ImmersiveFocusWatcher> std::unique_ptr<ash::ImmersiveFocusWatcher>
ImmersiveHandlerFactoryMus::CreateFocusWatcher( ImmersiveHandlerFactoryMus::CreateFocusWatcher(
ash::ImmersiveFullscreenController* controller) { ash::ImmersiveFullscreenController* controller) {
NOTIMPLEMENTED(); return std::make_unique<ImmersiveFocusWatcherMus>(controller);
return nullptr;
} }
std::unique_ptr<ash::ImmersiveGestureHandler> std::unique_ptr<ash::ImmersiveGestureHandler>
......
...@@ -5,6 +5,8 @@ ...@@ -5,6 +5,8 @@
#ifndef UI_AURA_CLIENT_TRANSIENT_WINDOW_CLIENT_H_ #ifndef UI_AURA_CLIENT_TRANSIENT_WINDOW_CLIENT_H_
#define UI_AURA_CLIENT_TRANSIENT_WINDOW_CLIENT_H_ #define UI_AURA_CLIENT_TRANSIENT_WINDOW_CLIENT_H_
#include <vector>
#include "ui/aura/aura_export.h" #include "ui/aura/aura_export.h"
namespace aura { namespace aura {
...@@ -29,6 +31,7 @@ class AURA_EXPORT TransientWindowClient { ...@@ -29,6 +31,7 @@ class AURA_EXPORT TransientWindowClient {
virtual void RemoveTransientChild(Window* parent, Window* child) = 0; virtual void RemoveTransientChild(Window* parent, Window* child) = 0;
virtual Window* GetTransientParent(Window* window) = 0; virtual Window* GetTransientParent(Window* window) = 0;
virtual const Window* GetTransientParent(const Window* window) = 0; virtual const Window* GetTransientParent(const Window* window) = 0;
virtual std::vector<Window*> GetTransientChildren(const Window* parent) = 0;
virtual void AddObserver(TransientWindowClientObserver* observer) = 0; virtual void AddObserver(TransientWindowClientObserver* observer) = 0;
virtual void RemoveObserver(TransientWindowClientObserver* observer) = 0; virtual void RemoveObserver(TransientWindowClientObserver* observer) = 0;
......
...@@ -1106,7 +1106,7 @@ bool DesktopNativeWidgetAura::ShouldActivate() const { ...@@ -1106,7 +1106,7 @@ bool DesktopNativeWidgetAura::ShouldActivate() const {
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// DesktopNativeWidgetAura, wmActivationChangeObserver implementation: // DesktopNativeWidgetAura, wm::ActivationChangeObserver implementation:
void DesktopNativeWidgetAura::OnWindowActivated( void DesktopNativeWidgetAura::OnWindowActivated(
wm::ActivationChangeObserver::ActivationReason reason, wm::ActivationChangeObserver::ActivationReason reason,
......
...@@ -45,6 +45,15 @@ const aura::Window* TransientWindowController::GetTransientParent( ...@@ -45,6 +45,15 @@ const aura::Window* TransientWindowController::GetTransientParent(
return window_manager ? window_manager->transient_parent() : nullptr; return window_manager ? window_manager->transient_parent() : nullptr;
} }
std::vector<aura::Window*> TransientWindowController::GetTransientChildren(
const aura::Window* parent) {
const TransientWindowManager* window_manager =
TransientWindowManager::GetIfExists(parent);
if (!window_manager)
return {};
return window_manager->transient_children();
}
void TransientWindowController::AddObserver( void TransientWindowController::AddObserver(
aura::client::TransientWindowClientObserver* observer) { aura::client::TransientWindowClientObserver* observer) {
observers_.AddObserver(observer); observers_.AddObserver(observer);
......
...@@ -30,6 +30,8 @@ class WM_CORE_EXPORT TransientWindowController ...@@ -30,6 +30,8 @@ class WM_CORE_EXPORT TransientWindowController
void RemoveTransientChild(aura::Window* parent, aura::Window* child) override; void RemoveTransientChild(aura::Window* parent, aura::Window* child) override;
aura::Window* GetTransientParent(aura::Window* window) override; aura::Window* GetTransientParent(aura::Window* window) override;
const aura::Window* GetTransientParent(const aura::Window* window) override; const aura::Window* GetTransientParent(const aura::Window* window) override;
std::vector<aura::Window*> GetTransientChildren(
const aura::Window* parent) override;
void AddObserver( void AddObserver(
aura::client::TransientWindowClientObserver* observer) override; aura::client::TransientWindowClientObserver* observer) override;
void RemoveObserver( void RemoveObserver(
......
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