2016-01-19 21:09:01 +01:00
|
|
|
// Copyright (c) 2016 The Chromium Embedded Framework 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 CEF_TESTS_CEFCLIENT_BROWSER_ROOT_WINDOW_VIEWS_H_
|
|
|
|
#define CEF_TESTS_CEFCLIENT_BROWSER_ROOT_WINDOW_VIEWS_H_
|
|
|
|
#pragma once
|
|
|
|
|
2021-06-17 22:08:01 +02:00
|
|
|
#include <memory>
|
2016-01-19 21:09:01 +01:00
|
|
|
#include <string>
|
|
|
|
|
2016-11-18 00:52:42 +01:00
|
|
|
#include "tests/cefclient/browser/client_handler.h"
|
|
|
|
#include "tests/cefclient/browser/root_window.h"
|
|
|
|
#include "tests/cefclient/browser/views_window.h"
|
2016-01-19 21:09:01 +01:00
|
|
|
|
|
|
|
namespace client {
|
|
|
|
|
|
|
|
// Views framework implementation of a top-level window in the browser process.
|
|
|
|
// The methods of this class must be called on the main thread unless otherwise
|
|
|
|
// indicated.
|
|
|
|
class RootWindowViews : public RootWindow,
|
|
|
|
public ClientHandler::Delegate,
|
|
|
|
public ViewsWindow::Delegate {
|
|
|
|
public:
|
|
|
|
// Constructor may be called on any thread.
|
|
|
|
RootWindowViews();
|
|
|
|
~RootWindowViews();
|
|
|
|
|
2023-03-16 18:19:50 +01:00
|
|
|
void SetTitlebarHeight(const std::optional<float>& height);
|
|
|
|
|
2016-01-19 21:09:01 +01:00
|
|
|
// RootWindow methods:
|
|
|
|
void Init(RootWindow::Delegate* delegate,
|
2021-06-19 21:54:45 +02:00
|
|
|
std::unique_ptr<RootWindowConfig> config,
|
2021-06-17 21:43:06 +02:00
|
|
|
const CefBrowserSettings& settings) override;
|
2016-01-19 21:09:01 +01:00
|
|
|
void InitAsPopup(RootWindow::Delegate* delegate,
|
|
|
|
bool with_controls,
|
|
|
|
bool with_osr,
|
|
|
|
const CefPopupFeatures& popupFeatures,
|
|
|
|
CefWindowInfo& windowInfo,
|
|
|
|
CefRefPtr<CefClient>& client,
|
2021-06-17 21:43:06 +02:00
|
|
|
CefBrowserSettings& settings) override;
|
|
|
|
void Show(ShowMode mode) override;
|
|
|
|
void Hide() override;
|
|
|
|
void SetBounds(int x, int y, size_t width, size_t height) override;
|
|
|
|
void Close(bool force) override;
|
|
|
|
void SetDeviceScaleFactor(float device_scale_factor) override;
|
|
|
|
float GetDeviceScaleFactor() const override;
|
|
|
|
CefRefPtr<CefBrowser> GetBrowser() const override;
|
|
|
|
ClientWindowHandle GetWindowHandle() const override;
|
|
|
|
bool WithWindowlessRendering() const override { return false; }
|
|
|
|
bool WithExtension() const override;
|
|
|
|
void OnExtensionsChanged(const ExtensionSet& extensions) override;
|
2016-01-19 21:09:01 +01:00
|
|
|
|
|
|
|
// ViewsWindow::Delegate methods:
|
2021-06-17 21:43:06 +02:00
|
|
|
bool WithControls() override;
|
|
|
|
bool WithExtension() override;
|
|
|
|
bool InitiallyHidden() override;
|
|
|
|
CefRefPtr<CefWindow> GetParentWindow() override;
|
2022-10-28 20:17:18 +02:00
|
|
|
CefRect GetInitialBounds() override;
|
|
|
|
cef_show_state_t GetInitialShowState() override;
|
2021-06-17 21:43:06 +02:00
|
|
|
scoped_refptr<ImageCache> GetImageCache() override;
|
|
|
|
void OnViewsWindowCreated(CefRefPtr<ViewsWindow> window) override;
|
2022-10-28 20:17:18 +02:00
|
|
|
void OnViewsWindowClosing(CefRefPtr<ViewsWindow> window) override;
|
2021-06-17 21:43:06 +02:00
|
|
|
void OnViewsWindowDestroyed(CefRefPtr<ViewsWindow> window) override;
|
|
|
|
void OnViewsWindowActivated(CefRefPtr<ViewsWindow> window) override;
|
2016-01-19 21:09:01 +01:00
|
|
|
ViewsWindow::Delegate* GetDelegateForPopup(
|
2021-06-17 21:43:06 +02:00
|
|
|
CefRefPtr<CefClient> client) override;
|
2017-08-04 00:55:19 +02:00
|
|
|
void CreateExtensionWindow(CefRefPtr<CefExtension> extension,
|
|
|
|
const CefRect& source_bounds,
|
|
|
|
CefRefPtr<CefWindow> parent_window,
|
2021-06-19 21:54:45 +02:00
|
|
|
base::OnceClosure close_callback) override;
|
2021-06-17 21:43:06 +02:00
|
|
|
void OnTest(int test_id) override;
|
|
|
|
void OnExit() override;
|
2016-01-19 21:09:01 +01:00
|
|
|
|
|
|
|
protected:
|
|
|
|
// ClientHandler::Delegate methods:
|
2021-06-17 21:43:06 +02:00
|
|
|
void OnBrowserCreated(CefRefPtr<CefBrowser> browser) override;
|
|
|
|
void OnBrowserClosing(CefRefPtr<CefBrowser> browser) override;
|
|
|
|
void OnBrowserClosed(CefRefPtr<CefBrowser> browser) override;
|
|
|
|
void OnSetAddress(const std::string& url) override;
|
|
|
|
void OnSetTitle(const std::string& title) override;
|
|
|
|
void OnSetFavicon(CefRefPtr<CefImage> image) override;
|
|
|
|
void OnSetFullscreen(bool fullscreen) override;
|
|
|
|
void OnAutoResize(const CefSize& new_size) override;
|
2016-01-19 21:09:01 +01:00
|
|
|
void OnSetLoadingState(bool isLoading,
|
|
|
|
bool canGoBack,
|
2021-06-17 21:43:06 +02:00
|
|
|
bool canGoForward) override;
|
2016-01-19 21:09:01 +01:00
|
|
|
void OnSetDraggableRegions(
|
2021-06-17 21:43:06 +02:00
|
|
|
const std::vector<CefDraggableRegion>& regions) override;
|
|
|
|
void OnTakeFocus(bool next) override;
|
|
|
|
void OnBeforeContextMenu(CefRefPtr<CefMenuModel> model) override;
|
2016-01-19 21:09:01 +01:00
|
|
|
|
|
|
|
private:
|
|
|
|
void CreateClientHandler(const std::string& url);
|
|
|
|
|
2019-11-18 21:02:39 +01:00
|
|
|
void InitOnUIThread(const CefBrowserSettings& settings,
|
|
|
|
CefRefPtr<CefRequestContext> request_context);
|
2016-01-19 21:09:01 +01:00
|
|
|
void CreateViewsWindow(const CefBrowserSettings& settings,
|
2017-08-04 00:55:19 +02:00
|
|
|
CefRefPtr<CefRequestContext> request_context,
|
|
|
|
const ImageCache::ImageSet& images);
|
2016-01-19 21:09:01 +01:00
|
|
|
|
|
|
|
void NotifyViewsWindowDestroyed();
|
2017-08-04 00:55:19 +02:00
|
|
|
void NotifyViewsWindowActivated();
|
2016-01-19 21:09:01 +01:00
|
|
|
void NotifyDestroyedIfDone();
|
|
|
|
|
2022-10-28 20:17:18 +02:00
|
|
|
// Members set during initialization. Safe to access from any thread.
|
2021-06-19 21:54:45 +02:00
|
|
|
std::unique_ptr<RootWindowConfig> config_;
|
2016-01-19 21:09:01 +01:00
|
|
|
CefRefPtr<ClientHandler> client_handler_;
|
2021-06-19 21:54:45 +02:00
|
|
|
bool initialized_ = false;
|
2016-01-19 21:09:01 +01:00
|
|
|
|
2022-10-28 20:17:18 +02:00
|
|
|
// Only accessed on the main thread.
|
2016-01-19 21:09:01 +01:00
|
|
|
CefRefPtr<CefBrowser> browser_;
|
2022-10-28 20:17:18 +02:00
|
|
|
bool window_destroyed_ = false;
|
|
|
|
bool browser_destroyed_ = false;
|
2016-01-19 21:09:01 +01:00
|
|
|
|
|
|
|
// Only accessed on the browser process UI thread.
|
2022-10-28 20:17:18 +02:00
|
|
|
CefRect initial_bounds_;
|
|
|
|
cef_show_state_t initial_show_state_ = CEF_SHOW_STATE_NORMAL;
|
|
|
|
bool position_on_resize_ = false;
|
2016-01-19 21:09:01 +01:00
|
|
|
CefRefPtr<ViewsWindow> window_;
|
2017-08-04 00:55:19 +02:00
|
|
|
ExtensionSet pending_extensions_;
|
|
|
|
scoped_refptr<ImageCache> image_cache_;
|
2016-01-19 21:09:01 +01:00
|
|
|
|
|
|
|
DISALLOW_COPY_AND_ASSIGN(RootWindowViews);
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace client
|
|
|
|
|
|
|
|
#endif // CEF_TESTS_CEFCLIENT_BROWSER_ROOT_WINDOW_VIEWS_H_
|