void WebContents::DidAttach() {
base::ListValue args;
args.Append(extra_params_.release());
- Emit("internal-did-attach", args);
+ Emit("did-attach", args);
}
int WebContents::GetGuestInstanceID() const {
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) ->
#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"
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;
}
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
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);
}
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)
#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"
WebFrame();
virtual ~WebFrame();
+ void SetName(const std::string& name);
+
double SetZoomLevel(double level);
double GetZoomLevel() const;
double SetZoomFactor(double factor);
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,
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++
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')
# 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) =>
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.
@attachWindow guestInstanceId, false
@pendingGuestCreation = true
- onFrameNameChanged: (name) ->
- @name ?= ''
- if @name is ''
- @webviewNode.removeAttribute 'name'
- else
- @webviewNode.setAttribute 'name', @name
-
@dispatchEvent = (webViewEvent) ->
@webviewNode.dispatchEvent webViewEvent
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
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