2015-01-31 05:41:36 +01:00
|
|
|
// Copyright (c) 2013 The Chromium Embedded Framework Authors. All rights
|
|
|
|
// reserved. Use of this source code is governed by a BSD-style license that
|
|
|
|
// can be found in the LICENSE file.
|
|
|
|
|
2016-11-18 00:52:42 +01:00
|
|
|
#ifndef CEF_TESTS_SHARED_RENDERER_CLIENT_APP_RENDERER_H_
|
|
|
|
#define CEF_TESTS_SHARED_RENDERER_CLIENT_APP_RENDERER_H_
|
2015-01-31 05:41:36 +01:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <set>
|
|
|
|
|
2016-11-18 00:52:42 +01:00
|
|
|
#include "tests/shared/common/client_app.h"
|
2015-01-31 05:41:36 +01:00
|
|
|
|
|
|
|
namespace client {
|
|
|
|
|
|
|
|
// Client app implementation for the renderer process.
|
2017-05-17 11:29:28 +02:00
|
|
|
class ClientAppRenderer : public ClientApp, public CefRenderProcessHandler {
|
2015-01-31 05:41:36 +01:00
|
|
|
public:
|
|
|
|
// Interface for renderer delegates. All Delegates must be returned via
|
|
|
|
// CreateDelegates. Do not perform work in the Delegate
|
|
|
|
// constructor. See CefRenderProcessHandler for documentation.
|
2017-02-09 23:07:43 +01:00
|
|
|
class Delegate : public virtual CefBaseRefCounted {
|
2015-01-31 05:41:36 +01:00
|
|
|
public:
|
|
|
|
virtual void OnWebKitInitialized(CefRefPtr<ClientAppRenderer> app) {}
|
|
|
|
|
|
|
|
virtual void OnBrowserCreated(CefRefPtr<ClientAppRenderer> app,
|
2019-03-19 10:42:54 +01:00
|
|
|
CefRefPtr<CefBrowser> browser,
|
|
|
|
CefRefPtr<CefDictionaryValue> extra_info) {}
|
2015-01-31 05:41:36 +01:00
|
|
|
|
|
|
|
virtual void OnBrowserDestroyed(CefRefPtr<ClientAppRenderer> app,
|
|
|
|
CefRefPtr<CefBrowser> browser) {}
|
|
|
|
|
|
|
|
virtual CefRefPtr<CefLoadHandler> GetLoadHandler(
|
|
|
|
CefRefPtr<ClientAppRenderer> app) {
|
2020-01-15 15:28:12 +01:00
|
|
|
return nullptr;
|
2015-01-31 05:41:36 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
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,
|
2019-05-24 22:23:43 +02:00
|
|
|
CefRefPtr<CefFrame> frame,
|
2015-01-31 05:41:36 +01:00
|
|
|
CefProcessId source_process,
|
|
|
|
CefRefPtr<CefProcessMessage> message) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2017-05-17 11:29:28 +02:00
|
|
|
typedef std::set<CefRefPtr<Delegate>> DelegateSet;
|
2015-01-31 05:41:36 +01:00
|
|
|
|
|
|
|
ClientAppRenderer();
|
|
|
|
|
|
|
|
private:
|
2015-02-03 00:18:16 +01:00
|
|
|
// Creates all of the Delegate objects. Implemented by cefclient in
|
|
|
|
// client_app_delegates_renderer.cc
|
2015-01-31 05:41:36 +01:00
|
|
|
static void CreateDelegates(DelegateSet& delegates);
|
|
|
|
|
|
|
|
// CefApp methods.
|
2021-06-17 21:43:06 +02:00
|
|
|
CefRefPtr<CefRenderProcessHandler> GetRenderProcessHandler() override {
|
2015-01-31 05:41:36 +01:00
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
// CefRenderProcessHandler methods.
|
2021-06-17 21:43:06 +02:00
|
|
|
void OnWebKitInitialized() override;
|
2019-03-19 10:42:54 +01:00
|
|
|
void OnBrowserCreated(CefRefPtr<CefBrowser> browser,
|
2021-06-17 21:43:06 +02:00
|
|
|
CefRefPtr<CefDictionaryValue> extra_info) override;
|
|
|
|
void OnBrowserDestroyed(CefRefPtr<CefBrowser> browser) override;
|
|
|
|
CefRefPtr<CefLoadHandler> GetLoadHandler() override;
|
2015-01-31 05:41:36 +01:00
|
|
|
void OnContextCreated(CefRefPtr<CefBrowser> browser,
|
|
|
|
CefRefPtr<CefFrame> frame,
|
2021-06-17 21:43:06 +02:00
|
|
|
CefRefPtr<CefV8Context> context) override;
|
2015-01-31 05:41:36 +01:00
|
|
|
void OnContextReleased(CefRefPtr<CefBrowser> browser,
|
|
|
|
CefRefPtr<CefFrame> frame,
|
2021-06-17 21:43:06 +02:00
|
|
|
CefRefPtr<CefV8Context> context) override;
|
2015-01-31 05:41:36 +01:00
|
|
|
void OnUncaughtException(CefRefPtr<CefBrowser> browser,
|
|
|
|
CefRefPtr<CefFrame> frame,
|
|
|
|
CefRefPtr<CefV8Context> context,
|
|
|
|
CefRefPtr<CefV8Exception> exception,
|
2021-06-17 21:43:06 +02:00
|
|
|
CefRefPtr<CefV8StackTrace> stackTrace) override;
|
2015-01-31 05:41:36 +01:00
|
|
|
void OnFocusedNodeChanged(CefRefPtr<CefBrowser> browser,
|
|
|
|
CefRefPtr<CefFrame> frame,
|
2021-06-17 21:43:06 +02:00
|
|
|
CefRefPtr<CefDOMNode> node) override;
|
2017-05-17 11:29:28 +02:00
|
|
|
bool OnProcessMessageReceived(CefRefPtr<CefBrowser> browser,
|
2019-05-24 22:23:43 +02:00
|
|
|
CefRefPtr<CefFrame> frame,
|
2017-05-17 11:29:28 +02:00
|
|
|
CefProcessId source_process,
|
2021-06-17 21:43:06 +02:00
|
|
|
CefRefPtr<CefProcessMessage> message) override;
|
2015-01-31 05:41:36 +01:00
|
|
|
|
|
|
|
private:
|
|
|
|
// Set of supported Delegates.
|
|
|
|
DelegateSet delegates_;
|
|
|
|
|
|
|
|
IMPLEMENT_REFCOUNTING(ClientAppRenderer);
|
|
|
|
DISALLOW_COPY_AND_ASSIGN(ClientAppRenderer);
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace client
|
|
|
|
|
2016-11-18 00:52:42 +01:00
|
|
|
#endif // CEF_TESTS_SHARED_RENDERER_CLIENT_APP_RENDERER_H_
|