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

Unified Diff: ui/wm/core/default_activation_client.cc

Issue 851853002: It is time. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Trying to reup because the last upload failed. Created 5 years, 11 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 | « ui/wm/core/default_activation_client.h ('k') | ui/wm/core/easy_resize_window_targeter.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/wm/core/default_activation_client.cc
diff --git a/ui/wm/core/default_activation_client.cc b/ui/wm/core/default_activation_client.cc
deleted file mode 100644
index d6383d6d08dc9fed6be69386d0c6a2c57d275fda..0000000000000000000000000000000000000000
--- a/ui/wm/core/default_activation_client.cc
+++ /dev/null
@@ -1,152 +0,0 @@
-// Copyright 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.
-
-#include "ui/wm/core/default_activation_client.h"
-
-#include "ui/aura/window.h"
-#include "ui/wm/public/activation_change_observer.h"
-#include "ui/wm/public/activation_delegate.h"
-
-namespace wm {
-
-// Takes care of observing root window destruction & destroying the client.
-class DefaultActivationClient::Deleter : public aura::WindowObserver {
- public:
- Deleter(DefaultActivationClient* client, aura::Window* root_window)
- : client_(client),
- root_window_(root_window) {
- root_window_->AddObserver(this);
- }
-
- private:
- virtual ~Deleter() {}
-
- // Overridden from WindowObserver:
- virtual void OnWindowDestroyed(aura::Window* window) override {
- DCHECK_EQ(window, root_window_);
- root_window_->RemoveObserver(this);
- delete client_;
- delete this;
- }
-
- DefaultActivationClient* client_;
- aura::Window* root_window_;
-
- DISALLOW_COPY_AND_ASSIGN(Deleter);
-};
-
-////////////////////////////////////////////////////////////////////////////////
-// DefaultActivationClient, public:
-
-DefaultActivationClient::DefaultActivationClient(aura::Window* root_window)
- : last_active_(NULL) {
- aura::client::SetActivationClient(root_window, this);
- new Deleter(this, root_window);
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// DefaultActivationClient, client::ActivationClient implementation:
-
-void DefaultActivationClient::AddObserver(
- aura::client::ActivationChangeObserver* observer) {
- observers_.AddObserver(observer);
-}
-
-void DefaultActivationClient::RemoveObserver(
- aura::client::ActivationChangeObserver* observer) {
- observers_.RemoveObserver(observer);
-}
-
-void DefaultActivationClient::ActivateWindow(aura::Window* window) {
- aura::Window* last_active = GetActiveWindow();
- if (last_active == window)
- return;
-
- last_active_ = last_active;
- RemoveActiveWindow(window);
- active_windows_.push_back(window);
- window->parent()->StackChildAtTop(window);
- window->AddObserver(this);
-
- FOR_EACH_OBSERVER(aura::client::ActivationChangeObserver,
- observers_,
- OnWindowActivated(window, last_active));
-
- aura::client::ActivationChangeObserver* observer =
- aura::client::GetActivationChangeObserver(last_active);
- if (observer)
- observer->OnWindowActivated(window, last_active);
- observer = aura::client::GetActivationChangeObserver(window);
- if (observer)
- observer->OnWindowActivated(window, last_active);
-}
-
-void DefaultActivationClient::DeactivateWindow(aura::Window* window) {
- aura::client::ActivationChangeObserver* observer =
- aura::client::GetActivationChangeObserver(window);
- if (observer)
- observer->OnWindowActivated(NULL, window);
- if (last_active_)
- ActivateWindow(last_active_);
-}
-
-aura::Window* DefaultActivationClient::GetActiveWindow() {
- if (active_windows_.empty())
- return NULL;
- return active_windows_.back();
-}
-
-aura::Window* DefaultActivationClient::GetActivatableWindow(
- aura::Window* window) {
- return NULL;
-}
-
-aura::Window* DefaultActivationClient::GetToplevelWindow(aura::Window* window) {
- return NULL;
-}
-
-bool DefaultActivationClient::CanActivateWindow(aura::Window* window) const {
- return true;
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// DefaultActivationClient, aura::WindowObserver implementation:
-
-void DefaultActivationClient::OnWindowDestroyed(aura::Window* window) {
- if (window == last_active_)
- last_active_ = NULL;
-
- if (window == GetActiveWindow()) {
- active_windows_.pop_back();
- aura::Window* next_active = GetActiveWindow();
- if (next_active && aura::client::GetActivationChangeObserver(next_active)) {
- aura::client::GetActivationChangeObserver(next_active)->OnWindowActivated(
- next_active, NULL);
- }
- return;
- }
-
- RemoveActiveWindow(window);
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// DefaultActivationClient, private:
-
-DefaultActivationClient::~DefaultActivationClient() {
- for (unsigned int i = 0; i < active_windows_.size(); ++i) {
- active_windows_[i]->RemoveObserver(this);
- }
-}
-
-void DefaultActivationClient::RemoveActiveWindow(aura::Window* window) {
- for (unsigned int i = 0; i < active_windows_.size(); ++i) {
- if (active_windows_[i] == window) {
- active_windows_.erase(active_windows_.begin() + i);
- window->RemoveObserver(this);
- return;
- }
- }
-}
-
-} // namespace wm
« no previous file with comments | « ui/wm/core/default_activation_client.h ('k') | ui/wm/core/easy_resize_window_targeter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698