Add 'close' and 'console-message' for <webview>
This commit is contained in:
parent
218d69d288
commit
485bd7bbd3
4 changed files with 28 additions and 0 deletions
|
@ -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) {
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -9,6 +9,8 @@ supportedWebViewEvents = [
|
|||
'did-start-loading'
|
||||
'did-stop-loading'
|
||||
'did-get-redirect-request'
|
||||
'console-message'
|
||||
'close'
|
||||
'crashed'
|
||||
'destroyed'
|
||||
]
|
||||
|
|
|
@ -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': []
|
||||
|
||||
|
|
Loading…
Reference in a new issue