Adding a private file api for copying images.

This adds a private file api to handle copying images to the system
clipboard. This is extended so when users click the copy button in the
Chrome OS files app, the file is copied to the system clipboard and can
then be pasted to different types of applications. This change will
present a similar solution to that of copying an image in the browser to
the system clipboard via the right click > copy image. This feature is
currently experimental and will be added behind a flag in the frontend.

Bug: 827333
Change-Id: I85b98b4f35151d0146a0c79b93976822c663651e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2317029
Commit-Queue: Alexander Nohe <[email protected]>
Reviewed-by: Luciano Pacheco <[email protected]>
Reviewed-by: Xiyuan Xia <[email protected]>
Cr-Commit-Position: refs/heads/master@{#802258}
diff --git a/chrome/browser/ui/ash/clipboard_util.cc b/chrome/browser/ui/ash/clipboard_util.cc
index 4380434..2cde774 100644
--- a/chrome/browser/ui/ash/clipboard_util.cc
+++ b/chrome/browser/ui/ash/clipboard_util.cc
@@ -40,19 +40,6 @@
   }
 }
 
-void DecodeFileAndCopyToClipboard(
-    scoped_refptr<base::RefCountedString> png_data) {
-  DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
-
-  // Decode the image in sandboxed process because |png_data| comes from
-  // external storage.
-  data_decoder::DecodeImageIsolated(
-      std::vector<uint8_t>(png_data->data().begin(), png_data->data().end()),
-      data_decoder::mojom::ImageCodec::DEFAULT, false,
-      data_decoder::kDefaultMaxSizeInBytes, gfx::Size(),
-      base::BindOnce(&CopyImageToClipboard, png_data));
-}
-
 }  // namespace
 
 void ReadFileAndCopyToClipboardLocal(const base::FilePath& local_file) {
@@ -66,6 +53,19 @@
   }
 
   content::GetUIThreadTaskRunner({})->PostTask(
-      FROM_HERE, base::BindOnce(&DecodeFileAndCopyToClipboard, png_data));
+      FROM_HERE, base::BindOnce(&DecodeImageFileAndCopyToClipboard, png_data));
+}
+
+void DecodeImageFileAndCopyToClipboard(
+    scoped_refptr<base::RefCountedString> png_data) {
+  DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
+
+  // Decode the image in sandboxed process because |png_data| comes from
+  // external storage.
+  data_decoder::DecodeImageIsolated(
+      std::vector<uint8_t>(png_data->data().begin(), png_data->data().end()),
+      data_decoder::mojom::ImageCodec::DEFAULT, false,
+      data_decoder::kDefaultMaxSizeInBytes, gfx::Size(),
+      base::BindOnce(&CopyImageToClipboard, png_data));
 }
 }  // namespace clipboard_util