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:
@@ -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
|
||||
|
Reference in New Issue
Block a user