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
|
|
|
#include "cefclient/browser/browser_window.h"
|
2015-01-27 01:03:25 +01:00
|
|
|
|
|
|
|
#include "include/base/cef_bind.h"
|
2015-01-31 01:55:56 +01:00
|
|
|
#include "cefclient/browser/main_message_loop.h"
|
2015-01-27 01:03:25 +01:00
|
|
|
|
|
|
|
namespace client {
|
|
|
|
|
2015-01-29 21:53:53 +01:00
|
|
|
BrowserWindow::BrowserWindow(Delegate* delegate)
|
2015-01-27 01:03:25 +01:00
|
|
|
: delegate_(delegate),
|
|
|
|
is_closing_(false) {
|
|
|
|
DCHECK(delegate_);
|
|
|
|
}
|
|
|
|
|
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_;
|
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
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();
|
|
|
|
DCHECK_EQ(browser->GetIdentifier(), browser_->GetIdentifier());
|
|
|
|
browser_ = NULL;
|
|
|
|
|
|
|
|
client_handler_->DetachDelegate();
|
|
|
|
client_handler_ = NULL;
|
|
|
|
|
|
|
|
// |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-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);
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace client
|