browser_app.cpp
2.78 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
#include "stdafx.h"
#include "etradeclient/browser/browser_app.h"
#include <algorithm>
#include "include/wrapper/cef_helpers.h"
BrowserApp::BrowserApp()
{}
BrowserApp::~BrowserApp()
{}
CefRefPtr<CefBrowserProcessHandler> BrowserApp::GetBrowserProcessHandler()
{
return this;
}
CefRefPtr<CefRenderProcessHandler> BrowserApp::GetRenderProcessHandler()
{
return this;
}
// Called on the browser process UI thread immediately after the CEF context has been initialized.
void BrowserApp::OnContextInitialized()
{
CEF_REQUIRE_UI_THREAD()
}
void BrowserApp::OnRenderThreadCreated(CefRefPtr<CefListValue> extra_info)
{
RenderDelegate::CreateRenderDelegates(m_browser_render_delegates);
for (const auto& render : m_browser_render_delegates)
render->OnRenderThreadCreated(this, extra_info);
}
void BrowserApp::OnWebKitInitialized()
{
for (const auto& render : m_browser_render_delegates)
render->OnWebKitInitialized(this);
}
void BrowserApp::OnBrowserCreated(CefRefPtr<CefBrowser> browser)
{
for (const auto& render : m_browser_render_delegates)
render->OnBrowserCreated(this, browser);
}
void BrowserApp::OnBrowserDestroyed(CefRefPtr<CefBrowser> browser)
{
for (const auto& render : m_browser_render_delegates)
render->OnBrowserDestroyed(this, browser);
}
void BrowserApp::OnContextCreated(CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame, CefRefPtr<CefV8Context> context)
{
for (const auto& render : m_browser_render_delegates)
render->OnContextCreated(this, browser, frame, context);
}
void BrowserApp::OnContextReleased(CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame, CefRefPtr<CefV8Context> context)
{
for (const auto& render : m_browser_render_delegates)
render->OnContextReleased(this, browser, frame, context);
}
void BrowserApp::OnUncaughtException(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
CefRefPtr<CefV8Context> context,
CefRefPtr<CefV8Exception> exception,
CefRefPtr<CefV8StackTrace> stackTrace)
{
for (const auto& render : m_browser_render_delegates)
render->OnUncaughtException(this, browser, frame, context, exception, stackTrace);
}
bool BrowserApp::OnProcessMessageReceived(CefRefPtr<CefBrowser> browser, CefProcessId source_process, CefRefPtr<CefProcessMessage> message)
{
DCHECK_EQ(source_process, PID_BROWSER);
bool handled = false;
// TODO: Study the mechanism of OnProcessMessageReceived and refactor this code.
RenderDelegate::BrowserRenderSet::iterator it = m_browser_render_delegates.begin();
for (; it != m_browser_render_delegates.end() && !handled; ++it)
{
handled = (*it)->OnProcessMessageReceived(this, browser, source_process, message);
}
return handled;
}
void BrowserApp::CreateRenderDelegates(BrowserRenderDelegateSetT& delegates)
{
RenderDelegate::CreateRenderDelegates(delegates);
}