Don't use Node's internal APIs
This commit is contained in:
parent
24bbe5dabf
commit
46b2b91a27
8 changed files with 25 additions and 21 deletions
|
@ -5,12 +5,11 @@
|
|||
#include "atom/browser/api/atom_api_power_monitor.h"
|
||||
|
||||
#include "atom/browser/browser.h"
|
||||
#include "atom/common/node_includes.h"
|
||||
#include "base/power_monitor/power_monitor.h"
|
||||
#include "base/power_monitor/power_monitor_device_source.h"
|
||||
#include "native_mate/dictionary.h"
|
||||
|
||||
#include "atom/common/node_includes.h"
|
||||
|
||||
namespace atom {
|
||||
|
||||
namespace api {
|
||||
|
@ -41,9 +40,9 @@ void PowerMonitor::OnResume() {
|
|||
// static
|
||||
v8::Local<v8::Value> PowerMonitor::Create(v8::Isolate* isolate) {
|
||||
if (!Browser::Get()->is_ready()) {
|
||||
node::ThrowError(
|
||||
isolate->ThrowException(v8::Exception::Error(mate::StringToV8(
|
||||
isolate,
|
||||
"Cannot initialize \"power-monitor\" module before app is ready");
|
||||
"Cannot initialize \"power-monitor\" module before app is ready")));
|
||||
return v8::Null(isolate);
|
||||
}
|
||||
|
||||
|
|
|
@ -113,14 +113,16 @@ mate::ObjectTemplateBuilder Screen::GetObjectTemplateBuilder(
|
|||
// static
|
||||
v8::Local<v8::Value> Screen::Create(v8::Isolate* isolate) {
|
||||
if (!Browser::Get()->is_ready()) {
|
||||
node::ThrowError(isolate,
|
||||
"Cannot initialize \"screen\" module before app is ready");
|
||||
isolate->ThrowException(v8::Exception::Error(mate::StringToV8(
|
||||
isolate,
|
||||
"Cannot initialize \"screen\" module before app is ready")));
|
||||
return v8::Null(isolate);
|
||||
}
|
||||
|
||||
gfx::Screen* screen = gfx::Screen::GetNativeScreen();
|
||||
if (!screen) {
|
||||
node::ThrowError(isolate, "Failed to get screen information");
|
||||
isolate->ThrowException(v8::Exception::Error(mate::StringToV8(
|
||||
isolate, "Failed to get screen information")));
|
||||
return v8::Null(isolate);
|
||||
}
|
||||
|
||||
|
|
|
@ -35,7 +35,8 @@ Tray::~Tray() {
|
|||
// static
|
||||
mate::Wrappable* Tray::New(v8::Isolate* isolate, const gfx::Image& image) {
|
||||
if (!Browser::Get()->is_ready()) {
|
||||
node::ThrowError(isolate, "Cannot create Tray before app is ready");
|
||||
isolate->ThrowException(v8::Exception::Error(mate::StringToV8(
|
||||
isolate, "Cannot create Tray before app is ready")));
|
||||
return nullptr;
|
||||
}
|
||||
return new Tray(image);
|
||||
|
|
|
@ -717,17 +717,19 @@ void WebContents::PrintToPDF(const base::DictionaryValue& setting,
|
|||
PrintToPDF(setting, callback);
|
||||
}
|
||||
|
||||
void WebContents::AddWorkSpace(const base::FilePath& path) {
|
||||
void WebContents::AddWorkSpace(mate::Arguments* args,
|
||||
const base::FilePath& path) {
|
||||
if (path.empty()) {
|
||||
node::ThrowError(isolate(), "path cannot be empty");
|
||||
args->ThrowError("path cannot be empty");
|
||||
return;
|
||||
}
|
||||
DevToolsAddFileSystem(path);
|
||||
}
|
||||
|
||||
void WebContents::RemoveWorkSpace(const base::FilePath& path) {
|
||||
void WebContents::RemoveWorkSpace(mate::Arguments* args,
|
||||
const base::FilePath& path) {
|
||||
if (path.empty()) {
|
||||
node::ThrowError(isolate(), "path cannot be empty");
|
||||
args->ThrowError("path cannot be empty");
|
||||
return;
|
||||
}
|
||||
DevToolsRemoveFileSystem(path);
|
||||
|
|
|
@ -87,8 +87,8 @@ class WebContents : public mate::TrackableObject<WebContents>,
|
|||
const PrintToPDFCallback& callback);
|
||||
|
||||
// DevTools workspace api.
|
||||
void AddWorkSpace(const base::FilePath& path);
|
||||
void RemoveWorkSpace(const base::FilePath& path);
|
||||
void AddWorkSpace(mate::Arguments* args, const base::FilePath& path);
|
||||
void RemoveWorkSpace(mate::Arguments* args, const base::FilePath& path);
|
||||
|
||||
// Editing commands.
|
||||
void Undo();
|
||||
|
|
|
@ -209,8 +209,8 @@ void Window::OnExecuteWindowsCommand(const std::string& command_name) {
|
|||
mate::Wrappable* Window::New(v8::Isolate* isolate,
|
||||
const mate::Dictionary& options) {
|
||||
if (!Browser::Get()->is_ready()) {
|
||||
node::ThrowError(isolate,
|
||||
"Cannot create BrowserWindow before app is ready");
|
||||
isolate->ThrowException(v8::Exception::Error(mate::StringToV8(
|
||||
isolate, "Cannot create BrowserWindow before app is ready")));
|
||||
return nullptr;
|
||||
}
|
||||
return new Window(isolate, options);
|
||||
|
|
|
@ -30,7 +30,7 @@ RenderView* GetCurrentRenderView() {
|
|||
return RenderView::FromWebView(view);
|
||||
}
|
||||
|
||||
void Send(v8::Isolate* isolate,
|
||||
void Send(mate::Arguments* args,
|
||||
const base::string16& channel,
|
||||
const base::ListValue& arguments) {
|
||||
RenderView* render_view = GetCurrentRenderView();
|
||||
|
@ -41,10 +41,10 @@ void Send(v8::Isolate* isolate,
|
|||
render_view->GetRoutingID(), channel, arguments));
|
||||
|
||||
if (!success)
|
||||
node::ThrowError(isolate, "Unable to send AtomViewHostMsg_Message");
|
||||
args->ThrowError("Unable to send AtomViewHostMsg_Message");
|
||||
}
|
||||
|
||||
base::string16 SendSync(v8::Isolate* isolate,
|
||||
base::string16 SendSync(mate::Arguments* args,
|
||||
const base::string16& channel,
|
||||
const base::ListValue& arguments) {
|
||||
base::string16 json;
|
||||
|
@ -60,7 +60,7 @@ base::string16 SendSync(v8::Isolate* isolate,
|
|||
bool success = render_view->Send(message);
|
||||
|
||||
if (!success)
|
||||
node::ThrowError(isolate, "Unable to send AtomViewHostMsg_Message_Sync");
|
||||
args->ThrowError("Unable to send AtomViewHostMsg_Message_Sync");
|
||||
|
||||
return json;
|
||||
}
|
||||
|
|
2
vendor/node
vendored
2
vendor/node
vendored
|
@ -1 +1 @@
|
|||
Subproject commit 5a8258dfabe7ce3e1489b13d3459ef1d6260d6a5
|
||||
Subproject commit c8962e460f3bf03d405489a8380a5571730f5f8d
|
Loading…
Reference in a new issue