mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-01-10 17:23:26 +01:00
6702fc573a
- Move include/cef_build.h to include/base/cef_build.h. - Move libcef_dll/cef_macros.h to include/base/cef_macros.h. - Move include/cef_trace_event.h to include/base/cef_trace_event.h and include/internal/cef_trace_event_internal.h. - Remove the "CEF_" prefix from TRACE macros. - Add new include/base/cef_logging.h and include/internal/cef_logging_internal.h for logging support. - Add new include/wrapper/cef_helpers.h for CEF_REQUIRE_*_THREAD macros and CefScopedArgArray. - Delete the util.h headers used by tests that duplicated the above functionality. git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@1767 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
161 lines
5.7 KiB
C++
161 lines
5.7 KiB
C++
// 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.
|
|
|
|
// This file is shared by cefclient and cef_unittests so don't include using
|
|
// a qualified path.
|
|
#include "client_app.h" // NOLINT(build/include)
|
|
|
|
#include <string>
|
|
|
|
#include "include/cef_cookie.h"
|
|
#include "include/cef_process_message.h"
|
|
#include "include/cef_task.h"
|
|
#include "include/cef_v8.h"
|
|
#include "include/wrapper/cef_helpers.h"
|
|
|
|
ClientApp::ClientApp() {
|
|
}
|
|
|
|
void ClientApp::OnRegisterCustomSchemes(
|
|
CefRefPtr<CefSchemeRegistrar> registrar) {
|
|
// Default schemes that support cookies.
|
|
cookieable_schemes_.push_back("http");
|
|
cookieable_schemes_.push_back("https");
|
|
|
|
RegisterCustomSchemes(registrar, cookieable_schemes_);
|
|
}
|
|
|
|
void ClientApp::OnContextInitialized() {
|
|
CreateBrowserDelegates(browser_delegates_);
|
|
|
|
// Register cookieable schemes with the global cookie manager.
|
|
CefRefPtr<CefCookieManager> manager = CefCookieManager::GetGlobalManager();
|
|
DCHECK(manager.get());
|
|
manager->SetSupportedSchemes(cookieable_schemes_);
|
|
|
|
print_handler_ = CreatePrintHandler();
|
|
|
|
BrowserDelegateSet::iterator it = browser_delegates_.begin();
|
|
for (; it != browser_delegates_.end(); ++it)
|
|
(*it)->OnContextInitialized(this);
|
|
}
|
|
|
|
void ClientApp::OnBeforeChildProcessLaunch(
|
|
CefRefPtr<CefCommandLine> command_line) {
|
|
BrowserDelegateSet::iterator it = browser_delegates_.begin();
|
|
for (; it != browser_delegates_.end(); ++it)
|
|
(*it)->OnBeforeChildProcessLaunch(this, command_line);
|
|
}
|
|
|
|
void ClientApp::OnRenderProcessThreadCreated(
|
|
CefRefPtr<CefListValue> extra_info) {
|
|
BrowserDelegateSet::iterator it = browser_delegates_.begin();
|
|
for (; it != browser_delegates_.end(); ++it)
|
|
(*it)->OnRenderProcessThreadCreated(this, extra_info);
|
|
}
|
|
|
|
void ClientApp::OnRenderThreadCreated(CefRefPtr<CefListValue> extra_info) {
|
|
CreateRenderDelegates(render_delegates_);
|
|
|
|
RenderDelegateSet::iterator it = render_delegates_.begin();
|
|
for (; it != render_delegates_.end(); ++it)
|
|
(*it)->OnRenderThreadCreated(this, extra_info);
|
|
}
|
|
|
|
void ClientApp::OnWebKitInitialized() {
|
|
RenderDelegateSet::iterator it = render_delegates_.begin();
|
|
for (; it != render_delegates_.end(); ++it)
|
|
(*it)->OnWebKitInitialized(this);
|
|
}
|
|
|
|
void ClientApp::OnBrowserCreated(CefRefPtr<CefBrowser> browser) {
|
|
RenderDelegateSet::iterator it = render_delegates_.begin();
|
|
for (; it != render_delegates_.end(); ++it)
|
|
(*it)->OnBrowserCreated(this, browser);
|
|
}
|
|
|
|
void ClientApp::OnBrowserDestroyed(CefRefPtr<CefBrowser> browser) {
|
|
RenderDelegateSet::iterator it = render_delegates_.begin();
|
|
for (; it != render_delegates_.end(); ++it)
|
|
(*it)->OnBrowserDestroyed(this, browser);
|
|
}
|
|
|
|
CefRefPtr<CefLoadHandler> ClientApp::GetLoadHandler() {
|
|
CefRefPtr<CefLoadHandler> load_handler;
|
|
RenderDelegateSet::iterator it = render_delegates_.begin();
|
|
for (; it != render_delegates_.end() && !load_handler.get(); ++it)
|
|
load_handler = (*it)->GetLoadHandler(this);
|
|
|
|
return load_handler;
|
|
}
|
|
|
|
bool ClientApp::OnBeforeNavigation(CefRefPtr<CefBrowser> browser,
|
|
CefRefPtr<CefFrame> frame,
|
|
CefRefPtr<CefRequest> request,
|
|
NavigationType navigation_type,
|
|
bool is_redirect) {
|
|
RenderDelegateSet::iterator it = render_delegates_.begin();
|
|
for (; it != render_delegates_.end(); ++it) {
|
|
if ((*it)->OnBeforeNavigation(this, browser, frame, request,
|
|
navigation_type, is_redirect)) {
|
|
return true;
|
|
}
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
void ClientApp::OnContextCreated(CefRefPtr<CefBrowser> browser,
|
|
CefRefPtr<CefFrame> frame,
|
|
CefRefPtr<CefV8Context> context) {
|
|
RenderDelegateSet::iterator it = render_delegates_.begin();
|
|
for (; it != render_delegates_.end(); ++it)
|
|
(*it)->OnContextCreated(this, browser, frame, context);
|
|
}
|
|
|
|
void ClientApp::OnContextReleased(CefRefPtr<CefBrowser> browser,
|
|
CefRefPtr<CefFrame> frame,
|
|
CefRefPtr<CefV8Context> context) {
|
|
RenderDelegateSet::iterator it = render_delegates_.begin();
|
|
for (; it != render_delegates_.end(); ++it)
|
|
(*it)->OnContextReleased(this, browser, frame, context);
|
|
}
|
|
|
|
void ClientApp::OnUncaughtException(CefRefPtr<CefBrowser> browser,
|
|
CefRefPtr<CefFrame> frame,
|
|
CefRefPtr<CefV8Context> context,
|
|
CefRefPtr<CefV8Exception> exception,
|
|
CefRefPtr<CefV8StackTrace> stackTrace) {
|
|
RenderDelegateSet::iterator it = render_delegates_.begin();
|
|
for (; it != render_delegates_.end(); ++it) {
|
|
(*it)->OnUncaughtException(this, browser, frame, context, exception,
|
|
stackTrace);
|
|
}
|
|
}
|
|
|
|
void ClientApp::OnFocusedNodeChanged(CefRefPtr<CefBrowser> browser,
|
|
CefRefPtr<CefFrame> frame,
|
|
CefRefPtr<CefDOMNode> node) {
|
|
RenderDelegateSet::iterator it = render_delegates_.begin();
|
|
for (; it != render_delegates_.end(); ++it)
|
|
(*it)->OnFocusedNodeChanged(this, browser, frame, node);
|
|
}
|
|
|
|
bool ClientApp::OnProcessMessageReceived(
|
|
CefRefPtr<CefBrowser> browser,
|
|
CefProcessId source_process,
|
|
CefRefPtr<CefProcessMessage> message) {
|
|
DCHECK_EQ(source_process, PID_BROWSER);
|
|
|
|
bool handled = false;
|
|
|
|
RenderDelegateSet::iterator it = render_delegates_.begin();
|
|
for (; it != render_delegates_.end() && !handled; ++it) {
|
|
handled = (*it)->OnProcessMessageReceived(this, browser, source_process,
|
|
message);
|
|
}
|
|
|
|
return handled;
|
|
}
|