2015-01-31 05:41:36 +01:00
|
|
|
// Copyright (c) 2013 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/shared/renderer/client_app_renderer.h"
|
2015-01-31 05:41:36 +01:00
|
|
|
|
2015-02-02 22:03:19 +01:00
|
|
|
#include "include/base/cef_logging.h"
|
|
|
|
|
2015-01-31 05:41:36 +01:00
|
|
|
namespace client {
|
|
|
|
|
|
|
|
ClientAppRenderer::ClientAppRenderer() {
|
2015-09-09 16:05:39 +02:00
|
|
|
CreateDelegates(delegates_);
|
2015-01-31 05:41:36 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void ClientAppRenderer::OnWebKitInitialized() {
|
|
|
|
DelegateSet::iterator it = delegates_.begin();
|
|
|
|
for (; it != delegates_.end(); ++it)
|
|
|
|
(*it)->OnWebKitInitialized(this);
|
|
|
|
}
|
|
|
|
|
2019-03-19 10:42:54 +01:00
|
|
|
void ClientAppRenderer::OnBrowserCreated(
|
|
|
|
CefRefPtr<CefBrowser> browser,
|
|
|
|
CefRefPtr<CefDictionaryValue> extra_info) {
|
2015-01-31 05:41:36 +01:00
|
|
|
DelegateSet::iterator it = delegates_.begin();
|
|
|
|
for (; it != delegates_.end(); ++it)
|
2019-03-19 10:42:54 +01:00
|
|
|
(*it)->OnBrowserCreated(this, browser, extra_info);
|
2015-01-31 05:41:36 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void ClientAppRenderer::OnBrowserDestroyed(CefRefPtr<CefBrowser> browser) {
|
|
|
|
DelegateSet::iterator it = delegates_.begin();
|
|
|
|
for (; it != delegates_.end(); ++it)
|
|
|
|
(*it)->OnBrowserDestroyed(this, browser);
|
|
|
|
}
|
|
|
|
|
|
|
|
CefRefPtr<CefLoadHandler> ClientAppRenderer::GetLoadHandler() {
|
|
|
|
CefRefPtr<CefLoadHandler> load_handler;
|
|
|
|
DelegateSet::iterator it = delegates_.begin();
|
|
|
|
for (; it != delegates_.end() && !load_handler.get(); ++it)
|
|
|
|
load_handler = (*it)->GetLoadHandler(this);
|
|
|
|
|
|
|
|
return load_handler;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ClientAppRenderer::OnContextCreated(CefRefPtr<CefBrowser> browser,
|
|
|
|
CefRefPtr<CefFrame> frame,
|
|
|
|
CefRefPtr<CefV8Context> context) {
|
|
|
|
DelegateSet::iterator it = delegates_.begin();
|
|
|
|
for (; it != delegates_.end(); ++it)
|
|
|
|
(*it)->OnContextCreated(this, browser, frame, context);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ClientAppRenderer::OnContextReleased(CefRefPtr<CefBrowser> browser,
|
|
|
|
CefRefPtr<CefFrame> frame,
|
|
|
|
CefRefPtr<CefV8Context> context) {
|
|
|
|
DelegateSet::iterator it = delegates_.begin();
|
|
|
|
for (; it != delegates_.end(); ++it)
|
|
|
|
(*it)->OnContextReleased(this, browser, frame, context);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ClientAppRenderer::OnUncaughtException(
|
|
|
|
CefRefPtr<CefBrowser> browser,
|
|
|
|
CefRefPtr<CefFrame> frame,
|
|
|
|
CefRefPtr<CefV8Context> context,
|
|
|
|
CefRefPtr<CefV8Exception> exception,
|
|
|
|
CefRefPtr<CefV8StackTrace> stackTrace) {
|
|
|
|
DelegateSet::iterator it = delegates_.begin();
|
|
|
|
for (; it != delegates_.end(); ++it) {
|
|
|
|
(*it)->OnUncaughtException(this, browser, frame, context, exception,
|
|
|
|
stackTrace);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void ClientAppRenderer::OnFocusedNodeChanged(CefRefPtr<CefBrowser> browser,
|
|
|
|
CefRefPtr<CefFrame> frame,
|
|
|
|
CefRefPtr<CefDOMNode> node) {
|
|
|
|
DelegateSet::iterator it = delegates_.begin();
|
|
|
|
for (; it != delegates_.end(); ++it)
|
|
|
|
(*it)->OnFocusedNodeChanged(this, browser, frame, node);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool ClientAppRenderer::OnProcessMessageReceived(
|
|
|
|
CefRefPtr<CefBrowser> browser,
|
2019-05-24 22:23:43 +02:00
|
|
|
CefRefPtr<CefFrame> frame,
|
2015-01-31 05:41:36 +01:00
|
|
|
CefProcessId source_process,
|
|
|
|
CefRefPtr<CefProcessMessage> message) {
|
|
|
|
DCHECK_EQ(source_process, PID_BROWSER);
|
|
|
|
|
|
|
|
bool handled = false;
|
|
|
|
|
|
|
|
DelegateSet::iterator it = delegates_.begin();
|
|
|
|
for (; it != delegates_.end() && !handled; ++it) {
|
2019-05-24 22:23:43 +02:00
|
|
|
handled = (*it)->OnProcessMessageReceived(this, browser, frame,
|
|
|
|
source_process, message);
|
2015-01-31 05:41:36 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return handled;
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace client
|