1 // Copyright (c) 2013 The Chromium Embedded Framework Authors. All rights
2 // reserved. Use of this source code is governed by a BSD-style license that
3 // can be found in the LICENSE file.
4
5 #include "tests/shared/renderer/client_app_renderer.h"
6
7 #include "include/base/cef_logging.h"
8
9 namespace client {
10
ClientAppRenderer()11 ClientAppRenderer::ClientAppRenderer() {
12 CreateDelegates(delegates_);
13 }
14
OnWebKitInitialized()15 void ClientAppRenderer::OnWebKitInitialized() {
16 DelegateSet::iterator it = delegates_.begin();
17 for (; it != delegates_.end(); ++it)
18 (*it)->OnWebKitInitialized(this);
19 }
20
OnBrowserCreated(CefRefPtr<CefBrowser> browser,CefRefPtr<CefDictionaryValue> extra_info)21 void ClientAppRenderer::OnBrowserCreated(
22 CefRefPtr<CefBrowser> browser,
23 CefRefPtr<CefDictionaryValue> extra_info) {
24 DelegateSet::iterator it = delegates_.begin();
25 for (; it != delegates_.end(); ++it)
26 (*it)->OnBrowserCreated(this, browser, extra_info);
27 }
28
OnBrowserDestroyed(CefRefPtr<CefBrowser> browser)29 void ClientAppRenderer::OnBrowserDestroyed(CefRefPtr<CefBrowser> browser) {
30 DelegateSet::iterator it = delegates_.begin();
31 for (; it != delegates_.end(); ++it)
32 (*it)->OnBrowserDestroyed(this, browser);
33 }
34
GetLoadHandler()35 CefRefPtr<CefLoadHandler> ClientAppRenderer::GetLoadHandler() {
36 CefRefPtr<CefLoadHandler> load_handler;
37 DelegateSet::iterator it = delegates_.begin();
38 for (; it != delegates_.end() && !load_handler.get(); ++it)
39 load_handler = (*it)->GetLoadHandler(this);
40
41 return load_handler;
42 }
43
OnContextCreated(CefRefPtr<CefBrowser> browser,CefRefPtr<CefFrame> frame,CefRefPtr<CefV8Context> context)44 void ClientAppRenderer::OnContextCreated(CefRefPtr<CefBrowser> browser,
45 CefRefPtr<CefFrame> frame,
46 CefRefPtr<CefV8Context> context) {
47 DelegateSet::iterator it = delegates_.begin();
48 for (; it != delegates_.end(); ++it)
49 (*it)->OnContextCreated(this, browser, frame, context);
50 }
51
OnContextReleased(CefRefPtr<CefBrowser> browser,CefRefPtr<CefFrame> frame,CefRefPtr<CefV8Context> context)52 void ClientAppRenderer::OnContextReleased(CefRefPtr<CefBrowser> browser,
53 CefRefPtr<CefFrame> frame,
54 CefRefPtr<CefV8Context> context) {
55 DelegateSet::iterator it = delegates_.begin();
56 for (; it != delegates_.end(); ++it)
57 (*it)->OnContextReleased(this, browser, frame, context);
58 }
59
OnUncaughtException(CefRefPtr<CefBrowser> browser,CefRefPtr<CefFrame> frame,CefRefPtr<CefV8Context> context,CefRefPtr<CefV8Exception> exception,CefRefPtr<CefV8StackTrace> stackTrace)60 void ClientAppRenderer::OnUncaughtException(
61 CefRefPtr<CefBrowser> browser,
62 CefRefPtr<CefFrame> frame,
63 CefRefPtr<CefV8Context> context,
64 CefRefPtr<CefV8Exception> exception,
65 CefRefPtr<CefV8StackTrace> stackTrace) {
66 DelegateSet::iterator it = delegates_.begin();
67 for (; it != delegates_.end(); ++it) {
68 (*it)->OnUncaughtException(this, browser, frame, context, exception,
69 stackTrace);
70 }
71 }
72
OnFocusedNodeChanged(CefRefPtr<CefBrowser> browser,CefRefPtr<CefFrame> frame,CefRefPtr<CefDOMNode> node)73 void ClientAppRenderer::OnFocusedNodeChanged(CefRefPtr<CefBrowser> browser,
74 CefRefPtr<CefFrame> frame,
75 CefRefPtr<CefDOMNode> node) {
76 DelegateSet::iterator it = delegates_.begin();
77 for (; it != delegates_.end(); ++it)
78 (*it)->OnFocusedNodeChanged(this, browser, frame, node);
79 }
80
OnProcessMessageReceived(CefRefPtr<CefBrowser> browser,CefRefPtr<CefFrame> frame,CefProcessId source_process,CefRefPtr<CefProcessMessage> message)81 bool ClientAppRenderer::OnProcessMessageReceived(
82 CefRefPtr<CefBrowser> browser,
83 CefRefPtr<CefFrame> frame,
84 CefProcessId source_process,
85 CefRefPtr<CefProcessMessage> message) {
86 DCHECK_EQ(source_process, PID_BROWSER);
87
88 bool handled = false;
89
90 DelegateSet::iterator it = delegates_.begin();
91 for (; it != delegates_.end() && !handled; ++it) {
92 handled = (*it)->OnProcessMessageReceived(this, browser, frame,
93 source_process, message);
94 }
95
96 return handled;
97 }
98
99 } // namespace client
100