Chromium Code Reviews| Index: content/browser/web_contents/aura/native_view_screen_bounds_observer.h |
| diff --git a/content/browser/web_contents/aura/native_view_screen_bounds_observer.h b/content/browser/web_contents/aura/native_view_screen_bounds_observer.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..9ecff9d19565142904da497dcbbb6baad8a77589 |
| --- /dev/null |
| +++ b/content/browser/web_contents/aura/native_view_screen_bounds_observer.h |
| @@ -0,0 +1,71 @@ |
| +// Copyright (c) 2013 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 CONTENT_BROWSER_WEB_CONTENTS_AURA_NATIVE_VIEW_SCREEN_BOUNDS_OBSERVER_H__ |
| +#define CONTENT_BROWSER_WEB_CONTENTS_AURA_NATIVE_VIEW_SCREEN_BOUNDS_OBSERVER_H__ |
| + |
| +#include <set> |
| + |
| +#include "base/compiler_specific.h" |
| +#include "content/common/content_export.h" |
| +#include "ui/aura/root_window_observer.h" |
| +#include "ui/aura/window_observer.h" |
| + |
| +namespace content { |
| + |
| +class CONTENT_EXPORT NativeViewScreenBoundsObserverDelegate { |
| + public: |
| + NativeViewScreenBoundsObserverDelegate() { } |
| + virtual ~NativeViewScreenBoundsObserverDelegate() { } |
| + |
| + virtual aura::Window* GetDelegateWindow() = 0; |
| + virtual void AddDelegateWindowObserver(aura::WindowObserver* observer) = 0; |
| + virtual void RemoveDelegateWindowObserver(aura::WindowObserver* observer) = 0; |
| + virtual void AddRootWindowObserver(aura::RootWindowObserver* observer) = 0; |
| + virtual void RemoveRootWindowObserver(aura::RootWindowObserver* observer) = 0; |
|
sadrul
2013/11/08 02:16:26
You don't need any of the above in this interface.
rharrison
2013/11/12 22:16:29
Done.
|
| + virtual void OnScreenPositionChanged() = 0; |
| + virtual void OnScreenBoundsChanged() = 0; |
| + |
| + private: |
| + DISALLOW_COPY_AND_ASSIGN(NativeViewScreenBoundsObserverDelegate); |
| +}; |
| + |
| +class CONTENT_EXPORT NativeViewScreenBoundsObserver |
| + : public aura::WindowObserver, |
| + public aura::RootWindowObserver { |
| + public: |
| + NativeViewScreenBoundsObserver(); |
| + virtual ~NativeViewScreenBoundsObserver(); |
| + |
| + virtual void Init(NativeViewScreenBoundsObserverDelegate* delegate); |
|
sadrul
2013/11/08 02:16:26
This doesn't need to be virtual?
rharrison
2013/11/12 22:16:29
Done.
|
| + |
| + // Overridden from aura::WindowObserver: |
| + virtual void OnWindowParentChanged(aura::Window* window, |
| + aura::Window* parent) OVERRIDE; |
| + virtual void OnWindowBoundsChanged(aura::Window* window, |
| + const gfx::Rect& old_bounds, |
| + const gfx::Rect& new_bounds) OVERRIDE; |
| + virtual void OnWindowAddedToRootWindow(aura::Window* window) OVERRIDE; |
| + virtual void OnWindowRemovingFromRootWindow(aura::Window* window) OVERRIDE; |
| + |
| + // Overridden RootWindowObserver: |
| + virtual void OnRootWindowHostMoved(const aura::RootWindow* root, |
| + const gfx::Point& new_origin) OVERRIDE; |
| + |
| + private: |
| + friend class NativeViewScreenBoundsObserverTest; |
| + |
| + |
| + std::set<aura::Window*> GenerateAncestors(aura::Window* window); |
| + void AddToObserved(const std::set<aura::Window*>& windows); |
| + void RemoveFromObserved(const std::set<aura::Window*>& windows); |
| + |
| + NativeViewScreenBoundsObserverDelegate* delegate_; |
| + std::set<aura::Window*> observed_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(NativeViewScreenBoundsObserver); |
| +}; |
| + |
| +} // namespace content |
| +#endif // CONTENT_BROWSER_WEB_CONTENTS_AURA_NATIVE_VIEW_SCREEN_BOUNDS_OBSERVER_H__ |