Remove NativeWindow::CallDevToolsFunction
This commit is contained in:
parent
7f42c0fa21
commit
7f7cdbf775
2 changed files with 16 additions and 36 deletions
|
@ -869,7 +869,8 @@ void NativeWindow::DevToolsSaveToFile(const std::string& url,
|
||||||
base::FilePath default_path(base::FilePath::FromUTF8Unsafe(url));
|
base::FilePath default_path(base::FilePath::FromUTF8Unsafe(url));
|
||||||
if (!file_dialog::ShowSaveDialog(this, url, default_path, filters, &path)) {
|
if (!file_dialog::ShowSaveDialog(this, url, default_path, filters, &path)) {
|
||||||
base::StringValue url_value(url);
|
base::StringValue url_value(url);
|
||||||
CallDevToolsFunction("DevToolsAPI.canceledSaveURL", &url_value);
|
inspectable_web_contents()->CallClientFunction(
|
||||||
|
"DevToolsAPI.canceledSaveURL", &url_value, nullptr, nullptr);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -879,7 +880,8 @@ void NativeWindow::DevToolsSaveToFile(const std::string& url,
|
||||||
|
|
||||||
// Notify devtools.
|
// Notify devtools.
|
||||||
base::StringValue url_value(url);
|
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,
|
void NativeWindow::DevToolsAppendToFile(const std::string& url,
|
||||||
|
@ -891,7 +893,8 @@ void NativeWindow::DevToolsAppendToFile(const std::string& url,
|
||||||
|
|
||||||
// Notify devtools.
|
// Notify devtools.
|
||||||
base::StringValue url_value(url);
|
base::StringValue url_value(url);
|
||||||
CallDevToolsFunction("DevToolsAPI.appendedToURL", &url_value);
|
inspectable_web_contents()->CallClientFunction(
|
||||||
|
"DevToolsAPI.appendedToURL", &url_value, nullptr, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void NativeWindow::DevToolsFocused() {
|
void NativeWindow::DevToolsFocused() {
|
||||||
|
@ -929,8 +932,11 @@ void NativeWindow::DevToolsAddFileSystem() {
|
||||||
scoped_ptr<base::DictionaryValue> file_system_value;
|
scoped_ptr<base::DictionaryValue> file_system_value;
|
||||||
if (!file_system.file_system_path.empty())
|
if (!file_system.file_system_path.empty())
|
||||||
file_system_value.reset(CreateFileSystemValue(file_system));
|
file_system_value.reset(CreateFileSystemValue(file_system));
|
||||||
CallDevToolsFunction("DevToolsAPI.fileSystemAdded", error_string_value.get(),
|
inspectable_web_contents()->CallClientFunction(
|
||||||
file_system_value.get(), nullptr);
|
"DevToolsAPI.fileSystemAdded",
|
||||||
|
error_string_value.get(),
|
||||||
|
file_system_value.get(),
|
||||||
|
nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void NativeWindow::DevToolsRemoveFileSystem(
|
void NativeWindow::DevToolsRemoveFileSystem(
|
||||||
|
@ -945,8 +951,11 @@ void NativeWindow::DevToolsRemoveFileSystem(
|
||||||
}
|
}
|
||||||
|
|
||||||
base::StringValue file_system_path_value(file_system_path);
|
base::StringValue file_system_path_value(file_system_path);
|
||||||
CallDevToolsFunction("DevToolsAPI.fileSystemRemoved",
|
inspectable_web_contents()->CallClientFunction(
|
||||||
&file_system_path_value, nullptr, nullptr);
|
"DevToolsAPI.fileSystemRemoved",
|
||||||
|
&file_system_path_value,
|
||||||
|
nullptr,
|
||||||
|
nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void NativeWindow::ScheduleUnresponsiveEvent(int ms) {
|
void NativeWindow::ScheduleUnresponsiveEvent(int ms) {
|
||||||
|
@ -977,27 +986,4 @@ void NativeWindow::OnCapturePageDone(const CapturePageCallback& callback,
|
||||||
callback.Run(bitmap);
|
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
|
} // namespace atom
|
||||||
|
|
|
@ -345,12 +345,6 @@ class NativeWindow : public brightray::DefaultWebContentsDelegate,
|
||||||
// Dispatch unresponsive event to observers.
|
// Dispatch unresponsive event to observers.
|
||||||
void NotifyWindowUnresponsive();
|
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.
|
// Called when CapturePage has done.
|
||||||
void OnCapturePageDone(const CapturePageCallback& callback,
|
void OnCapturePageDone(const CapturePageCallback& callback,
|
||||||
const SkBitmap& bitmap,
|
const SkBitmap& bitmap,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue