|
@@ -9,6 +9,7 @@
|
|
|
#include "base/containers/contains.h"
|
|
|
#include "base/run_loop.h"
|
|
|
#include "base/strings/utf_string_conversions.h"
|
|
|
+#include "shell/browser/browser.h"
|
|
|
#include "shell/common/gin_converters/image_converter.h"
|
|
|
#include "shell/common/gin_helper/dictionary.h"
|
|
|
#include "shell/common/node_includes.h"
|
|
@@ -220,10 +221,18 @@ void Clipboard::WriteBookmark(const std::u16string& title,
|
|
|
}
|
|
|
|
|
|
gfx::Image Clipboard::ReadImage(gin_helper::Arguments* args) {
|
|
|
+ // The ReadPng uses thread pool which requires app ready.
|
|
|
+ if (IsBrowserProcess() && !Browser::Get()->is_ready()) {
|
|
|
+ args->ThrowError(
|
|
|
+ "clipboard.readImage is available only after app ready in the main "
|
|
|
+ "process");
|
|
|
+ return gfx::Image();
|
|
|
+ }
|
|
|
+
|
|
|
ui::Clipboard* clipboard = ui::Clipboard::GetForCurrentThread();
|
|
|
absl::optional<gfx::Image> image;
|
|
|
|
|
|
- base::RunLoop run_loop;
|
|
|
+ base::RunLoop run_loop(base::RunLoop::Type::kNestableTasksAllowed);
|
|
|
base::RepeatingClosure callback = run_loop.QuitClosure();
|
|
|
clipboard->ReadPng(
|
|
|
GetClipboardBuffer(args),
|