blob: 1ae149b369cd9b5db4d06999e5e7909da17ce899 [file] [log] [blame]
// 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 CHROME_BROWSER_UI_AURA_ACTIVE_DESKTOP_MONITOR_H_
#define CHROME_BROWSER_UI_AURA_ACTIVE_DESKTOP_MONITOR_H_
#include "base/basictypes.h"
#include "base/compiler_specific.h"
#include "chrome/browser/ui/host_desktop.h"
#include "ui/aura/env_observer.h"
// Tracks the most-recently activated host desktop type by observing
// RootWindowHost activations.
class ActiveDesktopMonitor : public aura::EnvObserver {
public:
// Constructs an ActiveDesktopMonitor which initially uses |initial_desktop|
// as the |last_activated_desktop_| until a root window is activated.
explicit ActiveDesktopMonitor(chrome::HostDesktopType initial_desktop);
virtual ~ActiveDesktopMonitor();
// Returns the host desktop type of the most-recently activated
// RootWindowHost. This desktop type may no longer exist (e.g., the Ash
// desktop may have closed since being active, and no RWHs on the native
// desktop have yet been activated).
static chrome::HostDesktopType GetLastActivatedDesktopType();
private:
// Returns true if |root_window| is hosted by a DesktopRootWindowHost.
static bool IsDesktopWindow(aura::RootWindow* root_window);
// aura::EnvObserver methods.
virtual void OnWindowInitialized(aura::Window* window) OVERRIDE;
virtual void OnRootWindowActivated(aura::RootWindow* root_window) OVERRIDE;
static ActiveDesktopMonitor* g_instance_;
chrome::HostDesktopType last_activated_desktop_;
DISALLOW_COPY_AND_ASSIGN(ActiveDesktopMonitor);
};
#endif // CHROME_BROWSER_UI_AURA_ACTIVE_DESKTOP_MONITOR_H_