// Copyright © 2018 The CefSharp Authors. All rights reserved. // // Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. #pragma once #include "Stdafx.h" #include "include\cef_extension.h" #include "include\cef_extension_handler.h" #include "BrowserSettings.h" #include "CefExtensionWrapper.h" #include "CefBrowserWrapper.h" #include "CefGetExtensionResourceCallbackWrapper.h" #include "WindowInfo.h" using namespace CefSharp; namespace CefSharp { namespace Internals { private class CefExtensionHandlerAdapter : public CefExtensionHandler { gcroot _handler; public: CefExtensionHandlerAdapter(IExtensionHandler^ handler) : _handler(handler) { } ~CefExtensionHandlerAdapter() { delete _handler; _handler = nullptr; } /// // Called if the CefRequestContext::LoadExtension request fails. |result| will // be the error code. /// /*--cef()--*/ void OnExtensionLoadFailed(cef_errorcode_t result) override { _handler->OnExtensionLoadFailed((CefErrorCode)result); } /// // Called if the CefRequestContext::LoadExtension request succeeds. // |extension| is the loaded extension. /// /*--cef()--*/ void OnExtensionLoaded(CefRefPtr extension) override { //TODO: Should this be auto disposed? _handler->OnExtensionLoaded(gcnew CefExtensionWrapper(extension)); } /// // Called after the CefExtension::Unload request has completed. /// /*--cef()--*/ void OnExtensionUnloaded(CefRefPtr extension) override { //TODO: Add comment to interface saying extension is only valid within the scope //of this method as it's auto disposed CefExtensionWrapper wrapper(extension); _handler->OnExtensionUnloaded(%wrapper); } /// // Called when an extension needs a browser to host a background script // specified via the "background" manifest key. The browser will have no // visible window and cannot be displayed. |extension| is the extension that // is loading the background script. |url| is an internally generated // reference to an HTML page that will be used to load the background script // via a