Chromium Code Reviews| Index: chrome/browser/extensions/clipboard_extension_helper.h |
| diff --git a/chrome/browser/extensions/clipboard_extension_helper.h b/chrome/browser/extensions/clipboard_extension_helper.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..afdc1e054ae55a619013858520fd70874708901f |
| --- /dev/null |
| +++ b/chrome/browser/extensions/clipboard_extension_helper.h |
| @@ -0,0 +1,57 @@ |
| +// 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_H_ |
| +#define CHROME_BROWSER_EXTENSIONS_CLIPBOARD_EXTENSION_HELPER_H_ |
| + |
| +#include <string> |
| +#include <vector> |
| + |
| +#include "base/callback.h" |
| +#include "extensions/common/api/clipboard.h" |
| +#include "ui/gfx/image/image_skia.h" |
| + |
| +namespace ui { |
| +class ScopedClipboardWriter; |
| +} |
| + |
| +namespace extensions { |
| + |
| +namespace clipboard = api::clipboard; |
|
Devlin
2016/11/16 02:34:33
not allowed in .h files
jennyz
2016/12/07 01:21:47
Done.
|
| + |
| +// 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, |
| + clipboard::ImageType type, |
| + const base::Closure& success_callback, |
| + const base::Closure& error_callback); |
| + |
| + protected: |
| + // A class to decode PNG and JPEG file. |
| + class ClipboardImageDataDecoder; |
| + |
| + static ClipboardImageDataDecoder* clipboard_image_data_decoder_; |
| + |
| + private: |
| + // Handles decoded image data. |
| + void OnImageDecoded(const SkBitmap& bitmap); |
| + // Handles image decoding failure case. |
| + void OnImageDecodeFailure(); |
| + // Handles image decoding request cancelation case. |
| + void OnImageDecodeCancel(); |
| + |
| + base::Closure image_save_success_callback_; |
| + base::Closure image_save_error_callback_; |
| + std::unique_ptr<ui::ScopedClipboardWriter> clipboard_writer_; |
|
Devlin
2016/11/16 02:34:33
DISALLOW_COPY_AND_ASSIGN
jennyz
2016/12/07 01:21:48
Done.
|
| +}; |
| + |
| +} // namespace extensions |
| + |
| +#endif // CHROME_BROWSER_EXTENSIONS_CLIPBOARD_EXTENSION_HELPER_H_ |