Skip to content

Commit

Permalink
Add OnRenderProcessTerminated - Resolves issue cefsharp#207
Browse files Browse the repository at this point in the history
  • Loading branch information
amaitland committed Jun 24, 2014
1 parent feabb4f commit 852e887
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 0 deletions.
9 changes: 9 additions & 0 deletions CefSharp.Core/Internals/ClientAdapter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,15 @@ namespace CefSharp
}
}

void ClientAdapter::OnRenderProcessTerminated(CefRefPtr<CefBrowser> browser, TerminationStatus status)
{
IRequestHandler^ handler = _browserControl->RequestHandler;
if (handler != nullptr)
{
handler->OnRenderProcessTerminated(_browserControl, (CefTerminationStatus)status);
}
}

bool ClientAdapter::OnBeforeResourceLoad(CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame, CefRefPtr<CefRequest> request)
{
// TOOD: Try to support with CEF3; seems quite difficult because the method signature has changed greatly with many parts
Expand Down
1 change: 1 addition & 0 deletions CefSharp.Core/Internals/ClientAdapter.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ namespace CefSharp
virtual DECL bool OnBeforeBrowse(CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame, CefRefPtr<CefRequest> 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<CefBrowser> browser, const CefString& plugin_path) OVERRIDE;
virtual DECL void OnRenderProcessTerminated(CefRefPtr<CefBrowser> browser, TerminationStatus status) OVERRIDE;

// CefDisplayHandler
virtual DECL void OnLoadingStateChange(CefRefPtr<CefBrowser> browser, bool isLoading, bool canGoBack, bool canGoForward) OVERRIDE;
Expand Down
5 changes: 5 additions & 0 deletions CefSharp.Example/RequestHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,10 @@ bool IRequestHandler.OnBeforePluginLoad(IWebBrowser browser, string url, string
//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.
}
}
}
1 change: 1 addition & 0 deletions CefSharp/CefSharp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@
</ItemGroup>
<ItemGroup>
<Compile Include="CefFileDialogMode.cs" />
<Compile Include="CefTerminationStatus.cs" />
<Compile Include="IDialogHandler.cs" />
<Compile Include="AddressChangedEventArgs.cs" />
<Compile Include="DownloadItem.cs" />
Expand Down
20 changes: 20 additions & 0 deletions CefSharp/CefTerminationStatus.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
namespace CefSharp
{
public enum CefTerminationStatus
{
///
// Non-zero exit status.
///
AbnormalTermination = 0,

///
// SIGKILL or task manager kill.
///
ProcessWasKilled,

///
// Segmentation fault.
///
ProcessCrashed
}
}
7 changes: 7 additions & 0 deletions CefSharp/IRequestHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,12 @@ public interface IRequestHandler
/// <param name="info">plugin information</param>
/// <returns>Return true to block loading of the plugin.</returns>
bool OnBeforePluginLoad(IWebBrowser browser, string url, string policyUrl, IWebPluginInfo info);

/// <summary>
/// Called when the render process terminates unexpectedly.
/// </summary>
/// <param name="browser">the browser object</param>
/// <param name="status">indicates how the process terminated.</param>
void OnRenderProcessTerminated(IWebBrowser browser, CefTerminationStatus status);
}
}

0 comments on commit 852e887

Please sign in to comment.