From: Cheng Zhao Date: Fri, 5 Jun 2015 05:32:01 +0000 (+0800) Subject: Remove NativeWindow::CallDevToolsFunction X-Git-Tag: v0.27.3~5^2~11 X-Git-Url: http://git.khamidou.com/?a=commitdiff_plain;h=7f7cdbf775625a034d2adf1da1cb77aaf7b24c43;p=electron.git Remove NativeWindow::CallDevToolsFunction --- diff --git a/atom/browser/native_window.cc b/atom/browser/native_window.cc index d63c7a14..c254ed96 100644 --- a/atom/browser/native_window.cc +++ b/atom/browser/native_window.cc @@ -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 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 diff --git a/atom/browser/native_window.h b/atom/browser/native_window.h index eb3aad65..fb614bad 100644 --- a/atom/browser/native_window.h +++ b/atom/browser/native_window.h @@ -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,