Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1880)

Unified Diff: chrome/browser/extensions/clipboard_extension_helper_chromeos.h

Issue 2379573008: Add SetImageData api to chrome.clipboard. (Closed)
Patch Set: Fix nits. Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/extensions/clipboard_extension_helper_chromeos.h
diff --git a/chrome/browser/extensions/clipboard_extension_helper_chromeos.h b/chrome/browser/extensions/clipboard_extension_helper_chromeos.h
new file mode 100644
index 0000000000000000000000000000000000000000..78f6aebc949547077228e3d454d1c642ac1fe17c
--- /dev/null
+++ b/chrome/browser/extensions/clipboard_extension_helper_chromeos.h
@@ -0,0 +1,52 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_EXTENSIONS_CLIPBOARD_EXTENSION_HELPER_CHROMEOS_H_
+#define CHROME_BROWSER_EXTENSIONS_CLIPBOARD_EXTENSION_HELPER_CHROMEOS_H_
+
+#include <string>
+#include <vector>
+
+#include "base/callback.h"
+#include "extensions/common/api/clipboard.h"
+
+class SkBitmap;
+
+namespace extensions {
+
+// A helper class for decoding the image data and saving decoded image data on
+// clipboard, called from clipboard extension API.
+class ClipboardExtensionHelper {
+ public:
+ ClipboardExtensionHelper();
+ ~ClipboardExtensionHelper();
+
+ // Decodes and saves the image data on clipboard. Must run on UI thread.
+ void DecodeAndSaveImageData(
+ const std::vector<char>& data,
+ api::clipboard::ImageType type,
+ const base::Closure& success_callback,
+ const base::Callback<void(const std::string&)>& error_callback);
+
+ private:
+ // A class to decode PNG and JPEG file.
+ class ClipboardImageDataDecoder;
+
+ // Handles decoded image data.
+ void OnImageDecoded(const SkBitmap& bitmap);
+ // Handles image decoding failure case.
+ void OnImageDecodeFailure();
+ // Handles image decoding request cancelation case.
+ void OnImageDecodeCancel();
+
+ std::unique_ptr<ClipboardImageDataDecoder> clipboard_image_data_decoder_;
+ base::Closure image_save_success_callback_;
+ base::Callback<void(const std::string&)> image_save_error_callback_;
+
+ DISALLOW_COPY_AND_ASSIGN(ClipboardExtensionHelper);
+};
+
+} // namespace extensions
+
+#endif // CHROME_BROWSER_EXTENSIONS_CLIPBOARD_EXTENSION_HELPER_CHROMEOS_H_

Powered by Google App Engine
This is Rietveld 408576698