-
Notifications
You must be signed in to change notification settings - Fork 68
/
app_renderer_impl.cc
64 lines (49 loc) · 2.05 KB
/
app_renderer_impl.cc
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
// Copyright (c) 2017 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.
#include "examples/shared/app_factory.h"
#include "include/wrapper/cef_message_router.h"
namespace message_router {
// Implementation of CefApp for the renderer process.
class RendererApp : public CefApp, public CefRenderProcessHandler {
public:
RendererApp() {}
// CefApp methods:
CefRefPtr<CefRenderProcessHandler> GetRenderProcessHandler() override {
return this;
}
// CefRenderProcessHandler methods:
void OnWebKitInitialized() override {
// Create the renderer-side router for query handling.
CefMessageRouterConfig config;
message_router_ = CefMessageRouterRendererSide::Create(config);
}
void OnContextCreated(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
CefRefPtr<CefV8Context> context) override {
message_router_->OnContextCreated(browser, frame, context);
}
void OnContextReleased(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
CefRefPtr<CefV8Context> context) override {
message_router_->OnContextReleased(browser, frame, context);
}
bool OnProcessMessageReceived(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
CefProcessId source_process,
CefRefPtr<CefProcessMessage> message) override {
return message_router_->OnProcessMessageReceived(browser, frame,
source_process, message);
}
private:
// Handles the renderer side of query routing.
CefRefPtr<CefMessageRouterRendererSide> message_router_;
IMPLEMENT_REFCOUNTING(RendererApp);
DISALLOW_COPY_AND_ASSIGN(RendererApp);
};
} // namespace message_router
namespace shared {
CefRefPtr<CefApp> CreateRendererProcessApp() {
return new message_router::RendererApp();
}
} // namespace shared