#include "atom/browser/web_view_guest_delegate.h"
#include "atom/common/api/api_messages.h"
#include "atom/common/event_emitter_caller.h"
+#include "atom/common/native_mate_converters/file_path_converter.h"
#include "atom/common/native_mate_converters/gfx_converter.h"
#include "atom/common/native_mate_converters/gurl_converter.h"
#include "atom/common/native_mate_converters/image_converter.h"
PrintToPDF(setting, callback);
}
+void WebContents::AddWorkSpace(const base::FilePath& path) {
+ if (path.empty()) {
+ node::ThrowError(isolate(), "path cannot be empty");
+ return;
+ }
+ DevToolsAddFileSystem(path);
+}
+
+void WebContents::RemoveWorkSpace(const base::FilePath& path) {
+ if (path.empty()) {
+ node::ThrowError(isolate(), "path cannot be empty");
+ return;
+ }
+ DevToolsRemoveFileSystem(path);
+}
+
void WebContents::Undo() {
web_contents()->Undo();
}
.SetMethod("inspectServiceWorker", &WebContents::InspectServiceWorker)
.SetMethod("print", &WebContents::Print)
.SetMethod("_printToPDF", &WebContents::PrintToPDF)
+ .SetMethod("addWorkSpace", &WebContents::AddWorkSpace)
+ .SetMethod("removeWorkSpace", &WebContents::RemoveWorkSpace)
.SetProperty("session", &WebContents::Session)
.Build());
public content::WebContentsObserver {
public:
// For node.js callback function type: function(error, buffer)
- typedef base::Callback<void(v8::Local<v8::Value>, v8::Local<v8::Value>)>
- PrintToPDFCallback;
+ using PrintToPDFCallback =
+ base::Callback<void(v8::Local<v8::Value>, v8::Local<v8::Value>)>;
// Create from an existing WebContents.
static mate::Handle<WebContents> CreateFrom(
void PrintToPDF(const base::DictionaryValue& setting,
const PrintToPDFCallback& callback);
+ // DevTools workspace api.
+ void AddWorkSpace(const base::FilePath& path);
+ void RemoveWorkSpace(const base::FilePath& path);
+
// Editing commands.
void Undo();
void Redo();
base::Unretained(this), url));
}
-void CommonWebContentsDelegate::DevToolsAddFileSystem() {
- file_dialog::Filters filters;
- base::FilePath default_path;
- std::vector<base::FilePath> paths;
- int flag = file_dialog::FILE_DIALOG_OPEN_DIRECTORY;
- if (!file_dialog::ShowOpenDialog(owner_window(), "", default_path,
- filters, flag, &paths))
- return;
+void CommonWebContentsDelegate::DevToolsAddFileSystem(
+ const base::FilePath& file_system_path) {
+ base::FilePath path = file_system_path;
+ if (path.empty()) {
+ file_dialog::Filters filters;
+ base::FilePath default_path;
+ std::vector<base::FilePath> paths;
+ int flag = file_dialog::FILE_DIALOG_OPEN_DIRECTORY;
+ if (!file_dialog::ShowOpenDialog(owner_window(), "", default_path,
+ filters, flag, &paths))
+ return;
+
+ path = paths[0];
+ }
- base::FilePath path = paths[0];
std::string registered_name;
std::string file_system_id = RegisterFileSystem(GetDevToolsWebContents(),
path,
}
void CommonWebContentsDelegate::DevToolsRemoveFileSystem(
- const std::string& file_system_path) {
+ const base::FilePath& file_system_path) {
if (!web_contents_)
return;
- base::FilePath path = base::FilePath::FromUTF8Unsafe(file_system_path);
- storage::IsolatedContext::GetInstance()->RevokeFileSystemByPath(path);
+ storage::IsolatedContext::GetInstance()->
+ RevokeFileSystemByPath(file_system_path);
for (auto it = saved_paths_.begin(); it != saved_paths_.end(); ++it)
- if (it->second == path) {
+ if (it->second == file_system_path) {
saved_paths_.erase(it);
break;
}
- base::StringValue file_system_path_value(file_system_path);
+ base::StringValue file_system_path_value(file_system_path.AsUTF8Unsafe());
web_contents_->CallClientFunction(
"DevToolsAPI.fileSystemRemoved",
&file_system_path_value,
bool save_as) override;
void DevToolsAppendToFile(const std::string& url,
const std::string& content) override;
- void DevToolsAddFileSystem() override;
- void DevToolsRemoveFileSystem(const std::string& file_system_path) override;
+ void DevToolsAddFileSystem(const base::FilePath& path) override;
+ void DevToolsRemoveFileSystem(
+ const base::FilePath& file_system_path) override;
private:
// Callback for when DevToolsSaveToFile has completed.
});
```
+### WebContents.addWorkSpace(path)
+
+* `path` String
+
+Adds the specified path to devtools workspace.
+
+### WebContents.removeWorkSpace(path)
+
+* `path` String
+
+Removes the specified path from devtools workspace.
+
### WebContents.send(channel[, args...])
* `channel` String