feat: implement File System API support (#41827)

* feat: implement File System API support

Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>

* test: add a test for writable permission checking

Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>

* fix: gn check include issues

Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>

* chore: feedback from review

Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>

* chore: cleanup feedback from review

Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>

* refactor: namespace to electron

Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>

* fixup! chore: cleanup feedback from review

Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>

* chore: address more feedback from review

Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>

* 5301485: Add content analysis to File System Access Javascript API.

5301485

Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>

* docs: improve typing of details object

Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>

* chore: address outstanding todo

Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>

* refactor: use Chrome's file system access blocklist

Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>

* lint

Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>

* fix: Windows build

Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>

* test: clarify test verbiage

Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>

---------

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
This commit is contained in:
trop[bot] 2024-04-15 12:22:17 -07:00 committed by GitHub
parent 20c6c37c1b
commit cf1087badd
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
23 changed files with 1562 additions and 9 deletions

View file

@ -17,6 +17,7 @@
#include "third_party/skia/include/core/SkImageInfo.h"
#include "third_party/skia/include/core/SkPixmap.h"
#include "ui/base/clipboard/clipboard_format_type.h"
#include "ui/base/clipboard/file_info.h"
#include "ui/base/clipboard/scoped_clipboard_writer.h"
#include "ui/gfx/codec/png_codec.h"
@ -274,6 +275,17 @@ void Clipboard::Clear(gin_helper::Arguments* args) {
ui::Clipboard::GetForCurrentThread()->Clear(GetClipboardBuffer(args));
}
// This exists for testing purposes ONLY.
void Clipboard::WriteFilesForTesting(const std::vector<base::FilePath>& files) {
std::vector<ui::FileInfo> file_infos;
for (const auto& file : files) {
file_infos.emplace_back(ui::FileInfo(ui::FileInfo(file, file.BaseName())));
}
ui::ScopedClipboardWriter writer(ui::ClipboardBuffer::kCopyPaste);
writer.WriteFilenames(ui::FileInfosToURIList(file_infos));
}
} // namespace electron::api
namespace {
@ -302,6 +314,8 @@ void Initialize(v8::Local<v8::Object> exports,
dict.SetMethod("writeFindText", &electron::api::Clipboard::WriteFindText);
dict.SetMethod("readBuffer", &electron::api::Clipboard::ReadBuffer);
dict.SetMethod("writeBuffer", &electron::api::Clipboard::WriteBuffer);
dict.SetMethod("_writeFilesForTesting",
&electron::api::Clipboard::WriteFilesForTesting);
dict.SetMethod("clear", &electron::api::Clipboard::Clear);
}