diff --git a/atom/browser/api/atom_api_web_contents.cc b/atom/browser/api/atom_api_web_contents.cc index d85f91ebfb02..3b80e3b5462b 100644 --- a/atom/browser/api/atom_api_web_contents.cc +++ b/atom/browser/api/atom_api_web_contents.cc @@ -64,6 +64,24 @@ WebContents::~WebContents() { Destroy(); } +bool WebContents::AddMessageToConsole(content::WebContents* source, + int32 level, + const base::string16& message, + int32 line_no, + const base::string16& source_id) { + base::ListValue args; + args.AppendInteger(level); + args.AppendString(message); + args.AppendInteger(line_no); + args.AppendString(source_id); + Emit("console-message", args); + return true; +} + +void WebContents::CloseContents(content::WebContents* source) { + Emit("close"); +} + content::WebContents* WebContents::OpenURLFromTab( content::WebContents* source, const content::OpenURLParams& params) { diff --git a/atom/browser/api/atom_api_web_contents.h b/atom/browser/api/atom_api_web_contents.h index 7dbc1ca815f1..4a104f3fda85 100644 --- a/atom/browser/api/atom_api_web_contents.h +++ b/atom/browser/api/atom_api_web_contents.h @@ -88,6 +88,12 @@ class WebContents : public mate::EventEmitter, v8::Isolate* isolate) override; // content::WebContentsDelegate: + bool AddMessageToConsole(content::WebContents* source, + int32 level, + const base::string16& message, + int32 line_no, + const base::string16& source_id) override; + void CloseContents(content::WebContents* source) override; content::WebContents* OpenURLFromTab( content::WebContents* source, const content::OpenURLParams& params) override; diff --git a/atom/browser/lib/guest-view-manager.coffee b/atom/browser/lib/guest-view-manager.coffee index 279873254958..94c2bbd23c7b 100644 --- a/atom/browser/lib/guest-view-manager.coffee +++ b/atom/browser/lib/guest-view-manager.coffee @@ -9,6 +9,8 @@ supportedWebViewEvents = [ 'did-start-loading' 'did-stop-loading' 'did-get-redirect-request' + 'console-message' + 'close' 'crashed' 'destroyed' ] diff --git a/atom/renderer/lib/guest-view-internal.coffee b/atom/renderer/lib/guest-view-internal.coffee index 69a67ae9b755..8dc271515fa5 100644 --- a/atom/renderer/lib/guest-view-internal.coffee +++ b/atom/renderer/lib/guest-view-internal.coffee @@ -9,6 +9,8 @@ WEB_VIEW_EVENTS = 'did-start-loading': [] 'did-stop-loading': [] 'did-get-redirect-request': ['oldUrl', 'newUrl', 'isMainFrame'] + 'console-message': ['level', 'message', 'line', 'sourceId'] + 'close': [] 'crashed': [] 'destroyed': []