2013-04-14 07:36:48 +00:00
|
|
|
// Copyright (c) 2013 GitHub, Inc. All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
|
|
// found in the LICENSE file.
|
|
|
|
|
2014-03-16 00:30:26 +00:00
|
|
|
#include "atom/browser/api/atom_api_window.h"
|
2013-04-14 07:36:48 +00:00
|
|
|
|
2014-03-16 01:13:06 +00:00
|
|
|
#include <string>
|
|
|
|
|
2013-12-27 07:41:00 +00:00
|
|
|
#include "base/bind.h"
|
2013-12-11 07:48:19 +00:00
|
|
|
#include "base/process/kill.h"
|
2014-03-16 00:30:26 +00:00
|
|
|
#include "atom/browser/native_window.h"
|
|
|
|
#include "atom/common/v8/native_type_conversions.h"
|
2013-04-18 16:06:10 +00:00
|
|
|
#include "content/public/browser/navigation_entry.h"
|
2013-04-17 12:05:43 +00:00
|
|
|
#include "content/public/browser/web_contents.h"
|
2013-04-23 09:21:34 +00:00
|
|
|
#include "content/public/browser/render_process_host.h"
|
2013-04-17 14:49:49 +00:00
|
|
|
#include "ui/gfx/point.h"
|
|
|
|
#include "ui/gfx/size.h"
|
2013-04-15 16:25:08 +00:00
|
|
|
|
2014-04-17 05:45:14 +00:00
|
|
|
#include "atom/common/node_includes.h"
|
2013-12-17 06:01:40 +00:00
|
|
|
#include "vendor/node/src/node_buffer.h"
|
2013-12-11 07:48:19 +00:00
|
|
|
|
2013-04-18 07:09:53 +00:00
|
|
|
using content::NavigationController;
|
2013-04-17 14:49:49 +00:00
|
|
|
using node::ObjectWrap;
|
2013-04-15 16:25:08 +00:00
|
|
|
|
2013-04-29 11:38:18 +00:00
|
|
|
#define UNWRAP_WINDOW_AND_CHECK \
|
2013-06-18 13:40:03 +00:00
|
|
|
Window* self = ObjectWrap::Unwrap<Window>(args.This()); \
|
|
|
|
if (self == NULL) \
|
|
|
|
return node::ThrowError("Window is already destroyed")
|
2013-04-29 11:38:18 +00:00
|
|
|
|
2013-04-14 07:36:48 +00:00
|
|
|
namespace atom {
|
|
|
|
|
2013-04-15 16:25:08 +00:00
|
|
|
namespace api {
|
|
|
|
|
|
|
|
Window::Window(v8::Handle<v8::Object> wrapper, base::DictionaryValue* options)
|
|
|
|
: EventEmitter(wrapper),
|
2013-04-20 05:42:39 +00:00
|
|
|
window_(NativeWindow::Create(options)) {
|
2013-04-17 12:05:43 +00:00
|
|
|
window_->InitFromOptions(options);
|
2013-04-18 15:50:47 +00:00
|
|
|
window_->AddObserver(this);
|
2013-04-15 16:25:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Window::~Window() {
|
2013-05-02 10:19:07 +00:00
|
|
|
Emit("destroyed");
|
|
|
|
|
2013-05-01 15:28:01 +00:00
|
|
|
window_->RemoveObserver(this);
|
2013-04-15 16:25:08 +00:00
|
|
|
}
|
|
|
|
|
2013-04-18 15:50:47 +00:00
|
|
|
void Window::OnPageTitleUpdated(bool* prevent_default,
|
|
|
|
const std::string& title) {
|
2013-05-01 15:28:01 +00:00
|
|
|
base::ListValue args;
|
|
|
|
args.AppendString(title);
|
|
|
|
*prevent_default = Emit("page-title-updated", &args);
|
|
|
|
}
|
|
|
|
|
2013-08-29 03:47:07 +00:00
|
|
|
void Window::OnLoadingStateChanged(bool is_loading) {
|
|
|
|
base::ListValue args;
|
|
|
|
args.AppendBoolean(is_loading);
|
|
|
|
Emit("loading-state-changed", &args);
|
|
|
|
}
|
|
|
|
|
2013-05-01 15:28:01 +00:00
|
|
|
void Window::WillCloseWindow(bool* prevent_default) {
|
2013-05-02 10:19:07 +00:00
|
|
|
*prevent_default = Emit("close");
|
2013-05-01 15:28:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Window::OnWindowClosed() {
|
2013-05-02 10:19:07 +00:00
|
|
|
Emit("closed");
|
|
|
|
|
2013-09-27 07:20:55 +00:00
|
|
|
// Free memory when native window is closed, the delete is delayed so other
|
|
|
|
// observers would not get a invalid pointer of NativeWindow.
|
|
|
|
base::MessageLoop::current()->DeleteSoon(FROM_HERE, this);
|
2013-04-18 15:50:47 +00:00
|
|
|
}
|
|
|
|
|
2013-05-24 09:58:39 +00:00
|
|
|
void Window::OnWindowBlur() {
|
|
|
|
Emit("blur");
|
|
|
|
}
|
|
|
|
|
2013-06-06 11:45:48 +00:00
|
|
|
void Window::OnRendererUnresponsive() {
|
|
|
|
Emit("unresponsive");
|
|
|
|
}
|
|
|
|
|
|
|
|
void Window::OnRendererResponsive() {
|
|
|
|
Emit("responsive");
|
|
|
|
}
|
|
|
|
|
2013-12-06 07:53:40 +00:00
|
|
|
void Window::OnRenderViewDeleted(int process_id, int routing_id) {
|
|
|
|
base::ListValue args;
|
|
|
|
args.AppendInteger(process_id);
|
|
|
|
args.AppendInteger(routing_id);
|
|
|
|
Emit("render-view-deleted", &args);
|
2013-12-06 06:44:25 +00:00
|
|
|
}
|
|
|
|
|
2013-06-10 12:50:25 +00:00
|
|
|
void Window::OnRendererCrashed() {
|
|
|
|
Emit("crashed");
|
|
|
|
}
|
|
|
|
|
2013-12-11 07:48:19 +00:00
|
|
|
void Window::OnCapturePageDone(const RefCountedV8Function& callback,
|
2013-11-22 06:23:19 +00:00
|
|
|
const std::vector<unsigned char>& data) {
|
2014-01-27 07:14:11 +00:00
|
|
|
v8::Locker locker(node_isolate);
|
2013-12-11 07:48:19 +00:00
|
|
|
v8::HandleScope handle_scope(node_isolate);
|
2013-11-22 06:23:19 +00:00
|
|
|
|
2013-12-11 07:48:19 +00:00
|
|
|
v8::Local<v8::Value> buffer = node::Buffer::New(
|
2013-11-22 06:23:19 +00:00
|
|
|
reinterpret_cast<const char*>(data.data()),
|
|
|
|
data.size());
|
2013-12-11 07:48:19 +00:00
|
|
|
callback->NewHandle(node_isolate)->Call(
|
|
|
|
v8::Context::GetCurrent()->Global(), 1, &buffer);
|
2013-11-22 06:23:19 +00:00
|
|
|
}
|
|
|
|
|
2013-04-15 16:25:08 +00:00
|
|
|
// static
|
2013-12-11 07:48:19 +00:00
|
|
|
void Window::New(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
2013-06-18 13:40:03 +00:00
|
|
|
if (!args.IsConstructCall())
|
|
|
|
return node::ThrowError("Require constructor call");
|
|
|
|
|
2013-12-05 15:47:07 +00:00
|
|
|
scoped_ptr<base::Value> options;
|
|
|
|
if (!FromV8Arguments(args, &options))
|
|
|
|
return node::ThrowTypeError("Bad argument");
|
2013-04-15 16:25:08 +00:00
|
|
|
|
|
|
|
if (!options || !options->IsType(base::Value::TYPE_DICTIONARY))
|
2013-12-05 15:47:07 +00:00
|
|
|
return node::ThrowTypeError("Options must be dictionary");
|
2013-04-15 16:25:08 +00:00
|
|
|
|
|
|
|
new Window(args.This(), static_cast<base::DictionaryValue*>(options.get()));
|
|
|
|
|
2013-10-05 13:05:59 +00:00
|
|
|
// Give js code a chance to do initialization.
|
|
|
|
node::MakeCallback(args.This(), "_init", 0, NULL);
|
2013-04-14 07:36:48 +00:00
|
|
|
}
|
|
|
|
|
2013-04-17 14:49:49 +00:00
|
|
|
// static
|
2013-12-11 07:48:19 +00:00
|
|
|
void Window::Destroy(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
2013-04-29 11:38:18 +00:00
|
|
|
UNWRAP_WINDOW_AND_CHECK;
|
2013-04-17 14:49:49 +00:00
|
|
|
|
2013-12-04 14:00:20 +00:00
|
|
|
base::ProcessHandle handle = self->window_->GetRenderProcessHandle();
|
2014-03-26 01:58:40 +00:00
|
|
|
delete self;
|
2013-04-17 14:49:49 +00:00
|
|
|
|
2013-12-27 07:41:00 +00:00
|
|
|
// Make sure the renderer process is terminated, it could happen that the
|
|
|
|
// renderer process became a zombie.
|
|
|
|
base::MessageLoop::current()->PostDelayedTask(
|
|
|
|
FROM_HERE,
|
2013-12-29 14:11:54 +00:00
|
|
|
base::Bind(base::IgnoreResult(base::KillProcess), handle, 0, false),
|
2013-12-27 07:41:00 +00:00
|
|
|
base::TimeDelta::FromMilliseconds(5000));
|
2013-04-17 14:49:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// static
|
2013-12-11 07:48:19 +00:00
|
|
|
void Window::Close(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
2013-04-29 11:38:18 +00:00
|
|
|
UNWRAP_WINDOW_AND_CHECK;
|
2013-04-17 14:49:49 +00:00
|
|
|
self->window_->Close();
|
|
|
|
}
|
|
|
|
|
|
|
|
// static
|
2013-12-11 07:48:19 +00:00
|
|
|
void Window::Focus(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
2013-04-29 11:38:18 +00:00
|
|
|
UNWRAP_WINDOW_AND_CHECK;
|
2013-04-17 14:49:49 +00:00
|
|
|
self->window_->Focus(args[0]->IsBoolean() ? args[0]->BooleanValue(): true);
|
|
|
|
}
|
|
|
|
|
2013-05-16 14:56:52 +00:00
|
|
|
// static
|
2013-12-11 07:48:19 +00:00
|
|
|
void Window::IsFocused(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
2013-05-16 14:56:52 +00:00
|
|
|
UNWRAP_WINDOW_AND_CHECK;
|
2013-12-11 07:48:19 +00:00
|
|
|
args.GetReturnValue().Set(self->window_->IsFocused());
|
2013-05-16 14:56:52 +00:00
|
|
|
}
|
|
|
|
|
2013-04-17 14:49:49 +00:00
|
|
|
// static
|
2013-12-11 07:48:19 +00:00
|
|
|
void Window::Show(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
2013-04-29 11:38:18 +00:00
|
|
|
UNWRAP_WINDOW_AND_CHECK;
|
2013-04-17 14:49:49 +00:00
|
|
|
self->window_->Show();
|
|
|
|
}
|
|
|
|
|
|
|
|
// static
|
2013-12-11 07:48:19 +00:00
|
|
|
void Window::Hide(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
2013-04-29 11:38:18 +00:00
|
|
|
UNWRAP_WINDOW_AND_CHECK;
|
2013-04-17 14:49:49 +00:00
|
|
|
self->window_->Hide();
|
|
|
|
}
|
|
|
|
|
2013-10-03 00:27:59 +00:00
|
|
|
// static
|
2013-12-11 07:48:19 +00:00
|
|
|
void Window::IsVisible(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
2013-10-03 00:27:59 +00:00
|
|
|
UNWRAP_WINDOW_AND_CHECK;
|
2013-12-11 07:48:19 +00:00
|
|
|
return args.GetReturnValue().Set(self->window_->IsVisible());
|
2013-10-03 00:27:59 +00:00
|
|
|
}
|
|
|
|
|
2013-04-17 14:49:49 +00:00
|
|
|
// static
|
2013-12-11 07:48:19 +00:00
|
|
|
void Window::Maximize(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
2013-04-29 11:38:18 +00:00
|
|
|
UNWRAP_WINDOW_AND_CHECK;
|
2013-04-17 14:49:49 +00:00
|
|
|
self->window_->Maximize();
|
|
|
|
}
|
|
|
|
|
|
|
|
// static
|
2013-12-11 07:48:19 +00:00
|
|
|
void Window::Unmaximize(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
2013-04-29 11:38:18 +00:00
|
|
|
UNWRAP_WINDOW_AND_CHECK;
|
2013-04-17 14:49:49 +00:00
|
|
|
self->window_->Unmaximize();
|
|
|
|
}
|
|
|
|
|
|
|
|
// static
|
2013-12-11 07:48:19 +00:00
|
|
|
void Window::Minimize(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
2013-04-29 11:38:18 +00:00
|
|
|
UNWRAP_WINDOW_AND_CHECK;
|
2013-04-17 14:49:49 +00:00
|
|
|
self->window_->Minimize();
|
|
|
|
}
|
|
|
|
|
|
|
|
// static
|
2013-12-11 07:48:19 +00:00
|
|
|
void Window::Restore(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
2013-04-29 11:38:18 +00:00
|
|
|
UNWRAP_WINDOW_AND_CHECK;
|
2013-04-17 14:49:49 +00:00
|
|
|
self->window_->Restore();
|
|
|
|
}
|
|
|
|
|
|
|
|
// static
|
2013-12-11 07:48:19 +00:00
|
|
|
void Window::SetFullscreen(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
2013-04-29 11:38:18 +00:00
|
|
|
UNWRAP_WINDOW_AND_CHECK;
|
2013-04-17 14:49:49 +00:00
|
|
|
|
2013-09-24 01:41:54 +00:00
|
|
|
bool fs;
|
|
|
|
if (!FromV8Arguments(args, &fs))
|
2013-04-17 14:49:49 +00:00
|
|
|
return node::ThrowTypeError("Bad argument");
|
|
|
|
|
2013-09-24 01:41:54 +00:00
|
|
|
self->window_->SetFullscreen(fs);
|
2013-04-17 14:49:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// static
|
2013-12-11 07:48:19 +00:00
|
|
|
void Window::IsFullscreen(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
2013-04-29 11:38:18 +00:00
|
|
|
UNWRAP_WINDOW_AND_CHECK;
|
2013-12-11 07:48:19 +00:00
|
|
|
args.GetReturnValue().Set(self->window_->IsFullscreen());
|
2013-04-17 14:49:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// static
|
2013-12-11 07:48:19 +00:00
|
|
|
void Window::SetSize(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
2013-04-29 11:38:18 +00:00
|
|
|
UNWRAP_WINDOW_AND_CHECK;
|
2013-04-17 14:49:49 +00:00
|
|
|
|
2013-09-24 01:41:54 +00:00
|
|
|
int width, height;
|
|
|
|
if (!FromV8Arguments(args, &width, &height))
|
2013-04-17 14:49:49 +00:00
|
|
|
return node::ThrowTypeError("Bad argument");
|
|
|
|
|
2013-09-24 01:41:54 +00:00
|
|
|
self->window_->SetSize(gfx::Size(width, height));
|
2013-04-17 14:49:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// static
|
2013-12-11 07:48:19 +00:00
|
|
|
void Window::GetSize(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
2013-04-29 11:38:18 +00:00
|
|
|
UNWRAP_WINDOW_AND_CHECK;
|
2013-04-17 14:49:49 +00:00
|
|
|
|
|
|
|
gfx::Size size = self->window_->GetSize();
|
|
|
|
v8::Handle<v8::Array> ret = v8::Array::New(2);
|
2013-09-24 01:41:54 +00:00
|
|
|
ret->Set(0, ToV8Value(size.width()));
|
|
|
|
ret->Set(1, ToV8Value(size.height()));
|
2013-04-17 14:49:49 +00:00
|
|
|
|
2013-12-11 07:48:19 +00:00
|
|
|
args.GetReturnValue().Set(ret);
|
2013-04-17 14:49:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// static
|
2013-12-11 07:48:19 +00:00
|
|
|
void Window::SetMinimumSize(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
2013-04-29 11:38:18 +00:00
|
|
|
UNWRAP_WINDOW_AND_CHECK;
|
2013-04-17 14:49:49 +00:00
|
|
|
|
2013-09-24 01:41:54 +00:00
|
|
|
int width, height;
|
|
|
|
if (!FromV8Arguments(args, &width, &height))
|
2013-04-17 14:49:49 +00:00
|
|
|
return node::ThrowTypeError("Bad argument");
|
|
|
|
|
2013-09-24 01:41:54 +00:00
|
|
|
self->window_->SetMinimumSize(gfx::Size(width, height));
|
2013-04-17 14:49:49 +00:00
|
|
|
}
|
|
|
|
|
2013-04-18 07:38:04 +00:00
|
|
|
// static
|
2013-12-11 07:48:19 +00:00
|
|
|
void Window::GetMinimumSize(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
2013-04-29 11:38:18 +00:00
|
|
|
UNWRAP_WINDOW_AND_CHECK;
|
2013-04-18 07:38:04 +00:00
|
|
|
|
|
|
|
gfx::Size size = self->window_->GetMinimumSize();
|
|
|
|
v8::Handle<v8::Array> ret = v8::Array::New(2);
|
2013-09-24 01:41:54 +00:00
|
|
|
ret->Set(0, ToV8Value(size.width()));
|
|
|
|
ret->Set(1, ToV8Value(size.height()));
|
2013-04-18 07:38:04 +00:00
|
|
|
|
2013-12-11 07:48:19 +00:00
|
|
|
args.GetReturnValue().Set(ret);
|
2013-04-18 07:38:04 +00:00
|
|
|
}
|
|
|
|
|
2013-04-17 14:49:49 +00:00
|
|
|
// static
|
2013-12-11 07:48:19 +00:00
|
|
|
void Window::SetMaximumSize(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
2013-04-29 11:38:18 +00:00
|
|
|
UNWRAP_WINDOW_AND_CHECK;
|
2013-04-17 14:49:49 +00:00
|
|
|
|
2013-09-24 01:41:54 +00:00
|
|
|
int width, height;
|
|
|
|
if (!FromV8Arguments(args, &width, &height))
|
2013-04-17 14:49:49 +00:00
|
|
|
return node::ThrowTypeError("Bad argument");
|
|
|
|
|
2013-09-24 01:41:54 +00:00
|
|
|
self->window_->SetMaximumSize(gfx::Size(width, height));
|
2013-04-17 14:49:49 +00:00
|
|
|
}
|
|
|
|
|
2013-04-18 07:38:04 +00:00
|
|
|
// static
|
2013-12-11 07:48:19 +00:00
|
|
|
void Window::GetMaximumSize(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
2013-04-29 11:38:18 +00:00
|
|
|
UNWRAP_WINDOW_AND_CHECK;
|
2013-04-18 07:38:04 +00:00
|
|
|
|
|
|
|
gfx::Size size = self->window_->GetMaximumSize();
|
|
|
|
v8::Handle<v8::Array> ret = v8::Array::New(2);
|
2013-09-24 01:41:54 +00:00
|
|
|
ret->Set(0, ToV8Value(size.width()));
|
|
|
|
ret->Set(1, ToV8Value(size.height()));
|
2013-04-18 07:38:04 +00:00
|
|
|
|
2013-12-11 07:48:19 +00:00
|
|
|
args.GetReturnValue().Set(ret);
|
2013-04-18 07:38:04 +00:00
|
|
|
}
|
|
|
|
|
2013-04-17 14:49:49 +00:00
|
|
|
// static
|
2013-12-11 07:48:19 +00:00
|
|
|
void Window::SetResizable(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
2013-04-29 11:38:18 +00:00
|
|
|
UNWRAP_WINDOW_AND_CHECK;
|
2013-04-17 14:49:49 +00:00
|
|
|
|
2013-09-24 01:41:54 +00:00
|
|
|
bool resizable;
|
|
|
|
if (!FromV8Arguments(args, &resizable))
|
2013-04-17 14:49:49 +00:00
|
|
|
return node::ThrowTypeError("Bad argument");
|
|
|
|
|
2013-09-24 01:41:54 +00:00
|
|
|
self->window_->SetResizable(resizable);
|
2013-04-17 14:49:49 +00:00
|
|
|
}
|
|
|
|
|
2013-04-18 07:38:04 +00:00
|
|
|
// static
|
2013-12-11 07:48:19 +00:00
|
|
|
void Window::IsResizable(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
2013-04-29 11:38:18 +00:00
|
|
|
UNWRAP_WINDOW_AND_CHECK;
|
2013-12-11 07:48:19 +00:00
|
|
|
args.GetReturnValue().Set(self->window_->IsResizable());
|
2013-04-18 07:38:04 +00:00
|
|
|
}
|
|
|
|
|
2013-04-17 14:49:49 +00:00
|
|
|
// static
|
2013-12-11 07:48:19 +00:00
|
|
|
void Window::SetAlwaysOnTop(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
2013-04-29 11:38:18 +00:00
|
|
|
UNWRAP_WINDOW_AND_CHECK;
|
2013-04-17 14:49:49 +00:00
|
|
|
|
2013-09-24 01:41:54 +00:00
|
|
|
bool top;
|
|
|
|
if (!FromV8Arguments(args, &top))
|
2013-04-17 14:49:49 +00:00
|
|
|
return node::ThrowTypeError("Bad argument");
|
|
|
|
|
2013-09-24 01:41:54 +00:00
|
|
|
self->window_->SetAlwaysOnTop(top);
|
2013-04-17 14:49:49 +00:00
|
|
|
}
|
|
|
|
|
2013-04-18 07:38:04 +00:00
|
|
|
// static
|
2013-12-11 07:48:19 +00:00
|
|
|
void Window::IsAlwaysOnTop(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
2013-04-29 11:38:18 +00:00
|
|
|
UNWRAP_WINDOW_AND_CHECK;
|
2013-12-11 07:48:19 +00:00
|
|
|
args.GetReturnValue().Set(self->window_->IsAlwaysOnTop());
|
2013-04-18 07:38:04 +00:00
|
|
|
}
|
|
|
|
|
2013-05-10 12:34:05 +00:00
|
|
|
// static
|
2013-12-11 07:48:19 +00:00
|
|
|
void Window::Center(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
2013-05-10 12:34:05 +00:00
|
|
|
UNWRAP_WINDOW_AND_CHECK;
|
|
|
|
self->window_->Center();
|
|
|
|
}
|
|
|
|
|
2013-04-17 14:49:49 +00:00
|
|
|
// static
|
2013-12-11 07:48:19 +00:00
|
|
|
void Window::SetPosition(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
2013-04-29 11:38:18 +00:00
|
|
|
UNWRAP_WINDOW_AND_CHECK;
|
2013-04-17 14:49:49 +00:00
|
|
|
|
2013-09-24 01:41:54 +00:00
|
|
|
int x, y;
|
|
|
|
if (!FromV8Arguments(args, &x, &y))
|
2013-04-17 14:49:49 +00:00
|
|
|
return node::ThrowTypeError("Bad argument");
|
|
|
|
|
2013-09-24 01:41:54 +00:00
|
|
|
self->window_->SetPosition(gfx::Point(x, y));
|
2013-04-17 14:49:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// static
|
2013-12-11 07:48:19 +00:00
|
|
|
void Window::GetPosition(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
2013-04-29 11:38:18 +00:00
|
|
|
UNWRAP_WINDOW_AND_CHECK;
|
2013-04-17 14:49:49 +00:00
|
|
|
|
|
|
|
gfx::Point pos = self->window_->GetPosition();
|
|
|
|
v8::Handle<v8::Array> ret = v8::Array::New(2);
|
2013-09-24 01:41:54 +00:00
|
|
|
ret->Set(0, ToV8Value(pos.x()));
|
|
|
|
ret->Set(1, ToV8Value(pos.y()));
|
2013-04-17 14:49:49 +00:00
|
|
|
|
2013-12-11 07:48:19 +00:00
|
|
|
args.GetReturnValue().Set(ret);
|
2013-04-17 14:49:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// static
|
2013-12-11 07:48:19 +00:00
|
|
|
void Window::SetTitle(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
2013-04-29 11:38:18 +00:00
|
|
|
UNWRAP_WINDOW_AND_CHECK;
|
2013-04-17 14:49:49 +00:00
|
|
|
|
2013-09-24 01:41:54 +00:00
|
|
|
std::string title;
|
|
|
|
if (!FromV8Arguments(args, &title))
|
2013-04-17 14:49:49 +00:00
|
|
|
return node::ThrowTypeError("Bad argument");
|
|
|
|
|
2013-09-24 01:41:54 +00:00
|
|
|
self->window_->SetTitle(title);
|
2013-04-17 14:49:49 +00:00
|
|
|
}
|
|
|
|
|
2013-04-18 06:30:05 +00:00
|
|
|
// static
|
2013-12-11 07:48:19 +00:00
|
|
|
void Window::GetTitle(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
2013-04-29 11:38:18 +00:00
|
|
|
UNWRAP_WINDOW_AND_CHECK;
|
2013-12-11 07:48:19 +00:00
|
|
|
args.GetReturnValue().Set(ToV8Value(self->window_->GetTitle()));
|
2013-04-18 06:30:05 +00:00
|
|
|
}
|
|
|
|
|
2013-04-17 14:49:49 +00:00
|
|
|
// static
|
2013-12-11 07:48:19 +00:00
|
|
|
void Window::FlashFrame(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
2013-04-29 11:38:18 +00:00
|
|
|
UNWRAP_WINDOW_AND_CHECK;
|
2013-04-17 14:49:49 +00:00
|
|
|
self->window_->FlashFrame(
|
|
|
|
args[0]->IsBoolean() ? args[0]->BooleanValue(): true);
|
|
|
|
}
|
|
|
|
|
|
|
|
// static
|
2013-12-11 07:48:19 +00:00
|
|
|
void Window::SetKiosk(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
2013-04-29 11:38:18 +00:00
|
|
|
UNWRAP_WINDOW_AND_CHECK;
|
2013-04-17 14:49:49 +00:00
|
|
|
|
2013-09-24 01:41:54 +00:00
|
|
|
bool kiosk;
|
|
|
|
if (!FromV8Arguments(args, &kiosk))
|
2013-04-17 14:49:49 +00:00
|
|
|
return node::ThrowTypeError("Bad argument");
|
|
|
|
|
2013-09-24 01:41:54 +00:00
|
|
|
self->window_->SetKiosk(kiosk);
|
2013-04-17 14:49:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// static
|
2013-12-11 07:48:19 +00:00
|
|
|
void Window::IsKiosk(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
2013-04-29 11:38:18 +00:00
|
|
|
UNWRAP_WINDOW_AND_CHECK;
|
2013-12-11 07:48:19 +00:00
|
|
|
args.GetReturnValue().Set(self->window_->IsKiosk());
|
2013-04-17 14:49:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// static
|
2013-12-11 07:48:19 +00:00
|
|
|
void Window::OpenDevTools(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
2013-04-29 11:38:18 +00:00
|
|
|
UNWRAP_WINDOW_AND_CHECK;
|
2013-05-10 12:34:05 +00:00
|
|
|
self->window_->OpenDevTools();
|
2013-04-17 14:49:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// static
|
2013-12-11 07:48:19 +00:00
|
|
|
void Window::CloseDevTools(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
2013-04-29 11:38:18 +00:00
|
|
|
UNWRAP_WINDOW_AND_CHECK;
|
2013-04-17 14:49:49 +00:00
|
|
|
self->window_->CloseDevTools();
|
|
|
|
}
|
|
|
|
|
2013-11-05 02:32:45 +00:00
|
|
|
// static
|
2013-12-11 07:48:19 +00:00
|
|
|
void Window::IsDevToolsOpened(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
2013-11-05 02:32:45 +00:00
|
|
|
UNWRAP_WINDOW_AND_CHECK;
|
2013-12-11 07:48:19 +00:00
|
|
|
args.GetReturnValue().Set(self->window_->IsDevToolsOpened());
|
2013-11-05 02:32:45 +00:00
|
|
|
}
|
|
|
|
|
2013-07-18 11:21:25 +00:00
|
|
|
// static
|
2013-12-11 07:48:19 +00:00
|
|
|
void Window::InspectElement(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
2013-07-18 11:21:25 +00:00
|
|
|
UNWRAP_WINDOW_AND_CHECK;
|
|
|
|
|
2013-09-24 01:41:54 +00:00
|
|
|
int x, y;
|
|
|
|
if (!FromV8Arguments(args, &x, &y))
|
|
|
|
return node::ThrowTypeError("Bad argument");
|
2013-07-18 11:21:25 +00:00
|
|
|
|
2013-09-24 01:41:54 +00:00
|
|
|
self->window_->InspectElement(x, y);
|
2013-07-18 11:21:25 +00:00
|
|
|
}
|
|
|
|
|
2014-02-24 04:08:33 +00:00
|
|
|
// static
|
|
|
|
void Window::DebugDevTools(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
|
|
|
UNWRAP_WINDOW_AND_CHECK;
|
2014-03-04 06:35:35 +00:00
|
|
|
if (self->window_->IsDevToolsOpened())
|
|
|
|
NativeWindow::Debug(self->window_->GetDevToolsWebContents());
|
2014-02-24 04:08:33 +00:00
|
|
|
}
|
|
|
|
|
2013-05-24 09:51:15 +00:00
|
|
|
// static
|
2013-12-11 07:48:19 +00:00
|
|
|
void Window::FocusOnWebView(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
2013-05-24 09:51:15 +00:00
|
|
|
UNWRAP_WINDOW_AND_CHECK;
|
|
|
|
self->window_->FocusOnWebView();
|
|
|
|
}
|
|
|
|
|
|
|
|
// static
|
2013-12-11 07:48:19 +00:00
|
|
|
void Window::BlurWebView(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
2013-05-24 09:51:15 +00:00
|
|
|
UNWRAP_WINDOW_AND_CHECK;
|
|
|
|
self->window_->BlurWebView();
|
|
|
|
}
|
|
|
|
|
2013-08-16 04:56:25 +00:00
|
|
|
// static
|
2013-12-11 07:48:19 +00:00
|
|
|
void Window::IsWebViewFocused(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
2013-08-16 04:56:25 +00:00
|
|
|
UNWRAP_WINDOW_AND_CHECK;
|
2013-12-11 07:48:19 +00:00
|
|
|
args.GetReturnValue().Set(self->window_->IsWebViewFocused());
|
2013-08-16 04:56:25 +00:00
|
|
|
}
|
|
|
|
|
2013-11-22 06:23:19 +00:00
|
|
|
// static
|
2013-12-11 07:48:19 +00:00
|
|
|
void Window::CapturePage(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
2013-11-22 06:23:19 +00:00
|
|
|
UNWRAP_WINDOW_AND_CHECK;
|
|
|
|
|
|
|
|
gfx::Rect rect;
|
2013-12-11 07:48:19 +00:00
|
|
|
RefCountedV8Function callback;
|
2013-11-22 06:29:20 +00:00
|
|
|
if (!FromV8Arguments(args, &rect, &callback) &&
|
|
|
|
!FromV8Arguments(args, &callback))
|
2013-11-22 06:23:19 +00:00
|
|
|
return node::ThrowTypeError("Bad argument");
|
|
|
|
|
|
|
|
self->window_->CapturePage(rect, base::Bind(&Window::OnCapturePageDone,
|
|
|
|
base::Unretained(self),
|
|
|
|
callback));
|
|
|
|
}
|
|
|
|
|
2013-04-18 07:09:53 +00:00
|
|
|
// static
|
2013-12-11 07:48:19 +00:00
|
|
|
void Window::GetPageTitle(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
2013-04-29 11:38:18 +00:00
|
|
|
UNWRAP_WINDOW_AND_CHECK;
|
2013-12-11 07:48:19 +00:00
|
|
|
args.GetReturnValue().Set(ToV8Value(
|
|
|
|
self->window_->GetWebContents()->GetTitle()));
|
2013-04-18 07:09:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// static
|
2013-12-11 07:48:19 +00:00
|
|
|
void Window::IsLoading(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
2013-04-29 11:38:18 +00:00
|
|
|
UNWRAP_WINDOW_AND_CHECK;
|
2013-12-11 07:48:19 +00:00
|
|
|
args.GetReturnValue().Set(self->window_->GetWebContents()->IsLoading());
|
2013-04-18 07:09:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// static
|
2013-12-15 09:09:35 +00:00
|
|
|
void Window::IsWaitingForResponse(
|
|
|
|
const v8::FunctionCallbackInfo<v8::Value>& args) {
|
2013-04-29 11:38:18 +00:00
|
|
|
UNWRAP_WINDOW_AND_CHECK;
|
2013-12-11 07:48:19 +00:00
|
|
|
args.GetReturnValue().Set(
|
|
|
|
self->window_->GetWebContents()->IsWaitingForResponse());
|
2013-04-18 07:09:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// static
|
2013-12-11 07:48:19 +00:00
|
|
|
void Window::Stop(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
2013-04-29 11:38:18 +00:00
|
|
|
UNWRAP_WINDOW_AND_CHECK;
|
2013-04-18 07:09:53 +00:00
|
|
|
self->window_->GetWebContents()->Stop();
|
|
|
|
}
|
|
|
|
|
2013-04-23 09:21:34 +00:00
|
|
|
// static
|
2013-12-11 07:48:19 +00:00
|
|
|
void Window::GetRoutingID(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
2013-04-29 11:38:18 +00:00
|
|
|
UNWRAP_WINDOW_AND_CHECK;
|
2013-12-11 07:48:19 +00:00
|
|
|
args.GetReturnValue().Set(self->window_->GetWebContents()->GetRoutingID());
|
2013-04-23 09:21:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// static
|
2013-12-11 07:48:19 +00:00
|
|
|
void Window::GetProcessID(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
2013-04-29 11:38:18 +00:00
|
|
|
UNWRAP_WINDOW_AND_CHECK;
|
2013-04-23 09:21:34 +00:00
|
|
|
|
2013-12-11 07:48:19 +00:00
|
|
|
args.GetReturnValue().Set(
|
2013-04-23 09:21:34 +00:00
|
|
|
self->window_->GetWebContents()->GetRenderProcessHost()->GetID());
|
|
|
|
}
|
|
|
|
|
2013-06-10 12:50:25 +00:00
|
|
|
// static
|
2013-12-11 07:48:19 +00:00
|
|
|
void Window::IsCrashed(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
2013-06-10 12:50:25 +00:00
|
|
|
UNWRAP_WINDOW_AND_CHECK;
|
2013-12-11 07:48:19 +00:00
|
|
|
args.GetReturnValue().Set(self->window_->GetWebContents()->IsCrashed());
|
2013-06-10 12:50:25 +00:00
|
|
|
}
|
|
|
|
|
2014-04-04 14:28:18 +00:00
|
|
|
// static
|
|
|
|
void Window::GetDevTools(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
|
|
|
UNWRAP_WINDOW_AND_CHECK;
|
|
|
|
|
|
|
|
content::WebContents* web_contents = self->window_->GetDevToolsWebContents();
|
|
|
|
v8::Local<v8::Object> devtools = v8::Object::New();
|
|
|
|
devtools->Set(ToV8Value("processId"),
|
|
|
|
ToV8Value(web_contents->GetRenderProcessHost()->GetID()));
|
|
|
|
devtools->Set(ToV8Value("routingId"),
|
|
|
|
ToV8Value(web_contents->GetRoutingID()));
|
|
|
|
args.GetReturnValue().Set(devtools);
|
|
|
|
}
|
|
|
|
|
2014-04-08 04:50:12 +00:00
|
|
|
// static
|
|
|
|
void Window::ExecuteJavaScriptInDevTools(
|
|
|
|
const v8::FunctionCallbackInfo<v8::Value>& args) {
|
|
|
|
UNWRAP_WINDOW_AND_CHECK;
|
|
|
|
|
|
|
|
std::string code;
|
|
|
|
if (!FromV8Arguments(args, &code))
|
|
|
|
return node::ThrowTypeError("Bad argument");
|
|
|
|
|
|
|
|
self->window_->ExecuteJavaScriptInDevTools(code);
|
|
|
|
}
|
|
|
|
|
2013-04-18 07:09:53 +00:00
|
|
|
// static
|
2013-12-11 07:48:19 +00:00
|
|
|
void Window::LoadURL(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
2013-04-29 11:38:18 +00:00
|
|
|
UNWRAP_WINDOW_AND_CHECK;
|
2013-04-18 07:09:53 +00:00
|
|
|
|
2013-12-05 02:08:11 +00:00
|
|
|
GURL url;
|
2013-09-24 01:41:54 +00:00
|
|
|
if (!FromV8Arguments(args, &url))
|
2013-04-18 07:09:53 +00:00
|
|
|
return node::ThrowTypeError("Bad argument");
|
|
|
|
|
|
|
|
NavigationController& controller =
|
|
|
|
self->window_->GetWebContents()->GetController();
|
2013-12-05 02:08:11 +00:00
|
|
|
|
|
|
|
content::NavigationController::LoadURLParams params(url);
|
|
|
|
params.transition_type = content::PAGE_TRANSITION_TYPED;
|
|
|
|
params.override_user_agent = content::NavigationController::UA_OVERRIDE_TRUE;
|
|
|
|
controller.LoadURLWithParams(params);
|
2013-04-18 07:09:53 +00:00
|
|
|
}
|
|
|
|
|
2013-04-18 16:06:10 +00:00
|
|
|
// static
|
2013-12-11 07:48:19 +00:00
|
|
|
void Window::GetURL(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
2013-04-29 11:38:18 +00:00
|
|
|
UNWRAP_WINDOW_AND_CHECK;
|
2013-04-18 16:06:10 +00:00
|
|
|
|
|
|
|
NavigationController& controller =
|
|
|
|
self->window_->GetWebContents()->GetController();
|
2013-12-05 02:08:11 +00:00
|
|
|
GURL url;
|
2013-04-18 16:06:10 +00:00
|
|
|
if (controller.GetActiveEntry())
|
2013-12-05 02:08:11 +00:00
|
|
|
url = controller.GetActiveEntry()->GetVirtualURL();
|
2013-04-18 16:06:10 +00:00
|
|
|
|
2013-12-11 07:48:19 +00:00
|
|
|
args.GetReturnValue().Set(ToV8Value(url));
|
2013-04-18 16:06:10 +00:00
|
|
|
}
|
|
|
|
|
2013-04-18 07:09:53 +00:00
|
|
|
// static
|
2013-12-11 07:48:19 +00:00
|
|
|
void Window::CanGoBack(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
2013-04-29 11:38:18 +00:00
|
|
|
UNWRAP_WINDOW_AND_CHECK;
|
2013-04-18 07:09:53 +00:00
|
|
|
|
|
|
|
NavigationController& controller =
|
|
|
|
self->window_->GetWebContents()->GetController();
|
|
|
|
|
2013-12-11 07:48:19 +00:00
|
|
|
args.GetReturnValue().Set(controller.CanGoBack());
|
2013-04-18 07:09:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// static
|
2013-12-11 07:48:19 +00:00
|
|
|
void Window::CanGoForward(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
2013-04-29 11:38:18 +00:00
|
|
|
UNWRAP_WINDOW_AND_CHECK;
|
2013-04-18 07:09:53 +00:00
|
|
|
|
|
|
|
NavigationController& controller =
|
|
|
|
self->window_->GetWebContents()->GetController();
|
|
|
|
|
2013-12-11 07:48:19 +00:00
|
|
|
args.GetReturnValue().Set(controller.CanGoForward());
|
2013-04-18 07:09:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// static
|
2013-12-11 07:48:19 +00:00
|
|
|
void Window::CanGoToOffset(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
2013-04-29 11:38:18 +00:00
|
|
|
UNWRAP_WINDOW_AND_CHECK;
|
2013-04-18 07:09:53 +00:00
|
|
|
|
2013-09-24 01:41:54 +00:00
|
|
|
int offset;
|
|
|
|
if (!FromV8Arguments(args, &offset))
|
2013-04-18 07:09:53 +00:00
|
|
|
return node::ThrowTypeError("Bad argument");
|
|
|
|
|
|
|
|
NavigationController& controller =
|
|
|
|
self->window_->GetWebContents()->GetController();
|
|
|
|
|
2013-12-11 07:48:19 +00:00
|
|
|
args.GetReturnValue().Set(controller.CanGoToOffset(offset));
|
2013-04-18 07:09:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// static
|
2013-12-11 07:48:19 +00:00
|
|
|
void Window::GoBack(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
2013-04-29 11:38:18 +00:00
|
|
|
UNWRAP_WINDOW_AND_CHECK;
|
2013-04-18 07:09:53 +00:00
|
|
|
|
|
|
|
NavigationController& controller =
|
|
|
|
self->window_->GetWebContents()->GetController();
|
|
|
|
controller.GoBack();
|
|
|
|
}
|
|
|
|
|
|
|
|
// static
|
2013-12-11 07:48:19 +00:00
|
|
|
void Window::GoForward(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
2013-04-29 11:38:18 +00:00
|
|
|
UNWRAP_WINDOW_AND_CHECK;
|
2013-04-18 07:09:53 +00:00
|
|
|
|
|
|
|
NavigationController& controller =
|
|
|
|
self->window_->GetWebContents()->GetController();
|
|
|
|
controller.GoForward();
|
|
|
|
}
|
|
|
|
|
|
|
|
// static
|
2013-12-11 07:48:19 +00:00
|
|
|
void Window::GoToIndex(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
2013-04-29 11:38:18 +00:00
|
|
|
UNWRAP_WINDOW_AND_CHECK;
|
2013-04-18 07:09:53 +00:00
|
|
|
|
2013-09-24 01:41:54 +00:00
|
|
|
int index;
|
|
|
|
if (!FromV8Arguments(args, &index))
|
2013-04-18 07:09:53 +00:00
|
|
|
return node::ThrowTypeError("Bad argument");
|
|
|
|
|
|
|
|
NavigationController& controller =
|
|
|
|
self->window_->GetWebContents()->GetController();
|
2013-09-24 01:41:54 +00:00
|
|
|
controller.GoToIndex(index);
|
2013-04-18 07:09:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// static
|
2013-12-11 07:48:19 +00:00
|
|
|
void Window::GoToOffset(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
2013-04-29 11:38:18 +00:00
|
|
|
UNWRAP_WINDOW_AND_CHECK;
|
2013-04-18 07:09:53 +00:00
|
|
|
|
2013-09-24 01:41:54 +00:00
|
|
|
int offset;
|
|
|
|
if (!FromV8Arguments(args, &offset))
|
2013-04-18 07:09:53 +00:00
|
|
|
return node::ThrowTypeError("Bad argument");
|
|
|
|
|
|
|
|
NavigationController& controller =
|
|
|
|
self->window_->GetWebContents()->GetController();
|
2013-09-24 01:41:54 +00:00
|
|
|
controller.GoToOffset(offset);
|
2013-04-18 07:09:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// static
|
2013-12-11 07:48:19 +00:00
|
|
|
void Window::Reload(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
2013-04-29 11:38:18 +00:00
|
|
|
UNWRAP_WINDOW_AND_CHECK;
|
2013-04-18 07:09:53 +00:00
|
|
|
|
|
|
|
NavigationController& controller =
|
|
|
|
self->window_->GetWebContents()->GetController();
|
|
|
|
controller.Reload(args[0]->IsBoolean() ? args[0]->BooleanValue(): false);
|
|
|
|
}
|
|
|
|
|
|
|
|
// static
|
2013-12-15 09:09:35 +00:00
|
|
|
void Window::ReloadIgnoringCache(
|
|
|
|
const v8::FunctionCallbackInfo<v8::Value>& args) {
|
2013-04-29 11:38:18 +00:00
|
|
|
UNWRAP_WINDOW_AND_CHECK;
|
2013-04-18 07:09:53 +00:00
|
|
|
|
|
|
|
NavigationController& controller =
|
|
|
|
self->window_->GetWebContents()->GetController();
|
|
|
|
controller.ReloadIgnoringCache(
|
|
|
|
args[0]->IsBoolean() ? args[0]->BooleanValue(): false);
|
|
|
|
}
|
|
|
|
|
2013-04-15 16:25:08 +00:00
|
|
|
// static
|
|
|
|
void Window::Initialize(v8::Handle<v8::Object> target) {
|
|
|
|
v8::Local<v8::FunctionTemplate> t = v8::FunctionTemplate::New(Window::New);
|
|
|
|
t->InstanceTemplate()->SetInternalFieldCount(1);
|
2013-06-18 13:40:03 +00:00
|
|
|
t->SetClassName(v8::String::NewSymbol("BrowserWindow"));
|
2013-04-17 14:49:49 +00:00
|
|
|
|
2013-04-18 07:09:53 +00:00
|
|
|
NODE_SET_PROTOTYPE_METHOD(t, "destroy", Destroy);
|
|
|
|
NODE_SET_PROTOTYPE_METHOD(t, "close", Close);
|
|
|
|
NODE_SET_PROTOTYPE_METHOD(t, "focus", Focus);
|
2013-05-16 14:56:52 +00:00
|
|
|
NODE_SET_PROTOTYPE_METHOD(t, "isFocused", IsFocused);
|
2013-04-18 07:09:53 +00:00
|
|
|
NODE_SET_PROTOTYPE_METHOD(t, "show", Show);
|
|
|
|
NODE_SET_PROTOTYPE_METHOD(t, "hide", Hide);
|
2013-10-03 00:27:59 +00:00
|
|
|
NODE_SET_PROTOTYPE_METHOD(t, "isVisible", IsVisible);
|
2013-04-18 07:09:53 +00:00
|
|
|
NODE_SET_PROTOTYPE_METHOD(t, "maximize", Maximize);
|
|
|
|
NODE_SET_PROTOTYPE_METHOD(t, "unmaximize", Unmaximize);
|
|
|
|
NODE_SET_PROTOTYPE_METHOD(t, "minimize", Minimize);
|
|
|
|
NODE_SET_PROTOTYPE_METHOD(t, "restore", Restore);
|
2013-06-07 06:05:56 +00:00
|
|
|
NODE_SET_PROTOTYPE_METHOD(t, "setFullScreen", SetFullscreen);
|
|
|
|
NODE_SET_PROTOTYPE_METHOD(t, "isFullScreen", IsFullscreen);
|
2013-04-18 07:09:53 +00:00
|
|
|
NODE_SET_PROTOTYPE_METHOD(t, "setSize", SetSize);
|
|
|
|
NODE_SET_PROTOTYPE_METHOD(t, "getSize", GetSize);
|
|
|
|
NODE_SET_PROTOTYPE_METHOD(t, "setMinimumSize", SetMinimumSize);
|
2013-04-18 07:38:04 +00:00
|
|
|
NODE_SET_PROTOTYPE_METHOD(t, "getMinimumSize", GetMinimumSize);
|
2013-04-18 07:09:53 +00:00
|
|
|
NODE_SET_PROTOTYPE_METHOD(t, "setMaximumSize", SetMaximumSize);
|
2013-04-18 07:38:04 +00:00
|
|
|
NODE_SET_PROTOTYPE_METHOD(t, "getMaximumSize", GetMaximumSize);
|
2013-04-18 07:09:53 +00:00
|
|
|
NODE_SET_PROTOTYPE_METHOD(t, "setResizable", SetResizable);
|
2013-04-18 07:38:04 +00:00
|
|
|
NODE_SET_PROTOTYPE_METHOD(t, "isResizable", IsResizable);
|
2013-04-18 07:09:53 +00:00
|
|
|
NODE_SET_PROTOTYPE_METHOD(t, "setAlwaysOnTop", SetAlwaysOnTop);
|
2013-04-18 07:38:04 +00:00
|
|
|
NODE_SET_PROTOTYPE_METHOD(t, "isAlwaysOnTop", IsAlwaysOnTop);
|
2013-05-10 12:34:05 +00:00
|
|
|
NODE_SET_PROTOTYPE_METHOD(t, "center", Center);
|
2013-04-18 07:09:53 +00:00
|
|
|
NODE_SET_PROTOTYPE_METHOD(t, "setPosition", SetPosition);
|
|
|
|
NODE_SET_PROTOTYPE_METHOD(t, "getPosition", GetPosition);
|
|
|
|
NODE_SET_PROTOTYPE_METHOD(t, "setTitle", SetTitle);
|
|
|
|
NODE_SET_PROTOTYPE_METHOD(t, "getTitle", GetTitle);
|
|
|
|
NODE_SET_PROTOTYPE_METHOD(t, "flashFrame", FlashFrame);
|
|
|
|
NODE_SET_PROTOTYPE_METHOD(t, "setKiosk", SetKiosk);
|
|
|
|
NODE_SET_PROTOTYPE_METHOD(t, "isKiosk", IsKiosk);
|
2013-05-10 12:34:05 +00:00
|
|
|
NODE_SET_PROTOTYPE_METHOD(t, "openDevTools", OpenDevTools);
|
2013-04-18 07:09:53 +00:00
|
|
|
NODE_SET_PROTOTYPE_METHOD(t, "closeDevTools", CloseDevTools);
|
2013-11-05 02:32:45 +00:00
|
|
|
NODE_SET_PROTOTYPE_METHOD(t, "isDevToolsOpened", IsDevToolsOpened);
|
2013-07-18 11:21:25 +00:00
|
|
|
NODE_SET_PROTOTYPE_METHOD(t, "inspectElement", InspectElement);
|
2014-02-24 04:08:33 +00:00
|
|
|
NODE_SET_PROTOTYPE_METHOD(t, "debugDevTools", DebugDevTools);
|
2013-05-24 09:51:15 +00:00
|
|
|
NODE_SET_PROTOTYPE_METHOD(t, "focusOnWebView", FocusOnWebView);
|
|
|
|
NODE_SET_PROTOTYPE_METHOD(t, "blurWebView", BlurWebView);
|
2013-08-16 04:56:25 +00:00
|
|
|
NODE_SET_PROTOTYPE_METHOD(t, "isWebViewFocused", IsWebViewFocused);
|
2013-11-22 06:23:19 +00:00
|
|
|
NODE_SET_PROTOTYPE_METHOD(t, "capturePage", CapturePage);
|
2013-04-18 07:09:53 +00:00
|
|
|
|
|
|
|
NODE_SET_PROTOTYPE_METHOD(t, "getPageTitle", GetPageTitle);
|
|
|
|
NODE_SET_PROTOTYPE_METHOD(t, "isLoading", IsLoading);
|
|
|
|
NODE_SET_PROTOTYPE_METHOD(t, "isWaitingForResponse", IsWaitingForResponse);
|
|
|
|
NODE_SET_PROTOTYPE_METHOD(t, "stop", Stop);
|
2013-05-03 07:21:41 +00:00
|
|
|
NODE_SET_PROTOTYPE_METHOD(t, "getRoutingId", GetRoutingID);
|
|
|
|
NODE_SET_PROTOTYPE_METHOD(t, "getProcessId", GetProcessID);
|
2013-06-10 12:50:25 +00:00
|
|
|
NODE_SET_PROTOTYPE_METHOD(t, "isCrashed", IsCrashed);
|
2013-04-18 07:09:53 +00:00
|
|
|
|
2014-04-04 14:28:18 +00:00
|
|
|
NODE_SET_PROTOTYPE_METHOD(t, "getDevTools", GetDevTools);
|
2014-04-08 04:50:12 +00:00
|
|
|
NODE_SET_PROTOTYPE_METHOD(
|
|
|
|
t, "executeJavaScriptInDevTools", ExecuteJavaScriptInDevTools);
|
2014-04-04 14:28:18 +00:00
|
|
|
|
2013-05-03 07:21:41 +00:00
|
|
|
NODE_SET_PROTOTYPE_METHOD(t, "loadUrl", LoadURL);
|
|
|
|
NODE_SET_PROTOTYPE_METHOD(t, "getUrl", GetURL);
|
2013-04-18 07:09:53 +00:00
|
|
|
NODE_SET_PROTOTYPE_METHOD(t, "canGoBack", CanGoBack);
|
|
|
|
NODE_SET_PROTOTYPE_METHOD(t, "canGoForward", CanGoForward);
|
|
|
|
NODE_SET_PROTOTYPE_METHOD(t, "canGoToOffset", CanGoToOffset);
|
|
|
|
NODE_SET_PROTOTYPE_METHOD(t, "goBack", GoBack);
|
|
|
|
NODE_SET_PROTOTYPE_METHOD(t, "goForward", GoForward);
|
|
|
|
NODE_SET_PROTOTYPE_METHOD(t, "goToIndex", GoToIndex);
|
|
|
|
NODE_SET_PROTOTYPE_METHOD(t, "goToOffset", GoToOffset);
|
|
|
|
NODE_SET_PROTOTYPE_METHOD(t, "reload", Reload);
|
|
|
|
NODE_SET_PROTOTYPE_METHOD(t, "reloadIgnoringCache", ReloadIgnoringCache);
|
2013-04-17 14:49:49 +00:00
|
|
|
|
2013-06-18 13:40:03 +00:00
|
|
|
target->Set(v8::String::NewSymbol("BrowserWindow"), t->GetFunction());
|
2013-04-15 16:25:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace api
|
|
|
|
|
2013-04-14 07:36:48 +00:00
|
|
|
} // namespace atom
|
|
|
|
|
2013-04-21 06:53:26 +00:00
|
|
|
NODE_MODULE(atom_browser_window, atom::api::Window::Initialize)
|