Don't use Node's internal APIs
authorCheng Zhao <zcbenz@gmail.com>
Mon, 7 Sep 2015 08:12:31 +0000 (16:12 +0800)
committerCheng Zhao <zcbenz@gmail.com>
Mon, 7 Sep 2015 08:41:49 +0000 (16:41 +0800)
atom/browser/api/atom_api_power_monitor.cc
atom/browser/api/atom_api_screen.cc
atom/browser/api/atom_api_tray.cc
atom/browser/api/atom_api_web_contents.cc
atom/browser/api/atom_api_web_contents.h
atom/browser/api/atom_api_window.cc
atom/renderer/api/atom_api_renderer_ipc.cc
vendor/node

index 093df2a1d4ef0c550c0f2f3cc4f290882a60d4ab..31b35e10cea8ae631406aa28e98937694b9739f7 100644 (file)
@@ -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);
   }
 
index 9f81cf6eeff75b0d16c1d820a981532e996ef506..b73bda9ced843f88040e992491a98907c9197215 100644 (file)
@@ -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);
   }
 
index 1382f015a63be030e5eb373ef74ae3604c9c34dd..90bcbcf3e2a7b179267f42843804b0e6911f9693 100644 (file)
@@ -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);
index d22f7aab61fdedb7d831a2bae41204824077c442..9cb52a1ec74d2d6a2c9780729a43c25354d5d02c 100644 (file)
@@ -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);
index e2e405b73853f3263ffdcbdc54d3c6edecb20895..3c6bde9c24aa408448fd0473b86484f314922c9e 100644 (file)
@@ -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();
index e171fa7698f0e73f3ee14bc1a4835d6e013dc4b8..4acd101f3c98823eac4d79b8fdb7c7e6c65d423c 100644 (file)
@@ -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);
index d222f8f73b8591d3f9b2061f115672253407f638..bd0b62656c1d9eb38ab7de002a64916757f4b76b 100644 (file)
@@ -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;
 }
index 5a8258dfabe7ce3e1489b13d3459ef1d6260d6a5..c8962e460f3bf03d405489a8380a5571730f5f8d 160000 (submodule)
@@ -1 +1 @@
-Subproject commit 5a8258dfabe7ce3e1489b13d3459ef1d6260d6a5
+Subproject commit c8962e460f3bf03d405489a8380a5571730f5f8d