Adapt to API changes of Chromium and node.
This commit is contained in:
parent
58ccb27792
commit
cd4c5d976b
55 changed files with 281 additions and 402 deletions
|
@ -13,8 +13,8 @@
|
|||
#include "atom/common/node_includes.h"
|
||||
|
||||
using content::RenderView;
|
||||
using WebKit::WebFrame;
|
||||
using WebKit::WebView;
|
||||
using blink::WebFrame;
|
||||
using blink::WebView;
|
||||
|
||||
namespace {
|
||||
|
||||
|
@ -30,7 +30,7 @@ RenderView* GetCurrentRenderView() {
|
|||
return RenderView::FromWebView(view);
|
||||
}
|
||||
|
||||
void Send(const string16& channel, const base::ListValue& arguments) {
|
||||
void Send(const base::string16& channel, const base::ListValue& arguments) {
|
||||
RenderView* render_view = GetCurrentRenderView();
|
||||
if (render_view == NULL)
|
||||
return;
|
||||
|
@ -42,8 +42,9 @@ void Send(const string16& channel, const base::ListValue& arguments) {
|
|||
node::ThrowError("Unable to send AtomViewHostMsg_Message");
|
||||
}
|
||||
|
||||
string16 SendSync(const string16& channel, const base::ListValue& arguments) {
|
||||
string16 json;
|
||||
base::string16 SendSync(const base::string16& channel,
|
||||
const base::ListValue& arguments) {
|
||||
base::string16 json;
|
||||
|
||||
RenderView* render_view = GetCurrentRenderView();
|
||||
if (render_view == NULL)
|
||||
|
@ -69,4 +70,4 @@ void Initialize(v8::Handle<v8::Object> exports) {
|
|||
|
||||
} // namespace
|
||||
|
||||
NODE_MODULE(atom_renderer_ipc, Initialize)
|
||||
NODE_MODULE_X(atom_renderer_ipc, Initialize, NULL, NM_F_BUILTIN)
|
||||
|
|
|
@ -17,8 +17,8 @@ namespace api {
|
|||
|
||||
namespace {
|
||||
|
||||
WebKit::WebView* GetCurrentWebView() {
|
||||
WebKit::WebFrame* frame = WebKit::WebFrame::frameForCurrentContext();
|
||||
blink::WebView* GetCurrentWebView() {
|
||||
blink::WebFrame* frame = blink::WebFrame::frameForCurrentContext();
|
||||
if (!frame)
|
||||
return NULL;
|
||||
return frame->view();
|
||||
|
@ -41,12 +41,12 @@ double WebView::GetZoomLevel() const {
|
|||
}
|
||||
|
||||
double WebView::SetZoomFactor(double factor) {
|
||||
return WebKit::WebView::zoomLevelToZoomFactor(SetZoomLevel(
|
||||
WebKit::WebView::zoomFactorToZoomLevel(factor)));
|
||||
return blink::WebView::zoomLevelToZoomFactor(SetZoomLevel(
|
||||
blink::WebView::zoomFactorToZoomLevel(factor)));
|
||||
}
|
||||
|
||||
double WebView::GetZoomFactor() const {
|
||||
return WebKit::WebView::zoomLevelToZoomFactor(GetZoomLevel());
|
||||
return blink::WebView::zoomLevelToZoomFactor(GetZoomLevel());
|
||||
}
|
||||
|
||||
mate::ObjectTemplateBuilder WebView::GetObjectTemplateBuilder(
|
||||
|
@ -77,4 +77,4 @@ void Initialize(v8::Handle<v8::Object> exports) {
|
|||
|
||||
} // namespace
|
||||
|
||||
NODE_MODULE(atom_renderer_web_view, Initialize)
|
||||
NODE_MODULE_X(atom_renderer_web_view, Initialize, NULL, NM_F_BUILTIN)
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
#include "native_mate/handle.h"
|
||||
#include "native_mate/wrappable.h"
|
||||
|
||||
namespace WebKit {
|
||||
namespace blink {
|
||||
class WebView;
|
||||
}
|
||||
|
||||
|
@ -33,7 +33,7 @@ class WebView : public mate::Wrappable {
|
|||
virtual mate::ObjectTemplateBuilder GetObjectTemplateBuilder(
|
||||
v8::Isolate* isolate);
|
||||
|
||||
WebKit::WebView* web_view_;
|
||||
blink::WebView* web_view_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(WebView);
|
||||
};
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
#include "base/memory/scoped_ptr.h"
|
||||
#include "base/values.h"
|
||||
#include "content/public/renderer/render_view.h"
|
||||
#include "native_mate/converter.h"
|
||||
#include "third_party/WebKit/public/web/WebFrame.h"
|
||||
#include "third_party/WebKit/public/web/WebView.h"
|
||||
|
||||
|
@ -21,8 +22,8 @@ namespace atom {
|
|||
namespace {
|
||||
|
||||
v8::Handle<v8::Object> GetProcessObject(v8::Handle<v8::Context> context) {
|
||||
v8::Handle<v8::Object> process =
|
||||
context->Global()->Get(v8::String::New("process"))->ToObject();
|
||||
v8::Handle<v8::Object> process = context->Global()->Get(
|
||||
mate::StringToV8(context->GetIsolate(), "process"))->ToObject();
|
||||
DCHECK(!process.IsEmpty());
|
||||
|
||||
return process;
|
||||
|
@ -36,24 +37,26 @@ AtomRendererBindings::AtomRendererBindings() {
|
|||
AtomRendererBindings::~AtomRendererBindings() {
|
||||
}
|
||||
|
||||
void AtomRendererBindings::BindToFrame(WebKit::WebFrame* frame) {
|
||||
v8::HandleScope handle_scope(node_isolate);
|
||||
void AtomRendererBindings::BindToFrame(blink::WebFrame* frame) {
|
||||
v8::Isolate* isolate = v8::Isolate::GetCurrent();
|
||||
v8::HandleScope handle_scope(isolate);
|
||||
|
||||
v8::Handle<v8::Context> context = frame->mainWorldScriptContext();
|
||||
if (context.IsEmpty())
|
||||
return;
|
||||
|
||||
v8::Context::Scope scope(context);
|
||||
AtomBindings::BindTo(GetProcessObject(context));
|
||||
AtomBindings::BindTo(isolate, GetProcessObject(context));
|
||||
}
|
||||
|
||||
void AtomRendererBindings::OnBrowserMessage(content::RenderView* render_view,
|
||||
const string16& channel,
|
||||
const base::string16& channel,
|
||||
const base::ListValue& args) {
|
||||
if (!render_view->GetWebView())
|
||||
return;
|
||||
|
||||
v8::HandleScope handle_scope(node_isolate);
|
||||
v8::Isolate* isolate = v8::Isolate::GetCurrent();
|
||||
v8::HandleScope handle_scope(isolate);
|
||||
|
||||
v8::Local<v8::Context> context =
|
||||
render_view->GetWebView()->mainFrame()->mainWorldScriptContext();
|
||||
|
@ -67,7 +70,7 @@ void AtomRendererBindings::OnBrowserMessage(content::RenderView* render_view,
|
|||
|
||||
std::vector<v8::Handle<v8::Value>> arguments;
|
||||
arguments.reserve(1 + args.GetSize());
|
||||
arguments.push_back(mate::ConvertToV8(node_isolate, channel));
|
||||
arguments.push_back(mate::ConvertToV8(isolate, channel));
|
||||
|
||||
for (size_t i = 0; i < args.GetSize(); i++) {
|
||||
const base::Value* value;
|
||||
|
@ -75,7 +78,7 @@ void AtomRendererBindings::OnBrowserMessage(content::RenderView* render_view,
|
|||
arguments.push_back(converter->ToV8Value(value, context));
|
||||
}
|
||||
|
||||
node::MakeCallback(process, "emit", arguments.size(), &arguments[0]);
|
||||
node::MakeCallback(isolate, process, "emit", arguments.size(), &arguments[0]);
|
||||
}
|
||||
|
||||
} // namespace atom
|
||||
|
|
|
@ -17,7 +17,7 @@ namespace content {
|
|||
class RenderView;
|
||||
}
|
||||
|
||||
namespace WebKit {
|
||||
namespace blink {
|
||||
class WebFrame;
|
||||
}
|
||||
|
||||
|
@ -29,11 +29,11 @@ class AtomRendererBindings : public AtomBindings {
|
|||
virtual ~AtomRendererBindings();
|
||||
|
||||
// Call BindTo for process object of the frame.
|
||||
void BindToFrame(WebKit::WebFrame* frame);
|
||||
void BindToFrame(blink::WebFrame* frame);
|
||||
|
||||
// Dispatch messages from browser.
|
||||
void OnBrowserMessage(content::RenderView* render_view,
|
||||
const string16& channel,
|
||||
const base::string16& channel,
|
||||
const base::ListValue& args);
|
||||
|
||||
private:
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
#include "atom/common/node_includes.h"
|
||||
|
||||
using WebKit::WebFrame;
|
||||
using blink::WebFrame;
|
||||
|
||||
namespace atom {
|
||||
|
||||
|
@ -36,7 +36,7 @@ AtomRenderViewObserver::AtomRenderViewObserver(
|
|||
AtomRenderViewObserver::~AtomRenderViewObserver() {
|
||||
}
|
||||
|
||||
void AtomRenderViewObserver::DidCreateDocumentElement(WebKit::WebFrame* frame) {
|
||||
void AtomRenderViewObserver::DidCreateDocumentElement(blink::WebFrame* frame) {
|
||||
// Read --zoom-factor from command line.
|
||||
std::string zoom_factor_str = CommandLine::ForCurrentProcess()->
|
||||
GetSwitchValueASCII(switches::kZoomFactor);;
|
||||
|
@ -45,12 +45,12 @@ void AtomRenderViewObserver::DidCreateDocumentElement(WebKit::WebFrame* frame) {
|
|||
double zoom_factor;
|
||||
if (!base::StringToDouble(zoom_factor_str, &zoom_factor))
|
||||
return;
|
||||
double zoom_level = WebKit::WebView::zoomFactorToZoomLevel(zoom_factor);
|
||||
double zoom_level = blink::WebView::zoomFactorToZoomLevel(zoom_factor);
|
||||
frame->view()->setZoomLevel(zoom_level);
|
||||
}
|
||||
|
||||
void AtomRenderViewObserver::DraggableRegionsChanged(WebKit::WebFrame* frame) {
|
||||
WebKit::WebVector<WebKit::WebDraggableRegion> webregions =
|
||||
void AtomRenderViewObserver::DraggableRegionsChanged(blink::WebFrame* frame) {
|
||||
blink::WebVector<blink::WebDraggableRegion> webregions =
|
||||
frame->document().draggableRegions();
|
||||
std::vector<DraggableRegion> regions;
|
||||
for (size_t i = 0; i < webregions.size(); ++i) {
|
||||
|
@ -72,12 +72,12 @@ bool AtomRenderViewObserver::OnMessageReceived(const IPC::Message& message) {
|
|||
return handled;
|
||||
}
|
||||
|
||||
void AtomRenderViewObserver::OnBrowserMessage(const string16& channel,
|
||||
void AtomRenderViewObserver::OnBrowserMessage(const base::string16& channel,
|
||||
const base::ListValue& args) {
|
||||
if (!render_view()->GetWebView())
|
||||
return;
|
||||
|
||||
WebKit::WebFrame* frame = render_view()->GetWebView()->mainFrame();
|
||||
blink::WebFrame* frame = render_view()->GetWebView()->mainFrame();
|
||||
if (!renderer_client_->IsNodeBindingEnabled(frame))
|
||||
return;
|
||||
|
||||
|
|
|
@ -25,11 +25,11 @@ class AtomRenderViewObserver : public content::RenderViewObserver {
|
|||
|
||||
private:
|
||||
// content::RenderViewObserver implementation.
|
||||
virtual void DidCreateDocumentElement(WebKit::WebFrame* frame) OVERRIDE;
|
||||
virtual void DraggableRegionsChanged(WebKit::WebFrame* frame) OVERRIDE;
|
||||
virtual void DidCreateDocumentElement(blink::WebFrame* frame) OVERRIDE;
|
||||
virtual void DraggableRegionsChanged(blink::WebFrame* frame) OVERRIDE;
|
||||
virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
|
||||
|
||||
void OnBrowserMessage(const string16& channel,
|
||||
void OnBrowserMessage(const base::string16& channel,
|
||||
const base::ListValue& args);
|
||||
|
||||
// Weak reference to renderer client.
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
#include "atom/renderer/api/atom_renderer_bindings.h"
|
||||
#include "atom/renderer/atom_render_view_observer.h"
|
||||
#include "base/command_line.h"
|
||||
#include "native_mate/converter.h"
|
||||
#include "third_party/WebKit/public/web/WebDocument.h"
|
||||
#include "third_party/WebKit/public/web/WebFrame.h"
|
||||
|
||||
|
@ -65,16 +66,21 @@ void AtomRendererClient::RenderThreadStarted() {
|
|||
|
||||
// Create a default empty environment which would be used when we need to
|
||||
// run V8 code out of a window context (like running a uv callback).
|
||||
v8::HandleScope handle_scope(node_isolate);
|
||||
v8::Local<v8::Context> context = v8::Context::New(node_isolate);
|
||||
v8::Isolate* isolate = v8::Isolate::GetCurrent();
|
||||
v8::HandleScope handle_scope(isolate);
|
||||
v8::Local<v8::Context> context = v8::Context::New(isolate);
|
||||
global_env = node::Environment::New(context);
|
||||
}
|
||||
|
||||
void AtomRendererClient::RenderFrameCreated(
|
||||
content::RenderFrame* render_frame) {
|
||||
}
|
||||
|
||||
void AtomRendererClient::RenderViewCreated(content::RenderView* render_view) {
|
||||
new AtomRenderViewObserver(render_view, this);
|
||||
}
|
||||
|
||||
void AtomRendererClient::DidCreateScriptContext(WebKit::WebFrame* frame,
|
||||
void AtomRendererClient::DidCreateScriptContext(blink::WebFrame* frame,
|
||||
v8::Handle<v8::Context> context,
|
||||
int extension_group,
|
||||
int world_id) {
|
||||
|
@ -88,7 +94,8 @@ void AtomRendererClient::DidCreateScriptContext(WebKit::WebFrame* frame,
|
|||
v8::Context::Scope scope(context);
|
||||
|
||||
// Check the existance of process object to prevent duplicate initialization.
|
||||
if (context->Global()->Has(v8::String::New("process")))
|
||||
if (context->Global()->Has(
|
||||
mate::StringToV8(context->GetIsolate(), "process")))
|
||||
return;
|
||||
|
||||
// Give the node loop a run to make sure everything is ready.
|
||||
|
@ -109,7 +116,7 @@ void AtomRendererClient::DidCreateScriptContext(WebKit::WebFrame* frame,
|
|||
}
|
||||
|
||||
void AtomRendererClient::WillReleaseScriptContext(
|
||||
WebKit::WebFrame* frame,
|
||||
blink::WebFrame* frame,
|
||||
v8::Handle<v8::Context> context,
|
||||
int world_id) {
|
||||
if (!IsNodeBindingEnabled(frame))
|
||||
|
@ -143,7 +150,7 @@ void AtomRendererClient::WillReleaseScriptContext(
|
|||
}
|
||||
}
|
||||
|
||||
bool AtomRendererClient::ShouldFork(WebKit::WebFrame* frame,
|
||||
bool AtomRendererClient::ShouldFork(blink::WebFrame* frame,
|
||||
const GURL& url,
|
||||
const std::string& http_method,
|
||||
bool is_initial_navigation,
|
||||
|
@ -156,7 +163,7 @@ bool AtomRendererClient::ShouldFork(WebKit::WebFrame* frame,
|
|||
return http_method == "GET";
|
||||
}
|
||||
|
||||
bool AtomRendererClient::IsNodeBindingEnabled(WebKit::WebFrame* frame) {
|
||||
bool AtomRendererClient::IsNodeBindingEnabled(blink::WebFrame* frame) {
|
||||
if (node_integration_ == DISABLE)
|
||||
return false;
|
||||
// Node integration is enabled in main frame unless explictly disabled.
|
||||
|
|
|
@ -24,7 +24,7 @@ class AtomRendererClient : public content::ContentRendererClient {
|
|||
AtomRendererClient();
|
||||
virtual ~AtomRendererClient();
|
||||
|
||||
bool IsNodeBindingEnabled(WebKit::WebFrame* frame = NULL);
|
||||
bool IsNodeBindingEnabled(blink::WebFrame* frame = NULL);
|
||||
|
||||
AtomRendererBindings* atom_bindings() const { return atom_bindings_.get(); }
|
||||
|
||||
|
@ -36,16 +36,18 @@ class AtomRendererClient : public content::ContentRendererClient {
|
|||
DISABLE,
|
||||
};
|
||||
|
||||
// content::ContentRendererClient:
|
||||
virtual void RenderThreadStarted() OVERRIDE;
|
||||
virtual void RenderFrameCreated(content::RenderFrame* render_frame) OVERRIDE;
|
||||
virtual void RenderViewCreated(content::RenderView*) OVERRIDE;
|
||||
virtual void DidCreateScriptContext(WebKit::WebFrame* frame,
|
||||
virtual void DidCreateScriptContext(blink::WebFrame* frame,
|
||||
v8::Handle<v8::Context> context,
|
||||
int extension_group,
|
||||
int world_id) OVERRIDE;
|
||||
virtual void WillReleaseScriptContext(WebKit::WebFrame* frame,
|
||||
virtual void WillReleaseScriptContext(blink::WebFrame* frame,
|
||||
v8::Handle<v8::Context>,
|
||||
int world_id) OVERRIDE;
|
||||
virtual bool ShouldFork(WebKit::WebFrame* frame,
|
||||
int world_id);
|
||||
virtual bool ShouldFork(blink::WebFrame* frame,
|
||||
const GURL& url,
|
||||
const std::string& http_method,
|
||||
bool is_initial_navigation,
|
||||
|
@ -61,7 +63,7 @@ class AtomRendererClient : public content::ContentRendererClient {
|
|||
NodeIntegration node_integration_;
|
||||
|
||||
// The main frame.
|
||||
WebKit::WebFrame* main_frame_;
|
||||
blink::WebFrame* main_frame_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(AtomRendererClient);
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue