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.
|
|
|
|
|
2016-11-18 00:52:42 +01:00
|
|
|
#include "tests/cefclient/browser/browser_window.h"
|
2015-01-27 01:03:25 +01:00
|
|
|
|
2021-06-17 22:08:01 +02:00
|
|
|
#include "include/base/cef_callback.h"
|
2016-11-18 00:52:42 +01:00
|
|
|
#include "tests/shared/browser/main_message_loop.h"
|
2015-01-27 01:03:25 +01:00
|
|
|
|
|
|
|
namespace client {
|
|
|
|
|
2024-01-20 03:22:56 +01:00
|
|
|
BrowserWindow::BrowserWindow(Delegate* delegate) : delegate_(delegate) {
|
2015-01-27 01:03:25 +01:00
|
|
|
DCHECK(delegate_);
|
|
|
|
}
|
|
|
|
|
2017-05-17 11:29:28 +02:00
|
|
|
void BrowserWindow::SetDeviceScaleFactor(float device_scale_factor) {}
|
2015-08-10 22:49:45 +02:00
|
|
|
|
|
|
|
float BrowserWindow::GetDeviceScaleFactor() const {
|
|
|
|
return 1.0f;
|
|
|
|
}
|
|
|
|
|
2015-01-29 21:53:53 +01:00
|
|
|
CefRefPtr<CefBrowser> BrowserWindow::GetBrowser() const {
|
2015-01-27 01:03:25 +01:00
|
|
|
REQUIRE_MAIN_THREAD();
|
|
|
|
return browser_;
|
|
|
|
}
|
|
|
|
|
2015-01-29 21:53:53 +01:00
|
|
|
bool BrowserWindow::IsClosing() const {
|
2015-01-27 01:03:25 +01:00
|
|
|
REQUIRE_MAIN_THREAD();
|
|
|
|
return is_closing_;
|
|
|
|
}
|
|
|
|
|
2024-04-17 18:01:26 +02:00
|
|
|
bool BrowserWindow::UseAlloyStyle() const {
|
|
|
|
return delegate_->UseAlloyStyle();
|
|
|
|
}
|
|
|
|
|
2015-01-29 21:53:53 +01:00
|
|
|
void BrowserWindow::OnBrowserCreated(CefRefPtr<CefBrowser> browser) {
|
2015-01-27 01:03:25 +01:00
|
|
|
REQUIRE_MAIN_THREAD();
|
|
|
|
DCHECK(!browser_);
|
|
|
|
browser_ = browser;
|
|
|
|
|
|
|
|
delegate_->OnBrowserCreated(browser);
|
|
|
|
}
|
|
|
|
|
2015-01-29 21:53:53 +01:00
|
|
|
void BrowserWindow::OnBrowserClosing(CefRefPtr<CefBrowser> browser) {
|
2015-01-27 01:03:25 +01:00
|
|
|
REQUIRE_MAIN_THREAD();
|
|
|
|
DCHECK_EQ(browser->GetIdentifier(), browser_->GetIdentifier());
|
|
|
|
is_closing_ = true;
|
2018-09-20 15:00:14 +02:00
|
|
|
|
|
|
|
delegate_->OnBrowserWindowClosing();
|
2015-01-27 01:03:25 +01:00
|
|
|
}
|
|
|
|
|
2015-01-29 21:53:53 +01:00
|
|
|
void BrowserWindow::OnBrowserClosed(CefRefPtr<CefBrowser> browser) {
|
2015-01-27 01:03:25 +01:00
|
|
|
REQUIRE_MAIN_THREAD();
|
2015-10-14 18:44:22 +02:00
|
|
|
if (browser_.get()) {
|
|
|
|
DCHECK_EQ(browser->GetIdentifier(), browser_->GetIdentifier());
|
2020-01-15 15:28:12 +01:00
|
|
|
browser_ = nullptr;
|
2015-10-14 18:44:22 +02:00
|
|
|
}
|
2015-01-27 01:03:25 +01:00
|
|
|
|
|
|
|
client_handler_->DetachDelegate();
|
2020-01-15 15:28:12 +01:00
|
|
|
client_handler_ = nullptr;
|
2015-01-27 01:03:25 +01:00
|
|
|
|
|
|
|
// |this| may be deleted.
|
|
|
|
delegate_->OnBrowserWindowDestroyed();
|
|
|
|
}
|
|
|
|
|
2015-01-29 21:53:53 +01:00
|
|
|
void BrowserWindow::OnSetAddress(const std::string& url) {
|
2015-01-27 01:03:25 +01:00
|
|
|
REQUIRE_MAIN_THREAD();
|
|
|
|
delegate_->OnSetAddress(url);
|
|
|
|
}
|
|
|
|
|
2015-01-29 21:53:53 +01:00
|
|
|
void BrowserWindow::OnSetTitle(const std::string& title) {
|
2015-01-27 01:03:25 +01:00
|
|
|
REQUIRE_MAIN_THREAD();
|
|
|
|
delegate_->OnSetTitle(title);
|
|
|
|
}
|
|
|
|
|
2015-06-05 00:33:24 +02:00
|
|
|
void BrowserWindow::OnSetFullscreen(bool fullscreen) {
|
|
|
|
REQUIRE_MAIN_THREAD();
|
|
|
|
delegate_->OnSetFullscreen(fullscreen);
|
|
|
|
}
|
|
|
|
|
2017-08-04 00:55:19 +02:00
|
|
|
void BrowserWindow::OnAutoResize(const CefSize& new_size) {
|
|
|
|
REQUIRE_MAIN_THREAD();
|
|
|
|
delegate_->OnAutoResize(new_size);
|
|
|
|
}
|
|
|
|
|
2015-01-29 21:53:53 +01:00
|
|
|
void BrowserWindow::OnSetLoadingState(bool isLoading,
|
|
|
|
bool canGoBack,
|
|
|
|
bool canGoForward) {
|
2015-01-27 01:03:25 +01:00
|
|
|
REQUIRE_MAIN_THREAD();
|
|
|
|
delegate_->OnSetLoadingState(isLoading, canGoBack, canGoForward);
|
|
|
|
}
|
|
|
|
|
2015-04-24 15:48:32 +02:00
|
|
|
void BrowserWindow::OnSetDraggableRegions(
|
2017-05-17 11:29:28 +02:00
|
|
|
const std::vector<CefDraggableRegion>& regions) {
|
2015-04-24 15:48:32 +02:00
|
|
|
REQUIRE_MAIN_THREAD();
|
|
|
|
delegate_->OnSetDraggableRegions(regions);
|
|
|
|
}
|
|
|
|
|
2015-01-27 01:03:25 +01:00
|
|
|
} // namespace client
|