blob: b7e72afd0f856cc2c8690981015c58e7ed92fed6 [file] [log] [blame]
// Copyright 2017 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 <map>
#include <set>
#include <string>
#include "ash/ash_export.h"
#include "base/macros.h"
#include "ui/aura/window_observer.h"
namespace aura {
class Window;
namespace ash {
// WallpaperWindowStateManager remembers which windows have been minimized in
// order to restore them when the wallpaper viewer is hidden.
class ASH_EXPORT WallpaperWindowStateManager : public aura::WindowObserver {
typedef std::map<std::string, std::set<aura::Window*>>
// Minimizes all windows except the active window.
// TODO(mash): Expose this via a mojo API.
static void MinimizeInactiveWindows(const std::string& user_id_hash);
// Unminimizes all minimized windows restoring them to their previous state.
// This should only be called after calling MinimizeInactiveWindows.
// TODO(mash): Expose this via a mojo API.
static void RestoreWindows(const std::string& user_id_hash);
~WallpaperWindowStateManager() override;
// Store all unminimized windows except |active_window| and minimize them.
// All the windows are saved in a map and the key value is |user_id_hash|.
void BuildWindowListAndMinimizeInactiveForUser(
const std::string& user_id_hash,
aura::Window* active_window);
// Unminimize all the stored windows for |user_id_hash|.
void RestoreMinimizedWindows(const std::string& user_id_hash);
// Remove the observer from |window| if |window| is no longer referenced in
// user_id_hash_window_list_map_.
void RemoveObserverIfUnreferenced(aura::Window* window);
// aura::WindowObserver overrides.
void OnWindowDestroyed(aura::Window* window) override;
// aura::WindowObserver overrides.
void OnWindowStackingChanged(aura::Window* window) override;
// Map of user id hash and associated list of minimized windows.
UserIDHashWindowListMap user_id_hash_window_list_map_;
} // namespace ash