2013-01-03 18:24:24 +01:00
|
|
|
// Copyright (c) 2013 The Chromium Embedded Framework Authors. All rights
|
2012-04-03 03:34:16 +02:00
|
|
|
// reserved. Use of this source code is governed by a BSD-style license that
|
|
|
|
// can be found in the LICENSE file.
|
|
|
|
|
2012-04-12 22:21:50 +02:00
|
|
|
#ifndef CEF_TESTS_CEFCLIENT_CLIENT_APP_H_
|
|
|
|
#define CEF_TESTS_CEFCLIENT_CLIENT_APP_H_
|
2012-04-03 03:34:16 +02:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <map>
|
|
|
|
#include <set>
|
|
|
|
#include <string>
|
|
|
|
#include <utility>
|
2012-06-19 18:29:49 +02:00
|
|
|
#include <vector>
|
2012-04-03 03:34:16 +02:00
|
|
|
#include "include/cef_app.h"
|
|
|
|
|
2012-04-12 22:21:50 +02:00
|
|
|
class ClientApp : public CefApp,
|
2012-06-19 18:29:49 +02:00
|
|
|
public CefBrowserProcessHandler,
|
2012-04-12 22:21:50 +02:00
|
|
|
public CefRenderProcessHandler {
|
2012-04-03 03:34:16 +02:00
|
|
|
public:
|
2012-09-28 19:11:10 +02:00
|
|
|
// Interface for browser delegates. All BrowserDelegates must be returned via
|
|
|
|
// CreateBrowserDelegates. Do not perform work in the BrowserDelegate
|
2013-01-03 18:24:24 +01:00
|
|
|
// constructor. See CefBrowserProcessHandler for documentation.
|
2012-09-28 19:11:10 +02:00
|
|
|
class BrowserDelegate : public virtual CefBase {
|
|
|
|
public:
|
2013-01-03 18:24:24 +01:00
|
|
|
virtual void OnContextInitialized(CefRefPtr<ClientApp> app) {}
|
2012-09-28 19:11:10 +02:00
|
|
|
|
|
|
|
virtual void OnBeforeChildProcessLaunch(
|
|
|
|
CefRefPtr<ClientApp> app,
|
2013-01-03 18:24:24 +01:00
|
|
|
CefRefPtr<CefCommandLine> command_line) {}
|
2012-11-20 21:08:36 +01:00
|
|
|
|
|
|
|
virtual void OnRenderProcessThreadCreated(
|
|
|
|
CefRefPtr<ClientApp> app,
|
2013-01-03 18:24:24 +01:00
|
|
|
CefRefPtr<CefListValue> extra_info) {}
|
2012-09-28 19:11:10 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
typedef std::set<CefRefPtr<BrowserDelegate> > BrowserDelegateSet;
|
|
|
|
|
2012-04-12 22:21:50 +02:00
|
|
|
// Interface for renderer delegates. All RenderDelegates must be returned via
|
|
|
|
// CreateRenderDelegates. Do not perform work in the RenderDelegate
|
2013-01-03 18:24:24 +01:00
|
|
|
// constructor. See CefRenderProcessHandler for documentation.
|
2012-04-12 22:21:50 +02:00
|
|
|
class RenderDelegate : public virtual CefBase {
|
2012-04-03 03:34:16 +02:00
|
|
|
public:
|
2012-11-20 21:08:36 +01:00
|
|
|
virtual void OnRenderThreadCreated(CefRefPtr<ClientApp> app,
|
2013-01-03 18:24:24 +01:00
|
|
|
CefRefPtr<CefListValue> extra_info) {}
|
2012-08-29 00:26:35 +02:00
|
|
|
|
2013-01-03 18:24:24 +01:00
|
|
|
virtual void OnWebKitInitialized(CefRefPtr<ClientApp> app) {}
|
2012-04-03 03:34:16 +02:00
|
|
|
|
2012-11-09 19:47:09 +01:00
|
|
|
virtual void OnBrowserCreated(CefRefPtr<ClientApp> app,
|
2013-01-03 18:24:24 +01:00
|
|
|
CefRefPtr<CefBrowser> browser) {}
|
2012-11-09 19:47:09 +01:00
|
|
|
|
2012-11-02 19:16:28 +01:00
|
|
|
virtual void OnBrowserDestroyed(CefRefPtr<ClientApp> app,
|
2013-01-03 18:24:24 +01:00
|
|
|
CefRefPtr<CefBrowser> browser) {}
|
2012-11-02 19:16:28 +01:00
|
|
|
|
2013-09-13 01:36:54 +02:00
|
|
|
virtual CefRefPtr<CefLoadHandler> GetLoadHandler(CefRefPtr<ClientApp> app) {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2013-11-21 21:59:28 +01:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2012-04-12 22:21:50 +02:00
|
|
|
virtual void OnContextCreated(CefRefPtr<ClientApp> app,
|
2012-04-03 03:34:16 +02:00
|
|
|
CefRefPtr<CefBrowser> browser,
|
|
|
|
CefRefPtr<CefFrame> frame,
|
2013-01-03 18:24:24 +01:00
|
|
|
CefRefPtr<CefV8Context> context) {}
|
2012-04-03 03:34:16 +02:00
|
|
|
|
2012-04-12 22:21:50 +02:00
|
|
|
virtual void OnContextReleased(CefRefPtr<ClientApp> app,
|
2012-04-03 03:34:16 +02:00
|
|
|
CefRefPtr<CefBrowser> browser,
|
|
|
|
CefRefPtr<CefFrame> frame,
|
2013-01-03 18:24:24 +01:00
|
|
|
CefRefPtr<CefV8Context> context) {}
|
2012-04-03 03:34:16 +02:00
|
|
|
|
2012-11-02 19:16:28 +01:00
|
|
|
virtual void OnUncaughtException(CefRefPtr<ClientApp> app,
|
|
|
|
CefRefPtr<CefBrowser> browser,
|
|
|
|
CefRefPtr<CefFrame> frame,
|
|
|
|
CefRefPtr<CefV8Context> context,
|
|
|
|
CefRefPtr<CefV8Exception> exception,
|
2013-01-03 18:24:24 +01:00
|
|
|
CefRefPtr<CefV8StackTrace> stackTrace) {}
|
|
|
|
|
2012-06-11 17:52:49 +02:00
|
|
|
virtual void OnFocusedNodeChanged(CefRefPtr<ClientApp> app,
|
|
|
|
CefRefPtr<CefBrowser> browser,
|
|
|
|
CefRefPtr<CefFrame> frame,
|
2013-01-03 18:24:24 +01:00
|
|
|
CefRefPtr<CefDOMNode> node) {}
|
2012-06-11 17:52:49 +02:00
|
|
|
|
2012-04-03 03:34:16 +02:00
|
|
|
// Called when a process message is received. Return true if the message was
|
2012-04-12 22:21:50 +02:00
|
|
|
// handled and should not be passed on to other handlers. RenderDelegates
|
|
|
|
// should check for unique message names to avoid interfering with each
|
|
|
|
// other.
|
2012-06-11 22:03:49 +02:00
|
|
|
virtual bool OnProcessMessageReceived(
|
2012-04-12 22:21:50 +02:00
|
|
|
CefRefPtr<ClientApp> app,
|
2012-04-03 03:34:16 +02:00
|
|
|
CefRefPtr<CefBrowser> browser,
|
|
|
|
CefProcessId source_process,
|
|
|
|
CefRefPtr<CefProcessMessage> message) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2012-04-12 22:21:50 +02:00
|
|
|
typedef std::set<CefRefPtr<RenderDelegate> > RenderDelegateSet;
|
|
|
|
|
|
|
|
ClientApp();
|
2012-04-03 03:34:16 +02:00
|
|
|
|
|
|
|
private:
|
2012-09-28 19:11:10 +02:00
|
|
|
// Creates all of the BrowserDelegate objects. Implemented in
|
|
|
|
// client_app_delegates.
|
|
|
|
static void CreateBrowserDelegates(BrowserDelegateSet& delegates);
|
|
|
|
|
2012-04-12 22:21:50 +02:00
|
|
|
// Creates all of the RenderDelegate objects. Implemented in
|
|
|
|
// client_app_delegates.
|
|
|
|
static void CreateRenderDelegates(RenderDelegateSet& delegates);
|
2012-04-03 03:34:16 +02:00
|
|
|
|
2012-04-24 20:01:48 +02:00
|
|
|
// Registers custom schemes. Implemented in client_app_delegates.
|
2012-06-19 18:29:49 +02:00
|
|
|
static void RegisterCustomSchemes(CefRefPtr<CefSchemeRegistrar> registrar,
|
|
|
|
std::vector<CefString>& cookiable_schemes);
|
2012-04-24 20:01:48 +02:00
|
|
|
|
2012-04-03 03:34:16 +02:00
|
|
|
// CefApp methods.
|
2012-04-24 20:01:48 +02:00
|
|
|
virtual void OnRegisterCustomSchemes(
|
2014-01-28 00:31:03 +01:00
|
|
|
CefRefPtr<CefSchemeRegistrar> registrar) OVERRIDE;
|
2012-06-19 18:29:49 +02:00
|
|
|
virtual CefRefPtr<CefBrowserProcessHandler> GetBrowserProcessHandler()
|
|
|
|
OVERRIDE { return this; }
|
2012-04-03 03:34:16 +02:00
|
|
|
virtual CefRefPtr<CefRenderProcessHandler> GetRenderProcessHandler()
|
|
|
|
OVERRIDE { return this; }
|
2012-06-19 18:29:49 +02:00
|
|
|
|
|
|
|
// CefBrowserProcessHandler methods.
|
2012-09-28 19:11:10 +02:00
|
|
|
virtual void OnContextInitialized() OVERRIDE;
|
|
|
|
virtual void OnBeforeChildProcessLaunch(
|
|
|
|
CefRefPtr<CefCommandLine> command_line) OVERRIDE;
|
2012-11-20 21:08:36 +01:00
|
|
|
virtual void OnRenderProcessThreadCreated(CefRefPtr<CefListValue> extra_info)
|
|
|
|
OVERRIDE;
|
2012-04-03 03:34:16 +02:00
|
|
|
|
|
|
|
// CefRenderProcessHandler methods.
|
2012-11-20 21:08:36 +01:00
|
|
|
virtual void OnRenderThreadCreated(CefRefPtr<CefListValue> extra_info)
|
|
|
|
OVERRIDE;
|
2012-04-03 03:34:16 +02:00
|
|
|
virtual void OnWebKitInitialized() OVERRIDE;
|
2012-11-09 19:47:09 +01:00
|
|
|
virtual void OnBrowserCreated(CefRefPtr<CefBrowser> browser) OVERRIDE;
|
2012-11-02 19:16:28 +01:00
|
|
|
virtual void OnBrowserDestroyed(CefRefPtr<CefBrowser> browser) OVERRIDE;
|
2013-09-13 01:36:54 +02:00
|
|
|
virtual CefRefPtr<CefLoadHandler> GetLoadHandler() OVERRIDE;
|
2013-11-21 21:59:28 +01:00
|
|
|
virtual bool OnBeforeNavigation(CefRefPtr<CefBrowser> browser,
|
|
|
|
CefRefPtr<CefFrame> frame,
|
|
|
|
CefRefPtr<CefRequest> request,
|
|
|
|
NavigationType navigation_type,
|
|
|
|
bool is_redirect) OVERRIDE;
|
2012-04-03 03:34:16 +02:00
|
|
|
virtual void OnContextCreated(CefRefPtr<CefBrowser> browser,
|
|
|
|
CefRefPtr<CefFrame> frame,
|
|
|
|
CefRefPtr<CefV8Context> context) OVERRIDE;
|
|
|
|
virtual void OnContextReleased(CefRefPtr<CefBrowser> browser,
|
|
|
|
CefRefPtr<CefFrame> frame,
|
|
|
|
CefRefPtr<CefV8Context> context) OVERRIDE;
|
2012-11-02 19:16:28 +01:00
|
|
|
virtual void OnUncaughtException(CefRefPtr<CefBrowser> browser,
|
|
|
|
CefRefPtr<CefFrame> frame,
|
|
|
|
CefRefPtr<CefV8Context> context,
|
|
|
|
CefRefPtr<CefV8Exception> exception,
|
|
|
|
CefRefPtr<CefV8StackTrace> stackTrace)
|
|
|
|
OVERRIDE;
|
2012-06-11 17:52:49 +02:00
|
|
|
virtual void OnFocusedNodeChanged(CefRefPtr<CefBrowser> browser,
|
|
|
|
CefRefPtr<CefFrame> frame,
|
|
|
|
CefRefPtr<CefDOMNode> node) OVERRIDE;
|
2012-06-11 22:03:49 +02:00
|
|
|
virtual bool OnProcessMessageReceived(
|
2012-04-03 03:34:16 +02:00
|
|
|
CefRefPtr<CefBrowser> browser,
|
|
|
|
CefProcessId source_process,
|
|
|
|
CefRefPtr<CefProcessMessage> message) OVERRIDE;
|
|
|
|
|
2014-01-28 00:31:03 +01:00
|
|
|
// Set of supported BrowserDelegates. Only used in the browser process.
|
2012-09-28 19:11:10 +02:00
|
|
|
BrowserDelegateSet browser_delegates_;
|
|
|
|
|
2014-01-28 00:31:03 +01:00
|
|
|
// Set of supported RenderDelegates. Only used in the renderer process.
|
2012-04-12 22:21:50 +02:00
|
|
|
RenderDelegateSet render_delegates_;
|
2012-04-03 03:34:16 +02:00
|
|
|
|
2014-01-28 00:31:03 +01:00
|
|
|
// Schemes that will be registered with the global cookie manager. Used in
|
|
|
|
// both the browser and renderer process.
|
2012-06-19 18:29:49 +02:00
|
|
|
std::vector<CefString> cookieable_schemes_;
|
|
|
|
|
2012-04-12 22:21:50 +02:00
|
|
|
IMPLEMENT_REFCOUNTING(ClientApp);
|
2012-04-03 03:34:16 +02:00
|
|
|
};
|
|
|
|
|
2012-04-12 22:21:50 +02:00
|
|
|
#endif // CEF_TESTS_CEFCLIENT_CLIENT_APP_H_
|