Discard all our custom V8 helpers, use native-mate instead.
This commit is contained in:
parent
ef5342b86e
commit
a040a96652
28 changed files with 484 additions and 1552 deletions
|
@ -16,30 +16,6 @@
|
|||
|
||||
#include "atom/common/node_includes.h"
|
||||
|
||||
namespace mate {
|
||||
|
||||
template<>
|
||||
struct Converter<atom::NativeWindow*> {
|
||||
static bool FromV8(v8::Isolate* isolate,
|
||||
v8::Handle<v8::Value> val,
|
||||
atom::NativeWindow** out) {
|
||||
using atom::api::Window;
|
||||
if (val->IsNull()) {
|
||||
*out = NULL;
|
||||
return true; // NULL is a valid value for NativeWindow*.
|
||||
} else if (val->IsObject()) {
|
||||
Window* window = Window::Unwrap<Window>(val->ToObject());
|
||||
*out = window->window();
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace mate
|
||||
|
||||
|
||||
namespace {
|
||||
|
||||
void ShowMessageBox(int type,
|
||||
|
@ -47,18 +23,18 @@ void ShowMessageBox(int type,
|
|||
const std::string& title,
|
||||
const std::string& message,
|
||||
const std::string& detail,
|
||||
atom::NativeWindow* window,
|
||||
atom::api::Window* window,
|
||||
mate::Arguments* args) {
|
||||
v8::Handle<v8::Value> peek = args->PeekNext();
|
||||
atom::MessageBoxCallback callback;
|
||||
if (mate::Converter<atom::MessageBoxCallback>::FromV8(node_isolate,
|
||||
peek,
|
||||
&callback)) {
|
||||
atom::ShowMessageBox(window, (atom::MessageBoxType)type, buttons, title,
|
||||
message, detail, callback);
|
||||
atom::ShowMessageBox(window->window(), (atom::MessageBoxType)type, buttons,
|
||||
title, message, detail, callback);
|
||||
} else {
|
||||
int chosen = atom::ShowMessageBox(
|
||||
window,
|
||||
window->window(),
|
||||
(atom::MessageBoxType)type,
|
||||
buttons,
|
||||
title,
|
||||
|
@ -71,18 +47,18 @@ void ShowMessageBox(int type,
|
|||
void ShowOpenDialog(const std::string& title,
|
||||
const base::FilePath& default_path,
|
||||
int properties,
|
||||
atom::NativeWindow* window,
|
||||
atom::api::Window* window,
|
||||
mate::Arguments* args) {
|
||||
v8::Handle<v8::Value> peek = args->PeekNext();
|
||||
file_dialog::OpenDialogCallback callback;
|
||||
if (mate::Converter<file_dialog::OpenDialogCallback>::FromV8(node_isolate,
|
||||
peek,
|
||||
&callback)) {
|
||||
file_dialog::ShowOpenDialog(window, title, default_path, properties,
|
||||
callback);
|
||||
file_dialog::ShowOpenDialog(window->window(), title, default_path,
|
||||
properties, callback);
|
||||
} else {
|
||||
std::vector<base::FilePath> paths;
|
||||
if (file_dialog::ShowOpenDialog(window,
|
||||
if (file_dialog::ShowOpenDialog(window->window(),
|
||||
title,
|
||||
default_path,
|
||||
properties,
|
||||
|
@ -93,19 +69,18 @@ void ShowOpenDialog(const std::string& title,
|
|||
|
||||
void ShowSaveDialog(const std::string& title,
|
||||
const base::FilePath& default_path,
|
||||
atom::NativeWindow* window,
|
||||
atom::api::Window* window,
|
||||
mate::Arguments* args) {
|
||||
v8::Handle<v8::Value> peek = args->PeekNext();
|
||||
file_dialog::SaveDialogCallback callback;
|
||||
if (mate::Converter<file_dialog::SaveDialogCallback>::FromV8(node_isolate,
|
||||
peek,
|
||||
&callback)) {
|
||||
file_dialog::ShowSaveDialog(window, title, default_path, callback);
|
||||
file_dialog::ShowSaveDialog(window->window(), title, default_path,
|
||||
callback);
|
||||
} else {
|
||||
base::FilePath path;
|
||||
if (file_dialog::ShowSaveDialog(window,
|
||||
title,
|
||||
default_path,
|
||||
if (file_dialog::ShowSaveDialog(window->window(), title, default_path,
|
||||
&path))
|
||||
args->Return(path);
|
||||
}
|
||||
|
|
|
@ -1,99 +0,0 @@
|
|||
// 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.
|
||||
|
||||
#include "atom/browser/api/atom_api_event.h"
|
||||
|
||||
#include "atom/common/api/api_messages.h"
|
||||
#include "atom/common/node_includes.h"
|
||||
#include "atom/common/v8/native_type_conversions.h"
|
||||
#include "content/public/browser/web_contents.h"
|
||||
|
||||
namespace atom {
|
||||
|
||||
namespace api {
|
||||
|
||||
ScopedPersistent<v8::Function> Event::constructor_template_;
|
||||
|
||||
Event::Event()
|
||||
: sender_(NULL),
|
||||
message_(NULL),
|
||||
prevent_default_(false) {
|
||||
}
|
||||
|
||||
Event::~Event() {
|
||||
}
|
||||
|
||||
// static
|
||||
v8::Handle<v8::Object> Event::CreateV8Object() {
|
||||
if (constructor_template_.IsEmpty()) {
|
||||
v8::Local<v8::FunctionTemplate> t = v8::FunctionTemplate::New(New);
|
||||
t->InstanceTemplate()->SetInternalFieldCount(1);
|
||||
t->SetClassName(v8::String::NewSymbol("Event"));
|
||||
|
||||
NODE_SET_PROTOTYPE_METHOD(t, "preventDefault", PreventDefault);
|
||||
NODE_SET_PROTOTYPE_METHOD(t, "sendReply", SendReply);
|
||||
NODE_SET_PROTOTYPE_METHOD(t, "destroy", Destroy);
|
||||
|
||||
constructor_template_.reset(t->GetFunction());
|
||||
}
|
||||
|
||||
v8::Handle<v8::Function> t = constructor_template_.NewHandle(node_isolate);
|
||||
return t->NewInstance(0, NULL);
|
||||
}
|
||||
|
||||
void Event::SetSenderAndMessage(content::WebContents* sender,
|
||||
IPC::Message* message) {
|
||||
DCHECK(!sender_);
|
||||
DCHECK(!message_);
|
||||
sender_ = sender;
|
||||
message_ = message;
|
||||
|
||||
Observe(sender);
|
||||
}
|
||||
|
||||
void Event::WebContentsDestroyed(content::WebContents* web_contents) {
|
||||
sender_ = NULL;
|
||||
message_ = NULL;
|
||||
}
|
||||
|
||||
// static
|
||||
void Event::New(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||
Event* event = new Event;
|
||||
event->Wrap(args.This());
|
||||
}
|
||||
|
||||
// static
|
||||
void Event::PreventDefault(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||
Event* event = Unwrap<Event>(args.This());
|
||||
if (event == NULL)
|
||||
return node::ThrowError("Event is already destroyed");
|
||||
|
||||
event->prevent_default_ = true;
|
||||
}
|
||||
|
||||
// static
|
||||
void Event::SendReply(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||
Event* event = Unwrap<Event>(args.This());
|
||||
if (event == NULL)
|
||||
return node::ThrowError("Event is already destroyed");
|
||||
|
||||
if (event->message_ == NULL || event->sender_ == NULL)
|
||||
return node::ThrowError("Can only send reply to synchronous events");
|
||||
|
||||
string16 json = FromV8Value(args[0]);
|
||||
|
||||
AtomViewHostMsg_Message_Sync::WriteReplyParams(event->message_, json);
|
||||
event->sender_->Send(event->message_);
|
||||
|
||||
delete event;
|
||||
}
|
||||
|
||||
// static
|
||||
void Event::Destroy(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||
delete Unwrap<Event>(args.This());
|
||||
}
|
||||
|
||||
} // namespace api
|
||||
|
||||
} // namespace atom
|
|
@ -1,65 +0,0 @@
|
|||
// 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.
|
||||
|
||||
#ifndef ATOM_BROWSER_API_ATOM_API_EVENT_H_
|
||||
#define ATOM_BROWSER_API_ATOM_API_EVENT_H_
|
||||
|
||||
#include "atom/common/v8/scoped_persistent.h"
|
||||
#include "base/basictypes.h"
|
||||
#include "base/compiler_specific.h"
|
||||
#include "base/strings/string16.h"
|
||||
#include "content/public/browser/web_contents_observer.h"
|
||||
#include "vendor/node/src/node_object_wrap.h"
|
||||
|
||||
namespace IPC {
|
||||
class Message;
|
||||
}
|
||||
|
||||
namespace atom {
|
||||
|
||||
namespace api {
|
||||
|
||||
class Event : public node::ObjectWrap,
|
||||
public content::WebContentsObserver {
|
||||
public:
|
||||
virtual ~Event();
|
||||
|
||||
// Create a V8 Event object.
|
||||
static v8::Handle<v8::Object> CreateV8Object();
|
||||
|
||||
// Pass the sender and message to be replied.
|
||||
void SetSenderAndMessage(content::WebContents* sender, IPC::Message* message);
|
||||
|
||||
// Whether event.preventDefault() is called.
|
||||
bool prevent_default() const { return prevent_default_; }
|
||||
|
||||
protected:
|
||||
Event();
|
||||
|
||||
// content::WebContentsObserver implementations:
|
||||
virtual void WebContentsDestroyed(content::WebContents*) OVERRIDE;
|
||||
|
||||
private:
|
||||
static void New(const v8::FunctionCallbackInfo<v8::Value>& args);
|
||||
|
||||
static void PreventDefault(const v8::FunctionCallbackInfo<v8::Value>& args);
|
||||
static void SendReply(const v8::FunctionCallbackInfo<v8::Value>& args);
|
||||
static void Destroy(const v8::FunctionCallbackInfo<v8::Value>& args);
|
||||
|
||||
static ScopedPersistent<v8::Function> constructor_template_;
|
||||
|
||||
// Replyer for the synchronous messages.
|
||||
content::WebContents* sender_;
|
||||
IPC::Message* message_;
|
||||
|
||||
bool prevent_default_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(Event);
|
||||
};
|
||||
|
||||
} // namespace api
|
||||
|
||||
} // namespace atom
|
||||
|
||||
#endif // ATOM_BROWSER_API_ATOM_API_EVENT_H_
|
|
@ -13,30 +13,6 @@
|
|||
|
||||
#include "atom/common/node_includes.h"
|
||||
|
||||
namespace mate {
|
||||
|
||||
template<>
|
||||
struct Converter<atom::NativeWindow*> {
|
||||
static bool FromV8(v8::Isolate* isolate,
|
||||
v8::Handle<v8::Value> val,
|
||||
atom::NativeWindow** out) {
|
||||
using atom::api::Window;
|
||||
if (val->IsNull()) {
|
||||
*out = NULL;
|
||||
return true; // NULL is a valid value for NativeWindow*.
|
||||
} else if (val->IsObject()) {
|
||||
Window* window = Window::Unwrap<Window>(val->ToObject());
|
||||
*out = window->window();
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace mate
|
||||
|
||||
|
||||
namespace atom {
|
||||
|
||||
namespace api {
|
||||
|
|
|
@ -7,14 +7,13 @@
|
|||
|
||||
#include <string>
|
||||
|
||||
#include "atom/browser/api/atom_api_window.h"
|
||||
#include "base/memory/scoped_ptr.h"
|
||||
#include "ui/base/models/simple_menu_model.h"
|
||||
#include "native_mate/wrappable.h"
|
||||
|
||||
namespace atom {
|
||||
|
||||
class NativeWindow;
|
||||
|
||||
namespace api {
|
||||
|
||||
class MenuMac;
|
||||
|
@ -51,7 +50,7 @@ class Menu : public mate::Wrappable,
|
|||
virtual string16 GetSublabelForCommandId(int command_id) const OVERRIDE;
|
||||
virtual void ExecuteCommand(int command_id, int event_flags) OVERRIDE;
|
||||
|
||||
virtual void Popup(NativeWindow* window) = 0;
|
||||
virtual void Popup(Window* window) = 0;
|
||||
|
||||
scoped_ptr<ui::SimpleMenuModel> model_;
|
||||
|
||||
|
@ -81,7 +80,7 @@ class Menu : public mate::Wrappable,
|
|||
bool IsVisibleAt(int index) const;
|
||||
|
||||
#if defined(OS_WIN) || defined(TOOLKIT_GTK)
|
||||
void AttachToWindow(NativeWindow* window);
|
||||
void AttachToWindow(Window* window);
|
||||
#endif
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(Menu);
|
||||
|
|
|
@ -18,10 +18,11 @@ namespace api {
|
|||
MenuGtk::MenuGtk() {
|
||||
}
|
||||
|
||||
void MenuGtk::Popup(NativeWindow* native_window) {
|
||||
void MenuGtk::Popup(Window* window) {
|
||||
uint32_t triggering_event_time;
|
||||
gfx::Point point;
|
||||
|
||||
BrowserWindow* native_window = window->window();
|
||||
GdkEventButton* event = native_window->GetWebContents()->
|
||||
GetRenderWidgetHostView()->GetLastMouseDown();
|
||||
if (event) {
|
||||
|
@ -36,11 +37,8 @@ void MenuGtk::Popup(NativeWindow* native_window) {
|
|||
menu_gtk_->PopupAsContext(point, triggering_event_time);
|
||||
}
|
||||
|
||||
void Menu::AttachToWindow(NativeWindow* window) {
|
||||
if (window == NULL)
|
||||
return node::ThrowTypeError("Window is dead");
|
||||
|
||||
static_cast<NativeWindowGtk*>(native_window)->SetMenu(model_.get());
|
||||
void Menu::AttachToWindow(Window* window) {
|
||||
static_cast<NativeWindowGtk*>(window->window())->SetMenu(model_.get());
|
||||
}
|
||||
|
||||
// static
|
||||
|
|
|
@ -15,7 +15,7 @@ namespace api {
|
|||
class MenuGtk : public Menu,
|
||||
public ::MenuGtk::Delegate {
|
||||
protected:
|
||||
virtual void Popup(NativeWindow* window) OVERRIDE;
|
||||
virtual void Popup(Window* window) OVERRIDE;
|
||||
|
||||
private:
|
||||
MenuGtk();
|
||||
|
|
|
@ -19,7 +19,7 @@ class MenuMac : public Menu {
|
|||
protected:
|
||||
MenuMac();
|
||||
|
||||
virtual void Popup(NativeWindow* window) OVERRIDE;
|
||||
virtual void Popup(Window* window) OVERRIDE;
|
||||
|
||||
base::scoped_nsobject<AtomMenuController> menu_controller_;
|
||||
|
||||
|
|
|
@ -19,22 +19,23 @@ namespace api {
|
|||
MenuMac::MenuMac() {
|
||||
}
|
||||
|
||||
void MenuMac::Popup(NativeWindow* native_window) {
|
||||
void MenuMac::Popup(Window* window) {
|
||||
base::scoped_nsobject<AtomMenuController> menu_controller(
|
||||
[[AtomMenuController alloc] initWithModel:model_.get()]);
|
||||
|
||||
NSWindow* window = native_window->GetNativeWindow();
|
||||
NativeWindow* native_window = window->window();
|
||||
NSWindow* nswindow = native_window->GetNativeWindow();
|
||||
content::WebContents* web_contents = native_window->GetWebContents();
|
||||
|
||||
// Fake out a context menu event.
|
||||
NSEvent* currentEvent = [NSApp currentEvent];
|
||||
NSPoint position = [window mouseLocationOutsideOfEventStream];
|
||||
NSPoint position = [nswindow mouseLocationOutsideOfEventStream];
|
||||
NSTimeInterval eventTime = [currentEvent timestamp];
|
||||
NSEvent* clickEvent = [NSEvent mouseEventWithType:NSRightMouseDown
|
||||
location:position
|
||||
modifierFlags:NSRightMouseDownMask
|
||||
timestamp:eventTime
|
||||
windowNumber:[window windowNumber]
|
||||
windowNumber:[nswindow windowNumber]
|
||||
context:nil
|
||||
eventNumber:0
|
||||
clickCount:1
|
||||
|
|
|
@ -18,17 +18,14 @@ namespace api {
|
|||
MenuWin::MenuWin() {
|
||||
}
|
||||
|
||||
void MenuWin::Popup(NativeWindow* native_window) {
|
||||
void MenuWin::Popup(Window* window) {
|
||||
gfx::Point cursor = gfx::Screen::GetNativeScreen()->GetCursorScreenPoint();
|
||||
menu_.reset(new atom::Menu2(model_.get()));
|
||||
menu_->RunContextMenuAt(cursor);
|
||||
}
|
||||
|
||||
void Menu::AttachToWindow(NativeWindow* window) {
|
||||
if (window == NULL)
|
||||
return node::ThrowTypeError("Window is dead");
|
||||
|
||||
static_cast<NativeWindowWin*>(native_window)->SetMenu(model_.get());
|
||||
void Menu::AttachToWindow(Window* window) {
|
||||
static_cast<NativeWindowWin*>(window->window())->SetMenu(model_.get());
|
||||
}
|
||||
|
||||
// static
|
||||
|
|
|
@ -15,7 +15,7 @@ namespace api {
|
|||
|
||||
class MenuWin : public Menu {
|
||||
protected:
|
||||
virtual void Popup(NativeWindow* window) OVERRIDE;
|
||||
virtual void Popup(Window* window) OVERRIDE;
|
||||
|
||||
private:
|
||||
MenuWin();
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -10,33 +10,41 @@
|
|||
|
||||
#include "base/memory/scoped_ptr.h"
|
||||
#include "atom/browser/native_window_observer.h"
|
||||
#include "atom/common/api/atom_api_event_emitter.h"
|
||||
#include "atom/common/v8/scoped_persistent.h"
|
||||
#include "atom/browser/api/event_emitter.h"
|
||||
|
||||
class GURL;
|
||||
|
||||
namespace base {
|
||||
class DictionaryValue;
|
||||
}
|
||||
|
||||
namespace mate {
|
||||
class Arguments;
|
||||
class Dictionary;
|
||||
}
|
||||
|
||||
namespace atom {
|
||||
|
||||
class NativeWindow;
|
||||
|
||||
namespace api {
|
||||
|
||||
class Window : public EventEmitter,
|
||||
class Window : public mate::EventEmitter,
|
||||
public NativeWindowObserver {
|
||||
public:
|
||||
virtual ~Window();
|
||||
static mate::Wrappable* New(mate::Arguments* args,
|
||||
const base::DictionaryValue& options);
|
||||
|
||||
static void Initialize(v8::Handle<v8::Object> target);
|
||||
static void BuildPrototype(v8::Isolate* isolate,
|
||||
v8::Handle<v8::ObjectTemplate> prototype);
|
||||
|
||||
NativeWindow* window() { return window_.get(); }
|
||||
NativeWindow* window() const { return window_.get(); }
|
||||
|
||||
protected:
|
||||
explicit Window(v8::Handle<v8::Object> wrapper,
|
||||
base::DictionaryValue* options);
|
||||
explicit Window(base::DictionaryValue* options);
|
||||
virtual ~Window();
|
||||
|
||||
// Implementations of NativeWindowObserver.
|
||||
// Implementations of NativeWindowObserver:
|
||||
virtual void OnPageTitleUpdated(bool* prevent_default,
|
||||
const std::string& title) OVERRIDE;
|
||||
virtual void OnLoadingStateChanged(bool is_loading) OVERRIDE;
|
||||
|
@ -49,82 +57,73 @@ class Window : public EventEmitter,
|
|||
virtual void OnRendererCrashed() OVERRIDE;
|
||||
|
||||
private:
|
||||
static void New(const v8::FunctionCallbackInfo<v8::Value>& args);
|
||||
static void Destroy(const v8::FunctionCallbackInfo<v8::Value>& args);
|
||||
|
||||
// APIs for NativeWindow.
|
||||
static void Close(const v8::FunctionCallbackInfo<v8::Value>& args);
|
||||
static void Focus(const v8::FunctionCallbackInfo<v8::Value>& args);
|
||||
static void IsFocused(const v8::FunctionCallbackInfo<v8::Value>& args);
|
||||
static void Show(const v8::FunctionCallbackInfo<v8::Value>& args);
|
||||
static void Hide(const v8::FunctionCallbackInfo<v8::Value>& args);
|
||||
static void IsVisible(const v8::FunctionCallbackInfo<v8::Value>& args);
|
||||
static void Maximize(const v8::FunctionCallbackInfo<v8::Value>& args);
|
||||
static void Unmaximize(const v8::FunctionCallbackInfo<v8::Value>& args);
|
||||
static void Minimize(const v8::FunctionCallbackInfo<v8::Value>& args);
|
||||
static void Restore(const v8::FunctionCallbackInfo<v8::Value>& args);
|
||||
static void SetFullscreen(const v8::FunctionCallbackInfo<v8::Value>& args);
|
||||
static void IsFullscreen(const v8::FunctionCallbackInfo<v8::Value>& args);
|
||||
static void SetSize(const v8::FunctionCallbackInfo<v8::Value>& args);
|
||||
static void GetSize(const v8::FunctionCallbackInfo<v8::Value>& args);
|
||||
static void SetMinimumSize(const v8::FunctionCallbackInfo<v8::Value>& args);
|
||||
static void GetMinimumSize(const v8::FunctionCallbackInfo<v8::Value>& args);
|
||||
static void SetMaximumSize(const v8::FunctionCallbackInfo<v8::Value>& args);
|
||||
static void GetMaximumSize(const v8::FunctionCallbackInfo<v8::Value>& args);
|
||||
static void SetResizable(const v8::FunctionCallbackInfo<v8::Value>& args);
|
||||
static void IsResizable(const v8::FunctionCallbackInfo<v8::Value>& args);
|
||||
static void SetAlwaysOnTop(const v8::FunctionCallbackInfo<v8::Value>& args);
|
||||
static void IsAlwaysOnTop(const v8::FunctionCallbackInfo<v8::Value>& args);
|
||||
static void Center(const v8::FunctionCallbackInfo<v8::Value>& args);
|
||||
static void SetPosition(const v8::FunctionCallbackInfo<v8::Value>& args);
|
||||
static void GetPosition(const v8::FunctionCallbackInfo<v8::Value>& args);
|
||||
static void SetTitle(const v8::FunctionCallbackInfo<v8::Value>& args);
|
||||
static void GetTitle(const v8::FunctionCallbackInfo<v8::Value>& args);
|
||||
static void FlashFrame(const v8::FunctionCallbackInfo<v8::Value>& args);
|
||||
static void SetKiosk(const v8::FunctionCallbackInfo<v8::Value>& args);
|
||||
static void IsKiosk(const v8::FunctionCallbackInfo<v8::Value>& args);
|
||||
static void OpenDevTools(const v8::FunctionCallbackInfo<v8::Value>& args);
|
||||
static void CloseDevTools(const v8::FunctionCallbackInfo<v8::Value>& args);
|
||||
static void IsDevToolsOpened(const v8::FunctionCallbackInfo<v8::Value>& args);
|
||||
static void InspectElement(const v8::FunctionCallbackInfo<v8::Value>& args);
|
||||
static void DebugDevTools(const v8::FunctionCallbackInfo<v8::Value>& args);
|
||||
static void FocusOnWebView(const v8::FunctionCallbackInfo<v8::Value>& args);
|
||||
static void BlurWebView(const v8::FunctionCallbackInfo<v8::Value>& args);
|
||||
static void IsWebViewFocused(const v8::FunctionCallbackInfo<v8::Value>& args);
|
||||
static void CapturePage(const v8::FunctionCallbackInfo<v8::Value>& args);
|
||||
void Destroy();
|
||||
void Close();
|
||||
void Focus();
|
||||
bool IsFocused();
|
||||
void Show();
|
||||
void Hide();
|
||||
bool IsVisible();
|
||||
void Maximize();
|
||||
void Unmaximize();
|
||||
void Minimize();
|
||||
void Restore();
|
||||
void SetFullscreen(bool fullscreen);
|
||||
bool IsFullscreen();
|
||||
void SetSize(int width, int height);
|
||||
std::vector<int> GetSize();
|
||||
void SetMinimumSize(int width, int height);
|
||||
std::vector<int> GetMinimumSize();
|
||||
void SetMaximumSize(int width, int height);
|
||||
std::vector<int> GetMaximumSize();
|
||||
void SetResizable(bool resizable);
|
||||
bool IsResizable();
|
||||
void SetAlwaysOnTop(bool top);
|
||||
bool IsAlwaysOnTop();
|
||||
void Center();
|
||||
void SetPosition(int x, int y);
|
||||
std::vector<int> GetPosition();
|
||||
void SetTitle(const std::string& title);
|
||||
std::string GetTitle();
|
||||
void FlashFrame(bool flash);
|
||||
void SetKiosk(bool kiosk);
|
||||
bool IsKiosk();
|
||||
void OpenDevTools();
|
||||
void CloseDevTools();
|
||||
bool IsDevToolsOpened();
|
||||
void InspectElement(int x, int y);
|
||||
void DebugDevTools();
|
||||
void FocusOnWebView();
|
||||
void BlurWebView();
|
||||
bool IsWebViewFocused();
|
||||
void CapturePage(mate::Arguments* args);
|
||||
|
||||
// APIs for WebContents.
|
||||
static void GetPageTitle(const v8::FunctionCallbackInfo<v8::Value>& args);
|
||||
static void IsLoading(const v8::FunctionCallbackInfo<v8::Value>& args);
|
||||
static void IsWaitingForResponse(
|
||||
const v8::FunctionCallbackInfo<v8::Value>& args);
|
||||
static void Stop(const v8::FunctionCallbackInfo<v8::Value>& args);
|
||||
static void GetRoutingID(const v8::FunctionCallbackInfo<v8::Value>& args);
|
||||
static void GetProcessID(const v8::FunctionCallbackInfo<v8::Value>& args);
|
||||
static void IsCrashed(const v8::FunctionCallbackInfo<v8::Value>& args);
|
||||
string16 GetPageTitle();
|
||||
bool IsLoading();
|
||||
bool IsWaitingForResponse();
|
||||
void Stop();
|
||||
int GetRoutingID();
|
||||
int GetProcessID();
|
||||
bool IsCrashed();
|
||||
|
||||
// APIs for devtools.
|
||||
static void GetDevTools(const v8::FunctionCallbackInfo<v8::Value>& args);
|
||||
static void ExecuteJavaScriptInDevTools(
|
||||
const v8::FunctionCallbackInfo<v8::Value>& args);
|
||||
mate::Dictionary GetDevTools(v8::Isolate* isolate);
|
||||
void ExecuteJavaScriptInDevTools(const std::string& code);
|
||||
|
||||
// APIs for NavigationController.
|
||||
static void LoadURL(const v8::FunctionCallbackInfo<v8::Value>& args);
|
||||
static void GetURL(const v8::FunctionCallbackInfo<v8::Value>& args);
|
||||
static void CanGoBack(const v8::FunctionCallbackInfo<v8::Value>& args);
|
||||
static void CanGoForward(const v8::FunctionCallbackInfo<v8::Value>& args);
|
||||
static void CanGoToOffset(const v8::FunctionCallbackInfo<v8::Value>& args);
|
||||
static void GoBack(const v8::FunctionCallbackInfo<v8::Value>& args);
|
||||
static void GoForward(const v8::FunctionCallbackInfo<v8::Value>& args);
|
||||
static void GoToIndex(const v8::FunctionCallbackInfo<v8::Value>& args);
|
||||
static void GoToOffset(const v8::FunctionCallbackInfo<v8::Value>& args);
|
||||
static void Reload(const v8::FunctionCallbackInfo<v8::Value>& args);
|
||||
static void ReloadIgnoringCache(
|
||||
const v8::FunctionCallbackInfo<v8::Value>& args);
|
||||
|
||||
// Called when capturePage is done.
|
||||
void OnCapturePageDone(const RefCountedV8Function& callback,
|
||||
const std::vector<unsigned char>& data);
|
||||
void LoadURL(const GURL& url);
|
||||
GURL GetURL();
|
||||
bool CanGoBack();
|
||||
bool CanGoForward();
|
||||
bool CanGoToOffset(int offset);
|
||||
void GoBack();
|
||||
void GoForward();
|
||||
void GoToIndex(int index);
|
||||
void GoToOffset(int offset);
|
||||
void Reload();
|
||||
void ReloadIgnoringCache();
|
||||
|
||||
scoped_ptr<NativeWindow> window_;
|
||||
|
||||
|
|
|
@ -297,6 +297,10 @@ void NativeWindow::CapturePage(const gfx::Rect& rect,
|
|||
callback));
|
||||
}
|
||||
|
||||
void NativeWindow::DestroyWebContents() {
|
||||
inspectable_web_contents_.reset();
|
||||
}
|
||||
|
||||
void NativeWindow::CloseWebContents() {
|
||||
bool prevent_default = false;
|
||||
FOR_EACH_OBSERVER(NativeWindowObserver,
|
||||
|
@ -365,10 +369,6 @@ void NativeWindow::NotifyWindowBlur() {
|
|||
FOR_EACH_OBSERVER(NativeWindowObserver, observers_, OnWindowBlur());
|
||||
}
|
||||
|
||||
void NativeWindow::DestroyWebContents() {
|
||||
inspectable_web_contents_.reset();
|
||||
}
|
||||
|
||||
// In atom-shell all reloads and navigations started by renderer process would
|
||||
// be redirected to this method, so we can have precise control of how we
|
||||
// would open the url (in our case, is to restart the renderer process). See
|
||||
|
|
|
@ -158,6 +158,9 @@ class NativeWindow : public brightray::DefaultWebContentsDelegate,
|
|||
// Should be called by platform code when user want to close the window.
|
||||
virtual void CloseWebContents();
|
||||
|
||||
// Destroy the WebContents immediately.
|
||||
virtual void DestroyWebContents();
|
||||
|
||||
base::WeakPtr<NativeWindow> GetWeakPtr() {
|
||||
return weak_factory_.GetWeakPtr();
|
||||
}
|
||||
|
@ -196,9 +199,6 @@ class NativeWindow : public brightray::DefaultWebContentsDelegate,
|
|||
void NotifyWindowClosed();
|
||||
void NotifyWindowBlur();
|
||||
|
||||
// Destroy the inspectable_web_contents.
|
||||
void DestroyWebContents();
|
||||
|
||||
// Called when the window needs to update its draggable region.
|
||||
virtual void UpdateDraggableRegions(
|
||||
const std::vector<DraggableRegion>& regions) = 0;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue