mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-06-05 21:39:12 +02:00
cefclient: Split ClientApp into process-specific types (issue #1500).
git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@2015 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
This commit is contained in:
19
cef.gyp
19
cef.gyp
@ -396,11 +396,17 @@
|
||||
'libcef_dll_wrapper',
|
||||
],
|
||||
'sources': [
|
||||
'tests/cefclient/browser/client_app_browser.cc',
|
||||
'tests/cefclient/browser/client_app_browser.h',
|
||||
'tests/cefclient/browser/resource_util.h',
|
||||
'tests/cefclient/common/client_app.cc',
|
||||
'tests/cefclient/common/client_app.h',
|
||||
'tests/cefclient/common/client_app_other.cc',
|
||||
'tests/cefclient/common/client_app_other.h',
|
||||
'tests/cefclient/common/client_switches.cc',
|
||||
'tests/cefclient/common/client_switches.h',
|
||||
'tests/cefclient/renderer/client_app_renderer.cc',
|
||||
'tests/cefclient/renderer/client_app_renderer.h',
|
||||
'tests/cefclient/resources/osr_test.html',
|
||||
'tests/unittests/browser_info_map_unittest.cc',
|
||||
'tests/unittests/command_line_unittest.cc',
|
||||
@ -466,9 +472,8 @@
|
||||
},
|
||||
'include_dirs': [
|
||||
'.',
|
||||
# Necessary to allow resouce_util_* implementation files in cefclient to
|
||||
# include 'cefclient/*' files, without the tests/ fragment
|
||||
'./tests'
|
||||
# Necessary to allow unittest files to access cefclient files.
|
||||
'tests',
|
||||
],
|
||||
'conditions': [
|
||||
[ 'OS=="win"', {
|
||||
@ -1532,12 +1537,20 @@
|
||||
],
|
||||
'include_dirs': [
|
||||
'.',
|
||||
# Necessary to allow unittest files to access cefclient files.
|
||||
'tests',
|
||||
],
|
||||
'sources': [
|
||||
'tests/cefclient/browser/client_app_browser.cc',
|
||||
'tests/cefclient/browser/client_app_browser.h',
|
||||
'tests/cefclient/common/client_app.cc',
|
||||
'tests/cefclient/common/client_app.h',
|
||||
'tests/cefclient/common/client_app_other.cc',
|
||||
'tests/cefclient/common/client_app_other.h',
|
||||
'tests/cefclient/common/client_switches.cc',
|
||||
'tests/cefclient/common/client_switches.h',
|
||||
'tests/cefclient/renderer/client_app_renderer.cc',
|
||||
'tests/cefclient/renderer/client_app_renderer.h',
|
||||
'tests/cefclient/renderer/process_helper_mac.cc',
|
||||
'tests/unittests/client_app_delegates.cc',
|
||||
'tests/unittests/cookie_unittest.cc',
|
||||
|
@ -140,6 +140,8 @@
|
||||
'tests/cefclient/browser/browser_window.h',
|
||||
'tests/cefclient/browser/bytes_write_handler.cc',
|
||||
'tests/cefclient/browser/bytes_write_handler.h',
|
||||
'tests/cefclient/browser/client_app_browser.cc',
|
||||
'tests/cefclient/browser/client_app_browser.h',
|
||||
'tests/cefclient/browser/client_app_delegates_browser.cc',
|
||||
'tests/cefclient/browser/client_handler.cc',
|
||||
'tests/cefclient/browser/client_handler.h',
|
||||
@ -179,6 +181,8 @@
|
||||
'tests/cefclient/common/client_app.cc',
|
||||
'tests/cefclient/common/client_app.h',
|
||||
'tests/cefclient/common/client_app_delegates_common.cc',
|
||||
'tests/cefclient/common/client_app_other.cc',
|
||||
'tests/cefclient/common/client_app_other.h',
|
||||
'tests/cefclient/common/client_switches.cc',
|
||||
'tests/cefclient/common/client_switches.h',
|
||||
'tests/cefclient/common/scheme_test_common.cc',
|
||||
@ -186,6 +190,8 @@
|
||||
],
|
||||
'cefclient_sources_renderer': [
|
||||
'tests/cefclient/renderer/client_app_delegates_renderer.cc',
|
||||
'tests/cefclient/renderer/client_app_renderer.cc',
|
||||
'tests/cefclient/renderer/client_app_renderer.h',
|
||||
'tests/cefclient/renderer/client_renderer.cc',
|
||||
'tests/cefclient/renderer/client_renderer.h',
|
||||
'tests/cefclient/renderer/performance_test.cc',
|
||||
@ -254,7 +260,6 @@
|
||||
'<@(cefclient_sources_common)',
|
||||
],
|
||||
'cefclient_sources_mac_helper': [
|
||||
'tests/cefclient/renderer/client_app_delegates_stubs_mac.cc',
|
||||
'tests/cefclient/renderer/process_helper_mac.cc',
|
||||
'<@(cefclient_sources_common)',
|
||||
'<@(cefclient_sources_renderer)',
|
||||
|
@ -16,11 +16,14 @@
|
||||
#include "include/base/cef_logging.h"
|
||||
#include "include/base/cef_scoped_ptr.h"
|
||||
#include "include/cef_app.h"
|
||||
#include "include/cef_command_line.h"
|
||||
#include "include/wrapper/cef_helpers.h"
|
||||
#include "cefclient/browser/client_app_browser.h"
|
||||
#include "cefclient/browser/main_context_impl.h"
|
||||
#include "cefclient/browser/main_message_loop_std.h"
|
||||
#include "cefclient/browser/test_runner.h"
|
||||
#include "cefclient/common/client_app.h"
|
||||
#include "cefclient/common/client_app_other.h"
|
||||
#include "cefclient/renderer/client_app_renderer.h"
|
||||
|
||||
namespace client {
|
||||
namespace {
|
||||
@ -52,15 +55,33 @@ int RunMain(int argc, char* argv[]) {
|
||||
char** argv_copy = scoped_arg_array.array();
|
||||
|
||||
CefMainArgs main_args(argc, argv);
|
||||
CefRefPtr<ClientApp> app(new ClientApp);
|
||||
|
||||
// Parse command-line arguments.
|
||||
CefRefPtr<CefCommandLine> command_line = CefCommandLine::CreateCommandLine();
|
||||
command_line->InitFromArgv(argc, argv);
|
||||
|
||||
// Create a ClientApp of the correct type.
|
||||
CefRefPtr<CefApp> app;
|
||||
ClientApp::ProcessType process_type = ClientApp::GetProcessType(command_line);
|
||||
if (process_type == ClientApp::BrowserProcess) {
|
||||
app = new ClientAppBrowser();
|
||||
} else if (process_type == ClientApp::RendererProcess ||
|
||||
process_type == ClientApp::ZygoteProcess) {
|
||||
// On Linux the zygote process is used to spawn other process types. Since
|
||||
// we don't know what type of process it will be give it the renderer
|
||||
// client.
|
||||
app = new ClientAppRenderer();
|
||||
} else if (process_type == ClientApp::OtherProcess) {
|
||||
app = new ClientAppOther();
|
||||
}
|
||||
|
||||
// Execute the secondary process, if any.
|
||||
int exit_code = CefExecuteProcess(main_args, app.get(), NULL);
|
||||
int exit_code = CefExecuteProcess(main_args, app, NULL);
|
||||
if (exit_code >= 0)
|
||||
return exit_code;
|
||||
|
||||
// Create the main context object.
|
||||
scoped_ptr<MainContextImpl> context(new MainContextImpl(argc, argv, true));
|
||||
scoped_ptr<MainContextImpl> context(new MainContextImpl(command_line, true));
|
||||
|
||||
CefSettings settings;
|
||||
|
||||
@ -76,7 +97,7 @@ int RunMain(int argc, char* argv[]) {
|
||||
scoped_ptr<MainMessageLoop> message_loop(new MainMessageLoopStd);
|
||||
|
||||
// Initialize CEF.
|
||||
context->Initialize(main_args, settings, app.get(), NULL);
|
||||
context->Initialize(main_args, settings, app, NULL);
|
||||
|
||||
// The Chromium sandbox requires that there only be a single thread during
|
||||
// initialization. Therefore initialize GTK after CEF.
|
||||
|
@ -6,12 +6,12 @@
|
||||
#import <Cocoa/Cocoa.h>
|
||||
#include "include/cef_app.h"
|
||||
#import "include/cef_application_mac.h"
|
||||
#include "cefclient/browser/client_app_browser.h"
|
||||
#include "cefclient/browser/main_context_impl.h"
|
||||
#include "cefclient/browser/main_message_loop_std.h"
|
||||
#include "cefclient/browser/resource.h"
|
||||
#include "cefclient/browser/root_window.h"
|
||||
#include "cefclient/browser/test_runner.h"
|
||||
#include "cefclient/common/client_app.h"
|
||||
|
||||
namespace {
|
||||
|
||||
@ -177,20 +177,10 @@ void AddMenuItem(NSMenu *menu, NSString* label, int idval) {
|
||||
@end
|
||||
|
||||
namespace client {
|
||||
|
||||
// Stub implementations of ClientApp methods that are only used in the renderer
|
||||
// process.
|
||||
|
||||
// static
|
||||
void ClientApp::CreateRenderDelegates(RenderDelegateSet& delegates) {
|
||||
}
|
||||
|
||||
|
||||
namespace {
|
||||
|
||||
int RunMain(int argc, char* argv[]) {
|
||||
CefMainArgs main_args(argc, argv);
|
||||
CefRefPtr<ClientApp> app(new ClientApp);
|
||||
|
||||
// Initialize the AutoRelease pool.
|
||||
NSAutoreleasePool* autopool = [[NSAutoreleasePool alloc] init];
|
||||
@ -198,8 +188,18 @@ int RunMain(int argc, char* argv[]) {
|
||||
// Initialize the ClientApplication instance.
|
||||
[ClientApplication sharedApplication];
|
||||
|
||||
// Parse command-line arguments.
|
||||
CefRefPtr<CefCommandLine> command_line = CefCommandLine::CreateCommandLine();
|
||||
command_line->InitFromArgv(argc, argv);
|
||||
|
||||
// Create a ClientApp of the correct type.
|
||||
CefRefPtr<CefApp> app;
|
||||
ClientApp::ProcessType process_type = ClientApp::GetProcessType(command_line);
|
||||
if (process_type == ClientApp::BrowserProcess)
|
||||
app = new ClientAppBrowser();
|
||||
|
||||
// Create the main context object.
|
||||
scoped_ptr<MainContextImpl> context(new MainContextImpl(argc, argv, true));
|
||||
scoped_ptr<MainContextImpl> context(new MainContextImpl(command_line, true));
|
||||
|
||||
CefSettings settings;
|
||||
|
||||
@ -210,7 +210,7 @@ int RunMain(int argc, char* argv[]) {
|
||||
scoped_ptr<MainMessageLoop> message_loop(new MainMessageLoopStd);
|
||||
|
||||
// Initialize CEF.
|
||||
context->Initialize(main_args, settings, app.get(), NULL);
|
||||
context->Initialize(main_args, settings, app, NULL);
|
||||
|
||||
// Register scheme handlers.
|
||||
test_runner::RegisterSchemeHandlers();
|
||||
|
@ -5,13 +5,16 @@
|
||||
#include <windows.h>
|
||||
|
||||
#include "include/base/cef_scoped_ptr.h"
|
||||
#include "include/cef_command_line.h"
|
||||
#include "include/cef_sandbox_win.h"
|
||||
#include "cefclient/browser/client_app_browser.h"
|
||||
#include "cefclient/browser/main_context_impl.h"
|
||||
#include "cefclient/browser/main_message_loop_multithreaded_win.h"
|
||||
#include "cefclient/browser/main_message_loop_std.h"
|
||||
#include "cefclient/browser/root_window_manager.h"
|
||||
#include "cefclient/browser/test_runner.h"
|
||||
#include "cefclient/common/client_app.h"
|
||||
#include "cefclient/common/client_app_other.h"
|
||||
#include "cefclient/renderer/client_app_renderer.h"
|
||||
|
||||
// When generating projects with CMake the CEF_USE_SANDBOX value will be defined
|
||||
// automatically if using the required compiler version. Pass -DUSE_SANDBOX=OFF
|
||||
@ -29,6 +32,8 @@ namespace client {
|
||||
namespace {
|
||||
|
||||
int RunMain(HINSTANCE hInstance, int nCmdShow) {
|
||||
CefMainArgs main_args(hInstance);
|
||||
|
||||
void* sandbox_info = NULL;
|
||||
|
||||
#if defined(CEF_USE_SANDBOX)
|
||||
@ -38,16 +43,27 @@ int RunMain(HINSTANCE hInstance, int nCmdShow) {
|
||||
sandbox_info = scoped_sandbox.sandbox_info();
|
||||
#endif
|
||||
|
||||
CefMainArgs main_args(hInstance);
|
||||
CefRefPtr<ClientApp> app(new ClientApp);
|
||||
// Parse command-line arguments.
|
||||
CefRefPtr<CefCommandLine> command_line = CefCommandLine::CreateCommandLine();
|
||||
command_line->InitFromString(::GetCommandLineW());
|
||||
|
||||
// Create a ClientApp of the correct type.
|
||||
CefRefPtr<CefApp> app;
|
||||
ClientApp::ProcessType process_type = ClientApp::GetProcessType(command_line);
|
||||
if (process_type == ClientApp::BrowserProcess)
|
||||
app = new ClientAppBrowser();
|
||||
else if (process_type == ClientApp::RendererProcess)
|
||||
app = new ClientAppRenderer();
|
||||
else if (process_type == ClientApp::OtherProcess)
|
||||
app = new ClientAppOther();
|
||||
|
||||
// Execute the secondary process, if any.
|
||||
int exit_code = CefExecuteProcess(main_args, app.get(), sandbox_info);
|
||||
int exit_code = CefExecuteProcess(main_args, app, sandbox_info);
|
||||
if (exit_code >= 0)
|
||||
return exit_code;
|
||||
|
||||
// Create the main context object.
|
||||
scoped_ptr<MainContextImpl> context(new MainContextImpl(0, NULL, true));
|
||||
scoped_ptr<MainContextImpl> context(new MainContextImpl(command_line, true));
|
||||
|
||||
CefSettings settings;
|
||||
|
||||
@ -66,7 +82,7 @@ int RunMain(HINSTANCE hInstance, int nCmdShow) {
|
||||
message_loop.reset(new MainMessageLoopStd);
|
||||
|
||||
// Initialize CEF.
|
||||
context->Initialize(main_args, settings, app.get(), sandbox_info);
|
||||
context->Initialize(main_args, settings, app, sandbox_info);
|
||||
|
||||
// Register scheme handlers.
|
||||
test_runner::RegisterSchemeHandlers();
|
||||
|
43
tests/cefclient/browser/client_app_browser.cc
Normal file
43
tests/cefclient/browser/client_app_browser.cc
Normal file
@ -0,0 +1,43 @@
|
||||
// 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.
|
||||
|
||||
#include "cefclient/browser/client_app_browser.h"
|
||||
|
||||
#include "include/cef_cookie.h"
|
||||
|
||||
namespace client {
|
||||
|
||||
ClientAppBrowser::ClientAppBrowser() {
|
||||
}
|
||||
|
||||
void ClientAppBrowser::OnContextInitialized() {
|
||||
CreateDelegates(delegates_);
|
||||
|
||||
// Register cookieable schemes with the global cookie manager.
|
||||
CefRefPtr<CefCookieManager> manager = CefCookieManager::GetGlobalManager();
|
||||
DCHECK(manager.get());
|
||||
manager->SetSupportedSchemes(cookieable_schemes_);
|
||||
|
||||
print_handler_ = CreatePrintHandler();
|
||||
|
||||
DelegateSet::iterator it = delegates_.begin();
|
||||
for (; it != delegates_.end(); ++it)
|
||||
(*it)->OnContextInitialized(this);
|
||||
}
|
||||
|
||||
void ClientAppBrowser::OnBeforeChildProcessLaunch(
|
||||
CefRefPtr<CefCommandLine> command_line) {
|
||||
DelegateSet::iterator it = delegates_.begin();
|
||||
for (; it != delegates_.end(); ++it)
|
||||
(*it)->OnBeforeChildProcessLaunch(this, command_line);
|
||||
}
|
||||
|
||||
void ClientAppBrowser::OnRenderProcessThreadCreated(
|
||||
CefRefPtr<CefListValue> extra_info) {
|
||||
DelegateSet::iterator it = delegates_.begin();
|
||||
for (; it != delegates_.end(); ++it)
|
||||
(*it)->OnRenderProcessThreadCreated(this, extra_info);
|
||||
}
|
||||
|
||||
} // namespace client
|
73
tests/cefclient/browser/client_app_browser.h
Normal file
73
tests/cefclient/browser/client_app_browser.h
Normal file
@ -0,0 +1,73 @@
|
||||
// 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.
|
||||
|
||||
#ifndef CEF_TESTS_CEFCLIENT_BROWSER_CLIENT_APP_BROWSER_H_
|
||||
#define CEF_TESTS_CEFCLIENT_BROWSER_CLIENT_APP_BROWSER_H_
|
||||
#pragma once
|
||||
|
||||
#include <set>
|
||||
|
||||
#include "cefclient/common/client_app.h"
|
||||
|
||||
namespace client {
|
||||
|
||||
// Client app implementation for the browser process.
|
||||
class ClientAppBrowser : public ClientApp,
|
||||
public CefBrowserProcessHandler {
|
||||
public:
|
||||
// Interface for browser delegates. All Delegates must be returned via
|
||||
// CreateDelegates. Do not perform work in the Delegate
|
||||
// constructor. See CefBrowserProcessHandler for documentation.
|
||||
class Delegate : public virtual CefBase {
|
||||
public:
|
||||
virtual void OnContextInitialized(CefRefPtr<ClientApp> app) {}
|
||||
|
||||
virtual void OnBeforeChildProcessLaunch(
|
||||
CefRefPtr<ClientAppBrowser> app,
|
||||
CefRefPtr<CefCommandLine> command_line) {}
|
||||
|
||||
virtual void OnRenderProcessThreadCreated(
|
||||
CefRefPtr<ClientAppBrowser> app,
|
||||
CefRefPtr<CefListValue> extra_info) {}
|
||||
};
|
||||
|
||||
typedef std::set<CefRefPtr<Delegate> > DelegateSet;
|
||||
|
||||
ClientAppBrowser();
|
||||
|
||||
private:
|
||||
// Creates all of the Delegate objects. Implemented in
|
||||
// client_app_delegates.
|
||||
static void CreateDelegates(DelegateSet& delegates);
|
||||
|
||||
// Create the Linux print handler. Implemented in client_app_delegates.
|
||||
static CefRefPtr<CefPrintHandler> CreatePrintHandler();
|
||||
|
||||
// CefApp methods.
|
||||
CefRefPtr<CefBrowserProcessHandler> GetBrowserProcessHandler() OVERRIDE {
|
||||
return this;
|
||||
}
|
||||
|
||||
// CefBrowserProcessHandler methods.
|
||||
void OnContextInitialized() OVERRIDE;
|
||||
void OnBeforeChildProcessLaunch(
|
||||
CefRefPtr<CefCommandLine> command_line) OVERRIDE;
|
||||
void OnRenderProcessThreadCreated(
|
||||
CefRefPtr<CefListValue> extra_info) OVERRIDE;
|
||||
CefRefPtr<CefPrintHandler> GetPrintHandler() OVERRIDE {
|
||||
return print_handler_;
|
||||
}
|
||||
|
||||
// Set of supported Delegates.
|
||||
DelegateSet delegates_;
|
||||
|
||||
CefRefPtr<CefPrintHandler> print_handler_;
|
||||
|
||||
IMPLEMENT_REFCOUNTING(ClientAppBrowser);
|
||||
DISALLOW_COPY_AND_ASSIGN(ClientAppBrowser);
|
||||
};
|
||||
|
||||
} // namespace client
|
||||
|
||||
#endif // CEF_TESTS_CEFCLIENT_BROWSER_CLIENT_APP_BROWSER_H_
|
@ -2,7 +2,7 @@
|
||||
// reserved. Use of this source code is governed by a BSD-style license that
|
||||
// can be found in the LICENSE file.
|
||||
|
||||
#include "cefclient/common/client_app.h"
|
||||
#include "cefclient/browser/client_app_browser.h"
|
||||
|
||||
#if defined(OS_LINUX)
|
||||
#include "cefclient/browser/print_handler_gtk.h"
|
||||
@ -11,11 +11,11 @@
|
||||
namespace client {
|
||||
|
||||
// static
|
||||
void ClientApp::CreateBrowserDelegates(BrowserDelegateSet& delegates) {
|
||||
void ClientAppBrowser::CreateDelegates(DelegateSet& delegates) {
|
||||
}
|
||||
|
||||
// static
|
||||
CefRefPtr<CefPrintHandler> ClientApp::CreatePrintHandler() {
|
||||
CefRefPtr<CefPrintHandler> ClientAppBrowser::CreatePrintHandler() {
|
||||
#if defined(OS_LINUX)
|
||||
return new ClientPrintHandlerGtk();
|
||||
#else
|
||||
|
@ -15,19 +15,13 @@ const char kDefaultUrl[] = "http://www.google.com";
|
||||
|
||||
} // namespace
|
||||
|
||||
MainContextImpl::MainContextImpl(int argc,
|
||||
const char* const* argv,
|
||||
MainContextImpl::MainContextImpl(CefRefPtr<CefCommandLine> command_line,
|
||||
bool terminate_when_all_windows_closed)
|
||||
: terminate_when_all_windows_closed_(terminate_when_all_windows_closed),
|
||||
: command_line_(command_line),
|
||||
terminate_when_all_windows_closed_(terminate_when_all_windows_closed),
|
||||
initialized_(false),
|
||||
shutdown_(false) {
|
||||
// Parse the command line.
|
||||
command_line_ = CefCommandLine::CreateCommandLine();
|
||||
#if defined(OS_WIN)
|
||||
command_line_->InitFromString(::GetCommandLineW());
|
||||
#else
|
||||
command_line_->InitFromArgv(argc, argv);
|
||||
#endif
|
||||
DCHECK(command_line_.get());
|
||||
|
||||
// Set the main URL.
|
||||
if (command_line_->HasSwitch(switches::kUrl))
|
||||
|
@ -18,8 +18,7 @@ namespace client {
|
||||
// Used to store global context in the browser process.
|
||||
class MainContextImpl : public MainContext {
|
||||
public:
|
||||
MainContextImpl(int argc,
|
||||
const char* const* argv,
|
||||
MainContextImpl(CefRefPtr<CefCommandLine> command_line,
|
||||
bool terminate_when_all_windows_closed);
|
||||
|
||||
// MainContext members.
|
||||
@ -54,6 +53,7 @@ class MainContextImpl : public MainContext {
|
||||
return initialized_ && !shutdown_;
|
||||
}
|
||||
|
||||
CefRefPtr<CefCommandLine> command_line_;
|
||||
const bool terminate_when_all_windows_closed_;
|
||||
|
||||
// Track context state. Accessing these variables from multiple threads is
|
||||
@ -62,7 +62,6 @@ class MainContextImpl : public MainContext {
|
||||
bool initialized_;
|
||||
bool shutdown_;
|
||||
|
||||
CefRefPtr<CefCommandLine> command_line_;
|
||||
std::string main_url_;
|
||||
|
||||
scoped_ptr<RootWindowManager> root_window_manager_;
|
||||
|
@ -2,23 +2,45 @@
|
||||
// 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 "cefclient/common/client_app.h"
|
||||
|
||||
#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"
|
||||
#include "include/cef_command_line.h"
|
||||
|
||||
namespace client {
|
||||
|
||||
namespace {
|
||||
|
||||
// These flags must match the Chromium values.
|
||||
const char kProcessType[] = "type";
|
||||
const char kRendererProcess[] = "renderer";
|
||||
#if defined(OS_LINUX)
|
||||
const char kZygoteProcess[] = "zygote";
|
||||
#endif
|
||||
|
||||
} // namespace
|
||||
|
||||
|
||||
ClientApp::ClientApp() {
|
||||
}
|
||||
|
||||
// static
|
||||
ClientApp::ProcessType ClientApp::GetProcessType(
|
||||
CefRefPtr<CefCommandLine> command_line) {
|
||||
// The command-line flag won't be specified for the browser process.
|
||||
if (!command_line->HasSwitch(kProcessType))
|
||||
return BrowserProcess;
|
||||
|
||||
const std::string& process_type = command_line->GetSwitchValue(kProcessType);
|
||||
if (process_type == kRendererProcess)
|
||||
return RendererProcess;
|
||||
#if defined(OS_LINUX)
|
||||
else if (process_type == kZygoteProcess)
|
||||
return ZygoteProcess;
|
||||
#endif
|
||||
|
||||
return OtherProcess;
|
||||
}
|
||||
|
||||
void ClientApp::OnRegisterCustomSchemes(
|
||||
CefRefPtr<CefSchemeRegistrar> registrar) {
|
||||
// Default schemes that support cookies.
|
||||
@ -28,137 +50,4 @@ void ClientApp::OnRegisterCustomSchemes(
|
||||
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;
|
||||
}
|
||||
|
||||
} // namespace client
|
||||
|
@ -6,184 +6,41 @@
|
||||
#define CEF_TESTS_CEFCLIENT_COMMON_CLIENT_APP_H_
|
||||
#pragma once
|
||||
|
||||
#include <map>
|
||||
#include <set>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include "include/cef_app.h"
|
||||
|
||||
namespace client {
|
||||
|
||||
class ClientApp : public CefApp,
|
||||
public CefBrowserProcessHandler,
|
||||
public CefRenderProcessHandler {
|
||||
// Base class for customizing process-type-based behavior.
|
||||
class ClientApp : public CefApp {
|
||||
public:
|
||||
// Interface for browser delegates. All BrowserDelegates must be returned via
|
||||
// CreateBrowserDelegates. Do not perform work in the BrowserDelegate
|
||||
// constructor. See CefBrowserProcessHandler for documentation.
|
||||
class BrowserDelegate : public virtual CefBase {
|
||||
public:
|
||||
virtual void OnContextInitialized(CefRefPtr<ClientApp> app) {}
|
||||
|
||||
virtual void OnBeforeChildProcessLaunch(
|
||||
CefRefPtr<ClientApp> app,
|
||||
CefRefPtr<CefCommandLine> command_line) {}
|
||||
|
||||
virtual void OnRenderProcessThreadCreated(
|
||||
CefRefPtr<ClientApp> app,
|
||||
CefRefPtr<CefListValue> extra_info) {}
|
||||
};
|
||||
|
||||
typedef std::set<CefRefPtr<BrowserDelegate> > BrowserDelegateSet;
|
||||
|
||||
// Interface for renderer delegates. All RenderDelegates must be returned via
|
||||
// CreateRenderDelegates. Do not perform work in the RenderDelegate
|
||||
// constructor. See CefRenderProcessHandler for documentation.
|
||||
class RenderDelegate : public virtual CefBase {
|
||||
public:
|
||||
virtual void OnRenderThreadCreated(CefRefPtr<ClientApp> app,
|
||||
CefRefPtr<CefListValue> extra_info) {}
|
||||
|
||||
virtual void OnWebKitInitialized(CefRefPtr<ClientApp> app) {}
|
||||
|
||||
virtual void OnBrowserCreated(CefRefPtr<ClientApp> app,
|
||||
CefRefPtr<CefBrowser> browser) {}
|
||||
|
||||
virtual void OnBrowserDestroyed(CefRefPtr<ClientApp> app,
|
||||
CefRefPtr<CefBrowser> browser) {}
|
||||
|
||||
virtual CefRefPtr<CefLoadHandler> GetLoadHandler(CefRefPtr<ClientApp> app) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
virtual bool OnBeforeNavigation(CefRefPtr<ClientApp> app,
|
||||
CefRefPtr<CefBrowser> browser,
|
||||
CefRefPtr<CefFrame> frame,
|
||||
CefRefPtr<CefRequest> request,
|
||||
cef_navigation_type_t navigation_type,
|
||||
bool is_redirect) {
|
||||
return false;
|
||||
}
|
||||
|
||||
virtual void OnContextCreated(CefRefPtr<ClientApp> app,
|
||||
CefRefPtr<CefBrowser> browser,
|
||||
CefRefPtr<CefFrame> frame,
|
||||
CefRefPtr<CefV8Context> context) {}
|
||||
|
||||
virtual void OnContextReleased(CefRefPtr<ClientApp> app,
|
||||
CefRefPtr<CefBrowser> browser,
|
||||
CefRefPtr<CefFrame> frame,
|
||||
CefRefPtr<CefV8Context> context) {}
|
||||
|
||||
virtual void OnUncaughtException(CefRefPtr<ClientApp> app,
|
||||
CefRefPtr<CefBrowser> browser,
|
||||
CefRefPtr<CefFrame> frame,
|
||||
CefRefPtr<CefV8Context> context,
|
||||
CefRefPtr<CefV8Exception> exception,
|
||||
CefRefPtr<CefV8StackTrace> stackTrace) {}
|
||||
|
||||
virtual void OnFocusedNodeChanged(CefRefPtr<ClientApp> app,
|
||||
CefRefPtr<CefBrowser> browser,
|
||||
CefRefPtr<CefFrame> frame,
|
||||
CefRefPtr<CefDOMNode> node) {}
|
||||
|
||||
// Called when a process message is received. Return true if the message was
|
||||
// handled and should not be passed on to other handlers. RenderDelegates
|
||||
// should check for unique message names to avoid interfering with each
|
||||
// other.
|
||||
virtual bool OnProcessMessageReceived(
|
||||
CefRefPtr<ClientApp> app,
|
||||
CefRefPtr<CefBrowser> browser,
|
||||
CefProcessId source_process,
|
||||
CefRefPtr<CefProcessMessage> message) {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
typedef std::set<CefRefPtr<RenderDelegate> > RenderDelegateSet;
|
||||
|
||||
ClientApp();
|
||||
|
||||
enum ProcessType {
|
||||
BrowserProcess,
|
||||
RendererProcess,
|
||||
ZygoteProcess,
|
||||
OtherProcess,
|
||||
};
|
||||
|
||||
// Determine the process type based on command-line arguments.
|
||||
static ProcessType GetProcessType(CefRefPtr<CefCommandLine> command_line);
|
||||
|
||||
protected:
|
||||
// Schemes that will be registered with the global cookie manager.
|
||||
std::vector<CefString> cookieable_schemes_;
|
||||
|
||||
private:
|
||||
// Creates all of the BrowserDelegate objects. Implemented in
|
||||
// client_app_delegates.
|
||||
static void CreateBrowserDelegates(BrowserDelegateSet& delegates);
|
||||
|
||||
// Creates all of the RenderDelegate objects. Implemented in
|
||||
// client_app_delegates.
|
||||
static void CreateRenderDelegates(RenderDelegateSet& delegates);
|
||||
|
||||
// Registers custom schemes. Implemented in client_app_delegates.
|
||||
static void RegisterCustomSchemes(CefRefPtr<CefSchemeRegistrar> registrar,
|
||||
std::vector<CefString>& cookiable_schemes);
|
||||
|
||||
// Create the Linux print handler. Implemented in client_app_delegates.
|
||||
static CefRefPtr<CefPrintHandler> CreatePrintHandler();
|
||||
|
||||
// CefApp methods.
|
||||
void OnRegisterCustomSchemes(
|
||||
CefRefPtr<CefSchemeRegistrar> registrar) OVERRIDE;
|
||||
CefRefPtr<CefBrowserProcessHandler> GetBrowserProcessHandler() OVERRIDE {
|
||||
return this;
|
||||
}
|
||||
CefRefPtr<CefRenderProcessHandler> GetRenderProcessHandler() OVERRIDE {
|
||||
return this;
|
||||
}
|
||||
|
||||
// CefBrowserProcessHandler methods.
|
||||
void OnContextInitialized() OVERRIDE;
|
||||
void OnBeforeChildProcessLaunch(
|
||||
CefRefPtr<CefCommandLine> command_line) OVERRIDE;
|
||||
void OnRenderProcessThreadCreated(
|
||||
CefRefPtr<CefListValue> extra_info) OVERRIDE;
|
||||
CefRefPtr<CefPrintHandler> GetPrintHandler() OVERRIDE {
|
||||
return print_handler_;
|
||||
}
|
||||
|
||||
// CefRenderProcessHandler methods.
|
||||
void OnRenderThreadCreated(CefRefPtr<CefListValue> extra_info) OVERRIDE;
|
||||
void OnWebKitInitialized() OVERRIDE;
|
||||
void OnBrowserCreated(CefRefPtr<CefBrowser> browser) OVERRIDE;
|
||||
void OnBrowserDestroyed(CefRefPtr<CefBrowser> browser) OVERRIDE;
|
||||
CefRefPtr<CefLoadHandler> GetLoadHandler() OVERRIDE;
|
||||
bool OnBeforeNavigation(CefRefPtr<CefBrowser> browser,
|
||||
CefRefPtr<CefFrame> frame,
|
||||
CefRefPtr<CefRequest> request,
|
||||
NavigationType navigation_type,
|
||||
bool is_redirect) OVERRIDE;
|
||||
void OnContextCreated(CefRefPtr<CefBrowser> browser,
|
||||
CefRefPtr<CefFrame> frame,
|
||||
CefRefPtr<CefV8Context> context) OVERRIDE;
|
||||
void OnContextReleased(CefRefPtr<CefBrowser> browser,
|
||||
CefRefPtr<CefFrame> frame,
|
||||
CefRefPtr<CefV8Context> context) OVERRIDE;
|
||||
void OnUncaughtException(CefRefPtr<CefBrowser> browser,
|
||||
CefRefPtr<CefFrame> frame,
|
||||
CefRefPtr<CefV8Context> context,
|
||||
CefRefPtr<CefV8Exception> exception,
|
||||
CefRefPtr<CefV8StackTrace> stackTrace) OVERRIDE;
|
||||
void OnFocusedNodeChanged(CefRefPtr<CefBrowser> browser,
|
||||
CefRefPtr<CefFrame> frame,
|
||||
CefRefPtr<CefDOMNode> node) OVERRIDE;
|
||||
bool OnProcessMessageReceived(
|
||||
CefRefPtr<CefBrowser> browser,
|
||||
CefProcessId source_process,
|
||||
CefRefPtr<CefProcessMessage> message) OVERRIDE;
|
||||
|
||||
// Set of supported BrowserDelegates. Only used in the browser process.
|
||||
BrowserDelegateSet browser_delegates_;
|
||||
|
||||
// Set of supported RenderDelegates. Only used in the renderer process.
|
||||
RenderDelegateSet render_delegates_;
|
||||
|
||||
// Schemes that will be registered with the global cookie manager. Used in
|
||||
// both the browser and renderer process.
|
||||
std::vector<CefString> cookieable_schemes_;
|
||||
|
||||
CefRefPtr<CefPrintHandler> print_handler_;
|
||||
|
||||
IMPLEMENT_REFCOUNTING(ClientApp);
|
||||
DISALLOW_COPY_AND_ASSIGN(ClientApp);
|
||||
};
|
||||
|
||||
} // namespace client
|
||||
|
14
tests/cefclient/common/client_app_other.cc
Normal file
14
tests/cefclient/common/client_app_other.cc
Normal file
@ -0,0 +1,14 @@
|
||||
// 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/common/client_app_other.h"
|
||||
|
||||
#include "include/cef_command_line.h"
|
||||
|
||||
namespace client {
|
||||
|
||||
ClientAppOther::ClientAppOther() {
|
||||
}
|
||||
|
||||
} // namespace client
|
25
tests/cefclient/common/client_app_other.h
Normal file
25
tests/cefclient/common/client_app_other.h
Normal file
@ -0,0 +1,25 @@
|
||||
// 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.
|
||||
|
||||
#ifndef CEF_TESTS_CEFCLIENT_COMMON_CLIENT_APP_OTHER_H_
|
||||
#define CEF_TESTS_CEFCLIENT_COMMON_CLIENT_APP_OTHER_H_
|
||||
#pragma once
|
||||
|
||||
#include "cefclient/common/client_app.h"
|
||||
|
||||
namespace client {
|
||||
|
||||
// Client app implementation for other process types.
|
||||
class ClientAppOther : public ClientApp {
|
||||
public:
|
||||
ClientAppOther();
|
||||
|
||||
private:
|
||||
IMPLEMENT_REFCOUNTING(ClientAppOther);
|
||||
DISALLOW_COPY_AND_ASSIGN(ClientAppOther);
|
||||
};
|
||||
|
||||
} // namespace client
|
||||
|
||||
#endif // CEF_TESTS_CEFCLIENT_COMMON_CLIENT_APP_OTHER_H_
|
@ -2,9 +2,7 @@
|
||||
// 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_switches.h" // NOLINT(build/include)
|
||||
#include "cefclient/common/client_switches.h"
|
||||
|
||||
namespace client {
|
||||
namespace switches {
|
||||
|
@ -2,16 +2,16 @@
|
||||
// reserved. Use of this source code is governed by a BSD-style license that
|
||||
// can be found in the LICENSE file.
|
||||
|
||||
#include "cefclient/common/client_app.h"
|
||||
#include "cefclient/renderer/client_app_renderer.h"
|
||||
#include "cefclient/renderer/client_renderer.h"
|
||||
#include "cefclient/renderer/performance_test.h"
|
||||
|
||||
namespace client {
|
||||
|
||||
// static
|
||||
void ClientApp::CreateRenderDelegates(RenderDelegateSet& delegates) {
|
||||
renderer::CreateRenderDelegates(delegates);
|
||||
performance_test::CreateRenderDelegates(delegates);
|
||||
void ClientAppRenderer::CreateDelegates(DelegateSet& delegates) {
|
||||
renderer::CreateDelegates(delegates);
|
||||
performance_test::CreateDelegates(delegates);
|
||||
}
|
||||
|
||||
} // namespace client
|
||||
|
@ -1,21 +0,0 @@
|
||||
// Copyright (c) 2012 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/common/client_app.h"
|
||||
|
||||
namespace client {
|
||||
|
||||
// Stub implementations of ClientApp methods that are only used in the browser
|
||||
// process.
|
||||
|
||||
// static
|
||||
void ClientApp::CreateBrowserDelegates(BrowserDelegateSet& delegates) {
|
||||
}
|
||||
|
||||
// static
|
||||
CefRefPtr<CefPrintHandler> ClientApp::CreatePrintHandler() {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
} // namespace client
|
118
tests/cefclient/renderer/client_app_renderer.cc
Normal file
118
tests/cefclient/renderer/client_app_renderer.cc
Normal file
@ -0,0 +1,118 @@
|
||||
// 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.
|
||||
|
||||
#include "cefclient/renderer/client_app_renderer.h"
|
||||
|
||||
namespace client {
|
||||
|
||||
ClientAppRenderer::ClientAppRenderer() {
|
||||
}
|
||||
|
||||
void ClientAppRenderer::OnRenderThreadCreated(
|
||||
CefRefPtr<CefListValue> extra_info) {
|
||||
CreateDelegates(delegates_);
|
||||
|
||||
DelegateSet::iterator it = delegates_.begin();
|
||||
for (; it != delegates_.end(); ++it)
|
||||
(*it)->OnRenderThreadCreated(this, extra_info);
|
||||
}
|
||||
|
||||
void ClientAppRenderer::OnWebKitInitialized() {
|
||||
DelegateSet::iterator it = delegates_.begin();
|
||||
for (; it != delegates_.end(); ++it)
|
||||
(*it)->OnWebKitInitialized(this);
|
||||
}
|
||||
|
||||
void ClientAppRenderer::OnBrowserCreated(CefRefPtr<CefBrowser> browser) {
|
||||
DelegateSet::iterator it = delegates_.begin();
|
||||
for (; it != delegates_.end(); ++it)
|
||||
(*it)->OnBrowserCreated(this, browser);
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
bool ClientAppRenderer::OnBeforeNavigation(CefRefPtr<CefBrowser> browser,
|
||||
CefRefPtr<CefFrame> frame,
|
||||
CefRefPtr<CefRequest> request,
|
||||
NavigationType navigation_type,
|
||||
bool is_redirect) {
|
||||
DelegateSet::iterator it = delegates_.begin();
|
||||
for (; it != delegates_.end(); ++it) {
|
||||
if ((*it)->OnBeforeNavigation(this, browser, frame, request,
|
||||
navigation_type, is_redirect)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
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,
|
||||
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) {
|
||||
handled = (*it)->OnProcessMessageReceived(this, browser, source_process,
|
||||
message);
|
||||
}
|
||||
|
||||
return handled;
|
||||
}
|
||||
|
||||
} // namespace client
|
138
tests/cefclient/renderer/client_app_renderer.h
Normal file
138
tests/cefclient/renderer/client_app_renderer.h
Normal file
@ -0,0 +1,138 @@
|
||||
// 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.
|
||||
|
||||
#ifndef CEF_TESTS_CEFCLIENT_RENDERER_CLIENT_APP_RENDERER_H_
|
||||
#define CEF_TESTS_CEFCLIENT_RENDERER_CLIENT_APP_RENDERER_H_
|
||||
#pragma once
|
||||
|
||||
#include <set>
|
||||
|
||||
#include "cefclient/common/client_app.h"
|
||||
|
||||
namespace client {
|
||||
|
||||
// Client app implementation for the renderer process.
|
||||
class ClientAppRenderer : public ClientApp,
|
||||
public CefRenderProcessHandler {
|
||||
public:
|
||||
// Interface for renderer delegates. All Delegates must be returned via
|
||||
// CreateDelegates. Do not perform work in the Delegate
|
||||
// constructor. See CefRenderProcessHandler for documentation.
|
||||
class Delegate : public virtual CefBase {
|
||||
public:
|
||||
virtual void OnRenderThreadCreated(CefRefPtr<ClientAppRenderer> app,
|
||||
CefRefPtr<CefListValue> extra_info) {}
|
||||
|
||||
virtual void OnWebKitInitialized(CefRefPtr<ClientAppRenderer> app) {}
|
||||
|
||||
virtual void OnBrowserCreated(CefRefPtr<ClientAppRenderer> app,
|
||||
CefRefPtr<CefBrowser> browser) {}
|
||||
|
||||
virtual void OnBrowserDestroyed(CefRefPtr<ClientAppRenderer> app,
|
||||
CefRefPtr<CefBrowser> browser) {}
|
||||
|
||||
virtual CefRefPtr<CefLoadHandler> GetLoadHandler(
|
||||
CefRefPtr<ClientAppRenderer> app) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
virtual bool OnBeforeNavigation(CefRefPtr<ClientAppRenderer> app,
|
||||
CefRefPtr<CefBrowser> browser,
|
||||
CefRefPtr<CefFrame> frame,
|
||||
CefRefPtr<CefRequest> request,
|
||||
cef_navigation_type_t navigation_type,
|
||||
bool is_redirect) {
|
||||
return false;
|
||||
}
|
||||
|
||||
virtual void OnContextCreated(CefRefPtr<ClientAppRenderer> app,
|
||||
CefRefPtr<CefBrowser> browser,
|
||||
CefRefPtr<CefFrame> frame,
|
||||
CefRefPtr<CefV8Context> context) {}
|
||||
|
||||
virtual void OnContextReleased(CefRefPtr<ClientAppRenderer> app,
|
||||
CefRefPtr<CefBrowser> browser,
|
||||
CefRefPtr<CefFrame> frame,
|
||||
CefRefPtr<CefV8Context> context) {}
|
||||
|
||||
virtual void OnUncaughtException(CefRefPtr<ClientAppRenderer> app,
|
||||
CefRefPtr<CefBrowser> browser,
|
||||
CefRefPtr<CefFrame> frame,
|
||||
CefRefPtr<CefV8Context> context,
|
||||
CefRefPtr<CefV8Exception> exception,
|
||||
CefRefPtr<CefV8StackTrace> stackTrace) {}
|
||||
|
||||
virtual void OnFocusedNodeChanged(CefRefPtr<ClientAppRenderer> app,
|
||||
CefRefPtr<CefBrowser> browser,
|
||||
CefRefPtr<CefFrame> frame,
|
||||
CefRefPtr<CefDOMNode> node) {}
|
||||
|
||||
// Called when a process message is received. Return true if the message was
|
||||
// handled and should not be passed on to other handlers. Delegates
|
||||
// should check for unique message names to avoid interfering with each
|
||||
// other.
|
||||
virtual bool OnProcessMessageReceived(
|
||||
CefRefPtr<ClientAppRenderer> app,
|
||||
CefRefPtr<CefBrowser> browser,
|
||||
CefProcessId source_process,
|
||||
CefRefPtr<CefProcessMessage> message) {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
typedef std::set<CefRefPtr<Delegate> > DelegateSet;
|
||||
|
||||
ClientAppRenderer();
|
||||
|
||||
private:
|
||||
// Creates all of the Delegate objects. Implemented in
|
||||
// client_app_delegates.
|
||||
static void CreateDelegates(DelegateSet& delegates);
|
||||
|
||||
// CefApp methods.
|
||||
CefRefPtr<CefRenderProcessHandler> GetRenderProcessHandler() OVERRIDE {
|
||||
return this;
|
||||
}
|
||||
|
||||
// CefRenderProcessHandler methods.
|
||||
void OnRenderThreadCreated(CefRefPtr<CefListValue> extra_info) OVERRIDE;
|
||||
void OnWebKitInitialized() OVERRIDE;
|
||||
void OnBrowserCreated(CefRefPtr<CefBrowser> browser) OVERRIDE;
|
||||
void OnBrowserDestroyed(CefRefPtr<CefBrowser> browser) OVERRIDE;
|
||||
CefRefPtr<CefLoadHandler> GetLoadHandler() OVERRIDE;
|
||||
bool OnBeforeNavigation(CefRefPtr<CefBrowser> browser,
|
||||
CefRefPtr<CefFrame> frame,
|
||||
CefRefPtr<CefRequest> request,
|
||||
NavigationType navigation_type,
|
||||
bool is_redirect) OVERRIDE;
|
||||
void OnContextCreated(CefRefPtr<CefBrowser> browser,
|
||||
CefRefPtr<CefFrame> frame,
|
||||
CefRefPtr<CefV8Context> context) OVERRIDE;
|
||||
void OnContextReleased(CefRefPtr<CefBrowser> browser,
|
||||
CefRefPtr<CefFrame> frame,
|
||||
CefRefPtr<CefV8Context> context) OVERRIDE;
|
||||
void OnUncaughtException(CefRefPtr<CefBrowser> browser,
|
||||
CefRefPtr<CefFrame> frame,
|
||||
CefRefPtr<CefV8Context> context,
|
||||
CefRefPtr<CefV8Exception> exception,
|
||||
CefRefPtr<CefV8StackTrace> stackTrace) OVERRIDE;
|
||||
void OnFocusedNodeChanged(CefRefPtr<CefBrowser> browser,
|
||||
CefRefPtr<CefFrame> frame,
|
||||
CefRefPtr<CefDOMNode> node) OVERRIDE;
|
||||
bool OnProcessMessageReceived(
|
||||
CefRefPtr<CefBrowser> browser,
|
||||
CefProcessId source_process,
|
||||
CefRefPtr<CefProcessMessage> message) OVERRIDE;
|
||||
|
||||
private:
|
||||
// Set of supported Delegates.
|
||||
DelegateSet delegates_;
|
||||
|
||||
IMPLEMENT_REFCOUNTING(ClientAppRenderer);
|
||||
DISALLOW_COPY_AND_ASSIGN(ClientAppRenderer);
|
||||
};
|
||||
|
||||
} // namespace client
|
||||
|
||||
#endif // CEF_TESTS_CEFCLIENT_RENDERER_CLIENT_APP_RENDERER_H_
|
@ -19,33 +19,33 @@ namespace {
|
||||
// Must match the value in client_handler.cc.
|
||||
const char kFocusedNodeChangedMessage[] = "ClientRenderer.FocusedNodeChanged";
|
||||
|
||||
class ClientRenderDelegate : public ClientApp::RenderDelegate {
|
||||
class ClientRenderDelegate : public ClientAppRenderer::Delegate {
|
||||
public:
|
||||
ClientRenderDelegate()
|
||||
: last_node_is_editable_(false) {
|
||||
}
|
||||
|
||||
virtual void OnWebKitInitialized(CefRefPtr<ClientApp> app) OVERRIDE {
|
||||
virtual void OnWebKitInitialized(CefRefPtr<ClientAppRenderer> app) OVERRIDE {
|
||||
// Create the renderer-side router for query handling.
|
||||
CefMessageRouterConfig config;
|
||||
message_router_ = CefMessageRouterRendererSide::Create(config);
|
||||
}
|
||||
|
||||
virtual void OnContextCreated(CefRefPtr<ClientApp> app,
|
||||
virtual void OnContextCreated(CefRefPtr<ClientAppRenderer> app,
|
||||
CefRefPtr<CefBrowser> browser,
|
||||
CefRefPtr<CefFrame> frame,
|
||||
CefRefPtr<CefV8Context> context) OVERRIDE {
|
||||
message_router_->OnContextCreated(browser, frame, context);
|
||||
}
|
||||
|
||||
virtual void OnContextReleased(CefRefPtr<ClientApp> app,
|
||||
virtual void OnContextReleased(CefRefPtr<ClientAppRenderer> app,
|
||||
CefRefPtr<CefBrowser> browser,
|
||||
CefRefPtr<CefFrame> frame,
|
||||
CefRefPtr<CefV8Context> context) OVERRIDE {
|
||||
message_router_->OnContextReleased(browser, frame, context);
|
||||
}
|
||||
|
||||
virtual void OnFocusedNodeChanged(CefRefPtr<ClientApp> app,
|
||||
virtual void OnFocusedNodeChanged(CefRefPtr<ClientAppRenderer> app,
|
||||
CefRefPtr<CefBrowser> browser,
|
||||
CefRefPtr<CefFrame> frame,
|
||||
CefRefPtr<CefDOMNode> node) OVERRIDE {
|
||||
@ -61,7 +61,7 @@ class ClientRenderDelegate : public ClientApp::RenderDelegate {
|
||||
}
|
||||
|
||||
virtual bool OnProcessMessageReceived(
|
||||
CefRefPtr<ClientApp> app,
|
||||
CefRefPtr<ClientAppRenderer> app,
|
||||
CefRefPtr<CefBrowser> browser,
|
||||
CefProcessId source_process,
|
||||
CefRefPtr<CefProcessMessage> message) OVERRIDE {
|
||||
@ -80,7 +80,7 @@ class ClientRenderDelegate : public ClientApp::RenderDelegate {
|
||||
|
||||
} // namespace
|
||||
|
||||
void CreateRenderDelegates(ClientApp::RenderDelegateSet& delegates) {
|
||||
void CreateDelegates(ClientAppRenderer::DelegateSet& delegates) {
|
||||
delegates.insert(new ClientRenderDelegate);
|
||||
}
|
||||
|
||||
|
@ -7,13 +7,13 @@
|
||||
#pragma once
|
||||
|
||||
#include "include/cef_base.h"
|
||||
#include "cefclient/common/client_app.h"
|
||||
#include "cefclient/renderer/client_app_renderer.h"
|
||||
|
||||
namespace client {
|
||||
namespace renderer {
|
||||
|
||||
// Create the render delegate.
|
||||
void CreateRenderDelegates(ClientApp::RenderDelegateSet& delegates);
|
||||
void CreateDelegates(ClientAppRenderer::DelegateSet& delegates);
|
||||
|
||||
} // namespace renderer
|
||||
} // namespace client
|
||||
|
@ -126,15 +126,15 @@ class V8Handler : public CefV8Handler {
|
||||
};
|
||||
|
||||
// Handle bindings in the render process.
|
||||
class RenderDelegate : public ClientApp::RenderDelegate {
|
||||
class RenderDelegate : public ClientAppRenderer::Delegate {
|
||||
public:
|
||||
RenderDelegate() {
|
||||
}
|
||||
|
||||
virtual void OnContextCreated(CefRefPtr<ClientApp> app,
|
||||
CefRefPtr<CefBrowser> browser,
|
||||
CefRefPtr<CefFrame> frame,
|
||||
CefRefPtr<CefV8Context> context) OVERRIDE {
|
||||
virtual void OnContextCreated(CefRefPtr<ClientAppRenderer> app,
|
||||
CefRefPtr<CefBrowser> browser,
|
||||
CefRefPtr<CefFrame> frame,
|
||||
CefRefPtr<CefV8Context> context) OVERRIDE {
|
||||
CefRefPtr<CefV8Value> object = context->GetGlobal();
|
||||
|
||||
CefRefPtr<CefV8Handler> handler = new V8Handler();
|
||||
@ -157,7 +157,7 @@ class RenderDelegate : public ClientApp::RenderDelegate {
|
||||
|
||||
} // namespace
|
||||
|
||||
void CreateRenderDelegates(ClientApp::RenderDelegateSet& delegates) {
|
||||
void CreateDelegates(ClientAppRenderer::DelegateSet& delegates) {
|
||||
delegates.insert(new RenderDelegate);
|
||||
}
|
||||
|
||||
|
@ -6,13 +6,13 @@
|
||||
#define CEF_TESTS_CEFCLIENT_RENDERER_PERFORMANCE_TEST_H_
|
||||
#pragma once
|
||||
|
||||
#include "cefclient/common/client_app.h"
|
||||
#include "cefclient/renderer/client_app_renderer.h"
|
||||
|
||||
namespace client {
|
||||
namespace performance_test {
|
||||
|
||||
// Render delegate creation. Called from client_app_delegates.cc.
|
||||
void CreateRenderDelegates(ClientApp::RenderDelegateSet& delegates);
|
||||
void CreateDelegates(ClientAppRenderer::DelegateSet& delegates);
|
||||
|
||||
} // namespace performance_test
|
||||
} // namespace client
|
||||
|
@ -4,16 +4,34 @@
|
||||
|
||||
#include "include/cef_app.h"
|
||||
|
||||
// This file is shared by cefclient and cef_unittests so don't include using
|
||||
// a qualified path.
|
||||
#include "../common/client_app.h" // NOLINT(build/include)
|
||||
#include "cefclient/common/client_app_other.h"
|
||||
#include "cefclient/renderer/client_app_renderer.h"
|
||||
|
||||
// Process entry point.
|
||||
int main(int argc, char* argv[]) {
|
||||
namespace client {
|
||||
|
||||
int RunMain(int argc, char* argv[]) {
|
||||
CefMainArgs main_args(argc, argv);
|
||||
|
||||
CefRefPtr<CefApp> app(new client::ClientApp);
|
||||
// Parse command-line arguments.
|
||||
CefRefPtr<CefCommandLine> command_line = CefCommandLine::CreateCommandLine();
|
||||
command_line->InitFromArgv(argc, argv);
|
||||
|
||||
// Create a ClientApp of the correct type.
|
||||
CefRefPtr<CefApp> app;
|
||||
ClientApp::ProcessType process_type = ClientApp::GetProcessType(command_line);
|
||||
if (process_type == ClientApp::RendererProcess)
|
||||
app = new ClientAppRenderer();
|
||||
else if (process_type == ClientApp::OtherProcess)
|
||||
app = new ClientAppOther();
|
||||
|
||||
// Execute the secondary process.
|
||||
return CefExecuteProcess(main_args, app, NULL);
|
||||
}
|
||||
|
||||
} // namespace client
|
||||
|
||||
|
||||
// Process entry point.
|
||||
int main(int argc, char* argv[]) {
|
||||
return client::RunMain(argc, argv);
|
||||
}
|
||||
|
@ -2,81 +2,83 @@
|
||||
// reserved. Use of this source code is governed by a BSD-style license that
|
||||
// can be found in the LICENSE file.
|
||||
|
||||
#include "tests/cefclient/common/client_app.h"
|
||||
#include "tests/cefclient/browser/client_app_browser.h"
|
||||
#include "tests/cefclient/renderer/client_app_renderer.h"
|
||||
|
||||
using client::ClientApp;
|
||||
using client::ClientAppBrowser;
|
||||
using client::ClientAppRenderer;
|
||||
|
||||
void CreateBrowserDelegates(ClientApp::BrowserDelegateSet& delegates) {
|
||||
void CreateBrowserDelegates(ClientAppBrowser::DelegateSet& delegates) {
|
||||
// Bring in the Frame tests.
|
||||
extern void CreateFrameBrowserTests(
|
||||
ClientApp::BrowserDelegateSet& delegates);
|
||||
ClientAppBrowser::DelegateSet& delegates);
|
||||
CreateFrameBrowserTests(delegates);
|
||||
|
||||
// Bring in the Navigation tests.
|
||||
extern void CreateNavigationBrowserTests(
|
||||
ClientApp::BrowserDelegateSet& delegates);
|
||||
ClientAppBrowser::DelegateSet& delegates);
|
||||
CreateNavigationBrowserTests(delegates);
|
||||
|
||||
// Bring in the RequestHandler tests.
|
||||
extern void CreateRequestHandlerBrowserTests(
|
||||
ClientApp::BrowserDelegateSet& delegates);
|
||||
ClientAppBrowser::DelegateSet& delegates);
|
||||
CreateRequestHandlerBrowserTests(delegates);
|
||||
|
||||
// Bring in the V8 tests.
|
||||
extern void CreateV8BrowserTests(
|
||||
ClientApp::BrowserDelegateSet& delegates);
|
||||
ClientAppBrowser::DelegateSet& delegates);
|
||||
CreateV8BrowserTests(delegates);
|
||||
}
|
||||
|
||||
void CreateRenderDelegates(ClientApp::RenderDelegateSet& delegates) {
|
||||
void CreateRenderDelegates(ClientAppRenderer::DelegateSet& delegates) {
|
||||
// Bring in the Frame tests.
|
||||
extern void CreateFrameRendererTests(
|
||||
ClientApp::RenderDelegateSet& delegates);
|
||||
ClientAppRenderer::DelegateSet& delegates);
|
||||
CreateFrameRendererTests(delegates);
|
||||
|
||||
// Bring in the DOM tests.
|
||||
extern void CreateDOMRendererTests(
|
||||
ClientApp::RenderDelegateSet& delegates);
|
||||
ClientAppRenderer::DelegateSet& delegates);
|
||||
CreateDOMRendererTests(delegates);
|
||||
|
||||
// Bring in the message router tests.
|
||||
extern void CreateMessageRouterRendererTests(
|
||||
ClientApp::RenderDelegateSet& delegates);
|
||||
ClientAppRenderer::DelegateSet& delegates);
|
||||
CreateMessageRouterRendererTests(delegates);
|
||||
|
||||
// Bring in the Navigation tests.
|
||||
extern void CreateNavigationRendererTests(
|
||||
ClientApp::RenderDelegateSet& delegates);
|
||||
ClientAppRenderer::DelegateSet& delegates);
|
||||
CreateNavigationRendererTests(delegates);
|
||||
|
||||
// Bring in the process message tests.
|
||||
extern void CreateProcessMessageRendererTests(
|
||||
ClientApp::RenderDelegateSet& delegates);
|
||||
ClientAppRenderer::DelegateSet& delegates);
|
||||
CreateProcessMessageRendererTests(delegates);
|
||||
|
||||
// Bring in the RequestHandler tests.
|
||||
extern void CreateRequestHandlerRendererTests(
|
||||
ClientApp::RenderDelegateSet& delegates);
|
||||
ClientAppRenderer::DelegateSet& delegates);
|
||||
CreateRequestHandlerRendererTests(delegates);
|
||||
|
||||
// Bring in the Request tests.
|
||||
extern void CreateRequestRendererTests(
|
||||
ClientApp::RenderDelegateSet& delegates);
|
||||
ClientAppRenderer::DelegateSet& delegates);
|
||||
CreateRequestRendererTests(delegates);
|
||||
|
||||
// Bring in the routing test handler delegate.
|
||||
extern void CreateRoutingTestHandlerDelegate(
|
||||
ClientApp::RenderDelegateSet& delegates);
|
||||
ClientAppRenderer::DelegateSet& delegates);
|
||||
CreateRoutingTestHandlerDelegate(delegates);
|
||||
|
||||
// Bring in the URLRequest tests.
|
||||
extern void CreateURLRequestRendererTests(
|
||||
ClientApp::RenderDelegateSet& delegates);
|
||||
ClientAppRenderer::DelegateSet& delegates);
|
||||
CreateURLRequestRendererTests(delegates);
|
||||
|
||||
// Bring in the V8 tests.
|
||||
extern void CreateV8RendererTests(
|
||||
ClientApp::RenderDelegateSet& delegates);
|
||||
ClientAppRenderer::DelegateSet& delegates);
|
||||
CreateV8RendererTests(delegates);
|
||||
}
|
||||
|
||||
@ -106,12 +108,17 @@ void RegisterCustomSchemes(
|
||||
namespace client {
|
||||
|
||||
// static
|
||||
void ClientApp::CreateBrowserDelegates(BrowserDelegateSet& delegates) {
|
||||
void ClientAppBrowser::CreateDelegates(DelegateSet& delegates) {
|
||||
::CreateBrowserDelegates(delegates);
|
||||
}
|
||||
|
||||
// static
|
||||
void ClientApp::CreateRenderDelegates(RenderDelegateSet& delegates) {
|
||||
CefRefPtr<CefPrintHandler> ClientAppBrowser::CreatePrintHandler() {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// static
|
||||
void ClientAppRenderer::CreateDelegates(DelegateSet& delegates) {
|
||||
::CreateRenderDelegates(delegates);
|
||||
}
|
||||
|
||||
@ -122,10 +129,5 @@ void ClientApp::RegisterCustomSchemes(
|
||||
::RegisterCustomSchemes(registrar, cookiable_schemes);
|
||||
}
|
||||
|
||||
// static
|
||||
CefRefPtr<CefPrintHandler> ClientApp::CreatePrintHandler() {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
} // namespace client
|
||||
|
||||
|
@ -7,10 +7,10 @@
|
||||
|
||||
#include "include/cef_dom.h"
|
||||
#include "testing/gtest/include/gtest/gtest.h"
|
||||
#include "tests/cefclient/common/client_app.h"
|
||||
#include "tests/cefclient/renderer/client_app_renderer.h"
|
||||
#include "tests/unittests/test_handler.h"
|
||||
|
||||
using client::ClientApp;
|
||||
using client::ClientAppRenderer;
|
||||
|
||||
namespace {
|
||||
|
||||
@ -227,13 +227,13 @@ class TestDOMVisitor : public CefDOMVisitor {
|
||||
};
|
||||
|
||||
// Used in the render process.
|
||||
class DOMRendererTest : public ClientApp::RenderDelegate {
|
||||
class DOMRendererTest : public ClientAppRenderer::Delegate {
|
||||
public:
|
||||
DOMRendererTest() {
|
||||
}
|
||||
|
||||
bool OnProcessMessageReceived(
|
||||
CefRefPtr<ClientApp> app,
|
||||
CefRefPtr<ClientAppRenderer> app,
|
||||
CefRefPtr<CefBrowser> browser,
|
||||
CefProcessId source_process,
|
||||
CefRefPtr<CefProcessMessage> message) override {
|
||||
@ -339,6 +339,6 @@ TEST(DOMTest, Modify) {
|
||||
|
||||
// Entry point for creating DOM renderer test objects.
|
||||
// Called from client_app_delegates.cc.
|
||||
void CreateDOMRendererTests(ClientApp::RenderDelegateSet& delegates) {
|
||||
void CreateDOMRendererTests(ClientAppRenderer::DelegateSet& delegates) {
|
||||
delegates.insert(new DOMRendererTest);
|
||||
}
|
||||
|
@ -10,10 +10,12 @@
|
||||
#include "include/wrapper/cef_closure_task.h"
|
||||
#include "include/wrapper/cef_stream_resource_handler.h"
|
||||
#include "testing/gtest/include/gtest/gtest.h"
|
||||
#include "tests/cefclient/common/client_app.h"
|
||||
#include "tests/cefclient/browser/client_app_browser.h"
|
||||
#include "tests/cefclient/renderer/client_app_renderer.h"
|
||||
#include "tests/unittests/test_handler.h"
|
||||
|
||||
using client::ClientApp;
|
||||
using client::ClientAppBrowser;
|
||||
using client::ClientAppRenderer;
|
||||
|
||||
namespace {
|
||||
|
||||
@ -263,12 +265,12 @@ class FrameNavExpectationsFactoryRenderer : public FrameNavExpectationsFactory {
|
||||
|
||||
|
||||
// Browser side app delegate.
|
||||
class FrameNavBrowserTest : public ClientApp::BrowserDelegate {
|
||||
class FrameNavBrowserTest : public ClientAppBrowser::Delegate {
|
||||
public:
|
||||
FrameNavBrowserTest() {}
|
||||
|
||||
void OnBeforeChildProcessLaunch(
|
||||
CefRefPtr<ClientApp> app,
|
||||
CefRefPtr<ClientAppBrowser> app,
|
||||
CefRefPtr<CefCommandLine> command_line) override {
|
||||
if (!g_frame_nav_test)
|
||||
return;
|
||||
@ -286,7 +288,7 @@ class FrameNavBrowserTest : public ClientApp::BrowserDelegate {
|
||||
};
|
||||
|
||||
// Renderer side handler.
|
||||
class FrameNavRendererTest : public ClientApp::RenderDelegate,
|
||||
class FrameNavRendererTest : public ClientAppRenderer::Delegate,
|
||||
public CefLoadHandler {
|
||||
public:
|
||||
FrameNavRendererTest()
|
||||
@ -294,7 +296,7 @@ class FrameNavRendererTest : public ClientApp::RenderDelegate,
|
||||
nav_(0) {}
|
||||
|
||||
void OnRenderThreadCreated(
|
||||
CefRefPtr<ClientApp> app,
|
||||
CefRefPtr<ClientAppRenderer> app,
|
||||
CefRefPtr<CefListValue> extra_info) override {
|
||||
// The g_* values will be set when running in single-process mode.
|
||||
if (!g_frame_nav_test) {
|
||||
@ -325,7 +327,7 @@ class FrameNavRendererTest : public ClientApp::RenderDelegate,
|
||||
}
|
||||
|
||||
CefRefPtr<CefLoadHandler> GetLoadHandler(
|
||||
CefRefPtr<ClientApp> app) override {
|
||||
CefRefPtr<ClientAppRenderer> app) override {
|
||||
if (!run_test_)
|
||||
return NULL;
|
||||
|
||||
@ -354,7 +356,7 @@ class FrameNavRendererTest : public ClientApp::RenderDelegate,
|
||||
EXPECT_TRUE(expectations_->OnLoadEnd(browser, frame)) << "nav = " << nav_;
|
||||
}
|
||||
|
||||
bool OnBeforeNavigation(CefRefPtr<ClientApp> app,
|
||||
bool OnBeforeNavigation(CefRefPtr<ClientAppRenderer> app,
|
||||
CefRefPtr<CefBrowser> browser,
|
||||
CefRefPtr<CefFrame> frame,
|
||||
CefRefPtr<CefRequest> request,
|
||||
@ -2297,12 +2299,12 @@ scoped_ptr<FrameNavExpectationsFactoryRenderer>
|
||||
|
||||
// Entry point for creating frame browser test objects.
|
||||
// Called from client_app_delegates.cc.
|
||||
void CreateFrameBrowserTests(ClientApp::BrowserDelegateSet& delegates) {
|
||||
void CreateFrameBrowserTests(ClientAppBrowser::DelegateSet& delegates) {
|
||||
delegates.insert(new FrameNavBrowserTest);
|
||||
}
|
||||
|
||||
// Entry point for creating frame renderer test objects.
|
||||
// Called from client_app_delegates.cc.
|
||||
void CreateFrameRendererTests(ClientApp::RenderDelegateSet& delegates) {
|
||||
void CreateFrameRendererTests(ClientAppRenderer::DelegateSet& delegates) {
|
||||
delegates.insert(new FrameNavRendererTest);
|
||||
}
|
||||
|
@ -17,9 +17,9 @@
|
||||
#include "include/wrapper/cef_closure_task.h"
|
||||
#include "testing/gtest/include/gtest/gtest.h"
|
||||
#include "tests/unittests/routing_test_handler.h"
|
||||
#include "tests/cefclient/common/client_app.h"
|
||||
#include "tests/cefclient/renderer/client_app_renderer.h"
|
||||
|
||||
using client::ClientApp;
|
||||
using client::ClientAppRenderer;
|
||||
|
||||
namespace {
|
||||
|
||||
@ -41,7 +41,7 @@ void SetRouterConfig(CefMessageRouterConfig& config) {
|
||||
}
|
||||
|
||||
// Handle the renderer side of the routing implementation.
|
||||
class MRRenderDelegate : public ClientApp::RenderDelegate {
|
||||
class MRRenderDelegate : public ClientAppRenderer::Delegate {
|
||||
public:
|
||||
class V8HandlerImpl : public CefV8Handler {
|
||||
public:
|
||||
@ -114,14 +114,14 @@ class MRRenderDelegate : public ClientApp::RenderDelegate {
|
||||
|
||||
MRRenderDelegate() {}
|
||||
|
||||
void OnWebKitInitialized(CefRefPtr<ClientApp> app) override {
|
||||
void OnWebKitInitialized(CefRefPtr<ClientAppRenderer> app) override {
|
||||
// Create the renderer-side router for query handling.
|
||||
CefMessageRouterConfig config;
|
||||
SetRouterConfig(config);
|
||||
message_router_ = CefMessageRouterRendererSide::Create(config);
|
||||
}
|
||||
|
||||
void OnContextCreated(CefRefPtr<ClientApp> app,
|
||||
void OnContextCreated(CefRefPtr<ClientAppRenderer> app,
|
||||
CefRefPtr<CefBrowser> browser,
|
||||
CefRefPtr<CefFrame> frame,
|
||||
CefRefPtr<CefV8Context> context) override {
|
||||
@ -158,7 +158,7 @@ class MRRenderDelegate : public ClientApp::RenderDelegate {
|
||||
window->SetValue(kJSAssertContextCountFunc, context_count_func, attributes);
|
||||
}
|
||||
|
||||
void OnContextReleased(CefRefPtr<ClientApp> app,
|
||||
void OnContextReleased(CefRefPtr<ClientAppRenderer> app,
|
||||
CefRefPtr<CefBrowser> browser,
|
||||
CefRefPtr<CefFrame> frame,
|
||||
CefRefPtr<CefV8Context> context) override {
|
||||
@ -170,7 +170,7 @@ class MRRenderDelegate : public ClientApp::RenderDelegate {
|
||||
}
|
||||
|
||||
bool OnProcessMessageReceived(
|
||||
CefRefPtr<ClientApp> app,
|
||||
CefRefPtr<ClientAppRenderer> app,
|
||||
CefRefPtr<CefBrowser> browser,
|
||||
CefProcessId source_process,
|
||||
CefRefPtr<CefProcessMessage> message) override {
|
||||
@ -193,7 +193,7 @@ class MRRenderDelegate : public ClientApp::RenderDelegate {
|
||||
// Entry point for creating the test delegate.
|
||||
// Called from client_app_delegates.cc.
|
||||
void CreateMessageRouterRendererTests(
|
||||
ClientApp::RenderDelegateSet& delegates) {
|
||||
ClientAppRenderer::DelegateSet& delegates) {
|
||||
delegates.insert(new MRRenderDelegate);
|
||||
}
|
||||
|
||||
|
@ -13,11 +13,13 @@
|
||||
#include "include/cef_scheme.h"
|
||||
#include "include/wrapper/cef_closure_task.h"
|
||||
#include "testing/gtest/include/gtest/gtest.h"
|
||||
#include "tests/cefclient/common/client_app.h"
|
||||
#include "tests/cefclient/browser/client_app_browser.h"
|
||||
#include "tests/cefclient/renderer/client_app_renderer.h"
|
||||
#include "tests/unittests/test_handler.h"
|
||||
#include "tests/unittests/test_util.h"
|
||||
|
||||
using client::ClientApp;
|
||||
using client::ClientAppBrowser;
|
||||
using client::ClientAppRenderer;
|
||||
|
||||
namespace {
|
||||
|
||||
@ -58,12 +60,12 @@ static NavListItem kHNavList[] = {
|
||||
bool g_history_nav_test = false;
|
||||
|
||||
// Browser side.
|
||||
class HistoryNavBrowserTest : public ClientApp::BrowserDelegate {
|
||||
class HistoryNavBrowserTest : public ClientAppBrowser::Delegate {
|
||||
public:
|
||||
HistoryNavBrowserTest() {}
|
||||
|
||||
void OnBeforeChildProcessLaunch(
|
||||
CefRefPtr<ClientApp> app,
|
||||
CefRefPtr<ClientAppBrowser> app,
|
||||
CefRefPtr<CefCommandLine> command_line) override {
|
||||
if (!g_history_nav_test)
|
||||
return;
|
||||
@ -77,7 +79,7 @@ class HistoryNavBrowserTest : public ClientApp::BrowserDelegate {
|
||||
};
|
||||
|
||||
// Renderer side.
|
||||
class HistoryNavRendererTest : public ClientApp::RenderDelegate,
|
||||
class HistoryNavRendererTest : public ClientAppRenderer::Delegate,
|
||||
public CefLoadHandler {
|
||||
public:
|
||||
HistoryNavRendererTest()
|
||||
@ -85,7 +87,7 @@ class HistoryNavRendererTest : public ClientApp::RenderDelegate,
|
||||
nav_(0) {}
|
||||
|
||||
void OnRenderThreadCreated(
|
||||
CefRefPtr<ClientApp> app,
|
||||
CefRefPtr<ClientAppRenderer> app,
|
||||
CefRefPtr<CefListValue> extra_info) override {
|
||||
if (!g_history_nav_test) {
|
||||
// Check that the test should be run.
|
||||
@ -100,7 +102,7 @@ class HistoryNavRendererTest : public ClientApp::RenderDelegate,
|
||||
}
|
||||
|
||||
CefRefPtr<CefLoadHandler> GetLoadHandler(
|
||||
CefRefPtr<ClientApp> app) override {
|
||||
CefRefPtr<ClientAppRenderer> app) override {
|
||||
if (!run_test_)
|
||||
return NULL;
|
||||
|
||||
@ -174,7 +176,7 @@ class HistoryNavRendererTest : public ClientApp::RenderDelegate,
|
||||
SendTestResultsIfDone(browser);
|
||||
}
|
||||
|
||||
bool OnBeforeNavigation(CefRefPtr<ClientApp> app,
|
||||
bool OnBeforeNavigation(CefRefPtr<ClientAppRenderer> app,
|
||||
CefRefPtr<CefBrowser> browser,
|
||||
CefRefPtr<CefFrame> frame,
|
||||
CefRefPtr<CefRequest> request,
|
||||
@ -878,12 +880,12 @@ void SetOrderNavExtraInfo(CefRefPtr<CefListValue> extra_info) {
|
||||
bool g_order_nav_test = false;
|
||||
|
||||
// Browser side.
|
||||
class OrderNavBrowserTest : public ClientApp::BrowserDelegate {
|
||||
class OrderNavBrowserTest : public ClientAppBrowser::Delegate {
|
||||
public:
|
||||
OrderNavBrowserTest() {}
|
||||
|
||||
void OnBeforeChildProcessLaunch(
|
||||
CefRefPtr<ClientApp> app,
|
||||
CefRefPtr<ClientAppBrowser> app,
|
||||
CefRefPtr<CefCommandLine> command_line) override {
|
||||
if (!g_order_nav_test)
|
||||
return;
|
||||
@ -893,7 +895,7 @@ class OrderNavBrowserTest : public ClientApp::BrowserDelegate {
|
||||
}
|
||||
|
||||
void OnRenderProcessThreadCreated(
|
||||
CefRefPtr<ClientApp> app,
|
||||
CefRefPtr<ClientAppBrowser> app,
|
||||
CefRefPtr<CefListValue> extra_info) override {
|
||||
if (!g_order_nav_test)
|
||||
return;
|
||||
@ -990,7 +992,7 @@ class OrderNavLoadState {
|
||||
};
|
||||
|
||||
// Renderer side.
|
||||
class OrderNavRendererTest : public ClientApp::RenderDelegate,
|
||||
class OrderNavRendererTest : public ClientAppRenderer::Delegate,
|
||||
public CefLoadHandler {
|
||||
public:
|
||||
OrderNavRendererTest()
|
||||
@ -1001,7 +1003,7 @@ class OrderNavRendererTest : public ClientApp::RenderDelegate,
|
||||
state_popup_(true, false) {}
|
||||
|
||||
void OnRenderThreadCreated(
|
||||
CefRefPtr<ClientApp> app,
|
||||
CefRefPtr<ClientAppRenderer> app,
|
||||
CefRefPtr<CefListValue> extra_info) override {
|
||||
if (!g_order_nav_test) {
|
||||
// Check that the test should be run.
|
||||
@ -1024,7 +1026,7 @@ class OrderNavRendererTest : public ClientApp::RenderDelegate,
|
||||
TestListEqual(expected, extra_info);
|
||||
}
|
||||
|
||||
void OnWebKitInitialized(CefRefPtr<ClientApp> app) override {
|
||||
void OnWebKitInitialized(CefRefPtr<ClientAppRenderer> app) override {
|
||||
if (!run_test_)
|
||||
return;
|
||||
|
||||
@ -1033,7 +1035,7 @@ class OrderNavRendererTest : public ClientApp::RenderDelegate,
|
||||
got_webkit_initialized_.yes();
|
||||
}
|
||||
|
||||
void OnBrowserCreated(CefRefPtr<ClientApp> app,
|
||||
void OnBrowserCreated(CefRefPtr<ClientAppRenderer> app,
|
||||
CefRefPtr<CefBrowser> browser) override {
|
||||
if (!run_test_)
|
||||
return;
|
||||
@ -1062,7 +1064,7 @@ class OrderNavRendererTest : public ClientApp::RenderDelegate,
|
||||
}
|
||||
}
|
||||
|
||||
void OnBrowserDestroyed(CefRefPtr<ClientApp> app,
|
||||
void OnBrowserDestroyed(CefRefPtr<ClientAppRenderer> app,
|
||||
CefRefPtr<CefBrowser> browser) override {
|
||||
if (!run_test_)
|
||||
return;
|
||||
@ -1095,7 +1097,7 @@ class OrderNavRendererTest : public ClientApp::RenderDelegate,
|
||||
}
|
||||
|
||||
CefRefPtr<CefLoadHandler> GetLoadHandler(
|
||||
CefRefPtr<ClientApp> app) override {
|
||||
CefRefPtr<ClientAppRenderer> app) override {
|
||||
if (!run_test_)
|
||||
return NULL;
|
||||
|
||||
@ -1443,12 +1445,12 @@ const char kCrossOriginNavMsg[] = "NavigationTest.CrossOriginNav";
|
||||
bool g_cross_origin_nav_test = false;
|
||||
|
||||
// Browser side.
|
||||
class CrossOriginNavBrowserTest : public ClientApp::BrowserDelegate {
|
||||
class CrossOriginNavBrowserTest : public ClientAppBrowser::Delegate {
|
||||
public:
|
||||
CrossOriginNavBrowserTest() {}
|
||||
|
||||
void OnBeforeChildProcessLaunch(
|
||||
CefRefPtr<ClientApp> app,
|
||||
CefRefPtr<ClientAppBrowser> app,
|
||||
CefRefPtr<CefCommandLine> command_line) override {
|
||||
if (!g_cross_origin_nav_test)
|
||||
return;
|
||||
@ -1462,7 +1464,7 @@ class CrossOriginNavBrowserTest : public ClientApp::BrowserDelegate {
|
||||
};
|
||||
|
||||
// Renderer side.
|
||||
class CrossOriginNavRendererTest : public ClientApp::RenderDelegate,
|
||||
class CrossOriginNavRendererTest : public ClientAppRenderer::Delegate,
|
||||
public CefLoadHandler {
|
||||
public:
|
||||
CrossOriginNavRendererTest()
|
||||
@ -1472,7 +1474,7 @@ class CrossOriginNavRendererTest : public ClientApp::RenderDelegate,
|
||||
}
|
||||
|
||||
void OnRenderThreadCreated(
|
||||
CefRefPtr<ClientApp> app,
|
||||
CefRefPtr<ClientAppRenderer> app,
|
||||
CefRefPtr<CefListValue> extra_info) override {
|
||||
if (!g_cross_origin_nav_test) {
|
||||
// Check that the test should be run.
|
||||
@ -1490,7 +1492,7 @@ class CrossOriginNavRendererTest : public ClientApp::RenderDelegate,
|
||||
got_render_thread_created_.yes();
|
||||
}
|
||||
|
||||
void OnWebKitInitialized(CefRefPtr<ClientApp> app) override {
|
||||
void OnWebKitInitialized(CefRefPtr<ClientAppRenderer> app) override {
|
||||
if (!run_test_)
|
||||
return;
|
||||
|
||||
@ -1499,7 +1501,7 @@ class CrossOriginNavRendererTest : public ClientApp::RenderDelegate,
|
||||
got_webkit_initialized_.yes();
|
||||
}
|
||||
|
||||
void OnBrowserCreated(CefRefPtr<ClientApp> app,
|
||||
void OnBrowserCreated(CefRefPtr<ClientAppRenderer> app,
|
||||
CefRefPtr<CefBrowser> browser) override {
|
||||
if (!run_test_)
|
||||
return;
|
||||
@ -1512,7 +1514,7 @@ class CrossOriginNavRendererTest : public ClientApp::RenderDelegate,
|
||||
status->got_browser_created.yes();
|
||||
}
|
||||
|
||||
void OnBrowserDestroyed(CefRefPtr<ClientApp> app,
|
||||
void OnBrowserDestroyed(CefRefPtr<ClientAppRenderer> app,
|
||||
CefRefPtr<CefBrowser> browser) override {
|
||||
if (!run_test_)
|
||||
return;
|
||||
@ -1532,7 +1534,7 @@ class CrossOriginNavRendererTest : public ClientApp::RenderDelegate,
|
||||
}
|
||||
|
||||
CefRefPtr<CefLoadHandler> GetLoadHandler(
|
||||
CefRefPtr<ClientApp> app) override {
|
||||
CefRefPtr<ClientAppRenderer> app) override {
|
||||
if (!run_test_)
|
||||
return NULL;
|
||||
|
||||
@ -2070,7 +2072,7 @@ TEST(NavigationTest, BrowseDeny) {
|
||||
|
||||
// Entry point for creating navigation browser test objects.
|
||||
// Called from client_app_delegates.cc.
|
||||
void CreateNavigationBrowserTests(ClientApp::BrowserDelegateSet& delegates) {
|
||||
void CreateNavigationBrowserTests(ClientAppBrowser::DelegateSet& delegates) {
|
||||
delegates.insert(new HistoryNavBrowserTest);
|
||||
delegates.insert(new OrderNavBrowserTest);
|
||||
delegates.insert(new CrossOriginNavBrowserTest);
|
||||
@ -2078,7 +2080,7 @@ void CreateNavigationBrowserTests(ClientApp::BrowserDelegateSet& delegates) {
|
||||
|
||||
// Entry point for creating navigation renderer test objects.
|
||||
// Called from client_app_delegates.cc.
|
||||
void CreateNavigationRendererTests(ClientApp::RenderDelegateSet& delegates) {
|
||||
void CreateNavigationRendererTests(ClientAppRenderer::DelegateSet& delegates) {
|
||||
delegates.insert(new HistoryNavRendererTest);
|
||||
delegates.insert(new OrderNavRendererTest);
|
||||
delegates.insert(new CrossOriginNavRendererTest);
|
||||
|
@ -16,7 +16,6 @@
|
||||
#include "include/wrapper/cef_closure_task.h"
|
||||
#include "include/wrapper/cef_stream_resource_handler.h"
|
||||
#include "tests/cefclient/browser/resource_util.h"
|
||||
#include "tests/cefclient/common/client_app.h"
|
||||
#include "tests/unittests/routing_test_handler.h"
|
||||
|
||||
#if defined(OS_MACOSX)
|
||||
|
@ -8,11 +8,11 @@
|
||||
#include "include/cef_process_message.h"
|
||||
#include "include/cef_task.h"
|
||||
#include "testing/gtest/include/gtest/gtest.h"
|
||||
#include "tests/cefclient/common/client_app.h"
|
||||
#include "tests/cefclient/renderer/client_app_renderer.h"
|
||||
#include "tests/unittests/test_handler.h"
|
||||
#include "tests/unittests/test_util.h"
|
||||
|
||||
using client::ClientApp;
|
||||
using client::ClientAppRenderer;
|
||||
|
||||
namespace {
|
||||
|
||||
@ -42,12 +42,12 @@ CefRefPtr<CefProcessMessage> CreateTestMessage() {
|
||||
}
|
||||
|
||||
// Renderer side.
|
||||
class SendRecvRendererTest : public ClientApp::RenderDelegate {
|
||||
class SendRecvRendererTest : public ClientAppRenderer::Delegate {
|
||||
public:
|
||||
SendRecvRendererTest() {}
|
||||
|
||||
bool OnProcessMessageReceived(
|
||||
CefRefPtr<ClientApp> app,
|
||||
CefRefPtr<ClientAppRenderer> app,
|
||||
CefRefPtr<CefBrowser> browser,
|
||||
CefProcessId source_process,
|
||||
CefRefPtr<CefProcessMessage> message) override {
|
||||
@ -157,7 +157,7 @@ TEST(ProcessMessageTest, Copy) {
|
||||
// Entry point for creating process message renderer test objects.
|
||||
// Called from client_app_delegates.cc.
|
||||
void CreateProcessMessageRendererTests(
|
||||
ClientApp::RenderDelegateSet& delegates) {
|
||||
ClientAppRenderer::DelegateSet& delegates) {
|
||||
// For ProcessMessageTest.SendRecv
|
||||
delegates.insert(new SendRecvRendererTest);
|
||||
}
|
||||
|
@ -11,10 +11,12 @@
|
||||
#include "include/cef_cookie.h"
|
||||
#include "include/wrapper/cef_closure_task.h"
|
||||
#include "testing/gtest/include/gtest/gtest.h"
|
||||
#include "tests/cefclient/common/client_app.h"
|
||||
#include "tests/cefclient/browser/client_app_browser.h"
|
||||
#include "tests/cefclient/renderer/client_app_renderer.h"
|
||||
#include "tests/unittests/test_handler.h"
|
||||
|
||||
using client::ClientApp;
|
||||
using client::ClientAppBrowser;
|
||||
using client::ClientAppRenderer;
|
||||
|
||||
namespace {
|
||||
|
||||
@ -32,12 +34,12 @@ const char kNetNotifyMsg[] = "RequestHandlerTest.NetNotify";
|
||||
bool g_net_notify_test = false;
|
||||
|
||||
// Browser side.
|
||||
class NetNotifyBrowserTest : public ClientApp::BrowserDelegate {
|
||||
class NetNotifyBrowserTest : public ClientAppBrowser::Delegate {
|
||||
public:
|
||||
NetNotifyBrowserTest() {}
|
||||
|
||||
void OnBeforeChildProcessLaunch(
|
||||
CefRefPtr<ClientApp> app,
|
||||
CefRefPtr<ClientAppBrowser> app,
|
||||
CefRefPtr<CefCommandLine> command_line) override {
|
||||
if (!g_net_notify_test)
|
||||
return;
|
||||
@ -360,14 +362,14 @@ class NetNotifyTestHandler : public TestHandler {
|
||||
};
|
||||
|
||||
// Renderer side.
|
||||
class NetNotifyRendererTest : public ClientApp::RenderDelegate,
|
||||
class NetNotifyRendererTest : public ClientAppRenderer::Delegate,
|
||||
public CefLoadHandler {
|
||||
public:
|
||||
NetNotifyRendererTest()
|
||||
: run_test_(false) {}
|
||||
|
||||
void OnRenderThreadCreated(
|
||||
CefRefPtr<ClientApp> app,
|
||||
CefRefPtr<ClientAppRenderer> app,
|
||||
CefRefPtr<CefListValue> extra_info) override {
|
||||
if (!g_net_notify_test) {
|
||||
// Check that the test should be run.
|
||||
@ -382,7 +384,7 @@ class NetNotifyRendererTest : public ClientApp::RenderDelegate,
|
||||
}
|
||||
|
||||
CefRefPtr<CefLoadHandler> GetLoadHandler(
|
||||
CefRefPtr<ClientApp> app) override {
|
||||
CefRefPtr<ClientAppRenderer> app) override {
|
||||
if (run_test_)
|
||||
return this;
|
||||
return NULL;
|
||||
@ -405,7 +407,7 @@ class NetNotifyRendererTest : public ClientApp::RenderDelegate,
|
||||
}
|
||||
|
||||
bool OnProcessMessageReceived(
|
||||
CefRefPtr<ClientApp> app,
|
||||
CefRefPtr<ClientAppRenderer> app,
|
||||
CefRefPtr<CefBrowser> browser,
|
||||
CefProcessId source_process,
|
||||
CefRefPtr<CefProcessMessage> message) override {
|
||||
@ -506,13 +508,13 @@ TEST(RequestHandlerTest, NotificationsCrossOriginDelayedBrowser) {
|
||||
// Entry point for creating request handler browser test objects.
|
||||
// Called from client_app_delegates.cc.
|
||||
void CreateRequestHandlerBrowserTests(
|
||||
ClientApp::BrowserDelegateSet& delegates) {
|
||||
ClientAppBrowser::DelegateSet& delegates) {
|
||||
delegates.insert(new NetNotifyBrowserTest);
|
||||
}
|
||||
|
||||
// Entry point for creating request handler renderer test objects.
|
||||
// Called from client_app_delegates.cc.
|
||||
void CreateRequestHandlerRendererTests(
|
||||
ClientApp::RenderDelegateSet& delegates) {
|
||||
ClientAppRenderer::DelegateSet& delegates) {
|
||||
delegates.insert(new NetNotifyRendererTest);
|
||||
}
|
||||
|
@ -11,11 +11,11 @@
|
||||
#include "include/cef_request.h"
|
||||
#include "include/wrapper/cef_closure_task.h"
|
||||
#include "testing/gtest/include/gtest/gtest.h"
|
||||
#include "tests/cefclient/common/client_app.h"
|
||||
#include "tests/cefclient/renderer/client_app_renderer.h"
|
||||
#include "tests/unittests/test_handler.h"
|
||||
#include "tests/unittests/test_util.h"
|
||||
|
||||
using client::ClientApp;
|
||||
using client::ClientAppRenderer;
|
||||
|
||||
// Verify Set/Get methods for CefRequest, CefPostData and CefPostDataElement.
|
||||
TEST(RequestTest, SetGet) {
|
||||
@ -352,12 +352,12 @@ class TypeExpectations {
|
||||
};
|
||||
|
||||
// Renderer side.
|
||||
class TypeRendererTest : public ClientApp::RenderDelegate {
|
||||
class TypeRendererTest : public ClientAppRenderer::Delegate {
|
||||
public:
|
||||
TypeRendererTest() :
|
||||
expectations_(false, true) {}
|
||||
|
||||
bool OnBeforeNavigation(CefRefPtr<ClientApp> app,
|
||||
bool OnBeforeNavigation(CefRefPtr<ClientAppRenderer> app,
|
||||
CefRefPtr<CefBrowser> browser,
|
||||
CefRefPtr<CefFrame> frame,
|
||||
CefRefPtr<CefRequest> request,
|
||||
@ -543,6 +543,6 @@ TEST(RequestTest, ResourceAndTransitionType) {
|
||||
|
||||
// Entry point for creating request renderer test objects.
|
||||
// Called from client_app_delegates.cc.
|
||||
void CreateRequestRendererTests(ClientApp::RenderDelegateSet& delegates) {
|
||||
void CreateRequestRendererTests(ClientAppRenderer::DelegateSet& delegates) {
|
||||
delegates.insert(new TypeRendererTest);
|
||||
}
|
||||
|
@ -6,9 +6,9 @@
|
||||
#include "tests/unittests/chromium_includes.h"
|
||||
|
||||
#include "tests/unittests/routing_test_handler.h"
|
||||
#include "tests/cefclient/common/client_app.h"
|
||||
#include "tests/cefclient/renderer/client_app_renderer.h"
|
||||
|
||||
using client::ClientApp;
|
||||
using client::ClientAppRenderer;
|
||||
|
||||
namespace {
|
||||
|
||||
@ -18,25 +18,25 @@ void SetRouterConfig(CefMessageRouterConfig& config) {
|
||||
}
|
||||
|
||||
// Handle the renderer side of the routing implementation.
|
||||
class RoutingRenderDelegate : public ClientApp::RenderDelegate {
|
||||
class RoutingRenderDelegate : public ClientAppRenderer::Delegate {
|
||||
public:
|
||||
RoutingRenderDelegate() {}
|
||||
|
||||
void OnWebKitInitialized(CefRefPtr<ClientApp> app) override {
|
||||
void OnWebKitInitialized(CefRefPtr<ClientAppRenderer> app) override {
|
||||
// Create the renderer-side router for query handling.
|
||||
CefMessageRouterConfig config;
|
||||
SetRouterConfig(config);
|
||||
message_router_ = CefMessageRouterRendererSide::Create(config);
|
||||
}
|
||||
|
||||
void OnContextCreated(CefRefPtr<ClientApp> app,
|
||||
void OnContextCreated(CefRefPtr<ClientAppRenderer> app,
|
||||
CefRefPtr<CefBrowser> browser,
|
||||
CefRefPtr<CefFrame> frame,
|
||||
CefRefPtr<CefV8Context> context) override {
|
||||
message_router_->OnContextCreated(browser, frame, context);
|
||||
}
|
||||
|
||||
void OnContextReleased(CefRefPtr<ClientApp> app,
|
||||
void OnContextReleased(CefRefPtr<ClientAppRenderer> app,
|
||||
CefRefPtr<CefBrowser> browser,
|
||||
CefRefPtr<CefFrame> frame,
|
||||
CefRefPtr<CefV8Context> context) override {
|
||||
@ -44,7 +44,7 @@ class RoutingRenderDelegate : public ClientApp::RenderDelegate {
|
||||
}
|
||||
|
||||
bool OnProcessMessageReceived(
|
||||
CefRefPtr<ClientApp> app,
|
||||
CefRefPtr<ClientAppRenderer> app,
|
||||
CefRefPtr<CefBrowser> browser,
|
||||
CefProcessId source_process,
|
||||
CefRefPtr<CefProcessMessage> message) override {
|
||||
@ -104,6 +104,6 @@ bool RoutingTestHandler::OnProcessMessageReceived(
|
||||
// Entry point for creating the test delegate.
|
||||
// Called from client_app_delegates.cc.
|
||||
void CreateRoutingTestHandlerDelegate(
|
||||
ClientApp::RenderDelegateSet& delegates) {
|
||||
ClientAppRenderer::DelegateSet& delegates) {
|
||||
delegates.insert(new RoutingRenderDelegate);
|
||||
}
|
||||
|
@ -19,7 +19,9 @@
|
||||
#include "include/cef_task.h"
|
||||
#include "include/wrapper/cef_helpers.h"
|
||||
#include "include/wrapper/cef_closure_task.h"
|
||||
#include "tests/cefclient/common/client_app.h"
|
||||
#include "tests/cefclient/browser/client_app_browser.h"
|
||||
#include "tests/cefclient/common/client_app_other.h"
|
||||
#include "tests/cefclient/renderer/client_app_renderer.h"
|
||||
#include "tests/unittests/test_handler.h"
|
||||
#include "tests/unittests/test_suite.h"
|
||||
|
||||
@ -27,8 +29,6 @@
|
||||
#include "include/cef_sandbox_win.h"
|
||||
#endif
|
||||
|
||||
using client::ClientApp;
|
||||
|
||||
namespace {
|
||||
|
||||
// Thread used to run the test suite.
|
||||
@ -109,7 +109,26 @@ int main(int argc, char* argv[]) {
|
||||
windows_sandbox_info = scoped_sandbox.sandbox_info();
|
||||
#endif
|
||||
|
||||
CefRefPtr<CefApp> app(new client::ClientApp);
|
||||
// Parse command-line arguments.
|
||||
CefRefPtr<CefCommandLine> command_line = CefCommandLine::CreateCommandLine();
|
||||
#if defined(OS_WIN)
|
||||
command_line->InitFromString(::GetCommandLineW());
|
||||
#else
|
||||
command_line->InitFromArgv(argc, argv);
|
||||
#endif
|
||||
|
||||
// Create a ClientApp of the correct type.
|
||||
CefRefPtr<CefApp> app;
|
||||
client::ClientApp::ProcessType process_type =
|
||||
client::ClientApp::GetProcessType(command_line);
|
||||
if (process_type == client::ClientApp::BrowserProcess) {
|
||||
app = new client::ClientAppBrowser();
|
||||
} else if (process_type == client::ClientApp::RendererProcess ||
|
||||
process_type == client::ClientApp::ZygoteProcess) {
|
||||
app = new client::ClientAppRenderer();
|
||||
} else if (process_type == client::ClientApp::OtherProcess) {
|
||||
app = new client::ClientAppOther();
|
||||
}
|
||||
|
||||
// Execute the secondary process, if any.
|
||||
int exit_code = CefExecuteProcess(main_args, app, windows_sandbox_info);
|
||||
|
@ -19,11 +19,11 @@
|
||||
#include "include/cef_urlrequest.h"
|
||||
#include "include/wrapper/cef_closure_task.h"
|
||||
#include "testing/gtest/include/gtest/gtest.h"
|
||||
#include "tests/cefclient/common/client_app.h"
|
||||
#include "tests/cefclient/renderer/client_app_renderer.h"
|
||||
#include "tests/unittests/test_handler.h"
|
||||
#include "tests/unittests/test_util.h"
|
||||
|
||||
using client::ClientApp;
|
||||
using client::ClientAppRenderer;
|
||||
|
||||
// How to add a new test:
|
||||
// 1. Add a new value to the RequestTestMode enumeration.
|
||||
@ -844,7 +844,7 @@ class RequestTestRunner {
|
||||
};
|
||||
|
||||
// Renderer side.
|
||||
class RequestRendererTest : public ClientApp::RenderDelegate,
|
||||
class RequestRendererTest : public ClientAppRenderer::Delegate,
|
||||
public RequestTestRunner::Delegate {
|
||||
public:
|
||||
RequestRendererTest()
|
||||
@ -852,7 +852,7 @@ class RequestRendererTest : public ClientApp::RenderDelegate,
|
||||
}
|
||||
|
||||
bool OnProcessMessageReceived(
|
||||
CefRefPtr<ClientApp> app,
|
||||
CefRefPtr<ClientAppRenderer> app,
|
||||
CefRefPtr<CefBrowser> browser,
|
||||
CefProcessId source_process,
|
||||
CefRefPtr<CefProcessMessage> message) override {
|
||||
@ -892,7 +892,7 @@ class RequestRendererTest : public ClientApp::RenderDelegate,
|
||||
browser_ = NULL;
|
||||
}
|
||||
|
||||
CefRefPtr<ClientApp> app_;
|
||||
CefRefPtr<ClientAppRenderer> app_;
|
||||
CefRefPtr<CefBrowser> browser_;
|
||||
|
||||
RequestTestRunner test_runner_;
|
||||
@ -1048,7 +1048,7 @@ class RequestTestHandler : public TestHandler,
|
||||
|
||||
// Entry point for creating URLRequest renderer test objects.
|
||||
// Called from client_app_delegates.cc.
|
||||
void CreateURLRequestRendererTests(ClientApp::RenderDelegateSet& delegates) {
|
||||
void CreateURLRequestRendererTests(ClientAppRenderer::DelegateSet& delegates) {
|
||||
delegates.insert(new RequestRendererTest);
|
||||
}
|
||||
|
||||
|
@ -11,11 +11,13 @@
|
||||
#include "include/cef_task.h"
|
||||
#include "include/cef_v8.h"
|
||||
#include "include/wrapper/cef_closure_task.h"
|
||||
#include "tests/cefclient/common/client_app.h"
|
||||
#include "tests/cefclient/browser/client_app_browser.h"
|
||||
#include "tests/cefclient/renderer/client_app_renderer.h"
|
||||
#include "testing/gtest/include/gtest/gtest.h"
|
||||
#include "tests/unittests/test_handler.h"
|
||||
|
||||
using client::ClientApp;
|
||||
using client::ClientAppBrowser;
|
||||
using client::ClientAppRenderer;
|
||||
|
||||
// How to add a new test:
|
||||
// 1. Add a new value to the V8TestMode enumeration.
|
||||
@ -86,12 +88,12 @@ enum V8TestMode {
|
||||
V8TestMode g_current_test_mode = V8TEST_NONE;
|
||||
|
||||
// Browser side.
|
||||
class V8BrowserTest : public ClientApp::BrowserDelegate {
|
||||
class V8BrowserTest : public ClientAppBrowser::Delegate {
|
||||
public:
|
||||
V8BrowserTest() {}
|
||||
|
||||
void OnBeforeChildProcessLaunch(
|
||||
CefRefPtr<ClientApp> app,
|
||||
CefRefPtr<ClientAppBrowser> app,
|
||||
CefRefPtr<CefCommandLine> command_line) override {
|
||||
CefString process_type = command_line->GetSwitchValue("type");
|
||||
if (process_type == "renderer") {
|
||||
@ -108,7 +110,7 @@ class V8BrowserTest : public ClientApp::BrowserDelegate {
|
||||
|
||||
|
||||
// Renderer side.
|
||||
class V8RendererTest : public ClientApp::RenderDelegate,
|
||||
class V8RendererTest : public ClientAppRenderer::Delegate,
|
||||
public CefLoadHandler {
|
||||
public:
|
||||
V8RendererTest()
|
||||
@ -1699,7 +1701,7 @@ class V8RendererTest : public ClientApp::RenderDelegate,
|
||||
new Handler(&startup_test_success_));
|
||||
}
|
||||
|
||||
void OnBrowserCreated(CefRefPtr<ClientApp> app,
|
||||
void OnBrowserCreated(CefRefPtr<ClientAppRenderer> app,
|
||||
CefRefPtr<CefBrowser> browser) override {
|
||||
test_mode_ = g_current_test_mode;
|
||||
if (test_mode_ == V8TEST_NONE) {
|
||||
@ -1714,7 +1716,8 @@ class V8RendererTest : public ClientApp::RenderDelegate,
|
||||
RunStartupTest();
|
||||
}
|
||||
|
||||
CefRefPtr<CefLoadHandler> GetLoadHandler(CefRefPtr<ClientApp> app) override {
|
||||
CefRefPtr<CefLoadHandler> GetLoadHandler(
|
||||
CefRefPtr<ClientAppRenderer> app) override {
|
||||
if (test_mode_ == V8TEST_NONE)
|
||||
return NULL;
|
||||
|
||||
@ -1730,7 +1733,7 @@ class V8RendererTest : public ClientApp::RenderDelegate,
|
||||
}
|
||||
}
|
||||
|
||||
void OnContextCreated(CefRefPtr<ClientApp> app,
|
||||
void OnContextCreated(CefRefPtr<ClientAppRenderer> app,
|
||||
CefRefPtr<CefBrowser> browser,
|
||||
CefRefPtr<CefFrame> frame,
|
||||
CefRefPtr<CefV8Context> context) override {
|
||||
@ -1806,7 +1809,7 @@ class V8RendererTest : public ClientApp::RenderDelegate,
|
||||
}
|
||||
}
|
||||
|
||||
void OnContextReleased(CefRefPtr<ClientApp> app,
|
||||
void OnContextReleased(CefRefPtr<ClientAppRenderer> app,
|
||||
CefRefPtr<CefBrowser> browser,
|
||||
CefRefPtr<CefFrame> frame,
|
||||
CefRefPtr<CefV8Context> context) override {
|
||||
@ -1822,7 +1825,7 @@ class V8RendererTest : public ClientApp::RenderDelegate,
|
||||
}
|
||||
}
|
||||
|
||||
void OnUncaughtException(CefRefPtr<ClientApp> app,
|
||||
void OnUncaughtException(CefRefPtr<ClientAppRenderer> app,
|
||||
CefRefPtr<CefBrowser> browser,
|
||||
CefRefPtr<CefFrame> frame,
|
||||
CefRefPtr<CefV8Context> context,
|
||||
@ -1851,7 +1854,7 @@ class V8RendererTest : public ClientApp::RenderDelegate,
|
||||
}
|
||||
}
|
||||
|
||||
bool OnProcessMessageReceived(CefRefPtr<ClientApp> app,
|
||||
bool OnProcessMessageReceived(CefRefPtr<ClientAppRenderer> app,
|
||||
CefRefPtr<CefBrowser> browser,
|
||||
CefProcessId source_process,
|
||||
CefRefPtr<CefProcessMessage> message) override {
|
||||
@ -1967,7 +1970,7 @@ class V8RendererTest : public ClientApp::RenderDelegate,
|
||||
return context;
|
||||
}
|
||||
|
||||
CefRefPtr<ClientApp> app_;
|
||||
CefRefPtr<ClientAppRenderer> app_;
|
||||
CefRefPtr<CefBrowser> browser_;
|
||||
V8TestMode test_mode_;
|
||||
|
||||
@ -2096,13 +2099,13 @@ class V8TestHandler : public TestHandler {
|
||||
|
||||
// Entry point for creating V8 browser test objects.
|
||||
// Called from client_app_delegates.cc.
|
||||
void CreateV8BrowserTests(ClientApp::BrowserDelegateSet& delegates) {
|
||||
void CreateV8BrowserTests(ClientAppBrowser::DelegateSet& delegates) {
|
||||
delegates.insert(new V8BrowserTest);
|
||||
}
|
||||
|
||||
// Entry point for creating V8 renderer test objects.
|
||||
// Called from client_app_delegates.cc.
|
||||
void CreateV8RendererTests(ClientApp::RenderDelegateSet& delegates) {
|
||||
void CreateV8RendererTests(ClientAppRenderer::DelegateSet& delegates) {
|
||||
delegates.insert(new V8RendererTest);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user