2015-01-30 19:07:13 +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_std_mac.h"
|
2015-01-30 19:07:13 +01:00
|
|
|
|
|
|
|
#include <Cocoa/Cocoa.h>
|
|
|
|
|
|
|
|
#include "include/base/cef_logging.h"
|
2016-11-18 00:52:42 +01:00
|
|
|
#include "tests/cefclient/browser/client_handler_std.h"
|
|
|
|
#include "tests/shared/browser/main_message_loop.h"
|
2015-01-30 19:07:13 +01:00
|
|
|
|
|
|
|
namespace client {
|
|
|
|
|
|
|
|
BrowserWindowStdMac::BrowserWindowStdMac(Delegate* delegate,
|
|
|
|
const std::string& startup_url)
|
|
|
|
: BrowserWindow(delegate) {
|
|
|
|
client_handler_ = new ClientHandlerStd(this, startup_url);
|
|
|
|
}
|
|
|
|
|
2015-02-14 00:17:08 +01:00
|
|
|
void BrowserWindowStdMac::CreateBrowser(
|
|
|
|
ClientWindowHandle parent_handle,
|
|
|
|
const CefRect& rect,
|
|
|
|
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) {
|
2015-01-30 19:07:13 +01:00
|
|
|
REQUIRE_MAIN_THREAD();
|
|
|
|
|
|
|
|
CefWindowInfo window_info;
|
2017-05-17 11:29:28 +02:00
|
|
|
window_info.SetAsChild(parent_handle, rect.x, rect.y, rect.width,
|
|
|
|
rect.height);
|
2015-01-30 19:07:13 +01:00
|
|
|
|
|
|
|
CefBrowserHost::CreateBrowser(window_info, client_handler_,
|
2017-05-17 11:29:28 +02:00
|
|
|
client_handler_->startup_url(), settings,
|
2019-03-19 10:42:54 +01:00
|
|
|
extra_info, request_context);
|
2015-01-30 19:07:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void BrowserWindowStdMac::GetPopupConfig(CefWindowHandle temp_handle,
|
|
|
|
CefWindowInfo& windowInfo,
|
|
|
|
CefRefPtr<CefClient>& client,
|
|
|
|
CefBrowserSettings& settings) {
|
2017-05-31 17:33:30 +02:00
|
|
|
CEF_REQUIRE_UI_THREAD();
|
|
|
|
|
2015-01-30 19:07:13 +01:00
|
|
|
// The window will be properly sized after the browser is created.
|
|
|
|
windowInfo.SetAsChild(temp_handle, 0, 0, 0, 0);
|
|
|
|
client = client_handler_;
|
|
|
|
}
|
|
|
|
|
|
|
|
void BrowserWindowStdMac::ShowPopup(ClientWindowHandle parent_handle,
|
2017-05-17 11:29:28 +02:00
|
|
|
int x,
|
|
|
|
int y,
|
|
|
|
size_t width,
|
|
|
|
size_t height) {
|
2015-01-30 19:07:13 +01:00
|
|
|
REQUIRE_MAIN_THREAD();
|
|
|
|
|
2019-04-23 19:17:56 +02:00
|
|
|
NSView* browser_view = CAST_CEF_WINDOW_HANDLE_TO_NSVIEW(GetWindowHandle());
|
2015-01-30 19:07:13 +01:00
|
|
|
|
|
|
|
// Re-parent |browser_view| to |parent_handle|.
|
|
|
|
[browser_view removeFromSuperview];
|
2019-04-23 19:17:56 +02:00
|
|
|
[CAST_CEF_WINDOW_HANDLE_TO_NSVIEW(parent_handle) addSubview:browser_view];
|
2015-01-30 19:07:13 +01:00
|
|
|
|
|
|
|
NSSize size = NSMakeSize(static_cast<int>(width), static_cast<int>(height));
|
|
|
|
[browser_view setFrameSize:size];
|
|
|
|
}
|
|
|
|
|
|
|
|
void BrowserWindowStdMac::Show() {
|
|
|
|
REQUIRE_MAIN_THREAD();
|
2016-07-11 23:11:42 +02:00
|
|
|
// Nothing to do here. Chromium internally handles window show/hide.
|
2015-01-30 19:07:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void BrowserWindowStdMac::Hide() {
|
|
|
|
REQUIRE_MAIN_THREAD();
|
2016-07-11 23:11:42 +02:00
|
|
|
// Nothing to do here. Chromium internally handles window show/hide.
|
2015-01-30 19:07:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void BrowserWindowStdMac::SetBounds(int x, int y, size_t width, size_t height) {
|
|
|
|
REQUIRE_MAIN_THREAD();
|
|
|
|
// Nothing to do here. Cocoa will size the browser for us.
|
|
|
|
}
|
|
|
|
|
|
|
|
void BrowserWindowStdMac::SetFocus(bool focus) {
|
|
|
|
REQUIRE_MAIN_THREAD();
|
2016-07-11 23:11:42 +02:00
|
|
|
// Nothing to do here. Chromium internally handles window focus assignment.
|
2015-01-30 19:07:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
ClientWindowHandle BrowserWindowStdMac::GetWindowHandle() const {
|
|
|
|
REQUIRE_MAIN_THREAD();
|
|
|
|
|
|
|
|
if (browser_)
|
|
|
|
return browser_->GetHost()->GetWindowHandle();
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace client
|