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

Unified Diff: athena/wm/mru_window_tracker.cc

Issue 420603011: Split Screen mode implementation (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@split_view
Patch Set: Addressing sadrul's feedback, adding license header. Created 6 years, 4 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
« no previous file with comments | « athena/wm/mru_window_tracker.h ('k') | athena/wm/public/window_list_provider.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: athena/wm/mru_window_tracker.cc
diff --git a/athena/wm/mru_window_tracker.cc b/athena/wm/mru_window_tracker.cc
new file mode 100644
index 0000000000000000000000000000000000000000..b2cda0cbd6a68fa9a9d1d01f66c0fc39872b90ba
--- /dev/null
+++ b/athena/wm/mru_window_tracker.cc
@@ -0,0 +1,53 @@
+// Copyright 2014 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 "athena/wm/mru_window_tracker.h"
+
+#include "ui/aura/window.h"
+
+namespace athena {
+
+MruWindowTracker::MruWindowTracker(aura::Window* container)
+ : container_(container) {
+ container->AddObserver(this);
+}
+
+MruWindowTracker::~MruWindowTracker() {
+ if (container_)
+ container_->RemoveObserver(this);
+}
+
+aura::Window::Windows MruWindowTracker::GetWindowList() const {
+ return aura::Window::Windows(mru_windows_.begin(), mru_windows_.end());
+}
+
+void MruWindowTracker::MoveToFront(aura::Window* window) {
+ DCHECK(window);
+ CHECK_EQ(container_, window->parent());
+ std::list<aura::Window*>::iterator it =
+ std::find(mru_windows_.begin(), mru_windows_.end(), window);
+ DCHECK(it != mru_windows_.end());
+ mru_windows_.erase(it);
+ mru_windows_.push_back(window);
+}
+
+// Overridden from WindowObserver:
+void MruWindowTracker::OnWillRemoveWindow(aura::Window* window) {
+ std::list<aura::Window*>::iterator it =
+ std::find(mru_windows_.begin(), mru_windows_.end(), window);
+ if (it == mru_windows_.end()) {
+ // All normal windows should be tracked in mru_windows_
+ DCHECK_NE(window->type(), ui::wm::WINDOW_TYPE_NORMAL);
+ return;
+ }
+ mru_windows_.erase(it);
+}
+
+void MruWindowTracker::OnWindowAdded(aura::Window* new_window) {
+ // We are only interested in ordering normal windows.
+ if (new_window->type() == ui::wm::WINDOW_TYPE_NORMAL)
+ mru_windows_.push_back(new_window);
+}
+
+} // namespace athena
« no previous file with comments | « athena/wm/mru_window_tracker.h ('k') | athena/wm/public/window_list_provider.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698