Don't fork renderer process for guest
This commit is contained in:
parent
4ccb0cccf3
commit
58a38d90b8
10 changed files with 25 additions and 36 deletions
|
@ -160,7 +160,7 @@ content::WebContents* WebContents::CreateNewGuestWindow(
|
|||
void WebContents::DidAttach() {
|
||||
base::ListValue args;
|
||||
args.Append(extra_params_.release());
|
||||
Emit("internal-did-attach", args);
|
||||
Emit("did-attach", args);
|
||||
}
|
||||
|
||||
int WebContents::GetGuestInstanceID() const {
|
||||
|
|
|
@ -26,10 +26,6 @@ module.exports.wrap = (webContents) ->
|
|||
webContents.getId = -> "#{@getProcessId()}-#{@getRoutingId()}"
|
||||
webContents.equal = (other) -> @getId() is other.getId()
|
||||
|
||||
# Set frame name of WebContents.
|
||||
webContents.setName = (name) ->
|
||||
@send 'ATOM_SHELL_WEB_CONTENTS_SET_NAME', name
|
||||
|
||||
# Tell the rpc server that a render view has been deleted and we need to
|
||||
# release all objects owned by it.
|
||||
webContents.on 'render-view-deleted', (event, processId, routingId) ->
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
#include "atom/browser/atom_speech_recognition_manager_delegate.h"
|
||||
#include "atom/browser/native_window.h"
|
||||
#include "atom/browser/window_list.h"
|
||||
#include "base/command_line.h"
|
||||
#include "chrome/browser/printing/printing_message_filter.h"
|
||||
#include "chrome/browser/speech/tts_message_filter.h"
|
||||
#include "content/public/browser/render_process_host.h"
|
||||
|
@ -148,6 +149,9 @@ void AtomBrowserClient::AppendExtraCommandLineSwitches(
|
|||
|
||||
if (window != NULL)
|
||||
window->AppendExtraCommandLineSwitches(command_line, child_process_id);
|
||||
else
|
||||
// If we can not find a owner window then it is a guest web view.
|
||||
command_line->AppendSwitch("guest");
|
||||
|
||||
dying_render_process_ = NULL;
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ createGuest = (embedder, params) ->
|
|||
destroyGuest id
|
||||
|
||||
# Init guest web view after attached.
|
||||
guest.once 'internal-did-attach', (event, params) ->
|
||||
guest.once 'did-attach', (event, params) ->
|
||||
min = width: params.minwidth, height: params.minheight
|
||||
max = width: params.maxwidth, height: params.maxheight
|
||||
@setAutoSize params.autosize, min, max
|
||||
|
|
|
@ -24,6 +24,10 @@ WebFrame::WebFrame()
|
|||
WebFrame::~WebFrame() {
|
||||
}
|
||||
|
||||
void WebFrame::SetName(const std::string& name) {
|
||||
web_frame_->setName(blink::WebString::fromUTF8(name));
|
||||
}
|
||||
|
||||
double WebFrame::SetZoomLevel(double level) {
|
||||
return web_frame_->view()->setZoomLevel(level);
|
||||
}
|
||||
|
@ -50,6 +54,7 @@ v8::Handle<v8::Value> WebFrame::RegisterEmbedderCustomElement(
|
|||
mate::ObjectTemplateBuilder WebFrame::GetObjectTemplateBuilder(
|
||||
v8::Isolate* isolate) {
|
||||
return mate::ObjectTemplateBuilder(isolate)
|
||||
.SetMethod("setName", &WebFrame::SetName)
|
||||
.SetMethod("setZoomLevel", &WebFrame::SetZoomLevel)
|
||||
.SetMethod("getZoomLevel", &WebFrame::GetZoomLevel)
|
||||
.SetMethod("setZoomFactor", &WebFrame::SetZoomFactor)
|
||||
|
|
|
@ -5,6 +5,8 @@
|
|||
#ifndef ATOM_RENDERER_API_ATOM_API_WEB_FRAME_H_
|
||||
#define ATOM_RENDERER_API_ATOM_API_WEB_FRAME_H_
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "native_mate/handle.h"
|
||||
#include "native_mate/wrappable.h"
|
||||
|
||||
|
@ -24,6 +26,8 @@ class WebFrame : public mate::Wrappable {
|
|||
WebFrame();
|
||||
virtual ~WebFrame();
|
||||
|
||||
void SetName(const std::string& name);
|
||||
|
||||
double SetZoomLevel(double level);
|
||||
double GetZoomLevel() const;
|
||||
double SetZoomFactor(double factor);
|
||||
|
|
|
@ -214,6 +214,10 @@ bool AtomRendererClient::ShouldFork(blink::WebFrame* frame,
|
|||
bool is_initial_navigation,
|
||||
bool is_server_redirect,
|
||||
bool* send_referrer) {
|
||||
// Never fork renderer process for guests.
|
||||
if (frame->uniqueName().utf8() == "ATOM_SHELL_GUEST_WEB_VIEW")
|
||||
return false;
|
||||
|
||||
// Handle all the navigations and reloads in browser.
|
||||
// FIXME We only support GET here because http method will be ignored when
|
||||
// the OpenURLFromTab is triggered, which means form posting would not work,
|
||||
|
|
|
@ -1,10 +1,7 @@
|
|||
ipc = require 'ipc'
|
||||
webFrame = require 'web-frame'
|
||||
|
||||
requestId = 0
|
||||
|
||||
ipc.on 'ATOM_SHELL_WEB_CONTENTS_SET_NAME', (name) ->
|
||||
|
||||
module.exports =
|
||||
createGuest: (type, params, callback) ->
|
||||
requestId++
|
||||
|
|
|
@ -47,6 +47,11 @@ else
|
|||
global.__filename = __filename
|
||||
global.__dirname = __dirname
|
||||
|
||||
if '--guest' in process.argv
|
||||
# This is a guest web view.
|
||||
isGuest = true
|
||||
require('web-frame').setName 'ATOM_SHELL_GUEST_WEB_VIEW'
|
||||
|
||||
if location.protocol is 'chrome-devtools:'
|
||||
# Override some inspector APIs.
|
||||
require path.join(__dirname, 'inspector')
|
||||
|
|
|
@ -175,11 +175,6 @@ class WebView
|
|||
# No setter.
|
||||
enumerable: true
|
||||
|
||||
Object.defineProperty @webviewNode, 'name',
|
||||
get: => @name
|
||||
set: (value) => @webviewNode.setAttribute 'name', value
|
||||
enumerable: true
|
||||
|
||||
Object.defineProperty @webviewNode, 'partition',
|
||||
get: => @partition.toAttribute()
|
||||
set: (value) =>
|
||||
|
@ -243,19 +238,6 @@ class WebView
|
|||
return unless @guestInstanceId
|
||||
|
||||
guestViewInternal.setAllowTransparency @guestInstanceId, @allowtransparency
|
||||
else if name is 'name'
|
||||
# We treat null attribute (attribute removed) and the empty string as
|
||||
# one case.
|
||||
oldValue ?= ''
|
||||
newValue ?= ''
|
||||
|
||||
return if oldValue is newValue
|
||||
@name = newValue
|
||||
|
||||
return unless @guestInstanceId
|
||||
|
||||
# FIXME
|
||||
# WebViewInternal.setName @guestInstanceId, newValue
|
||||
else if name is 'src'
|
||||
# We treat null attribute (attribute removed) and the empty string as
|
||||
# one case.
|
||||
|
@ -399,13 +381,6 @@ class WebView
|
|||
@attachWindow guestInstanceId, false
|
||||
@pendingGuestCreation = true
|
||||
|
||||
onFrameNameChanged: (name) ->
|
||||
@name ?= ''
|
||||
if @name is ''
|
||||
@webviewNode.removeAttribute 'name'
|
||||
else
|
||||
@webviewNode.setAttribute 'name', @name
|
||||
|
||||
@dispatchEvent = (webViewEvent) ->
|
||||
@webviewNode.dispatchEvent webViewEvent
|
||||
|
||||
|
@ -446,7 +421,6 @@ class WebView
|
|||
maxwidth: parseInt @maxwidth || 0
|
||||
minheight: parseInt @minheight || 0
|
||||
minwidth: parseInt @minwidth || 0
|
||||
name: @name
|
||||
# We don't need to navigate new window from here.
|
||||
src: if isNewWindow then undefined else @src
|
||||
# If we have a partition from the opener, that will also be already
|
||||
|
@ -520,7 +494,7 @@ registerWebViewElement = ->
|
|||
internal.elementAttached = true
|
||||
internal.parseAttributes()
|
||||
|
||||
window.WebView = webView.registerEmbedderCustomElement 'webview',
|
||||
window.WebView = webFrame.registerEmbedderCustomElement 'webview',
|
||||
prototype: proto
|
||||
|
||||
# Delete the callbacks so developers cannot call them and produce unexpected
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue