mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-06-05 21:39:12 +02:00
Add OnRenderProcessTerminated and OnPluginCrashed notifications to CefLoadHandler (issue #633).
git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@710 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
This commit is contained in:
@ -88,6 +88,21 @@ typedef struct _cef_load_handler_t {
|
|||||||
struct _cef_browser_t* browser, struct _cef_frame_t* frame,
|
struct _cef_browser_t* browser, struct _cef_frame_t* frame,
|
||||||
enum cef_errorcode_t errorCode, const cef_string_t* errorText,
|
enum cef_errorcode_t errorCode, const cef_string_t* errorText,
|
||||||
const cef_string_t* failedUrl);
|
const cef_string_t* failedUrl);
|
||||||
|
|
||||||
|
///
|
||||||
|
// Called when the render process terminates unexpectedly. |status| indicates
|
||||||
|
// how the process terminated.
|
||||||
|
///
|
||||||
|
void (CEF_CALLBACK *on_render_process_terminated)(
|
||||||
|
struct _cef_load_handler_t* self, struct _cef_browser_t* browser,
|
||||||
|
enum cef_termination_status_t status);
|
||||||
|
|
||||||
|
///
|
||||||
|
// Called when a plugin has crashed. |plugin_path| is the path of the plugin
|
||||||
|
// that crashed.
|
||||||
|
///
|
||||||
|
void (CEF_CALLBACK *on_plugin_crashed)(struct _cef_load_handler_t* self,
|
||||||
|
struct _cef_browser_t* browser, const cef_string_t* plugin_path);
|
||||||
} cef_load_handler_t;
|
} cef_load_handler_t;
|
||||||
|
|
||||||
|
|
||||||
|
@ -50,6 +50,7 @@
|
|||||||
class CefLoadHandler : public virtual CefBase {
|
class CefLoadHandler : public virtual CefBase {
|
||||||
public:
|
public:
|
||||||
typedef cef_errorcode_t ErrorCode;
|
typedef cef_errorcode_t ErrorCode;
|
||||||
|
typedef cef_termination_status_t TerminationStatus;
|
||||||
|
|
||||||
///
|
///
|
||||||
// Called when the browser begins loading a frame. The |frame| value will
|
// Called when the browser begins loading a frame. The |frame| value will
|
||||||
@ -88,6 +89,22 @@ class CefLoadHandler : public virtual CefBase {
|
|||||||
ErrorCode errorCode,
|
ErrorCode errorCode,
|
||||||
const CefString& errorText,
|
const CefString& errorText,
|
||||||
const CefString& failedUrl) {}
|
const CefString& failedUrl) {}
|
||||||
|
|
||||||
|
///
|
||||||
|
// Called when the render process terminates unexpectedly. |status| indicates
|
||||||
|
// how the process terminated.
|
||||||
|
///
|
||||||
|
/*--cef()--*/
|
||||||
|
virtual void OnRenderProcessTerminated(CefRefPtr<CefBrowser> browser,
|
||||||
|
TerminationStatus status) {}
|
||||||
|
|
||||||
|
///
|
||||||
|
// Called when a plugin has crashed. |plugin_path| is the path of the plugin
|
||||||
|
// that crashed.
|
||||||
|
///
|
||||||
|
/*--cef()--*/
|
||||||
|
virtual void OnPluginCrashed(CefRefPtr<CefBrowser> browser,
|
||||||
|
const CefString& plugin_path) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // CEF_INCLUDE_CEF_LOAD_HANDLER_H_
|
#endif // CEF_INCLUDE_CEF_LOAD_HANDLER_H_
|
||||||
|
@ -580,6 +580,26 @@ typedef struct _cef_cookie_t {
|
|||||||
cef_time_t expires;
|
cef_time_t expires;
|
||||||
} cef_cookie_t;
|
} cef_cookie_t;
|
||||||
|
|
||||||
|
///
|
||||||
|
// Process termination status values.
|
||||||
|
///
|
||||||
|
enum cef_termination_status_t {
|
||||||
|
///
|
||||||
|
// Non-zero exit status.
|
||||||
|
///
|
||||||
|
TS_ABNORMAL_TERMINATION,
|
||||||
|
|
||||||
|
///
|
||||||
|
// SIGKILL or task manager kill.
|
||||||
|
///
|
||||||
|
TS_PROCESS_WAS_KILLED,
|
||||||
|
|
||||||
|
///
|
||||||
|
// Segmentation fault.
|
||||||
|
///
|
||||||
|
TS_PROCESS_CRASHED,
|
||||||
|
};
|
||||||
|
|
||||||
///
|
///
|
||||||
// Storage types.
|
// Storage types.
|
||||||
///
|
///
|
||||||
|
@ -1125,6 +1125,20 @@ void CefBrowserHostImpl::RenderViewReady() {
|
|||||||
|
|
||||||
void CefBrowserHostImpl::RenderViewGone(base::TerminationStatus status) {
|
void CefBrowserHostImpl::RenderViewGone(base::TerminationStatus status) {
|
||||||
queue_messages_ = true;
|
queue_messages_ = true;
|
||||||
|
|
||||||
|
cef_termination_status_t ts = TS_ABNORMAL_TERMINATION;
|
||||||
|
if (status == base::TERMINATION_STATUS_PROCESS_WAS_KILLED)
|
||||||
|
ts = TS_PROCESS_WAS_KILLED;
|
||||||
|
else if (status == base::TERMINATION_STATUS_PROCESS_CRASHED)
|
||||||
|
ts = TS_PROCESS_CRASHED;
|
||||||
|
else if (status != base::TERMINATION_STATUS_ABNORMAL_TERMINATION)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (client_.get()) {
|
||||||
|
CefRefPtr<CefLoadHandler> handler = client_->GetLoadHandler();
|
||||||
|
if (handler.get())
|
||||||
|
handler->OnRenderProcessTerminated(this, ts);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CefBrowserHostImpl::DidCommitProvisionalLoadForFrame(
|
void CefBrowserHostImpl::DidCommitProvisionalLoadForFrame(
|
||||||
@ -1179,6 +1193,14 @@ void CefBrowserHostImpl::DidFailLoad(int64 frame_id,
|
|||||||
OnLoadEnd(frame, validated_url);
|
OnLoadEnd(frame, validated_url);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CefBrowserHostImpl::PluginCrashed(const FilePath& plugin_path) {
|
||||||
|
if (client_.get()) {
|
||||||
|
CefRefPtr<CefLoadHandler> handler = client_->GetLoadHandler();
|
||||||
|
if (handler.get())
|
||||||
|
handler->OnPluginCrashed(this, plugin_path.value());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool CefBrowserHostImpl::OnMessageReceived(const IPC::Message& message) {
|
bool CefBrowserHostImpl::OnMessageReceived(const IPC::Message& message) {
|
||||||
bool handled = true;
|
bool handled = true;
|
||||||
IPC_BEGIN_MESSAGE_MAP(CefBrowserHostImpl, message)
|
IPC_BEGIN_MESSAGE_MAP(CefBrowserHostImpl, message)
|
||||||
|
@ -262,6 +262,7 @@ class CefBrowserHostImpl : public CefBrowserHost,
|
|||||||
bool is_main_frame,
|
bool is_main_frame,
|
||||||
int error_code,
|
int error_code,
|
||||||
const string16& error_description) OVERRIDE;
|
const string16& error_description) OVERRIDE;
|
||||||
|
virtual void PluginCrashed(const FilePath& plugin_path) OVERRIDE;
|
||||||
virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
|
virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
|
||||||
// Override to provide a thread safe implementation.
|
// Override to provide a thread safe implementation.
|
||||||
virtual bool Send(IPC::Message* message) OVERRIDE;
|
virtual bool Send(IPC::Message* message) OVERRIDE;
|
||||||
|
@ -93,6 +93,48 @@ void CEF_CALLBACK load_handler_on_load_error(struct _cef_load_handler_t* self,
|
|||||||
CefString(failedUrl));
|
CefString(failedUrl));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CEF_CALLBACK load_handler_on_render_process_terminated(
|
||||||
|
struct _cef_load_handler_t* self, cef_browser_t* browser,
|
||||||
|
enum cef_termination_status_t status) {
|
||||||
|
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||||
|
|
||||||
|
DCHECK(self);
|
||||||
|
if (!self)
|
||||||
|
return;
|
||||||
|
// Verify param: browser; type: refptr_diff
|
||||||
|
DCHECK(browser);
|
||||||
|
if (!browser)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// Execute
|
||||||
|
CefLoadHandlerCppToC::Get(self)->OnRenderProcessTerminated(
|
||||||
|
CefBrowserCToCpp::Wrap(browser),
|
||||||
|
status);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CEF_CALLBACK load_handler_on_plugin_crashed(
|
||||||
|
struct _cef_load_handler_t* self, cef_browser_t* browser,
|
||||||
|
const cef_string_t* plugin_path) {
|
||||||
|
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||||
|
|
||||||
|
DCHECK(self);
|
||||||
|
if (!self)
|
||||||
|
return;
|
||||||
|
// Verify param: browser; type: refptr_diff
|
||||||
|
DCHECK(browser);
|
||||||
|
if (!browser)
|
||||||
|
return;
|
||||||
|
// Verify param: plugin_path; type: string_byref_const
|
||||||
|
DCHECK(plugin_path);
|
||||||
|
if (!plugin_path)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// Execute
|
||||||
|
CefLoadHandlerCppToC::Get(self)->OnPluginCrashed(
|
||||||
|
CefBrowserCToCpp::Wrap(browser),
|
||||||
|
CefString(plugin_path));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// CONSTRUCTOR - Do not edit by hand.
|
// CONSTRUCTOR - Do not edit by hand.
|
||||||
|
|
||||||
@ -101,6 +143,9 @@ CefLoadHandlerCppToC::CefLoadHandlerCppToC(CefLoadHandler* cls)
|
|||||||
struct_.struct_.on_load_start = load_handler_on_load_start;
|
struct_.struct_.on_load_start = load_handler_on_load_start;
|
||||||
struct_.struct_.on_load_end = load_handler_on_load_end;
|
struct_.struct_.on_load_end = load_handler_on_load_end;
|
||||||
struct_.struct_.on_load_error = load_handler_on_load_error;
|
struct_.struct_.on_load_error = load_handler_on_load_error;
|
||||||
|
struct_.struct_.on_render_process_terminated =
|
||||||
|
load_handler_on_render_process_terminated;
|
||||||
|
struct_.struct_.on_plugin_crashed = load_handler_on_plugin_crashed;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
|
@ -93,6 +93,46 @@ void CefLoadHandlerCToCpp::OnLoadError(CefRefPtr<CefBrowser> browser,
|
|||||||
failedUrl.GetStruct());
|
failedUrl.GetStruct());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CefLoadHandlerCToCpp::OnRenderProcessTerminated(
|
||||||
|
CefRefPtr<CefBrowser> browser, TerminationStatus status) {
|
||||||
|
if (CEF_MEMBER_MISSING(struct_, on_render_process_terminated))
|
||||||
|
return;
|
||||||
|
|
||||||
|
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||||
|
|
||||||
|
// Verify param: browser; type: refptr_diff
|
||||||
|
DCHECK(browser.get());
|
||||||
|
if (!browser.get())
|
||||||
|
return;
|
||||||
|
|
||||||
|
// Execute
|
||||||
|
struct_->on_render_process_terminated(struct_,
|
||||||
|
CefBrowserCppToC::Wrap(browser),
|
||||||
|
status);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CefLoadHandlerCToCpp::OnPluginCrashed(CefRefPtr<CefBrowser> browser,
|
||||||
|
const CefString& plugin_path) {
|
||||||
|
if (CEF_MEMBER_MISSING(struct_, on_plugin_crashed))
|
||||||
|
return;
|
||||||
|
|
||||||
|
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||||
|
|
||||||
|
// Verify param: browser; type: refptr_diff
|
||||||
|
DCHECK(browser.get());
|
||||||
|
if (!browser.get())
|
||||||
|
return;
|
||||||
|
// Verify param: plugin_path; type: string_byref_const
|
||||||
|
DCHECK(!plugin_path.empty());
|
||||||
|
if (plugin_path.empty())
|
||||||
|
return;
|
||||||
|
|
||||||
|
// Execute
|
||||||
|
struct_->on_plugin_crashed(struct_,
|
||||||
|
CefBrowserCppToC::Wrap(browser),
|
||||||
|
plugin_path.GetStruct());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
template<> long CefCToCpp<CefLoadHandlerCToCpp, CefLoadHandler,
|
template<> long CefCToCpp<CefLoadHandlerCToCpp, CefLoadHandler,
|
||||||
|
@ -41,6 +41,10 @@ class CefLoadHandlerCToCpp
|
|||||||
virtual void OnLoadError(CefRefPtr<CefBrowser> browser,
|
virtual void OnLoadError(CefRefPtr<CefBrowser> browser,
|
||||||
CefRefPtr<CefFrame> frame, ErrorCode errorCode,
|
CefRefPtr<CefFrame> frame, ErrorCode errorCode,
|
||||||
const CefString& errorText, const CefString& failedUrl) OVERRIDE;
|
const CefString& errorText, const CefString& failedUrl) OVERRIDE;
|
||||||
|
virtual void OnRenderProcessTerminated(CefRefPtr<CefBrowser> browser,
|
||||||
|
TerminationStatus status) OVERRIDE;
|
||||||
|
virtual void OnPluginCrashed(CefRefPtr<CefBrowser> browser,
|
||||||
|
const CefString& plugin_path) OVERRIDE;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // BUILDING_CEF_SHARED
|
#endif // BUILDING_CEF_SHARED
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
// can be found in the LICENSE file.
|
// can be found in the LICENSE file.
|
||||||
|
|
||||||
#include "cefclient/client_handler.h"
|
#include "cefclient/client_handler.h"
|
||||||
|
#include <algorithm>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <string>
|
#include <string>
|
||||||
@ -282,6 +283,18 @@ void ClientHandler::OnLoadError(CefRefPtr<CefBrowser> browser,
|
|||||||
frame->LoadString(ss.str(), failedUrl);
|
frame->LoadString(ss.str(), failedUrl);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ClientHandler::OnRenderProcessTerminated(CefRefPtr<CefBrowser> browser,
|
||||||
|
TerminationStatus status) {
|
||||||
|
// Load google.com if that's not the website that we terminated on.
|
||||||
|
CefRefPtr<CefFrame> frame = browser->GetMainFrame();
|
||||||
|
std::string url = frame->GetURL();
|
||||||
|
std::transform(url.begin(), url.end(), url.begin(), tolower);
|
||||||
|
|
||||||
|
const char kLoadURL[] = "http://www.google.com";
|
||||||
|
if (url.find(kLoadURL) != 0)
|
||||||
|
frame->LoadURL(kLoadURL);
|
||||||
|
}
|
||||||
|
|
||||||
CefRefPtr<CefResourceHandler> ClientHandler::GetResourceHandler(
|
CefRefPtr<CefResourceHandler> ClientHandler::GetResourceHandler(
|
||||||
CefRefPtr<CefBrowser> browser,
|
CefRefPtr<CefBrowser> browser,
|
||||||
CefRefPtr<CefFrame> frame,
|
CefRefPtr<CefFrame> frame,
|
||||||
|
@ -149,6 +149,8 @@ class ClientHandler : public CefClient,
|
|||||||
ErrorCode errorCode,
|
ErrorCode errorCode,
|
||||||
const CefString& errorText,
|
const CefString& errorText,
|
||||||
const CefString& failedUrl) OVERRIDE;
|
const CefString& failedUrl) OVERRIDE;
|
||||||
|
virtual void OnRenderProcessTerminated(CefRefPtr<CefBrowser> browser,
|
||||||
|
TerminationStatus status) OVERRIDE;
|
||||||
|
|
||||||
// CefRequestHandler methods
|
// CefRequestHandler methods
|
||||||
virtual CefRefPtr<CefResourceHandler> GetResourceHandler(
|
virtual CefRefPtr<CefResourceHandler> GetResourceHandler(
|
||||||
|
Reference in New Issue
Block a user