2015-01-27 01:03:25 +01:00
|
|
|
// Copyright (c) 2015 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.
|
|
|
|
|
2015-01-31 01:55:56 +01:00
|
|
|
#ifndef CEF_TESTS_CEFCLIENT_BROWSER_BROWSER_WINDOW_H_
|
|
|
|
#define CEF_TESTS_CEFCLIENT_BROWSER_BROWSER_WINDOW_H_
|
|
|
|
#pragma once
|
2015-01-27 01:03:25 +01:00
|
|
|
|
2021-06-17 22:08:01 +02:00
|
|
|
#include <memory>
|
|
|
|
|
2015-01-27 01:03:25 +01:00
|
|
|
#include "include/cef_browser.h"
|
2016-11-18 00:52:42 +01:00
|
|
|
#include "tests/cefclient/browser/client_handler.h"
|
|
|
|
#include "tests/cefclient/browser/client_types.h"
|
2015-01-27 01:03:25 +01:00
|
|
|
|
|
|
|
namespace client {
|
|
|
|
|
|
|
|
// Represents a native child window hosting a single browser instance. The
|
|
|
|
// methods of this class must be called on the main thread unless otherwise
|
|
|
|
// indicated.
|
2015-01-30 19:55:55 +01:00
|
|
|
class BrowserWindow : public ClientHandler::Delegate {
|
2015-01-27 01:03:25 +01:00
|
|
|
public:
|
2015-02-03 00:18:16 +01:00
|
|
|
// This interface is implemented by the owner of the BrowserWindow. The
|
2015-01-27 01:03:25 +01:00
|
|
|
// methods of this class will be called on the main thread.
|
|
|
|
class Delegate {
|
|
|
|
public:
|
|
|
|
// Called when the browser has been created.
|
|
|
|
virtual void OnBrowserCreated(CefRefPtr<CefBrowser> browser) = 0;
|
|
|
|
|
2018-09-20 15:00:14 +02:00
|
|
|
// Called when the BrowserWindow is closing.
|
|
|
|
virtual void OnBrowserWindowClosing() {}
|
|
|
|
|
2015-02-03 00:18:16 +01:00
|
|
|
// Called when the BrowserWindow has been destroyed.
|
2015-01-27 01:03:25 +01:00
|
|
|
virtual void OnBrowserWindowDestroyed() = 0;
|
|
|
|
|
|
|
|
// Set the window URL address.
|
|
|
|
virtual void OnSetAddress(const std::string& url) = 0;
|
|
|
|
|
|
|
|
// Set the window title.
|
|
|
|
virtual void OnSetTitle(const std::string& title) = 0;
|
|
|
|
|
2015-06-05 00:33:24 +02:00
|
|
|
// Set fullscreen mode.
|
|
|
|
virtual void OnSetFullscreen(bool fullscreen) = 0;
|
|
|
|
|
2017-08-04 00:55:19 +02:00
|
|
|
// Auto-resize contents.
|
|
|
|
virtual void OnAutoResize(const CefSize& new_size) = 0;
|
|
|
|
|
2015-01-27 01:03:25 +01:00
|
|
|
// Set the loading state.
|
|
|
|
virtual void OnSetLoadingState(bool isLoading,
|
|
|
|
bool canGoBack,
|
|
|
|
bool canGoForward) = 0;
|
|
|
|
|
2015-04-24 15:48:32 +02:00
|
|
|
// Set the draggable regions.
|
|
|
|
virtual void OnSetDraggableRegions(
|
|
|
|
const std::vector<CefDraggableRegion>& regions) = 0;
|
|
|
|
|
2015-01-27 01:03:25 +01:00
|
|
|
protected:
|
|
|
|
virtual ~Delegate() {}
|
|
|
|
};
|
|
|
|
|
|
|
|
// Create a new browser and native window.
|
2015-01-29 21:53:53 +01:00
|
|
|
virtual void CreateBrowser(ClientWindowHandle parent_handle,
|
|
|
|
const CefRect& rect,
|
2015-02-14 00:17:08 +01:00
|
|
|
const CefBrowserSettings& settings,
|
2019-03-19 10:42:54 +01:00
|
|
|
CefRefPtr<CefDictionaryValue> extra_info,
|
2015-02-14 00:17:08 +01:00
|
|
|
CefRefPtr<CefRequestContext> request_context) = 0;
|
2015-01-27 01:03:25 +01:00
|
|
|
|
|
|
|
// Retrieve the configuration that will be used when creating a popup window.
|
2015-01-29 21:53:53 +01:00
|
|
|
// The popup browser will initially be parented to |temp_handle| which should
|
|
|
|
// be a pre-existing hidden window. The native window will be created later
|
2017-05-31 17:33:30 +02:00
|
|
|
// after the browser has been created. This method will be called on the
|
|
|
|
// browser process UI thread.
|
2015-01-29 21:53:53 +01:00
|
|
|
virtual void GetPopupConfig(CefWindowHandle temp_handle,
|
2015-01-27 01:03:25 +01:00
|
|
|
CefWindowInfo& windowInfo,
|
|
|
|
CefRefPtr<CefClient>& client,
|
|
|
|
CefBrowserSettings& settings) = 0;
|
|
|
|
|
|
|
|
// Show the popup window with correct parent and bounds in parent coordinates.
|
2015-01-29 21:53:53 +01:00
|
|
|
virtual void ShowPopup(ClientWindowHandle parent_handle,
|
2017-05-17 11:29:28 +02:00
|
|
|
int x,
|
|
|
|
int y,
|
|
|
|
size_t width,
|
|
|
|
size_t height) = 0;
|
2015-01-27 01:03:25 +01:00
|
|
|
|
|
|
|
// Show the window.
|
|
|
|
virtual void Show() = 0;
|
|
|
|
|
|
|
|
// Hide the window.
|
|
|
|
virtual void Hide() = 0;
|
|
|
|
|
|
|
|
// Set the window bounds in parent coordinates.
|
|
|
|
virtual void SetBounds(int x, int y, size_t width, size_t height) = 0;
|
|
|
|
|
|
|
|
// Set focus to the window.
|
2015-01-30 19:07:13 +01:00
|
|
|
virtual void SetFocus(bool focus) = 0;
|
2015-01-27 01:03:25 +01:00
|
|
|
|
2015-08-10 22:49:45 +02:00
|
|
|
// Set the device scale factor. Only used in combination with off-screen
|
|
|
|
// rendering.
|
|
|
|
virtual void SetDeviceScaleFactor(float device_scale_factor);
|
|
|
|
|
|
|
|
// Returns the device scale factor. Only used in combination with off-screen
|
|
|
|
// rendering.
|
|
|
|
virtual float GetDeviceScaleFactor() const;
|
|
|
|
|
2015-01-27 01:03:25 +01:00
|
|
|
// Returns the window handle.
|
2015-01-29 21:53:53 +01:00
|
|
|
virtual ClientWindowHandle GetWindowHandle() const = 0;
|
2015-01-27 01:03:25 +01:00
|
|
|
|
|
|
|
// Returns the browser owned by the window.
|
|
|
|
CefRefPtr<CefBrowser> GetBrowser() const;
|
|
|
|
|
|
|
|
// Returns true if the browser is closing.
|
|
|
|
bool IsClosing() const;
|
|
|
|
|
|
|
|
protected:
|
2021-06-17 22:08:01 +02:00
|
|
|
// Allow deletion via std::unique_ptr only.
|
|
|
|
friend std::default_delete<BrowserWindow>;
|
2015-01-27 01:03:25 +01:00
|
|
|
|
|
|
|
// Constructor may be called on any thread.
|
2015-02-03 00:18:16 +01:00
|
|
|
// |delegate| must outlive this object.
|
2015-01-29 21:53:53 +01:00
|
|
|
explicit BrowserWindow(Delegate* delegate);
|
2015-01-27 01:03:25 +01:00
|
|
|
|
2015-01-30 19:55:55 +01:00
|
|
|
// 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 OnSetFullscreen(bool fullscreen) override;
|
|
|
|
void OnAutoResize(const CefSize& new_size) override;
|
2015-01-27 01:03:25 +01:00
|
|
|
void OnSetLoadingState(bool isLoading,
|
|
|
|
bool canGoBack,
|
2021-06-17 21:43:06 +02:00
|
|
|
bool canGoForward) override;
|
2015-04-24 15:48:32 +02:00
|
|
|
void OnSetDraggableRegions(
|
2021-06-17 21:43:06 +02:00
|
|
|
const std::vector<CefDraggableRegion>& regions) override;
|
2015-01-27 01:03:25 +01:00
|
|
|
|
|
|
|
Delegate* delegate_;
|
|
|
|
CefRefPtr<CefBrowser> browser_;
|
2015-01-30 19:55:55 +01:00
|
|
|
CefRefPtr<ClientHandler> client_handler_;
|
2015-01-27 01:03:25 +01:00
|
|
|
bool is_closing_;
|
|
|
|
|
2015-01-31 01:55:56 +01:00
|
|
|
private:
|
2015-01-29 21:53:53 +01:00
|
|
|
DISALLOW_COPY_AND_ASSIGN(BrowserWindow);
|
2015-01-27 01:03:25 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace client
|
|
|
|
|
2015-01-31 01:55:56 +01:00
|
|
|
#endif // CEF_TESTS_CEFCLIENT_BROWSER_BROWSER_WINDOW_H_
|