1 // Copyright (c) 2012 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_LOAD_HANDLER_H_ 38 #define CEF_INCLUDE_CEF_LOAD_HANDLER_H_ 39 #pragma once 40 41 #include "include/cef_base.h" 42 #include "include/cef_browser.h" 43 #include "include/cef_frame.h" 44 45 /// 46 // Implement this interface to handle events related to browser load status. The 47 // methods of this class will be called on the browser process UI thread or 48 // render process main thread (TID_RENDERER). 49 /// 50 /*--cef(source=client)--*/ 51 class CefLoadHandler : public virtual CefBaseRefCounted { 52 public: 53 typedef cef_errorcode_t ErrorCode; 54 typedef cef_transition_type_t TransitionType; 55 56 /// 57 // Called when the loading state has changed. This callback will be executed 58 // twice -- once when loading is initiated either programmatically or by user 59 // action, and once when loading is terminated due to completion, cancellation 60 // of failure. It will be called before any calls to OnLoadStart and after all 61 // calls to OnLoadError and/or OnLoadEnd. 62 /// 63 /*--cef()--*/ OnLoadingStateChange(CefRefPtr<CefBrowser> browser,bool isLoading,bool canGoBack,bool canGoForward)64 virtual void OnLoadingStateChange(CefRefPtr<CefBrowser> browser, 65 bool isLoading, 66 bool canGoBack, 67 bool canGoForward) {} 68 69 /// 70 // Called after a navigation has been committed and before the browser begins 71 // loading contents in the frame. The |frame| value will never be empty -- 72 // call the IsMain() method to check if this frame is the main frame. 73 // |transition_type| provides information about the source of the navigation 74 // and an accurate value is only available in the browser process. Multiple 75 // frames may be loading at the same time. Sub-frames may start or continue 76 // loading after the main frame load has ended. This method will not be called 77 // for same page navigations (fragments, history state, etc.) or for 78 // navigations that fail or are canceled before commit. For notification of 79 // overall browser load status use OnLoadingStateChange instead. 80 /// 81 /*--cef()--*/ OnLoadStart(CefRefPtr<CefBrowser> browser,CefRefPtr<CefFrame> frame,TransitionType transition_type)82 virtual void OnLoadStart(CefRefPtr<CefBrowser> browser, 83 CefRefPtr<CefFrame> frame, 84 TransitionType transition_type) {} 85 86 /// 87 // Called when the browser is done loading a frame. The |frame| value will 88 // never be empty -- call the IsMain() method to check if this frame is the 89 // main frame. Multiple frames may be loading at the same time. Sub-frames may 90 // start or continue loading after the main frame load has ended. This method 91 // will not be called for same page navigations (fragments, history state, 92 // etc.) or for navigations that fail or are canceled before commit. For 93 // notification of overall browser load status use OnLoadingStateChange 94 // instead. 95 /// 96 /*--cef()--*/ OnLoadEnd(CefRefPtr<CefBrowser> browser,CefRefPtr<CefFrame> frame,int httpStatusCode)97 virtual void OnLoadEnd(CefRefPtr<CefBrowser> browser, 98 CefRefPtr<CefFrame> frame, 99 int httpStatusCode) {} 100 101 /// 102 // Called when a navigation fails or is canceled. This method may be called 103 // by itself if before commit or in combination with OnLoadStart/OnLoadEnd if 104 // after commit. |errorCode| is the error code number, |errorText| is the 105 // error text and |failedUrl| is the URL that failed to load. 106 // See net\base\net_error_list.h for complete descriptions of the error codes. 107 /// 108 /*--cef(optional_param=errorText)--*/ OnLoadError(CefRefPtr<CefBrowser> browser,CefRefPtr<CefFrame> frame,ErrorCode errorCode,const CefString & errorText,const CefString & failedUrl)109 virtual void OnLoadError(CefRefPtr<CefBrowser> browser, 110 CefRefPtr<CefFrame> frame, 111 ErrorCode errorCode, 112 const CefString& errorText, 113 const CefString& failedUrl) {} 114 }; 115 116 #endif // CEF_INCLUDE_CEF_LOAD_HANDLER_H_ 117