Index: chrome/browser/ui/views/frame/immersive_mode_controller_ash.cc |
diff --git a/chrome/browser/ui/views/frame/immersive_mode_controller_ash.cc b/chrome/browser/ui/views/frame/immersive_mode_controller_ash.cc |
index a35b5e16f29889d718951dfc1dfde35f36c7e940..2cd80295883f6fc66d6cbf1f1d15ca274a7b14c2 100644 |
--- a/chrome/browser/ui/views/frame/immersive_mode_controller_ash.cc |
+++ b/chrome/browser/ui/views/frame/immersive_mode_controller_ash.cc |
@@ -18,6 +18,7 @@ |
#include "ui/aura/client/aura_constants.h" |
#include "ui/aura/client/capture_client.h" |
#include "ui/aura/env.h" |
+#include "ui/aura/root_window.h" |
#include "ui/aura/window.h" |
#include "ui/aura/window_observer.h" |
#include "ui/compositor/layer_animation_observer.h" |
@@ -301,11 +302,12 @@ class ImmersiveModeControllerAsh::WindowObserver : public aura::WindowObserver { |
public: |
explicit WindowObserver(ImmersiveModeControllerAsh* controller) |
: controller_(controller) { |
- controller_->native_window_->AddObserver(this); |
+ window_ = controller_->native_window_; |
+ window_->AddObserver(this); |
} |
virtual ~WindowObserver() { |
- controller_->native_window_->RemoveObserver(this); |
+ window_->RemoveObserver(this); |
} |
// aura::WindowObserver overrides: |
@@ -326,8 +328,19 @@ class ImmersiveModeControllerAsh::WindowObserver : public aura::WindowObserver { |
} |
} |
+ virtual void OnWindowAddedToRootWindow(aura::Window* window) { |
+ DCHECK(window == window_); |
pkotwicz
2013/05/24 03:27:30
Nit: DCHECK_EQ
rharrison
2013/05/27 19:00:54
Done.
|
+ controller_->SetPreTargetHandler(); |
+ } |
+ |
+ virtual void OnWindowRemovedFromRootWindow(aura::Window* window) { |
+ DCHECK(window == window_); |
pkotwicz
2013/05/24 03:27:30
DCHECK_EQ
rharrison
2013/05/27 19:00:54
Done.
|
+ controller_->SetPreTargetHandler(); |
+ } |
+ |
private: |
ImmersiveModeControllerAsh* controller_; // Not owned. |
+ aura::Window* window_; // Not owned. |
DISALLOW_COPY_AND_ASSIGN(WindowObserver); |
}; |
@@ -377,6 +390,18 @@ void ImmersiveModeControllerAsh::MaybeRevealWithoutAnimation() { |
MaybeStartReveal(ANIMATE_NO); |
} |
+void ImmersiveModeControllerAsh::SetPreTargetHandler() { |
pkotwicz
2013/05/24 03:27:30
I don't think that you will need this function onc
rharrison
2013/05/27 19:00:54
I think it will still be needed to avoid code dupl
|
+ if (!native_window_) |
+ return; |
+ aura::RootWindow* root_window = native_window_->GetRootWindow(); |
+ if (!root_window) |
+ return; |
+ if (observers_enabled_) |
+ root_window->AddPreTargetHandler(this); |
+ else |
+ root_window->RemovePreTargetHandler(this); |
+} |
+ |
void ImmersiveModeControllerAsh::Init( |
Delegate* delegate, |
views::Widget* widget, |
@@ -661,10 +686,7 @@ void ImmersiveModeControllerAsh::EnableWindowObservers(bool enable) { |
focus_manager->RemoveFocusChangeListener(this); |
} |
- if (enable) |
- native_window_->AddPreTargetHandler(this); |
- else |
- native_window_->RemovePreTargetHandler(this); |
+ SetPreTargetHandler(); |
// The window observer adds and removes itself from the native window. |
window_observer_.reset(enable ? new WindowObserver(this) : NULL); |
@@ -1031,5 +1053,8 @@ bool ImmersiveModeControllerAsh::IsNearTopContainer(gfx::Point location) const { |
gfx::Rect near_bounds = top_container_->GetTargetBoundsInScreen(); |
if (reveal_state_ == CLOSED) |
near_bounds.Inset(gfx::Insets(0, 0, -kNearTopContainerDistance, 0)); |
- return near_bounds.Contains(location); |
+ return near_bounds.Contains(location) || |
pkotwicz
2013/05/24 03:27:30
Can you please add a comment as to why the conditi
rharrison
2013/05/27 19:00:54
Done.
|
+ ((location.y() < near_bounds.y()) && |
+ (location.x() >= near_bounds.x()) && |
+ (location.x() <= near_bounds.x() + near_bounds.width())); |
pkotwicz
2013/05/24 03:27:30
Nit: You can use near_bounds.right()
rharrison
2013/05/27 19:00:54
Done.
|
} |