Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(935)

Unified Diff: athena/wm/window_list_provider_impl.cc

Issue 480293003: Adding functions to the window_list_provider for accessing the activities window list (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Moved Window observer from ResourceManager to WindowListProvider Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: athena/wm/window_list_provider_impl.cc
diff --git a/athena/wm/window_list_provider_impl.cc b/athena/wm/window_list_provider_impl.cc
index 8b4cba5abdc2831bd80c81ccc263c33300e366b0..f3172de9bdd482e17ac8625b58681b8a1d27af7c 100644
--- a/athena/wm/window_list_provider_impl.cc
+++ b/athena/wm/window_list_provider_impl.cc
@@ -4,6 +4,7 @@
#include "athena/wm/window_list_provider_impl.h"
+#include "athena/wm/public/window_list_provider_observer.h"
#include "ui/aura/window.h"
namespace athena {
@@ -11,21 +12,92 @@ namespace athena {
WindowListProviderImpl::WindowListProviderImpl(aura::Window* container)
: container_(container) {
CHECK(container_);
+ container_->AddObserver(this);
}
WindowListProviderImpl::~WindowListProviderImpl() {
+ // Remove all remaining window observers.
+ const aura::Window::Windows& container_children = container_->children();
+ for (aura::Window::Windows::const_iterator iter = container_children.begin();
+ iter != container_children.end();
+ ++iter) {
+ if (IsValidWindow(*iter))
+ (*iter)->RemoveObserver(this);
+ }
+ container_->RemoveObserver(this);
+}
+
+void WindowListProviderImpl::AddObserver(WindowListProviderObserver* observer) {
+ observers_.AddObserver(observer);
}
-aura::Window::Windows WindowListProviderImpl::GetWindowList() const {
+void WindowListProviderImpl::RemoveObserver(
+ WindowListProviderObserver* observer) {
+ observers_.RemoveObserver(observer);
+}
+
+aura::Window::Windows WindowListProviderImpl::GetCurrentWindowList() const {
aura::Window::Windows list;
const aura::Window::Windows& container_children = container_->children();
for (aura::Window::Windows::const_iterator iter = container_children.begin();
iter != container_children.end();
++iter) {
- if ((*iter)->type() == ui::wm::WINDOW_TYPE_NORMAL)
+ if (IsValidWindow(*iter))
list.push_back(*iter);
}
return list;
}
+bool WindowListProviderImpl::IsWindowInList(aura::Window* window) const {
+ return window->parent() == container_ && IsValidWindow(window);
+}
+
+bool WindowListProviderImpl::IsValidWindow(aura::Window* window) const {
+ return window->type() == ui::wm::WINDOW_TYPE_NORMAL;
oshima 2014/09/09 18:28:37 Note: This is OK for now, but I think this logic s
Mr4D (OOO till 08-26) 2014/09/10 00:01:58 Acknowledged.
+}
+
+void WindowListProviderImpl::MoveToFront(aura::Window* window) {
+ DCHECK(IsWindowInList(window));
+ container_->StackChildAtTop(window);
+}
+
+void WindowListProviderImpl::StackWindowFrontOf(
+ aura::Window* window,
+ aura::Window* reference_window) {
+ DCHECK_NE(window, reference_window);
+ DCHECK(IsWindowInList(window));
+ DCHECK(IsWindowInList(reference_window));
+ container_->StackChildAbove(window, reference_window);
+}
+
+void WindowListProviderImpl::StackWindowBehindTo(
+ aura::Window* window,
+ aura::Window* reference_window) {
+ DCHECK_NE(window, reference_window);
+ DCHECK(IsWindowInList(window));
+ DCHECK(IsWindowInList(reference_window));
+ container_->StackChildBelow(window, reference_window);
+}
+
+void WindowListProviderImpl::OnWindowAdded(aura::Window* window) {
+ if (!IsValidWindow(window) || window->parent() != container_)
oshima 2014/09/09 18:28:37 IsWindowInList
Mr4D (OOO till 08-26) 2014/09/10 00:01:58 Done.
+ return;
+ window->AddObserver(this);
+}
+
+void WindowListProviderImpl::OnWillRemoveWindow(aura::Window* window) {
+ if (!IsValidWindow(window) || window->parent() != container_)
oshima 2014/09/09 18:28:37 ditto
Mr4D (OOO till 08-26) 2014/09/10 00:01:58 Done.
+ return;
+ window->RemoveObserver(this);
+}
+
+void WindowListProviderImpl::OnWindowStackingChanged(aura::Window* window) {
+ if (window == container_)
oshima 2014/09/09 18:28:37 ditto.
Mr4D (OOO till 08-26) 2014/09/10 00:01:58 Done.
+ return;
+ // Inform our listeners that the stacking has been changed.
+ FOR_EACH_OBSERVER(WindowListProviderObserver,
+ observers_,
+ OnActivityStackingChanged());
+}
+
} // namespace athena

Powered by Google App Engine
This is Rietveld 408576698