Add 'new-window' event for <webview>
This commit is contained in:
parent
d8447524cb
commit
194ed3884c
4 changed files with 27 additions and 8 deletions
|
@ -78,6 +78,21 @@ bool WebContents::AddMessageToConsole(content::WebContents* source,
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool WebContents::ShouldCreateWebContents(
|
||||||
|
content::WebContents* web_contents,
|
||||||
|
int route_id,
|
||||||
|
WindowContainerType window_container_type,
|
||||||
|
const base::string16& frame_name,
|
||||||
|
const GURL& target_url,
|
||||||
|
const std::string& partition_id,
|
||||||
|
content::SessionStorageNamespace* session_storage_namespace) {
|
||||||
|
base::ListValue args;
|
||||||
|
args.AppendString(target_url.spec());
|
||||||
|
args.AppendString(partition_id);
|
||||||
|
Emit("new-window", args);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
void WebContents::CloseContents(content::WebContents* source) {
|
void WebContents::CloseContents(content::WebContents* source) {
|
||||||
Emit("close");
|
Emit("close");
|
||||||
}
|
}
|
||||||
|
@ -210,14 +225,8 @@ void WebContents::WillAttach(content::WebContents* embedder_web_contents,
|
||||||
|
|
||||||
content::WebContents* WebContents::CreateNewGuestWindow(
|
content::WebContents* WebContents::CreateNewGuestWindow(
|
||||||
const content::WebContents::CreateParams& create_params) {
|
const content::WebContents::CreateParams& create_params) {
|
||||||
auto web_contents = content::WebContents::Create(create_params);
|
NOTREACHED() << "Should not create new window from guest";
|
||||||
// TODO Currently we just retain the web_contents on V8's heap, which will be
|
return nullptr;
|
||||||
// garbage collected later, we should provide a way to let users make use of
|
|
||||||
// this WebContents.
|
|
||||||
mate::Handle<WebContents> managed = CreateFrom(
|
|
||||||
v8::Isolate::GetCurrent(), web_contents);
|
|
||||||
managed->storage_.reset(web_contents);
|
|
||||||
return web_contents;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void WebContents::DidAttach() {
|
void WebContents::DidAttach() {
|
||||||
|
|
|
@ -93,6 +93,14 @@ class WebContents : public mate::EventEmitter,
|
||||||
const base::string16& message,
|
const base::string16& message,
|
||||||
int32 line_no,
|
int32 line_no,
|
||||||
const base::string16& source_id) override;
|
const base::string16& source_id) override;
|
||||||
|
bool ShouldCreateWebContents(
|
||||||
|
content::WebContents* web_contents,
|
||||||
|
int route_id,
|
||||||
|
WindowContainerType window_container_type,
|
||||||
|
const base::string16& frame_name,
|
||||||
|
const GURL& target_url,
|
||||||
|
const std::string& partition_id,
|
||||||
|
content::SessionStorageNamespace* session_storage_namespace) override;
|
||||||
void CloseContents(content::WebContents* source) override;
|
void CloseContents(content::WebContents* source) override;
|
||||||
content::WebContents* OpenURLFromTab(
|
content::WebContents* OpenURLFromTab(
|
||||||
content::WebContents* source,
|
content::WebContents* source,
|
||||||
|
|
|
@ -10,6 +10,7 @@ supportedWebViewEvents = [
|
||||||
'did-stop-loading'
|
'did-stop-loading'
|
||||||
'did-get-redirect-request'
|
'did-get-redirect-request'
|
||||||
'console-message'
|
'console-message'
|
||||||
|
'new-window'
|
||||||
'close'
|
'close'
|
||||||
'crashed'
|
'crashed'
|
||||||
'destroyed'
|
'destroyed'
|
||||||
|
|
|
@ -10,6 +10,7 @@ WEB_VIEW_EVENTS =
|
||||||
'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']
|
'console-message': ['level', 'message', 'line', 'sourceId']
|
||||||
|
'new-window': ['url', 'partitionId']
|
||||||
'close': []
|
'close': []
|
||||||
'crashed': []
|
'crashed': []
|
||||||
'destroyed': []
|
'destroyed': []
|
||||||
|
|
Loading…
Reference in a new issue