#ifndef EXTENSIONS_SHELL_BROWSER_ROOT_WINDOW_CONTROLLER_H_
#define EXTENSIONS_SHELL_BROWSER_ROOT_WINDOW_CONTROLLER_H_
#include <list>
#include <memory>
#include "base/memory/raw_ptr.h"
#include "extensions/browser/app_window/app_window_registry.h"
#include "ui/aura/client/window_parenting_client.h"
#include "ui/aura/window_tree_host_observer.h"
#include "ui/gfx/native_ui_types.h"
namespace aura {
class WindowTreeHost;
namespace client {
class ScreenPositionClient;
}
}
namespace content {
class BrowserContext;
}
namespace gfx {
class Rect;
class Size;
}
namespace extensions {
class AppWindow;
class RootWindowController : public aura::client::WindowParentingClient,
public aura::WindowTreeHostObserver,
public AppWindowRegistry::Observer {
public:
class DesktopDelegate {
public:
virtual ~DesktopDelegate() = default;
virtual void CloseRootWindowController(
RootWindowController* root_window_controller) = 0;
};
RootWindowController(DesktopDelegate* desktop_delegate,
const gfx::Rect& bounds,
content::BrowserContext* browser_context);
RootWindowController(const RootWindowController&) = delete;
RootWindowController& operator=(const RootWindowController&) = delete;
~RootWindowController() override;
void AddAppWindow(AppWindow* app_window, gfx::NativeWindow window);
void RemoveAppWindow(AppWindow* app_window);
void CloseAppWindows();
void UpdateSize(const gfx::Size& size);
aura::WindowTreeHost* host() { return host_.get(); }
aura::Window* GetDefaultParent(aura::Window* window,
const gfx::Rect& bounds,
const int64_t display_id) override;
void OnHostCloseRequested(aura::WindowTreeHost* host) override;
void OnAppWindowRemoved(AppWindow* app_window) override;
private:
void DestroyWindowTreeHost();
const raw_ptr<DesktopDelegate> desktop_delegate_;
const raw_ptr<content::BrowserContext> browser_context_;
std::unique_ptr<aura::client::ScreenPositionClient> screen_position_client_;
std::unique_ptr<aura::WindowTreeHost> host_;
std::list<raw_ptr<AppWindow, CtnExperimental>> app_windows_;
};
}
#endif