api base
This commit is contained in:
parent
c45d9555e7
commit
0dbe4bc417
7 changed files with 188 additions and 216 deletions
|
@ -288,6 +288,9 @@ WebContents::WebContents(v8::Isolate* isolate,
|
||||||
else if (options.Get("isBackgroundPage", &b) && b)
|
else if (options.Get("isBackgroundPage", &b) && b)
|
||||||
type_ = BACKGROUND_PAGE;
|
type_ = BACKGROUND_PAGE;
|
||||||
|
|
||||||
|
bool offscreen = false;
|
||||||
|
options.Get("offScreen", &offscreen);
|
||||||
|
|
||||||
// Obtain the session.
|
// Obtain the session.
|
||||||
std::string partition;
|
std::string partition;
|
||||||
mate::Handle<api::Session> session;
|
mate::Handle<api::Session> session;
|
||||||
|
@ -310,8 +313,8 @@ WebContents::WebContents(v8::Isolate* isolate,
|
||||||
guest_delegate_.reset(new WebViewGuestDelegate);
|
guest_delegate_.reset(new WebViewGuestDelegate);
|
||||||
params.guest_delegate = guest_delegate_.get();
|
params.guest_delegate = guest_delegate_.get();
|
||||||
web_contents = content::WebContents::Create(params);
|
web_contents = content::WebContents::Create(params);
|
||||||
} else {
|
} else if(offscreen) {
|
||||||
content::WebContents::CreateParams params(session->browser_context());
|
content::WebContents::CreateParams params(session->browser_context());
|
||||||
|
|
||||||
auto view = new OffScreenWebContentsView();
|
auto view = new OffScreenWebContentsView();
|
||||||
params.view = view;
|
params.view = view;
|
||||||
|
@ -319,6 +322,9 @@ WebContents::WebContents(v8::Isolate* isolate,
|
||||||
|
|
||||||
web_contents = content::WebContents::Create(params);
|
web_contents = content::WebContents::Create(params);
|
||||||
view->SetWebContents(web_contents);
|
view->SetWebContents(web_contents);
|
||||||
|
} else {
|
||||||
|
content::WebContents::CreateParams params(session->browser_context());
|
||||||
|
web_contents = content::WebContents::Create(params);
|
||||||
}
|
}
|
||||||
|
|
||||||
Observe(web_contents);
|
Observe(web_contents);
|
||||||
|
|
|
@ -74,14 +74,6 @@ Window::Window(v8::Isolate* isolate, const mate::Dictionary& options) {
|
||||||
mate::Dictionary web_preferences = mate::Dictionary::CreateEmpty(isolate);
|
mate::Dictionary web_preferences = mate::Dictionary::CreateEmpty(isolate);
|
||||||
options.Get(options::kWebPreferences, &web_preferences);
|
options.Get(options::kWebPreferences, &web_preferences);
|
||||||
|
|
||||||
bool b;
|
|
||||||
if (options.Get("disableGPU", &b) && b) {
|
|
||||||
base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
|
|
||||||
|
|
||||||
command_line->AppendSwitch(::switches::kDisableGpu);
|
|
||||||
command_line->AppendSwitch(::switches::kDisableGpuCompositing);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Copy the backgroundColor to webContents.
|
// Copy the backgroundColor to webContents.
|
||||||
v8::Local<v8::Value> value;
|
v8::Local<v8::Value> value;
|
||||||
if (options.Get(options::kBackgroundColor, &value))
|
if (options.Get(options::kBackgroundColor, &value))
|
||||||
|
|
|
@ -188,20 +188,12 @@ void CommonWebContentsDelegate::InitWithWebContents(
|
||||||
printing::PrintViewManagerBasic::CreateForWebContents(web_contents);
|
printing::PrintViewManagerBasic::CreateForWebContents(web_contents);
|
||||||
printing::PrintPreviewMessageHandler::CreateForWebContents(web_contents);
|
printing::PrintPreviewMessageHandler::CreateForWebContents(web_contents);
|
||||||
|
|
||||||
// content::WebContentsImpl* impl =
|
|
||||||
// reinterpret_cast<content::WebContentsImpl*>(web_contents);
|
|
||||||
|
|
||||||
std::cout << "end" << std::endl;
|
|
||||||
// Create InspectableWebContents.
|
// Create InspectableWebContents.
|
||||||
web_contents_.reset(brightray::InspectableWebContents::Create(web_contents));
|
web_contents_.reset(brightray::InspectableWebContents::Create(web_contents));
|
||||||
web_contents_->SetDelegate(this);
|
web_contents_->SetDelegate(this);
|
||||||
|
|
||||||
// impl->SetView(new OffScreenWebContentsView);
|
|
||||||
std::cout << "end" << std::endl;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CommonWebContentsDelegate::SetOwnerWindow(NativeWindow* owner_window) {
|
void CommonWebContentsDelegate::SetOwnerWindow(NativeWindow* owner_window) {
|
||||||
std::cout << "SetOwnerWindow" << std::endl;
|
|
||||||
SetOwnerWindow(GetWebContents(), owner_window);
|
SetOwnerWindow(GetWebContents(), owner_window);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -344,24 +344,6 @@ NativeWindowViews::~NativeWindowViews() {
|
||||||
window_->RemoveObserver(this);
|
window_->RemoveObserver(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void NativeWindowViews::RenderViewCreated(
|
|
||||||
content::RenderViewHost* render_view_host) {
|
|
||||||
std::cout << "NativeWindowViews::RenderViewCreated" << std::endl;
|
|
||||||
NativeWindow::RenderViewCreated(render_view_host);
|
|
||||||
|
|
||||||
content::RenderWidgetHostImpl* impl = content::RenderWidgetHostImpl::FromID(
|
|
||||||
render_view_host->GetProcess()->GetID(),
|
|
||||||
render_view_host->GetRoutingID());
|
|
||||||
if (impl) {
|
|
||||||
//auto win = new OffScreenWindow(impl);
|
|
||||||
|
|
||||||
/*auto view = widget()->GetContentsView();
|
|
||||||
view->AcquireLayer();
|
|
||||||
view->SetLayer(win->DelegatedFrameHostGetLayer());
|
|
||||||
win->DelegatedFrameHostGetLayer()->set_delegate(view);*/
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void NativeWindowViews::Close() {
|
void NativeWindowViews::Close() {
|
||||||
if (!IsClosable()) {
|
if (!IsClosable()) {
|
||||||
WindowList::WindowCloseCancelled(this);
|
WindowList::WindowCloseCancelled(this);
|
||||||
|
|
|
@ -49,7 +49,6 @@ class NativeWindowViews : public NativeWindow,
|
||||||
~NativeWindowViews() override;
|
~NativeWindowViews() override;
|
||||||
|
|
||||||
// NativeWindow:
|
// NativeWindow:
|
||||||
void RenderViewCreated(content::RenderViewHost*) override;
|
|
||||||
void Close() override;
|
void Close() override;
|
||||||
void CloseImmediately() override;
|
void CloseImmediately() override;
|
||||||
void Focus(bool focus) override;
|
void Focus(bool focus) override;
|
||||||
|
|
|
@ -25,8 +25,6 @@
|
||||||
#include "ui/gfx/switches.h"
|
#include "ui/gfx/switches.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <iostream>
|
|
||||||
|
|
||||||
DEFINE_WEB_CONTENTS_USER_DATA_KEY(atom::WebContentsPreferences);
|
DEFINE_WEB_CONTENTS_USER_DATA_KEY(atom::WebContentsPreferences);
|
||||||
|
|
||||||
namespace atom {
|
namespace atom {
|
||||||
|
|
|
@ -15,6 +15,9 @@ let mainWindow6 = null
|
||||||
let mainWindow7 = null
|
let mainWindow7 = null
|
||||||
let mainWindow8 = null
|
let mainWindow8 = null
|
||||||
|
|
||||||
|
app.commandLine.appendSwitch('--disable-gpu');
|
||||||
|
app.commandLine.appendSwitch('--disable-gpu-compositing');
|
||||||
|
|
||||||
// Quit when all windows are closed.
|
// Quit when all windows are closed.
|
||||||
app.on('window-all-closed', () => {
|
app.on('window-all-closed', () => {
|
||||||
app.quit()
|
app.quit()
|
||||||
|
@ -23,13 +26,13 @@ app.on('window-all-closed', () => {
|
||||||
exports.load = (appUrl) => {
|
exports.load = (appUrl) => {
|
||||||
app.on('ready', () => {
|
app.on('ready', () => {
|
||||||
mainWindow1 = new BrowserWindow({
|
mainWindow1 = new BrowserWindow({
|
||||||
disableGPU: true,
|
|
||||||
width: 800,
|
width: 800,
|
||||||
height: 600,
|
height: 600,
|
||||||
autoHideMenuBar: true,
|
autoHideMenuBar: true,
|
||||||
backgroundColor: '#FFFFFF',
|
backgroundColor: '#FFFFFF',
|
||||||
useContentSize: true,
|
useContentSize: true,
|
||||||
webPreferences: {
|
webPreferences: {
|
||||||
|
offScreen: true,
|
||||||
nodeIntegration: false
|
nodeIntegration: false
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -73,7 +76,7 @@ exports.load = (appUrl) => {
|
||||||
})
|
})
|
||||||
mainWindow2.loadURL(appUrl)
|
mainWindow2.loadURL(appUrl)
|
||||||
mainWindow2.focus()
|
mainWindow2.focus()
|
||||||
mainWindow2.webContents.on('dom-ready', () => {
|
/*mainWindow2.webContents.on('dom-ready', () => {
|
||||||
mainWindow2.webContents.beginFrameSubscription(() => {
|
mainWindow2.webContents.beginFrameSubscription(() => {
|
||||||
console.log("asd")
|
console.log("asd")
|
||||||
})
|
})
|
||||||
|
@ -88,180 +91,180 @@ exports.load = (appUrl) => {
|
||||||
console.log(`browser #2: ${d < 10 ? ` ${d}` : d} ms`)
|
console.log(`browser #2: ${d < 10 ? ` ${d}` : d} ms`)
|
||||||
|
|
||||||
start2 = end2
|
start2 = end2
|
||||||
})
|
})*/
|
||||||
|
//
|
||||||
mainWindow3 = new BrowserWindow({
|
// mainWindow3 = new BrowserWindow({
|
||||||
width: 800,
|
// width: 800,
|
||||||
height: 600,
|
// height: 600,
|
||||||
autoHideMenuBar: true,
|
// autoHideMenuBar: true,
|
||||||
backgroundColor: '#FFFFFF',
|
// backgroundColor: '#FFFFFF',
|
||||||
useContentSize: true,
|
// useContentSize: true,
|
||||||
webPreferences: {
|
// webPreferences: {
|
||||||
nodeIntegration: false
|
// nodeIntegration: false
|
||||||
}
|
// }
|
||||||
})
|
// })
|
||||||
mainWindow3.loadURL(appUrl)
|
// mainWindow3.loadURL(appUrl)
|
||||||
mainWindow3.focus()
|
// mainWindow3.focus()
|
||||||
mainWindow3.webContents.on('dom-ready', () => {
|
// mainWindow3.webContents.on('dom-ready', () => {
|
||||||
mainWindow3.webContents.beginFrameSubscription(() => {
|
// mainWindow3.webContents.beginFrameSubscription(() => {
|
||||||
console.log("asd")
|
// console.log("asd")
|
||||||
})
|
// })
|
||||||
})
|
// })
|
||||||
|
//
|
||||||
var start3, end3
|
// var start3, end3
|
||||||
start3 = +new Date();
|
// start3 = +new Date();
|
||||||
mainWindow3.webContents.on('paint', (e, rect, w, h, data) => {
|
// mainWindow3.webContents.on('paint', (e, rect, w, h, data) => {
|
||||||
end3 = +new Date();
|
// end3 = +new Date();
|
||||||
|
//
|
||||||
const d = end3 - start3
|
// const d = end3 - start3
|
||||||
console.log(`browser #3: ${d < 10 ? ` ${d}` : d} ms`)
|
// console.log(`browser #3: ${d < 10 ? ` ${d}` : d} ms`)
|
||||||
|
//
|
||||||
start3 = end3
|
// start3 = end3
|
||||||
})
|
// })
|
||||||
|
//
|
||||||
mainWindow4 = new BrowserWindow({
|
// mainWindow4 = new BrowserWindow({
|
||||||
width: 800,
|
// width: 800,
|
||||||
height: 600,
|
// height: 600,
|
||||||
autoHideMenuBar: true,
|
// autoHideMenuBar: true,
|
||||||
backgroundColor: '#FFFFFF',
|
// backgroundColor: '#FFFFFF',
|
||||||
useContentSize: true,
|
// useContentSize: true,
|
||||||
webPreferences: {
|
// webPreferences: {
|
||||||
nodeIntegration: false
|
// nodeIntegration: false
|
||||||
}
|
// }
|
||||||
})
|
// })
|
||||||
mainWindow4.loadURL(appUrl)
|
// mainWindow4.loadURL(appUrl)
|
||||||
mainWindow4.focus()
|
// mainWindow4.focus()
|
||||||
mainWindow4.webContents.on('dom-ready', () => {
|
// mainWindow4.webContents.on('dom-ready', () => {
|
||||||
mainWindow4.webContents.beginFrameSubscription(() => {
|
// mainWindow4.webContents.beginFrameSubscription(() => {
|
||||||
console.log("asd")
|
// console.log("asd")
|
||||||
})
|
// })
|
||||||
})
|
// })
|
||||||
|
//
|
||||||
var start4, end4
|
// var start4, end4
|
||||||
start4 = +new Date();
|
// start4 = +new Date();
|
||||||
mainWindow4.webContents.on('paint', (e, rect, w, h, data) => {
|
// mainWindow4.webContents.on('paint', (e, rect, w, h, data) => {
|
||||||
end4 = +new Date();
|
// end4 = +new Date();
|
||||||
|
//
|
||||||
const d = end4 - start4
|
// const d = end4 - start4
|
||||||
console.log(`browser #4: ${d < 10 ? ` ${d}` : d} ms`)
|
// console.log(`browser #4: ${d < 10 ? ` ${d}` : d} ms`)
|
||||||
|
//
|
||||||
start4 = end4
|
// start4 = end4
|
||||||
})
|
// })
|
||||||
|
//
|
||||||
mainWindow5 = new BrowserWindow({
|
// mainWindow5 = new BrowserWindow({
|
||||||
width: 800,
|
// width: 800,
|
||||||
height: 600,
|
// height: 600,
|
||||||
autoHideMenuBar: true,
|
// autoHideMenuBar: true,
|
||||||
backgroundColor: '#FFFFFF',
|
// backgroundColor: '#FFFFFF',
|
||||||
useContentSize: true,
|
// useContentSize: true,
|
||||||
webPreferences: {
|
// webPreferences: {
|
||||||
nodeIntegration: false
|
// nodeIntegration: false
|
||||||
}
|
// }
|
||||||
})
|
// })
|
||||||
mainWindow5.loadURL(appUrl)
|
// mainWindow5.loadURL(appUrl)
|
||||||
mainWindow5.focus()
|
// mainWindow5.focus()
|
||||||
mainWindow5.webContents.on('dom-ready', () => {
|
// mainWindow5.webContents.on('dom-ready', () => {
|
||||||
mainWindow5.webContents.beginFrameSubscription(() => {
|
// mainWindow5.webContents.beginFrameSubscription(() => {
|
||||||
console.log("asd")
|
// console.log("asd")
|
||||||
})
|
// })
|
||||||
})
|
// })
|
||||||
|
//
|
||||||
var start5, end5
|
// var start5, end5
|
||||||
start5 = +new Date();
|
// start5 = +new Date();
|
||||||
mainWindow5.webContents.on('paint', (e, rect, w, h, data) => {
|
// mainWindow5.webContents.on('paint', (e, rect, w, h, data) => {
|
||||||
end5 = +new Date();
|
// end5 = +new Date();
|
||||||
|
//
|
||||||
const d = end5 - start5
|
// const d = end5 - start5
|
||||||
console.log(`browser #5: ${d < 10 ? ` ${d}` : d} ms`)
|
// console.log(`browser #5: ${d < 10 ? ` ${d}` : d} ms`)
|
||||||
|
//
|
||||||
start5 = end5
|
// start5 = end5
|
||||||
})
|
// })
|
||||||
|
//
|
||||||
mainWindow6 = new BrowserWindow({
|
// mainWindow6 = new BrowserWindow({
|
||||||
width: 800,
|
// width: 800,
|
||||||
height: 600,
|
// height: 600,
|
||||||
autoHideMenuBar: true,
|
// autoHideMenuBar: true,
|
||||||
backgroundColor: '#FFFFFF',
|
// backgroundColor: '#FFFFFF',
|
||||||
useContentSize: true,
|
// useContentSize: true,
|
||||||
webPreferences: {
|
// webPreferences: {
|
||||||
nodeIntegration: false
|
// nodeIntegration: false
|
||||||
}
|
// }
|
||||||
})
|
// })
|
||||||
mainWindow6.loadURL(appUrl)
|
// mainWindow6.loadURL(appUrl)
|
||||||
mainWindow6.focus()
|
// mainWindow6.focus()
|
||||||
mainWindow6.webContents.on('dom-ready', () => {
|
// mainWindow6.webContents.on('dom-ready', () => {
|
||||||
mainWindow6.webContents.beginFrameSubscription(() => {
|
// mainWindow6.webContents.beginFrameSubscription(() => {
|
||||||
console.log("asd")
|
// console.log("asd")
|
||||||
})
|
// })
|
||||||
})
|
// })
|
||||||
|
//
|
||||||
var start6, end6
|
// var start6, end6
|
||||||
start6 = +new Date();
|
// start6 = +new Date();
|
||||||
mainWindow6.webContents.on('paint', (e, rect, w, h, data) => {
|
// mainWindow6.webContents.on('paint', (e, rect, w, h, data) => {
|
||||||
end6 = +new Date();
|
// end6 = +new Date();
|
||||||
|
//
|
||||||
const d = end6 - start6
|
// const d = end6 - start6
|
||||||
console.log(`browser #6: ${d < 10 ? ` ${d}` : d} ms`)
|
// console.log(`browser #6: ${d < 10 ? ` ${d}` : d} ms`)
|
||||||
|
//
|
||||||
start6 = end6
|
// start6 = end6
|
||||||
})
|
// })
|
||||||
|
//
|
||||||
mainWindow7 = new BrowserWindow({
|
// mainWindow7 = new BrowserWindow({
|
||||||
width: 800,
|
// width: 800,
|
||||||
height: 600,
|
// height: 600,
|
||||||
autoHideMenuBar: true,
|
// autoHideMenuBar: true,
|
||||||
backgroundColor: '#FFFFFF',
|
// backgroundColor: '#FFFFFF',
|
||||||
useContentSize: true,
|
// useContentSize: true,
|
||||||
webPreferences: {
|
// webPreferences: {
|
||||||
nodeIntegration: false
|
// nodeIntegration: false
|
||||||
}
|
// }
|
||||||
})
|
// })
|
||||||
mainWindow7.loadURL(appUrl)
|
// mainWindow7.loadURL(appUrl)
|
||||||
mainWindow7.focus()
|
// mainWindow7.focus()
|
||||||
mainWindow7.webContents.on('dom-ready', () => {
|
// mainWindow7.webContents.on('dom-ready', () => {
|
||||||
mainWindow7.webContents.beginFrameSubscription(() => {
|
// mainWindow7.webContents.beginFrameSubscription(() => {
|
||||||
console.log("asd")
|
// console.log("asd")
|
||||||
})
|
// })
|
||||||
})
|
// })
|
||||||
|
//
|
||||||
var start7, end7
|
// var start7, end7
|
||||||
start7 = +new Date();
|
// start7 = +new Date();
|
||||||
mainWindow7.webContents.on('paint', (e, rect, w, h, data) => {
|
// mainWindow7.webContents.on('paint', (e, rect, w, h, data) => {
|
||||||
end7 = +new Date();
|
// end7 = +new Date();
|
||||||
|
//
|
||||||
const d = end7 - start7
|
// const d = end7 - start7
|
||||||
console.log(`browser #7: ${d < 10 ? ` ${d}` : d} ms`)
|
// console.log(`browser #7: ${d < 10 ? ` ${d}` : d} ms`)
|
||||||
|
//
|
||||||
start7 = end7
|
// start7 = end7
|
||||||
})
|
// })
|
||||||
|
//
|
||||||
mainWindow8 = new BrowserWindow({
|
// mainWindow8 = new BrowserWindow({
|
||||||
width: 800,
|
// width: 800,
|
||||||
height: 600,
|
// height: 600,
|
||||||
autoHideMenuBar: true,
|
// autoHideMenuBar: true,
|
||||||
backgroundColor: '#FFFFFF',
|
// backgroundColor: '#FFFFFF',
|
||||||
useContentSize: true,
|
// useContentSize: true,
|
||||||
webPreferences: {
|
// webPreferences: {
|
||||||
nodeIntegration: false
|
// nodeIntegration: false
|
||||||
}
|
// }
|
||||||
})
|
// })
|
||||||
mainWindow8.loadURL(appUrl)
|
// mainWindow8.loadURL(appUrl)
|
||||||
mainWindow8.focus()
|
// mainWindow8.focus()
|
||||||
mainWindow8.webContents.on('dom-ready', () => {
|
// mainWindow8.webContents.on('dom-ready', () => {
|
||||||
mainWindow8.webContents.beginFrameSubscription(() => {
|
// mainWindow8.webContents.beginFrameSubscription(() => {
|
||||||
console.log("asd")
|
// console.log("asd")
|
||||||
})
|
// })
|
||||||
})
|
// })
|
||||||
|
//
|
||||||
var start8, end8
|
// var start8, end8
|
||||||
start8 = +new Date();
|
// start8 = +new Date();
|
||||||
mainWindow8.webContents.on('paint', (e, rect, w, h, data) => {
|
// mainWindow8.webContents.on('paint', (e, rect, w, h, data) => {
|
||||||
end8 = +new Date();
|
// end8 = +new Date();
|
||||||
|
//
|
||||||
const d = end8 - start8
|
// const d = end8 - start8
|
||||||
console.log(`browser #8: ${d < 10 ? ` ${d}` : d} ms`)
|
// console.log(`browser #8: ${d < 10 ? ` ${d}` : d} ms`)
|
||||||
|
//
|
||||||
start8 = end8
|
// start8 = end8
|
||||||
})
|
// })
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue