]> khamidou — GitHub mirrors - electron.git/commitdiff
Remove NativeWindow::CallDevToolsFunction
authorCheng Zhao <zcbenz@gmail.com>
Fri, 5 Jun 2015 05:32:01 +0000 (13:32 +0800)
committerCheng Zhao <zcbenz@gmail.com>
Fri, 5 Jun 2015 05:32:01 +0000 (13:32 +0800)
atom/browser/native_window.cc
atom/browser/native_window.h

index d63c7a14f7c7ac950abaf14ae18ffcd7c7de25cb..c254ed96042fa4c9c57cc68a1d8c77d5a74cd63c 100644 (file)
@@ -869,7 +869,8 @@ void NativeWindow::DevToolsSaveToFile(const std::string& url,
     base::FilePath default_path(base::FilePath::FromUTF8Unsafe(url));
     if (!file_dialog::ShowSaveDialog(this, url, default_path, filters, &path)) {
       base::StringValue url_value(url);
-      CallDevToolsFunction("DevToolsAPI.canceledSaveURL", &url_value);
+      inspectable_web_contents()->CallClientFunction(
+          "DevToolsAPI.canceledSaveURL", &url_value, nullptr, nullptr);
       return;
     }
   }
@@ -879,7 +880,8 @@ void NativeWindow::DevToolsSaveToFile(const std::string& url,
 
   // Notify devtools.
   base::StringValue url_value(url);
-  CallDevToolsFunction("DevToolsAPI.savedURL", &url_value);
+  inspectable_web_contents()->CallClientFunction(
+      "DevToolsAPI.savedURL", &url_value, nullptr, nullptr);
 }
 
 void NativeWindow::DevToolsAppendToFile(const std::string& url,
@@ -891,7 +893,8 @@ void NativeWindow::DevToolsAppendToFile(const std::string& url,
 
   // Notify devtools.
   base::StringValue url_value(url);
-  CallDevToolsFunction("DevToolsAPI.appendedToURL", &url_value);
+  inspectable_web_contents()->CallClientFunction(
+      "DevToolsAPI.appendedToURL", &url_value, nullptr, nullptr);
 }
 
 void NativeWindow::DevToolsFocused() {
@@ -929,8 +932,11 @@ void NativeWindow::DevToolsAddFileSystem() {
   scoped_ptr<base::DictionaryValue> file_system_value;
   if (!file_system.file_system_path.empty())
     file_system_value.reset(CreateFileSystemValue(file_system));
-  CallDevToolsFunction("DevToolsAPI.fileSystemAdded", error_string_value.get(),
-                       file_system_value.get(), nullptr);
+  inspectable_web_contents()->CallClientFunction(
+      "DevToolsAPI.fileSystemAdded",
+      error_string_value.get(),
+      file_system_value.get(),
+      nullptr);
 }
 
 void NativeWindow::DevToolsRemoveFileSystem(
@@ -945,8 +951,11 @@ void NativeWindow::DevToolsRemoveFileSystem(
     }
 
   base::StringValue file_system_path_value(file_system_path);
-  CallDevToolsFunction("DevToolsAPI.fileSystemRemoved",
-                       &file_system_path_value, nullptr, nullptr);
+  inspectable_web_contents()->CallClientFunction(
+      "DevToolsAPI.fileSystemRemoved",
+       &file_system_path_value,
+       nullptr,
+       nullptr);
 }
 
 void NativeWindow::ScheduleUnresponsiveEvent(int ms) {
@@ -977,27 +986,4 @@ void NativeWindow::OnCapturePageDone(const CapturePageCallback& callback,
   callback.Run(bitmap);
 }
 
-void NativeWindow::CallDevToolsFunction(const std::string& function_name,
-                                        const base::Value* arg1,
-                                        const base::Value* arg2,
-                                        const base::Value* arg3) {
-  std::string params;
-  if (arg1) {
-    std::string json;
-    base::JSONWriter::Write(arg1, &json);
-    params.append(json);
-    if (arg2) {
-      base::JSONWriter::Write(arg2, &json);
-      params.append(", " + json);
-      if (arg3) {
-        base::JSONWriter::Write(arg3, &json);
-        params.append(", " + json);
-      }
-    }
-  }
-  base::string16 javascript =
-      base::UTF8ToUTF16(function_name + "(" + params + ");");
-  GetDevToolsWebContents()->GetMainFrame()->ExecuteJavaScript(javascript);
-}
-
 }  // namespace atom
index eb3aad65986a481ec2f41a8142e89b7fab9d85e4..fb614bad2bdebd4bf2c247072d386af29095ec9f 100644 (file)
@@ -345,12 +345,6 @@ class NativeWindow : public brightray::DefaultWebContentsDelegate,
   // Dispatch unresponsive event to observers.
   void NotifyWindowUnresponsive();
 
-  // Call a function in devtools.
-  void CallDevToolsFunction(const std::string& function_name,
-                            const base::Value* arg1 = NULL,
-                            const base::Value* arg2 = NULL,
-                            const base::Value* arg3 = NULL);
-
   // Called when CapturePage has done.
   void OnCapturePageDone(const CapturePageCallback& callback,
                          const SkBitmap& bitmap,