render_delegate.cpp
3.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
#include "stdafx.h"
#include "etradeclient/browser/render_delegate.h"
#include "include/cef_values.h"
#include "include/cef_browser.h"
#include "include/cef_load_handler.h"
#include "etradeclient/browser/browser_app.h"
#include "etradeclient/browser/main_view_browser_handler.h"
namespace RenderDelegate
{
void BrowserRender::OnRenderThreadCreated(CefRefPtr<BrowserApp> app, CefRefPtr<CefListValue> extra_info)
{}
void BrowserRender::OnWebKitInitialized(CefRefPtr<BrowserApp> app)
{}
void BrowserRender::OnBrowserCreated(CefRefPtr<BrowserApp> app, CefRefPtr<CefBrowser> browser)
{}
void BrowserRender::OnBrowserDestroyed(CefRefPtr<BrowserApp> app, CefRefPtr<CefBrowser> browser)
{}
CefRefPtr<CefLoadHandler> BrowserRender::GetLoadHandler(CefRefPtr<BrowserApp> app)
{
return NULL;
}
bool BrowserRender::OnBeforeNavigation(CefRefPtr<BrowserApp> app,
CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
CefRefPtr<CefRequest> request,
cef_navigation_type_t navigation_type,
bool is_redirect)
{
return false;
}
void BrowserRender::OnContextCreated(CefRefPtr<BrowserApp> app,
CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
CefRefPtr<CefV8Context> context)
{}
void BrowserRender::OnContextReleased(CefRefPtr<BrowserApp> app,
CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
CefRefPtr<CefV8Context> context)
{}
void BrowserRender::OnUncaughtException(CefRefPtr<BrowserApp> app,
CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
CefRefPtr<CefV8Context> context,
CefRefPtr<CefV8Exception> exception,
CefRefPtr<CefV8StackTrace> stackTrace)
{}
// 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.
bool BrowserRender::OnProcessMessageReceived(CefRefPtr<BrowserApp> app,
CefRefPtr<CefBrowser> browser,
CefProcessId source_process,
CefRefPtr<CefProcessMessage> message)
{
return false;
}
class BrowserRenderDelegate : public BrowserRender
{
public:
BrowserRenderDelegate()
{}
virtual void OnWebKitInitialized(CefRefPtr<BrowserApp> app) OVERRIDE
{
// Create the renderer-side router for query handling.
CefMessageRouterConfig config;
m_msg_router = CefMessageRouterRendererSide::Create(config);
}
virtual void OnContextCreated(CefRefPtr<BrowserApp> app,
CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
CefRefPtr<CefV8Context> context) OVERRIDE
{
m_msg_router->OnContextCreated(browser, frame, context);
}
virtual void OnContextReleased(CefRefPtr<BrowserApp> app,
CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
CefRefPtr<CefV8Context> context) OVERRIDE
{
m_msg_router->OnContextReleased(browser, frame, context);
}
virtual bool OnProcessMessageReceived(CefRefPtr<BrowserApp> app,
CefRefPtr<CefBrowser> browser,
CefProcessId source_process,
CefRefPtr<CefProcessMessage> message) OVERRIDE
{
return m_msg_router->OnProcessMessageReceived(browser, source_process, message);
}
private:
// Handles the renderer side of query routing.
CefRefPtr<CefMessageRouterRendererSide> m_msg_router;
IMPLEMENT_REFCOUNTING(BrowserRenderDelegate);
};
void CreateRenderDelegates(BrowserRenderSet& delegates)
{
delegates.insert(new BrowserRenderDelegate);
}
} // RenderDelegate