Add background page web contents type
This commit is contained in:
parent
ee0bab6389
commit
f29801ad2b
3 changed files with 19 additions and 5 deletions
|
@ -193,10 +193,20 @@ struct Converter<atom::api::WebContents::Type> {
|
||||||
atom::api::WebContents::Type val) {
|
atom::api::WebContents::Type val) {
|
||||||
std::string type = "";
|
std::string type = "";
|
||||||
switch (val) {
|
switch (val) {
|
||||||
case atom::api::WebContents::Type::BROWSER_WINDOW: type = "window"; break;
|
case atom::api::WebContents::Type::BACKGROUND_PAGE:
|
||||||
case atom::api::WebContents::Type::WEB_VIEW: type = "webview"; break;
|
type = "backgroundPage";
|
||||||
case atom::api::WebContents::Type::REMOTE: type = "remote"; break;
|
break;
|
||||||
default: break;
|
case atom::api::WebContents::Type::BROWSER_WINDOW:
|
||||||
|
type = "window";
|
||||||
|
break;
|
||||||
|
case atom::api::WebContents::Type::REMOTE:
|
||||||
|
type = "remote";
|
||||||
|
break;
|
||||||
|
case atom::api::WebContents::Type::WEB_VIEW:
|
||||||
|
type = "webview";
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
return mate::ConvertToV8(isolate, type);
|
return mate::ConvertToV8(isolate, type);
|
||||||
}
|
}
|
||||||
|
@ -208,6 +218,8 @@ struct Converter<atom::api::WebContents::Type> {
|
||||||
return false;
|
return false;
|
||||||
if (type == "webview") {
|
if (type == "webview") {
|
||||||
*out = atom::api::WebContents::Type::WEB_VIEW;
|
*out = atom::api::WebContents::Type::WEB_VIEW;
|
||||||
|
} else if (type == "backgroundPage") {
|
||||||
|
*out = atom::api::WebContents::Type::BACKGROUND_PAGE;
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,9 +44,10 @@ class WebContents : public mate::TrackableObject<WebContents>,
|
||||||
public content::WebContentsObserver {
|
public content::WebContentsObserver {
|
||||||
public:
|
public:
|
||||||
enum Type {
|
enum Type {
|
||||||
|
BACKGROUND_PAGE, // A DevTools extension background page.
|
||||||
BROWSER_WINDOW, // Used by BrowserWindow.
|
BROWSER_WINDOW, // Used by BrowserWindow.
|
||||||
WEB_VIEW, // Used by <webview>.
|
|
||||||
REMOTE, // Thin wrap around an existing WebContents.
|
REMOTE, // Thin wrap around an existing WebContents.
|
||||||
|
WEB_VIEW, // Used by <webview>.
|
||||||
};
|
};
|
||||||
|
|
||||||
// For node.js callback function type: function(error, buffer)
|
// For node.js callback function type: function(error, buffer)
|
||||||
|
|
|
@ -73,6 +73,7 @@ const startBackgroundPages = function (manifest) {
|
||||||
const html = new Buffer(`<html><body>${scripts}</body></html>`)
|
const html = new Buffer(`<html><body>${scripts}</body></html>`)
|
||||||
|
|
||||||
const contents = webContents.create({
|
const contents = webContents.create({
|
||||||
|
type: 'backgroundPage',
|
||||||
commandLineSwitches: ['--background-page']
|
commandLineSwitches: ['--background-page']
|
||||||
})
|
})
|
||||||
backgroundPages[manifest.extensionId] = { html: html, webContents: contents }
|
backgroundPages[manifest.extensionId] = { html: html, webContents: contents }
|
||||||
|
|
Loading…
Reference in a new issue