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) {
|
||||
std::string type = "";
|
||||
switch (val) {
|
||||
case atom::api::WebContents::Type::BROWSER_WINDOW: type = "window"; break;
|
||||
case atom::api::WebContents::Type::WEB_VIEW: type = "webview"; break;
|
||||
case atom::api::WebContents::Type::REMOTE: type = "remote"; break;
|
||||
default: break;
|
||||
case atom::api::WebContents::Type::BACKGROUND_PAGE:
|
||||
type = "backgroundPage";
|
||||
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);
|
||||
}
|
||||
|
@ -208,6 +218,8 @@ struct Converter<atom::api::WebContents::Type> {
|
|||
return false;
|
||||
if (type == "webview") {
|
||||
*out = atom::api::WebContents::Type::WEB_VIEW;
|
||||
} else if (type == "backgroundPage") {
|
||||
*out = atom::api::WebContents::Type::BACKGROUND_PAGE;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -44,9 +44,10 @@ class WebContents : public mate::TrackableObject<WebContents>,
|
|||
public content::WebContentsObserver {
|
||||
public:
|
||||
enum Type {
|
||||
BACKGROUND_PAGE, // A DevTools extension background page.
|
||||
BROWSER_WINDOW, // Used by BrowserWindow.
|
||||
WEB_VIEW, // Used by <webview>.
|
||||
REMOTE, // Thin wrap around an existing WebContents.
|
||||
WEB_VIEW, // Used by <webview>.
|
||||
};
|
||||
|
||||
// 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 contents = webContents.create({
|
||||
type: 'backgroundPage',
|
||||
commandLineSwitches: ['--background-page']
|
||||
})
|
||||
backgroundPages[manifest.extensionId] = { html: html, webContents: contents }
|
||||
|
|
Loading…
Reference in a new issue