Commit 331bfdfc authored by Elliot Glaysher's avatar Elliot Glaysher Committed by Commit Bot

[ash] Make chrome's immersive mode watch properties.

Instead of implementing an ash specific observer type, watch shared
properties on the aura::Window instead. This removes dependence on
non-public ash types, and simplifies all three ashs (classic,mus,mash)
so they go through the same code path.

Bug: 640381
Change-Id: I1837202ae3fadd177c2a54b31d6cc31ed974b621
Test: ImmersiveModeControllerAshTest.*, Manual in all 3 configurations
Reviewed-on: https://chromium-review.googlesource.com/685538Reviewed-by: default avatarScott Violet <sky@chromium.org>
Commit-Queue: Elliot Glaysher <erg@chromium.org>
Cr-Commit-Position: refs/heads/master@{#504716}
parent a52799b9
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
#include "chrome/browser/ui/views/frame/immersive_mode_controller_ash.h" #include "chrome/browser/ui/views/frame/immersive_mode_controller_ash.h"
#include "ash/public/cpp/immersive/immersive_revealed_lock.h" #include "ash/public/cpp/immersive/immersive_revealed_lock.h"
#include "ash/public/cpp/window_properties.h"
#include "ash/shell.h" #include "ash/shell.h"
#include "ash/wm/tablet_mode/tablet_mode_controller.h" #include "ash/wm/tablet_mode/tablet_mode_controller.h"
#include "ash/wm/window_state.h" #include "ash/wm/window_state.h"
...@@ -204,30 +205,18 @@ void ImmersiveModeControllerAsh::EnableWindowObservers(bool enable) { ...@@ -204,30 +205,18 @@ void ImmersiveModeControllerAsh::EnableWindowObservers(bool enable) {
return; return;
observers_enabled_ = enable; observers_enabled_ = enable;
aura::Window* target_window = ash_util::IsRunningInMash()
? native_window_->GetRootWindow()
: native_window_;
content::Source<FullscreenController> source(browser_view_->browser() content::Source<FullscreenController> source(browser_view_->browser()
->exclusive_access_manager() ->exclusive_access_manager()
->fullscreen_controller()); ->fullscreen_controller());
if (enable) { if (enable) {
if (ash_util::IsRunningInMash()) { target_window->AddObserver(this);
browser_view_->GetWidget()->GetNativeView()->GetRootWindow()->AddObserver(
this);
// TODO: http://crbug.com/640381.
NOTIMPLEMENTED();
} else {
ash::wm::GetWindowState(native_window_)->AddObserver(this);
}
registrar_.Add(this, chrome::NOTIFICATION_FULLSCREEN_CHANGED, source); registrar_.Add(this, chrome::NOTIFICATION_FULLSCREEN_CHANGED, source);
} else { } else {
if (ash_util::IsRunningInMash()) { target_window->RemoveObserver(this);
browser_view_->GetWidget()
->GetNativeView()
->GetRootWindow()
->RemoveObserver(this);
// TODO: http://crbug.com/640381.
NOTIMPLEMENTED();
} else {
ash::wm::GetWindowState(native_window_)->RemoveObserver(this);
}
registrar_.Remove(this, chrome::NOTIFICATION_FULLSCREEN_CHANGED, source); registrar_.Remove(this, chrome::NOTIFICATION_FULLSCREEN_CHANGED, source);
} }
} }
...@@ -341,20 +330,6 @@ ImmersiveModeControllerAsh::GetVisibleBoundsInScreen() const { ...@@ -341,20 +330,6 @@ ImmersiveModeControllerAsh::GetVisibleBoundsInScreen() const {
return bounds_in_screen; return bounds_in_screen;
} }
// TODO(erg): Can we just observer the key change here?
void ImmersiveModeControllerAsh::OnPostWindowStateTypeChange(
ash::wm::WindowState* window_state,
ash::mojom::WindowStateType old_type) {
// Disable immersive fullscreen when the user exits fullscreen without going
// through FullscreenController::ToggleBrowserFullscreenMode(). This is the
// case if the user exits fullscreen via the restore button.
if (controller_->IsEnabled() && !window_state->IsFullscreen() &&
!window_state->IsMinimized() &&
old_type == ash::mojom::WindowStateType::FULLSCREEN) {
browser_view_->FullscreenStateChanged();
}
}
void ImmersiveModeControllerAsh::Observe( void ImmersiveModeControllerAsh::Observe(
int type, int type,
const content::NotificationSource& source, const content::NotificationSource& source,
...@@ -380,11 +355,19 @@ void ImmersiveModeControllerAsh::Observe( ...@@ -380,11 +355,19 @@ void ImmersiveModeControllerAsh::Observe(
void ImmersiveModeControllerAsh::OnWindowPropertyChanged(aura::Window* window, void ImmersiveModeControllerAsh::OnWindowPropertyChanged(aura::Window* window,
const void* key, const void* key,
intptr_t old) { intptr_t old) {
// In mash the window manager may move us out of immersive mode by changing if (key == ash::kWindowStateTypeKey) {
// the show state. When this happens notify the controller. ash::mojom::WindowStateType new_state =
DCHECK(ash_util::IsRunningInMash()); window->GetProperty(ash::kWindowStateTypeKey);
if (key == aura::client::kShowStateKey && ash::mojom::WindowStateType old_state = ash::mojom::WindowStateType(old);
!browser_view_->GetWidget()->IsFullscreen()) {
SetEnabled(false); // Disable immersive fullscreen when the user exits fullscreen without going
// through FullscreenController::ToggleBrowserFullscreenMode(). This is the
// case if the user exits fullscreen via the restore button.
if (controller_->IsEnabled() &&
new_state != ash::mojom::WindowStateType::FULLSCREEN &&
new_state != ash::mojom::WindowStateType::MINIMIZED &&
old_state == ash::mojom::WindowStateType::FULLSCREEN) {
browser_view_->FullscreenStateChanged();
}
} }
} }
...@@ -9,7 +9,6 @@ ...@@ -9,7 +9,6 @@
#include "ash/public/cpp/immersive/immersive_fullscreen_controller.h" #include "ash/public/cpp/immersive/immersive_fullscreen_controller.h"
#include "ash/public/cpp/immersive/immersive_fullscreen_controller_delegate.h" #include "ash/public/cpp/immersive/immersive_fullscreen_controller_delegate.h"
#include "ash/wm/window_state_observer.h"
#include "base/macros.h" #include "base/macros.h"
#include "chrome/browser/ui/views/frame/immersive_mode_controller.h" #include "chrome/browser/ui/views/frame/immersive_mode_controller.h"
#include "content/public/browser/notification_observer.h" #include "content/public/browser/notification_observer.h"
...@@ -26,7 +25,6 @@ class Window; ...@@ -26,7 +25,6 @@ class Window;
class ImmersiveModeControllerAsh class ImmersiveModeControllerAsh
: public ImmersiveModeController, : public ImmersiveModeController,
public ash::ImmersiveFullscreenControllerDelegate, public ash::ImmersiveFullscreenControllerDelegate,
public ash::wm::WindowStateObserver,
public content::NotificationObserver, public content::NotificationObserver,
public aura::WindowObserver { public aura::WindowObserver {
public: public:
...@@ -73,11 +71,6 @@ class ImmersiveModeControllerAsh ...@@ -73,11 +71,6 @@ class ImmersiveModeControllerAsh
void SetVisibleFraction(double visible_fraction) override; void SetVisibleFraction(double visible_fraction) override;
std::vector<gfx::Rect> GetVisibleBoundsInScreen() const override; std::vector<gfx::Rect> GetVisibleBoundsInScreen() const override;
// ash::wm::WindowStateObserver override:
void OnPostWindowStateTypeChange(
ash::wm::WindowState* window_state,
ash::mojom::WindowStateType old_type) override;
// content::NotificationObserver override: // content::NotificationObserver override:
void Observe(int type, void Observe(int type,
const content::NotificationSource& source, const content::NotificationSource& source,
......
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