diff --git a/CefSharp.Core/Internals/ClientAdapter.cpp b/CefSharp.Core/Internals/ClientAdapter.cpp index 615360292..c693ee896 100644 --- a/CefSharp.Core/Internals/ClientAdapter.cpp +++ b/CefSharp.Core/Internals/ClientAdapter.cpp @@ -228,6 +228,15 @@ namespace CefSharp } } + void ClientAdapter::OnRenderProcessTerminated(CefRefPtr browser, TerminationStatus status) + { + IRequestHandler^ handler = _browserControl->RequestHandler; + if (handler != nullptr) + { + handler->OnRenderProcessTerminated(_browserControl, (CefTerminationStatus)status); + } + } + bool ClientAdapter::OnBeforeResourceLoad(CefRefPtr browser, CefRefPtr frame, CefRefPtr request) { // TOOD: Try to support with CEF3; seems quite difficult because the method signature has changed greatly with many parts diff --git a/CefSharp.Core/Internals/ClientAdapter.h b/CefSharp.Core/Internals/ClientAdapter.h index bd77ba873..6939cf09c 100644 --- a/CefSharp.Core/Internals/ClientAdapter.h +++ b/CefSharp.Core/Internals/ClientAdapter.h @@ -87,6 +87,7 @@ namespace CefSharp virtual DECL bool OnBeforeBrowse(CefRefPtr browser, CefRefPtr frame, CefRefPtr request, bool isRedirect) OVERRIDE; virtual DECL bool OnBeforePluginLoad( CefRefPtr< CefBrowser > browser, const CefString& url, const CefString& policy_url, CefRefPtr< CefWebPluginInfo > info ) OVERRIDE; virtual DECL void OnPluginCrashed(CefRefPtr browser, const CefString& plugin_path) OVERRIDE; + virtual DECL void OnRenderProcessTerminated(CefRefPtr browser, TerminationStatus status) OVERRIDE; // CefDisplayHandler virtual DECL void OnLoadingStateChange(CefRefPtr browser, bool isLoading, bool canGoBack, bool canGoForward) OVERRIDE; diff --git a/CefSharp.Core/SchemeHandlerWrapper.cpp b/CefSharp.Core/SchemeHandlerWrapper.cpp index e563c2092..5d44aaa2b 100644 --- a/CefSharp.Core/SchemeHandlerWrapper.cpp +++ b/CefSharp.Core/SchemeHandlerWrapper.cpp @@ -61,7 +61,11 @@ namespace CefSharp _headers = ToHeaderMap(response->ResponseHeaders); - _callback->Continue(); + // If CEF has cancelled the initial request, throw away a response that comes afterwards. + if (_callback != nullptr) + { + _callback->Continue(); + } // Must be done AFTER CEF has been allowed to consume the headers etc. After this call is made, the SchemeHandlerWrapper // instance has likely been deallocated. diff --git a/CefSharp.Example/RequestHandler.cs b/CefSharp.Example/RequestHandler.cs index 91375fe7f..d4853f011 100644 --- a/CefSharp.Example/RequestHandler.cs +++ b/CefSharp.Example/RequestHandler.cs @@ -48,5 +48,10 @@ namespace CefSharp.Example //blockPluginLoad = info.Name.ToLower().Contains("flash"); return blockPluginLoad; } + + void IRequestHandler.OnRenderProcessTerminated(IWebBrowser browser, CefTerminationStatus status) + { + // TODO: Add your own code here for handling scenarios where the Render Process terminated for one reason or another. + } } } diff --git a/CefSharp.Wpf/ChromiumWebBrowser.cs b/CefSharp.Wpf/ChromiumWebBrowser.cs index 27dbfaba7..3709cdbc3 100644 --- a/CefSharp.Wpf/ChromiumWebBrowser.cs +++ b/CefSharp.Wpf/ChromiumWebBrowser.cs @@ -933,6 +933,41 @@ namespace CefSharp.Wpf managedCefBrowserAdapter.LoadHtml(html, url); } + public void Undo() + { + managedCefBrowserAdapter.Undo(); + } + + public void Redo() + { + managedCefBrowserAdapter.Redo(); + } + + public void Cut() + { + managedCefBrowserAdapter.Cut(); + } + + public void Copy() + { + managedCefBrowserAdapter.Copy(); + } + + public void Paste() + { + managedCefBrowserAdapter.Paste(); + } + + public void Delete() + { + managedCefBrowserAdapter.Delete(); + } + + public void SelectAll() + { + managedCefBrowserAdapter.SelectAll(); + } + public void Stop() { managedCefBrowserAdapter.Stop(); diff --git a/CefSharp/CefSharp.csproj b/CefSharp/CefSharp.csproj index 03f5083b2..7dbee84de 100644 --- a/CefSharp/CefSharp.csproj +++ b/CefSharp/CefSharp.csproj @@ -87,6 +87,7 @@ + diff --git a/CefSharp/CefTerminationStatus.cs b/CefSharp/CefTerminationStatus.cs new file mode 100644 index 000000000..be53f9eac --- /dev/null +++ b/CefSharp/CefTerminationStatus.cs @@ -0,0 +1,20 @@ +namespace CefSharp +{ + public enum CefTerminationStatus + { + /// + // Non-zero exit status. + /// + AbnormalTermination = 0, + + /// + // SIGKILL or task manager kill. + /// + ProcessWasKilled, + + /// + // Segmentation fault. + /// + ProcessCrashed + } +} diff --git a/CefSharp/IRequestHandler.cs b/CefSharp/IRequestHandler.cs index ee6a7629d..df10479fe 100644 --- a/CefSharp/IRequestHandler.cs +++ b/CefSharp/IRequestHandler.cs @@ -59,5 +59,12 @@ namespace CefSharp /// plugin information /// Return true to block loading of the plugin. bool OnBeforePluginLoad(IWebBrowser browser, string url, string policyUrl, IWebPluginInfo info); + + /// + /// Called when the render process terminates unexpectedly. + /// + /// the browser object + /// indicates how the process terminated. + void OnRenderProcessTerminated(IWebBrowser browser, CefTerminationStatus status); } }