#pragma once #include #include #include #include #include "browser/tab_manager.h" #include "cef/browser_client.h" #include "platform/types.h" #include "window/nebula_window.h" namespace nebula::app { class NebulaController final : public nebula::window::WindowDelegate, public nebula::browser::TabObserver, public nebula::cef::BrowserClientDelegate { public: NebulaController(nebula::platform::AppStartup startup, std::string initial_url); ~NebulaController() override; bool Create(); void OnWindowCreated() override; void OnWindowResized(const nebula::window::BrowserLayout& layout) override; void OnWindowCloseRequested() override; void OnActiveTabChanged(const nebula::browser::NebulaTab& tab) override; void OnBrowserCreated(nebula::cef::BrowserRole role, CefRefPtr browser) override; void OnBrowserClosing(nebula::cef::BrowserRole role, CefRefPtr browser) override; void OnChromeCommand(const std::string& command, const std::string& payload) override; void OnContentAddressChanged(CefRefPtr browser, const std::string& url) override; void OnContentTitleChanged(CefRefPtr browser, const std::string& title) override; void OnContentLoadingStateChanged(CefRefPtr browser, bool is_loading) override; void OnContentLoadProgressChanged(CefRefPtr browser, double progress) override; void OnContentLoadFinished(CefRefPtr browser, const std::string& url) override; void OnContentFaviconChanged(CefRefPtr browser, const std::vector& urls) override; void OnContentFullscreenChanged(CefRefPtr browser, bool fullscreen) override; void OnPopupRequested(CefRefPtr browser, const std::string& target_url) override; bool ShouldBypassInsecureWarning(CefRefPtr browser, const std::string& target_url) override; private: void CreateNewTab(); void ActivateTab(int tab_id); void CloseTab(int tab_id); void CreateChromeBrowser(); void CreateContentBrowser(); void ToggleMenuPopup(); void CloseMenuPopup(); void CreateMenuPopupBrowser(); void PositionMenuPopup(); void ToggleDevTools(); void AdjustZoom(double delta); void FreshReload(); void SetContentFullscreen(bool fullscreen); void ResizeBrowsers(); void SendChromeState(const nebula::browser::NebulaTab& tab); void RecordSiteHistory(const std::string& url); void InjectSettingsHistory(CefRefPtr browser); void PersistSession() const; void MaybeFinishShutdown(); nebula::platform::AppStartup startup_; std::string initial_url_; bool closing_ = false; bool chrome_ready_ = false; bool content_fullscreen_ = false; std::unique_ptr window_; nebula::browser::TabManager tabs_; CefRefPtr chrome_browser_; CefRefPtr menu_popup_browser_; CefRefPtr chrome_client_; CefRefPtr content_client_; CefRefPtr menu_popup_client_; std::unordered_set insecure_warning_bypasses_; std::vector site_history_; }; } // namespace nebula::app