summaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
authorben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-02-03 18:00:31 +0000
committerben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-02-03 18:00:31 +0000
commitafb7b55884fa8396e143b22e4ad457b74d43f390 (patch)
tree6a73cfc60a16b16f3aabccbdde8bd56a500e2595 /ui
parent90a35381feb0aca5d62b4b601285cb9d59b0d16e (diff)
downloadchromium_src-afb7b55884fa8396e143b22e4ad457b74d43f390.zip
chromium_src-afb7b55884fa8396e143b22e4ad457b74d43f390.tar.gz
chromium_src-afb7b55884fa8396e143b22e4ad457b74d43f390.tar.bz2
Move OnWindowInitialized() from RootWindowObserver to EnvObserver, the observer of a new global singleton "Env". This will allow us to support multiple RootWindows.
http://crbug.com/112131 TEST=none Review URL: https://chromiumcodereview.appspot.com/9310071 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@120349 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui')
-rw-r--r--ui/aura/aura.gyp19
-rw-r--r--ui/aura/env.cc49
-rw-r--r--ui/aura/env.h45
-rw-r--r--ui/aura/env_observer.h27
-rw-r--r--ui/aura/root_window.cc7
-rw-r--r--ui/aura/root_window.h3
-rw-r--r--ui/aura/root_window_observer.h3
-rw-r--r--ui/aura/test/aura_test_base.cc2
-rw-r--r--ui/aura/window.cc3
9 files changed, 136 insertions, 22 deletions
diff --git a/ui/aura/aura.gyp b/ui/aura/aura.gyp
index ecfd1bf..c84a74e 100644
--- a/ui/aura/aura.gyp
+++ b/ui/aura/aura.gyp
@@ -46,6 +46,15 @@
'client/window_move_client.h',
'client/window_types.h',
'cursor.h',
+ 'env.cc',
+ 'env.h',
+ 'env_observer.h',
+ 'event.cc',
+ 'event.h',
+ 'event_filter.h',
+ 'event_mac.mm',
+ 'event_mac.h',
+ 'focus_manager.h',
'gestures/gesture_recognizer.h',
'gestures/gesture_recognizer_aura.cc',
'gestures/gesture_recognizer_aura.h',
@@ -53,6 +62,8 @@
'gestures/gesture_point.h',
'gestures/gesture_sequence.cc',
'gestures/gesture_sequence.h',
+ 'layout_manager.cc',
+ 'layout_manager.h',
'root_window_host.h',
'root_window_host_linux.cc',
'root_window_host_mac.h',
@@ -65,14 +76,6 @@
'root_window_view_mac.mm',
'root_window.cc',
'root_window.h',
- 'event.cc',
- 'event.h',
- 'event_filter.h',
- 'event_mac.mm',
- 'event_mac.h',
- 'focus_manager.h',
- 'layout_manager.cc',
- 'layout_manager.h',
'screen_aura.cc',
'screen_aura.h',
'window.cc',
diff --git a/ui/aura/env.cc b/ui/aura/env.cc
new file mode 100644
index 0000000..e8cee8707
--- /dev/null
+++ b/ui/aura/env.cc
@@ -0,0 +1,49 @@
+// Copyright (c) 2012 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.
+
+#include "ui/aura/env.h"
+#include "ui/aura/env_observer.h"
+#include "ui/aura/window.h"
+
+namespace aura {
+
+// static
+Env* Env::instance_ = NULL;
+
+////////////////////////////////////////////////////////////////////////////////
+// Env, public:
+
+Env::Env() {}
+
+Env::~Env() {}
+
+// static
+Env* Env::GetInstance() {
+ if (!instance_)
+ instance_ = new Env;
+ return instance_;
+}
+
+// static
+void Env::DeleteInstance() {
+ delete instance_;
+ instance_ = NULL;
+}
+
+void Env::AddObserver(EnvObserver* observer) {
+ observers_.AddObserver(observer);
+}
+
+void Env::RemoveObserver(EnvObserver* observer) {
+ observers_.RemoveObserver(observer);
+}
+
+////////////////////////////////////////////////////////////////////////////////
+// Env, private:
+
+void Env::NotifyWindowInitialized(Window* window) {
+ FOR_EACH_OBSERVER(EnvObserver, observers_, OnWindowInitialized(window));
+}
+
+} // namespace aura
diff --git a/ui/aura/env.h b/ui/aura/env.h
new file mode 100644
index 0000000..12cb2ef
--- /dev/null
+++ b/ui/aura/env.h
@@ -0,0 +1,45 @@
+// Copyright (c) 2012 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 UI_AURA_ENV_H_
+#define UI_AURA_ENV_H_
+#pragma once
+
+#include "base/observer_list.h"
+#include "ui/aura/aura_export.h"
+
+namespace aura {
+
+class EnvObserver;
+class Window;
+
+// A singleton object that tracks general state within Aura.
+// TODO(beng): manage RootWindows.
+class AURA_EXPORT Env {
+ public:
+ Env();
+ ~Env();
+
+ static Env* GetInstance();
+ static void DeleteInstance();
+
+ void AddObserver(EnvObserver* observer);
+ void RemoveObserver(EnvObserver* observer);
+
+ private:
+ friend class Window;
+
+ // Called by the Window when it is initialized. Notifies observers.
+ void NotifyWindowInitialized(Window* window);
+
+ ObserverList<EnvObserver> observers_;
+
+ static Env* instance_;
+
+ DISALLOW_COPY_AND_ASSIGN(Env);
+};
+
+} // namespace aura
+
+#endif // UI_AURA_ENV_H_
diff --git a/ui/aura/env_observer.h b/ui/aura/env_observer.h
new file mode 100644
index 0000000..9a4541a
--- /dev/null
+++ b/ui/aura/env_observer.h
@@ -0,0 +1,27 @@
+// Copyright (c) 2012 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 UI_AURA_ENV_OBSERVER_H_
+#define UI_AURA_ENV_OBSERVER_H_
+#pragma once
+
+#include "base/observer_list.h"
+#include "ui/aura/aura_export.h"
+
+namespace aura {
+
+class Window;
+
+class AURA_EXPORT EnvObserver {
+ public:
+ // Called when |window| has been initialized.
+ virtual void OnWindowInitialized(Window* window) = 0;
+
+ protected:
+ virtual ~EnvObserver() {}
+};
+
+} // namespace aura
+
+#endif // UI_AURA_ENV_OBSERVER_H_
diff --git a/ui/aura/root_window.cc b/ui/aura/root_window.cc
index 0b4baa3..f79d4e0 100644
--- a/ui/aura/root_window.cc
+++ b/ui/aura/root_window.cc
@@ -268,13 +268,6 @@ void RootWindow::OnNativeScreenResized(const gfx::Size& size) {
SetHostSize(size);
}
-void RootWindow::OnWindowInitialized(Window* window) {
- FOR_EACH_OBSERVER(RootWindowObserver, observers_,
- OnWindowInitialized(window));
- if (window->IsVisible() && window->ContainsPointInRoot(last_mouse_location_))
- PostMouseMoveEventAfterWindowChange();
-}
-
void RootWindow::OnWindowDestroying(Window* window) {
// Update the focused window state if the window was focused.
if (focused_window_ == window) {
diff --git a/ui/aura/root_window.h b/ui/aura/root_window.h
index 4f5bd4f..740b259 100644
--- a/ui/aura/root_window.h
+++ b/ui/aura/root_window.h
@@ -115,9 +115,6 @@ class AURA_EXPORT RootWindow : public ui::CompositorDelegate,
// Called when the native screen's resolution changes.
void OnNativeScreenResized(const gfx::Size& size);
- // Invoked when |window| is initialized.
- void OnWindowInitialized(Window* window);
-
// Invoked when |window| is being destroyed.
void OnWindowDestroying(Window* window);
diff --git a/ui/aura/root_window_observer.h b/ui/aura/root_window_observer.h
index 5d8d6c4..8df353e 100644
--- a/ui/aura/root_window_observer.h
+++ b/ui/aura/root_window_observer.h
@@ -21,9 +21,6 @@ class AURA_EXPORT RootWindowObserver {
// Invoked after the RootWindow is resized.
virtual void OnRootWindowResized(const gfx::Size& new_size) {}
- // Invoked when a new window is initialized.
- virtual void OnWindowInitialized(Window* window) {}
-
// Invoked when a window is focused.
virtual void OnWindowFocused(Window* window) {}
diff --git a/ui/aura/test/aura_test_base.cc b/ui/aura/test/aura_test_base.cc
index 3e1e95f..20061dd 100644
--- a/ui/aura/test/aura_test_base.cc
+++ b/ui/aura/test/aura_test_base.cc
@@ -8,6 +8,7 @@
#include <ole2.h>
#endif
+#include "ui/aura/env.h"
#include "ui/aura/root_window.h"
#include "ui/gfx/compositor/layer_animator.h"
@@ -44,6 +45,7 @@ AuraTestBase::~AuraTestBase() {
// Ensure that we don't use the previously-allocated static RootWindow object
// later -- on Linux, it holds a reference to our message loop's X connection.
aura::RootWindow::DeleteInstance();
+ aura::Env::DeleteInstance();
}
void AuraTestBase::SetUp() {
diff --git a/ui/aura/window.cc b/ui/aura/window.cc
index a5869ba..765682c 100644
--- a/ui/aura/window.cc
+++ b/ui/aura/window.cc
@@ -11,6 +11,7 @@
#include "base/string_util.h"
#include "ui/aura/client/stacking_client.h"
#include "ui/aura/client/visibility_client.h"
+#include "ui/aura/env.h"
#include "ui/aura/event.h"
#include "ui/aura/event_filter.h"
#include "ui/aura/layout_manager.h"
@@ -118,7 +119,7 @@ void Window::Init(ui::Layer::LayerType layer_type) {
UpdateLayerName(name_);
layer_->SetFillsBoundsOpaquely(!transparent_);
- RootWindow::GetInstance()->OnWindowInitialized(this);
+ Env::GetInstance()->NotifyWindowInitialized(this);
}
void Window::SetType(client::WindowType type) {