Skip to content

Commit

Permalink
fix: crash when showin item in folder on DevTools
Browse files Browse the repository at this point in the history
  • Loading branch information
codebytere committed Feb 21, 2022
1 parent bdad633 commit 0344393
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
12 changes: 9 additions & 3 deletions shell/browser/ui/inspectable_web_contents.cc
Expand Up @@ -729,6 +729,11 @@ void InspectableWebContents::SetIsDocked(DispatchCallback callback,
std::move(callback).Run(nullptr);
}

void InspectableWebContents::OnOpenItemComplete(const base::FilePath& path,
const std::string& result) {
platform_util::ShowItemInFolder(path);
}

void InspectableWebContents::OpenInNewTab(const std::string& url) {}

void InspectableWebContents::ShowItemInFolder(
Expand All @@ -737,9 +742,10 @@ void InspectableWebContents::ShowItemInFolder(
return;

base::FilePath path = base::FilePath::FromUTF8Unsafe(file_system_path);

// Pass empty callback here; we can ignore errors
platform_util::OpenPath(path, platform_util::OpenCallback());
platform_util::OpenPath(
path.DirName(),
base::BindOnce(&InspectableWebContents::OnOpenItemComplete,
weak_factory_.GetWeakPtr(), path));
}

void InspectableWebContents::SaveToFile(const std::string& url,
Expand Down
3 changes: 3 additions & 0 deletions shell/browser/ui/inspectable_web_contents.h
Expand Up @@ -166,6 +166,9 @@ class InspectableWebContents
void CanShowSurvey(DispatchCallback callback,
const std::string& trigger) override {}

void OnOpenItemComplete(const base::FilePath& path,
const std::string& result);

// content::DevToolsFrontendHostDelegate:
void HandleMessageFromDevToolsFrontend(base::Value message);

Expand Down

0 comments on commit 0344393

Please sign in to comment.