1 // Copyright (c) 2016 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_VIEWS_CEF_BROWSER_VIEW_DELEGATE_H_ 38 #define CEF_INCLUDE_VIEWS_CEF_BROWSER_VIEW_DELEGATE_H_ 39 #pragma once 40 41 #include "include/cef_client.h" 42 #include "include/views/cef_view_delegate.h" 43 44 class CefBrowser; 45 class CefBrowserView; 46 47 /// 48 // Implement this interface to handle BrowserView events. The methods of this 49 // class will be called on the browser process UI thread unless otherwise 50 // indicated. 51 /// 52 /*--cef(source=client)--*/ 53 class CefBrowserViewDelegate : public CefViewDelegate { 54 public: 55 typedef cef_chrome_toolbar_type_t ChromeToolbarType; 56 57 /// 58 // Called when |browser| associated with |browser_view| is created. This 59 // method will be called after CefLifeSpanHandler::OnAfterCreated() is called 60 // for |browser| and before OnPopupBrowserViewCreated() is called for 61 // |browser|'s parent delegate if |browser| is a popup. 62 /// 63 /*--cef()--*/ OnBrowserCreated(CefRefPtr<CefBrowserView> browser_view,CefRefPtr<CefBrowser> browser)64 virtual void OnBrowserCreated(CefRefPtr<CefBrowserView> browser_view, 65 CefRefPtr<CefBrowser> browser) {} 66 67 /// 68 // Called when |browser| associated with |browser_view| is destroyed. Release 69 // all references to |browser| and do not attempt to execute any methods on 70 // |browser| after this callback returns. This method will be called before 71 // CefLifeSpanHandler::OnBeforeClose() is called for |browser|. 72 /// 73 /*--cef()--*/ OnBrowserDestroyed(CefRefPtr<CefBrowserView> browser_view,CefRefPtr<CefBrowser> browser)74 virtual void OnBrowserDestroyed(CefRefPtr<CefBrowserView> browser_view, 75 CefRefPtr<CefBrowser> browser) {} 76 77 /// 78 // Called before a new popup BrowserView is created. The popup originated 79 // from |browser_view|. |settings| and |client| are the values returned from 80 // CefLifeSpanHandler::OnBeforePopup(). |is_devtools| will be true if the 81 // popup will be a DevTools browser. Return the delegate that will be used for 82 // the new popup BrowserView. 83 /// 84 /*--cef()--*/ GetDelegateForPopupBrowserView(CefRefPtr<CefBrowserView> browser_view,const CefBrowserSettings & settings,CefRefPtr<CefClient> client,bool is_devtools)85 virtual CefRefPtr<CefBrowserViewDelegate> GetDelegateForPopupBrowserView( 86 CefRefPtr<CefBrowserView> browser_view, 87 const CefBrowserSettings& settings, 88 CefRefPtr<CefClient> client, 89 bool is_devtools) { 90 return this; 91 } 92 93 /// 94 // Called after |popup_browser_view| is created. This method will be called 95 // after CefLifeSpanHandler::OnAfterCreated() and OnBrowserCreated() are 96 // called for the new popup browser. The popup originated from |browser_view|. 97 // |is_devtools| will be true if the popup is a DevTools browser. Optionally 98 // add |popup_browser_view| to the views hierarchy yourself and return true. 99 // Otherwise return false and a default CefWindow will be created for the 100 // popup. 101 /// 102 /*--cef()--*/ OnPopupBrowserViewCreated(CefRefPtr<CefBrowserView> browser_view,CefRefPtr<CefBrowserView> popup_browser_view,bool is_devtools)103 virtual bool OnPopupBrowserViewCreated( 104 CefRefPtr<CefBrowserView> browser_view, 105 CefRefPtr<CefBrowserView> popup_browser_view, 106 bool is_devtools) { 107 return false; 108 } 109 110 /// 111 // Returns the Chrome toolbar type that will be available via 112 // CefBrowserView::GetChromeToolbar(). See that method for related 113 // documentation. 114 /// 115 /*--cef(default_retval=CEF_CTT_NONE)--*/ GetChromeToolbarType()116 virtual ChromeToolbarType GetChromeToolbarType() { return CEF_CTT_NONE; } 117 }; 118 119 #endif // CEF_INCLUDE_VIEWS_CEF_BROWSER_VIEW_DELEGATE_H_ 120