Rename web-view module to web-frame

This commit is contained in:
Cheng Zhao 2014-10-24 18:24:12 +08:00
parent 4f43c41577
commit 4ccb0cccf3
13 changed files with 116 additions and 120 deletions

View file

@ -0,0 +1,81 @@
// Copyright (c) 2014 GitHub, Inc. All rights reserved.
// Use of this source code is governed by the MIT license that can be
// found in the LICENSE file.
#include "atom/renderer/api/atom_api_web_frame.h"
#include "atom/common/native_mate_converters/string16_converter.h"
#include "native_mate/dictionary.h"
#include "native_mate/object_template_builder.h"
#include "third_party/WebKit/public/web/WebDocument.h"
#include "third_party/WebKit/public/web/WebLocalFrame.h"
#include "third_party/WebKit/public/web/WebView.h"
#include "atom/common/node_includes.h"
namespace atom {
namespace api {
WebFrame::WebFrame()
: web_frame_(blink::WebLocalFrame::frameForCurrentContext()) {
}
WebFrame::~WebFrame() {
}
double WebFrame::SetZoomLevel(double level) {
return web_frame_->view()->setZoomLevel(level);
}
double WebFrame::GetZoomLevel() const {
return web_frame_->view()->zoomLevel();
}
double WebFrame::SetZoomFactor(double factor) {
return blink::WebView::zoomLevelToZoomFactor(SetZoomLevel(
blink::WebView::zoomFactorToZoomLevel(factor)));
}
double WebFrame::GetZoomFactor() const {
return blink::WebView::zoomLevelToZoomFactor(GetZoomLevel());
}
v8::Handle<v8::Value> WebFrame::RegisterEmbedderCustomElement(
const base::string16& name, v8::Handle<v8::Object> options) {
blink::WebExceptionCode c = 0;
return web_frame_->document().registerEmbedderCustomElement(name, options, c);
}
mate::ObjectTemplateBuilder WebFrame::GetObjectTemplateBuilder(
v8::Isolate* isolate) {
return mate::ObjectTemplateBuilder(isolate)
.SetMethod("setZoomLevel", &WebFrame::SetZoomLevel)
.SetMethod("getZoomLevel", &WebFrame::GetZoomLevel)
.SetMethod("setZoomFactor", &WebFrame::SetZoomFactor)
.SetMethod("getZoomFactor", &WebFrame::GetZoomFactor)
.SetMethod("registerEmbedderCustomElement",
&WebFrame::RegisterEmbedderCustomElement);
}
// static
mate::Handle<WebFrame> WebFrame::Create(v8::Isolate* isolate) {
return CreateHandle(isolate, new WebFrame);
}
} // namespace api
} // namespace atom
namespace {
void Initialize(v8::Handle<v8::Object> exports, v8::Handle<v8::Value> unused,
v8::Handle<v8::Context> context, void* priv) {
v8::Isolate* isolate = context->GetIsolate();
mate::Dictionary dict(isolate, exports);
dict.Set("webFrame", atom::api::WebFrame::Create(isolate));
}
} // namespace
NODE_MODULE_CONTEXT_AWARE_BUILTIN(atom_renderer_web_frame, Initialize)

View file

@ -2,27 +2,27 @@
// Use of this source code is governed by the MIT license that can be
// found in the LICENSE file.
#ifndef ATOM_RENDERER_API_ATOM_API_WEB_VIEW_H_
#define ATOM_RENDERER_API_ATOM_API_WEB_VIEW_H_
#ifndef ATOM_RENDERER_API_ATOM_API_WEB_FRAME_H_
#define ATOM_RENDERER_API_ATOM_API_WEB_FRAME_H_
#include "native_mate/handle.h"
#include "native_mate/wrappable.h"
namespace blink {
class WebView;
class WebLocalFrame;
}
namespace atom {
namespace api {
class WebView : public mate::Wrappable {
class WebFrame : public mate::Wrappable {
public:
static mate::Handle<WebView> Create(v8::Isolate* isolate);
static mate::Handle<WebFrame> Create(v8::Isolate* isolate);
private:
WebView();
virtual ~WebView();
WebFrame();
virtual ~WebFrame();
double SetZoomLevel(double level);
double GetZoomLevel() const;
@ -36,13 +36,13 @@ class WebView : public mate::Wrappable {
virtual mate::ObjectTemplateBuilder GetObjectTemplateBuilder(
v8::Isolate* isolate);
blink::WebView* web_view_;
blink::WebLocalFrame* web_frame_;
DISALLOW_COPY_AND_ASSIGN(WebView);
DISALLOW_COPY_AND_ASSIGN(WebFrame);
};
} // namespace api
} // namespace atom
#endif // ATOM_RENDERER_API_ATOM_API_WEB_VIEW_H_
#endif // ATOM_RENDERER_API_ATOM_API_WEB_FRAME_H_

View file

@ -1,92 +0,0 @@
// Copyright (c) 2014 GitHub, Inc. All rights reserved.
// Use of this source code is governed by the MIT license that can be
// found in the LICENSE file.
#include "atom/renderer/api/atom_api_web_view.h"
#include "atom/common/native_mate_converters/string16_converter.h"
#include "native_mate/dictionary.h"
#include "native_mate/object_template_builder.h"
#include "third_party/WebKit/public/web/WebDocument.h"
#include "third_party/WebKit/public/web/WebLocalFrame.h"
#include "third_party/WebKit/public/web/WebView.h"
#include "atom/common/node_includes.h"
namespace atom {
namespace api {
namespace {
blink::WebView* GetCurrentWebView() {
blink::WebLocalFrame* frame = blink::WebLocalFrame::frameForCurrentContext();
if (!frame)
return NULL;
return frame->view();
}
} // namespace
WebView::WebView() : web_view_(GetCurrentWebView()) {
}
WebView::~WebView() {
}
double WebView::SetZoomLevel(double level) {
return web_view_->setZoomLevel(level);
}
double WebView::GetZoomLevel() const {
return web_view_->zoomLevel();
}
double WebView::SetZoomFactor(double factor) {
return blink::WebView::zoomLevelToZoomFactor(SetZoomLevel(
blink::WebView::zoomFactorToZoomLevel(factor)));
}
double WebView::GetZoomFactor() const {
return blink::WebView::zoomLevelToZoomFactor(GetZoomLevel());
}
v8::Handle<v8::Value> WebView::RegisterEmbedderCustomElement(
const base::string16& name, v8::Handle<v8::Object> options) {
auto document = blink::WebLocalFrame::frameForCurrentContext()->document();
blink::WebExceptionCode ec = 0;
return document.registerEmbedderCustomElement(name, options, ec);
}
mate::ObjectTemplateBuilder WebView::GetObjectTemplateBuilder(
v8::Isolate* isolate) {
return mate::ObjectTemplateBuilder(isolate)
.SetMethod("setZoomLevel", &WebView::SetZoomLevel)
.SetMethod("getZoomLevel", &WebView::GetZoomLevel)
.SetMethod("setZoomFactor", &WebView::SetZoomFactor)
.SetMethod("getZoomFactor", &WebView::GetZoomFactor)
.SetMethod("registerEmbedderCustomElement",
&WebView::RegisterEmbedderCustomElement);
}
// static
mate::Handle<WebView> WebView::Create(v8::Isolate* isolate) {
return CreateHandle(isolate, new WebView);
}
} // namespace api
} // namespace atom
namespace {
void Initialize(v8::Handle<v8::Object> exports, v8::Handle<v8::Value> unused,
v8::Handle<v8::Context> context, void* priv) {
v8::Isolate* isolate = context->GetIsolate();
mate::Dictionary dict(isolate, exports);
dict.Set("webView", atom::api::WebView::Create(isolate));
}
} // namespace
NODE_MODULE_CONTEXT_AWARE_BUILTIN(atom_renderer_web_view, Initialize)

View file

@ -0,0 +1 @@
module.exports = process.atomBinding('web_frame').webFrame

View file

@ -1 +0,0 @@
module.exports = process.atomBinding('web_view').webView

View file

@ -1,7 +1,10 @@
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++

View file

@ -57,4 +57,4 @@ else
# Override default web functions.
require path.join(__dirname, 'override')
# Load webview tag implementation.
require path.join(__dirname, 'webview')
require path.join(__dirname, 'web-view')

View file

@ -1,6 +1,6 @@
v8Util = process.atomBinding 'v8_util'
guestViewInternal = require './guest-view-internal'
webView = require 'web-view'
webFrame = require 'web-frame'
# ID generator.
nextId = 0
@ -487,7 +487,7 @@ registerBrowserPluginElement = ->
# Load the plugin immediately.
unused = this.nonExistentAttribute
WebView.BrowserPlugin = webView.registerEmbedderCustomElement 'browserplugin',
WebView.BrowserPlugin = webFrame.registerEmbedderCustomElement 'browserplugin',
extends: 'object', prototype: proto
delete proto.createdCallback