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

Unified Diff: athena/wm/window_list_provider_impl.cc

Issue 633623002: Handle transient children as a part of transient parent (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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 f684c4193126f3f5a42ed3fd99ee80085c76df72..a6aa78192208a394cc5ed1a30a9de4f7a89a88f7 100644
--- a/athena/wm/window_list_provider_impl.cc
+++ b/athena/wm/window_list_provider_impl.cc
@@ -6,41 +6,50 @@
#include <algorithm>
+#include "athena/athena_export.h"
#include "athena/wm/public/window_list_provider_observer.h"
#include "ui/aura/window.h"
+#include "ui/aura/window_property.h"
+#include "ui/wm/core/transient_window_manager.h"
+#include "ui/wm/core/window_util.h"
+
+DECLARE_EXPORTED_WINDOW_PROPERTY_TYPE(ATHENA_EXPORT, bool);
namespace athena {
+namespace {
+
+// Used to keep track of which window should be managed. This is necessary
+// as the necessary informatino used in IsValidWindow (transient parent
+// for example) may not available during destruction.
+DEFINE_WINDOW_PROPERTY_KEY(bool, kManagedKey, false);
+
+} // namespace
WindowListProviderImpl::WindowListProviderImpl(aura::Window* container)
: container_(container) {
CHECK(container_);
container_->AddObserver(this);
RecreateWindowList();
- std::for_each(window_list_.begin(), window_list_.end(),
- std::bind2nd(std::mem_fun(&aura::Window::AddObserver),
- this));
+ for (auto* window : window_list_)
Mr4D (OOO till 08-26) 2014/10/08 03:44:25 Don't you want to set the property here as well? M
+ window->AddObserver(this);
}
WindowListProviderImpl::~WindowListProviderImpl() {
// Remove all remaining window observers.
- for (aura::Window::Windows::const_iterator iter = window_list_.begin();
- iter != window_list_.end();
- ++iter) {
- CHECK(IsValidWindow(*iter));
- (*iter)->RemoveObserver(this);
+ for (auto* window : window_list_) {
+ CHECK(window->GetProperty(kManagedKey));
+ window->RemoveObserver(this);
}
container_->RemoveObserver(this);
}
-void WindowListProviderImpl::RecreateWindowList() {
- window_list_.clear();
- 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))
- window_list_.push_back(*iter);
- }
+bool WindowListProviderImpl::IsValidWindow(aura::Window* window) const {
+ if (wm::GetTransientParent(window))
+ return false;
+
+ // TODO(oshima): crbug.com/413912.
+ return window->type() == ui::wm::WINDOW_TYPE_NORMAL ||
+ window->type() == ui::wm::WINDOW_TYPE_PANEL;
}
void WindowListProviderImpl::AddObserver(WindowListProviderObserver* observer) {
@@ -57,15 +66,10 @@ const aura::Window::Windows& WindowListProviderImpl::GetWindowList() const {
}
bool WindowListProviderImpl::IsWindowInList(aura::Window* window) const {
+ // TODO(oshima): Use kManagedKey specify which windows are managed.
return window->parent() == container_ && IsValidWindow(window);
}
-bool WindowListProviderImpl::IsValidWindow(aura::Window* window) const {
- // TODO(oshima): crbug.com/413912
- return window->type() == ui::wm::WINDOW_TYPE_NORMAL ||
- window->type() == ui::wm::WINDOW_TYPE_PANEL;
-}
-
void WindowListProviderImpl::StackWindowFrontOf(
aura::Window* window,
aura::Window* reference_window) {
@@ -84,16 +88,26 @@ void WindowListProviderImpl::StackWindowBehindTo(
container_->StackChildBelow(window, reference_window);
}
+void WindowListProviderImpl::RecreateWindowList() {
+ window_list_.clear();
+ for (auto* window : container_->children()) {
+ if (window->GetProperty(kManagedKey))
+ window_list_.push_back(window);
+ }
+}
+
void WindowListProviderImpl::OnWindowAdded(aura::Window* window) {
if (!IsValidWindow(window) || window->parent() != container_)
return;
+
+ window->SetProperty(kManagedKey, true);
RecreateWindowList();
DCHECK(IsWindowInList(window));
window->AddObserver(this);
}
void WindowListProviderImpl::OnWillRemoveWindow(aura::Window* window) {
- if (!IsValidWindow(window) || window->parent() != container_)
+ if (!window->GetProperty(kManagedKey))
return;
DCHECK(IsWindowInList(window));
aura::Window::Windows::iterator find = std::find(window_list_.begin(),

Powered by Google App Engine
This is Rietveld 408576698