1 // Copyright (c) 2013 Marshall A. Greenblatt. All rights reserved. 2 // 3 // Redistribution and use in source and binary forms, with or without 4 // modification, are permitted provided that the following conditions are 5 // met: 6 // 7 // * Redistributions of source code must retain the above copyright 8 // notice, this list of conditions and the following disclaimer. 9 // * Redistributions in binary form must reproduce the above 10 // copyright notice, this list of conditions and the following disclaimer 11 // in the documentation and/or other materials provided with the 12 // distribution. 13 // * Neither the name of Google Inc. nor the name Chromium Embedded 14 // Framework nor the names of its contributors may be used to endorse 15 // or promote products derived from this software without specific prior 16 // written permission. 17 // 18 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 // 30 // --------------------------------------------------------------------------- 31 // 32 // The contents of this file must follow a specific format in order to 33 // support the CEF translator tool. See the translator.README.txt file in the 34 // tools directory for more information. 35 // 36 37 #ifndef CEF_INCLUDE_CEF_RENDER_PROCESS_HANDLER_H_ 38 #define CEF_INCLUDE_CEF_RENDER_PROCESS_HANDLER_H_ 39 #pragma once 40 41 #include "include/cef_base.h" 42 #include "include/cef_browser.h" 43 #include "include/cef_dom.h" 44 #include "include/cef_frame.h" 45 #include "include/cef_load_handler.h" 46 #include "include/cef_process_message.h" 47 #include "include/cef_v8.h" 48 #include "include/cef_values.h" 49 50 /// 51 // Class used to implement render process callbacks. The methods of this class 52 // will be called on the render process main thread (TID_RENDERER) unless 53 // otherwise indicated. 54 /// 55 /*--cef(source=client,no_debugct_check)--*/ 56 class CefRenderProcessHandler : public virtual CefBaseRefCounted { 57 public: 58 typedef cef_navigation_type_t NavigationType; 59 60 /// 61 // Called after WebKit has been initialized. 62 /// 63 /*--cef()--*/ OnWebKitInitialized()64 virtual void OnWebKitInitialized() {} 65 66 /// 67 // Called after a browser has been created. When browsing cross-origin a new 68 // browser will be created before the old browser with the same identifier is 69 // destroyed. |extra_info| is an optional read-only value originating from 70 // CefBrowserHost::CreateBrowser(), CefBrowserHost::CreateBrowserSync(), 71 // CefLifeSpanHandler::OnBeforePopup() or CefBrowserView::CreateBrowserView(). 72 /// 73 /*--cef(optional_param=extra_info)--*/ OnBrowserCreated(CefRefPtr<CefBrowser> browser,CefRefPtr<CefDictionaryValue> extra_info)74 virtual void OnBrowserCreated(CefRefPtr<CefBrowser> browser, 75 CefRefPtr<CefDictionaryValue> extra_info) {} 76 77 /// 78 // Called before a browser is destroyed. 79 /// 80 /*--cef()--*/ OnBrowserDestroyed(CefRefPtr<CefBrowser> browser)81 virtual void OnBrowserDestroyed(CefRefPtr<CefBrowser> browser) {} 82 83 /// 84 // Return the handler for browser load status events. 85 /// 86 /*--cef()--*/ GetLoadHandler()87 virtual CefRefPtr<CefLoadHandler> GetLoadHandler() { return nullptr; } 88 89 /// 90 // Called immediately after the V8 context for a frame has been created. To 91 // retrieve the JavaScript 'window' object use the CefV8Context::GetGlobal() 92 // method. V8 handles can only be accessed from the thread on which they are 93 // created. A task runner for posting tasks on the associated thread can be 94 // retrieved via the CefV8Context::GetTaskRunner() method. 95 /// 96 /*--cef()--*/ OnContextCreated(CefRefPtr<CefBrowser> browser,CefRefPtr<CefFrame> frame,CefRefPtr<CefV8Context> context)97 virtual void OnContextCreated(CefRefPtr<CefBrowser> browser, 98 CefRefPtr<CefFrame> frame, 99 CefRefPtr<CefV8Context> context) {} 100 101 /// 102 // Called immediately before the V8 context for a frame is released. No 103 // references to the context should be kept after this method is called. 104 /// 105 /*--cef()--*/ OnContextReleased(CefRefPtr<CefBrowser> browser,CefRefPtr<CefFrame> frame,CefRefPtr<CefV8Context> context)106 virtual void OnContextReleased(CefRefPtr<CefBrowser> browser, 107 CefRefPtr<CefFrame> frame, 108 CefRefPtr<CefV8Context> context) {} 109 110 /// 111 // Called for global uncaught exceptions in a frame. Execution of this 112 // callback is disabled by default. To enable set 113 // CefSettings.uncaught_exception_stack_size > 0. 114 /// 115 /*--cef()--*/ OnUncaughtException(CefRefPtr<CefBrowser> browser,CefRefPtr<CefFrame> frame,CefRefPtr<CefV8Context> context,CefRefPtr<CefV8Exception> exception,CefRefPtr<CefV8StackTrace> stackTrace)116 virtual void OnUncaughtException(CefRefPtr<CefBrowser> browser, 117 CefRefPtr<CefFrame> frame, 118 CefRefPtr<CefV8Context> context, 119 CefRefPtr<CefV8Exception> exception, 120 CefRefPtr<CefV8StackTrace> stackTrace) {} 121 122 /// 123 // Called when a new node in the the browser gets focus. The |node| value may 124 // be empty if no specific node has gained focus. The node object passed to 125 // this method represents a snapshot of the DOM at the time this method is 126 // executed. DOM objects are only valid for the scope of this method. Do not 127 // keep references to or attempt to access any DOM objects outside the scope 128 // of this method. 129 /// 130 /*--cef(optional_param=frame,optional_param=node)--*/ OnFocusedNodeChanged(CefRefPtr<CefBrowser> browser,CefRefPtr<CefFrame> frame,CefRefPtr<CefDOMNode> node)131 virtual void OnFocusedNodeChanged(CefRefPtr<CefBrowser> browser, 132 CefRefPtr<CefFrame> frame, 133 CefRefPtr<CefDOMNode> node) {} 134 135 /// 136 // Called when a new message is received from a different process. Return true 137 // if the message was handled or false otherwise. It is safe to keep a 138 // reference to |message| outside of this callback. 139 /// 140 /*--cef()--*/ OnProcessMessageReceived(CefRefPtr<CefBrowser> browser,CefRefPtr<CefFrame> frame,CefProcessId source_process,CefRefPtr<CefProcessMessage> message)141 virtual bool OnProcessMessageReceived(CefRefPtr<CefBrowser> browser, 142 CefRefPtr<CefFrame> frame, 143 CefProcessId source_process, 144 CefRefPtr<CefProcessMessage> message) { 145 return false; 146 } 147 }; 148 149 #endif // CEF_INCLUDE_CEF_RENDER_PROCESS_HANDLER_H_ 150