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.
|
|
|
|
|
|
|
|
#include "cefclient/browser_window_osr_win.h"
|
|
|
|
|
|
|
|
#include "cefclient/main_message_loop.h"
|
|
|
|
|
|
|
|
namespace client {
|
|
|
|
|
2015-01-29 21:53:53 +01:00
|
|
|
BrowserWindowOsrWin::BrowserWindowOsrWin(BrowserWindow::Delegate* delegate,
|
2015-01-27 01:03:25 +01:00
|
|
|
const std::string& startup_url,
|
|
|
|
bool transparent,
|
|
|
|
bool show_update_rect)
|
2015-01-29 21:53:53 +01:00
|
|
|
: BrowserWindow(delegate),
|
2015-01-27 01:03:25 +01:00
|
|
|
transparent_(transparent),
|
|
|
|
osr_hwnd_(NULL) {
|
|
|
|
osr_window_ = new OsrWindowWin(this, transparent, show_update_rect);
|
|
|
|
client_handler_ = new ClientHandlerOsr(this, osr_window_.get(), startup_url);
|
|
|
|
}
|
|
|
|
|
2015-01-29 21:53:53 +01:00
|
|
|
void BrowserWindowOsrWin::CreateBrowser(ClientWindowHandle parent_handle,
|
|
|
|
const CefRect& rect,
|
2015-01-27 01:03:25 +01:00
|
|
|
const CefBrowserSettings& settings) {
|
|
|
|
REQUIRE_MAIN_THREAD();
|
|
|
|
|
|
|
|
// Create the new browser and native window on the UI thread.
|
2015-01-29 21:53:53 +01:00
|
|
|
RECT wnd_rect = {rect.x, rect.y, rect.x + rect.width, rect.y + rect.height};
|
|
|
|
osr_window_->CreateBrowser(parent_handle, wnd_rect, client_handler_, settings,
|
2015-01-27 01:03:25 +01:00
|
|
|
client_handler_->startup_url());
|
|
|
|
}
|
|
|
|
|
2015-01-29 21:53:53 +01:00
|
|
|
void BrowserWindowOsrWin::GetPopupConfig(CefWindowHandle temp_handle,
|
2015-01-27 01:03:25 +01:00
|
|
|
CefWindowInfo& windowInfo,
|
|
|
|
CefRefPtr<CefClient>& client,
|
|
|
|
CefBrowserSettings& settings) {
|
|
|
|
// Note: This method may be called on any thread.
|
2015-01-29 21:53:53 +01:00
|
|
|
windowInfo.SetAsWindowless(temp_handle, transparent_);
|
2015-01-27 01:03:25 +01:00
|
|
|
client = client_handler_;
|
|
|
|
}
|
|
|
|
|
2015-01-29 21:53:53 +01:00
|
|
|
void BrowserWindowOsrWin::ShowPopup(ClientWindowHandle parent_handle,
|
2015-01-27 01:03:25 +01:00
|
|
|
int x, int y, size_t width, size_t height) {
|
|
|
|
REQUIRE_MAIN_THREAD();
|
|
|
|
if (osr_window_)
|
2015-01-29 21:53:53 +01:00
|
|
|
osr_window_->ShowPopup(parent_handle, x, y, width, height);
|
2015-01-27 01:03:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void BrowserWindowOsrWin::Show() {
|
|
|
|
REQUIRE_MAIN_THREAD();
|
|
|
|
if (osr_window_)
|
|
|
|
osr_window_->Show();
|
|
|
|
}
|
|
|
|
|
|
|
|
void BrowserWindowOsrWin::Hide() {
|
|
|
|
REQUIRE_MAIN_THREAD();
|
|
|
|
if (osr_window_)
|
|
|
|
osr_window_->Hide();
|
|
|
|
}
|
|
|
|
|
|
|
|
void BrowserWindowOsrWin::SetBounds(int x, int y, size_t width, size_t height) {
|
|
|
|
REQUIRE_MAIN_THREAD();
|
|
|
|
if (osr_window_)
|
|
|
|
osr_window_->SetBounds(x, y, width, height);
|
|
|
|
}
|
|
|
|
|
|
|
|
void BrowserWindowOsrWin::SetFocus() {
|
|
|
|
REQUIRE_MAIN_THREAD();
|
|
|
|
if (osr_window_)
|
|
|
|
osr_window_->SetFocus();
|
|
|
|
}
|
|
|
|
|
2015-01-29 21:53:53 +01:00
|
|
|
ClientWindowHandle BrowserWindowOsrWin::GetWindowHandle() const {
|
2015-01-27 01:03:25 +01:00
|
|
|
REQUIRE_MAIN_THREAD();
|
|
|
|
return osr_hwnd_;
|
|
|
|
}
|
|
|
|
|
|
|
|
void BrowserWindowOsrWin::OnBrowserClosed(CefRefPtr<CefBrowser> browser) {
|
|
|
|
REQUIRE_MAIN_THREAD();
|
|
|
|
|
|
|
|
// Release the OSR window reference. It will be deleted on the UI thread.
|
|
|
|
osr_window_ = NULL;
|
|
|
|
|
2015-01-29 21:53:53 +01:00
|
|
|
BrowserWindow::OnBrowserClosed(browser);
|
2015-01-27 01:03:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void BrowserWindowOsrWin::OnOsrNativeWindowCreated(HWND hwnd) {
|
|
|
|
REQUIRE_MAIN_THREAD();
|
|
|
|
DCHECK(!osr_hwnd_);
|
|
|
|
osr_hwnd_ = hwnd;
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace client
|