Add 'close' and 'console-message' for <webview>

This commit is contained in:
Cheng Zhao 2014-10-25 10:01:19 +08:00
parent 218d69d288
commit 485bd7bbd3
4 changed files with 28 additions and 0 deletions

View file

@ -64,6 +64,24 @@ WebContents::~WebContents() {
Destroy(); 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* WebContents::OpenURLFromTab(
content::WebContents* source, content::WebContents* source,
const content::OpenURLParams& params) { const content::OpenURLParams& params) {

View file

@ -88,6 +88,12 @@ class WebContents : public mate::EventEmitter,
v8::Isolate* isolate) override; v8::Isolate* isolate) override;
// content::WebContentsDelegate: // 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* OpenURLFromTab(
content::WebContents* source, content::WebContents* source,
const content::OpenURLParams& params) override; const content::OpenURLParams& params) override;

View file

@ -9,6 +9,8 @@ supportedWebViewEvents = [
'did-start-loading' 'did-start-loading'
'did-stop-loading' 'did-stop-loading'
'did-get-redirect-request' 'did-get-redirect-request'
'console-message'
'close'
'crashed' 'crashed'
'destroyed' 'destroyed'
] ]

View file

@ -9,6 +9,8 @@ WEB_VIEW_EVENTS =
'did-start-loading': [] 'did-start-loading': []
'did-stop-loading': [] 'did-stop-loading': []
'did-get-redirect-request': ['oldUrl', 'newUrl', 'isMainFrame'] 'did-get-redirect-request': ['oldUrl', 'newUrl', 'isMainFrame']
'console-message': ['level', 'message', 'line', 'sourceId']
'close': []
'crashed': [] 'crashed': []
'destroyed': [] 'destroyed': []