implement devtools showItemInFolder message

This commit is contained in:
Cheng Zhao 2018-07-04 15:29:05 +09:00
parent 5aa136a23d
commit 29ff9873f4
4 changed files with 12 additions and 0 deletions

View file

@ -168,6 +168,7 @@ DevToolsEmbedderMessageDispatcher::CreateForDevToolsFrontend(
d->RegisterHandlerWithCallback("setIsDocked", &Delegate::SetIsDocked,
delegate);
d->RegisterHandler("openInNewTab", &Delegate::OpenInNewTab, delegate);
d->RegisterHandler("showItemInFolder", &Delegate::ShowItemInFolder, delegate);
d->RegisterHandler("save", &Delegate::SaveToFile, delegate);
d->RegisterHandler("append", &Delegate::AppendToFile, delegate);
d->RegisterHandler("requestFileSystems", &Delegate::RequestFileSystems,

View file

@ -43,6 +43,7 @@ class DevToolsEmbedderMessageDispatcher {
virtual void SetIsDocked(const DispatchCallback& callback,
bool is_docked) = 0;
virtual void OpenInNewTab(const std::string& url) = 0;
virtual void ShowItemInFolder(const std::string& file_system_path) = 0;
virtual void SaveToFile(const std::string& url,
const std::string& content,
bool save_as) = 0;

View file

@ -7,6 +7,7 @@
#include "brightray/browser/inspectable_web_contents_impl.h"
#include "atom/common/platform_util.h"
#include "base/guid.h"
#include "base/json/json_reader.h"
#include "base/json/json_writer.h"
@ -485,6 +486,14 @@ void InspectableWebContentsImpl::SetIsDocked(const DispatchCallback& callback,
void InspectableWebContentsImpl::OpenInNewTab(const std::string& url) {}
void InspectableWebContentsImpl::ShowItemInFolder(
const std::string& file_system_path) {
if (file_system_path.empty())
return;
base::FilePath path = base::FilePath::FromUTF8Unsafe(file_system_path);
platform_util::ShowItemInFolder(path);
}
void InspectableWebContentsImpl::SaveToFile(const std::string& url,
const std::string& content,
bool save_as) {

View file

@ -83,6 +83,7 @@ class InspectableWebContentsImpl
int stream_id) override;
void SetIsDocked(const DispatchCallback& callback, bool is_docked) override;
void OpenInNewTab(const std::string& url) override;
void ShowItemInFolder(const std::string& file_system_path) override;
void SaveToFile(const std::string& url,
const std::string& content,
bool save_as) override;