Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_BROWSER_EXTENSIONS_CLIPBOARD_EXTENSION_HELPER_CHROMEOS_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_CLIPBOARD_EXTENSION_HELPER_CHROMEOS_H_ |
| 6 #define CHROME_BROWSER_EXTENSIONS_CLIPBOARD_EXTENSION_HELPER_CHROMEOS_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_CLIPBOARD_EXTENSION_HELPER_CHROMEOS_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/callback.h" | 11 #include "base/callback.h" |
| 12 #include "extensions/browser/api/clipboard/clipboard_api.h" | |
| 12 #include "extensions/common/api/clipboard.h" | 13 #include "extensions/common/api/clipboard.h" |
| 13 | 14 |
| 14 class SkBitmap; | 15 class SkBitmap; |
| 15 | 16 |
| 16 namespace extensions { | 17 namespace extensions { |
| 17 | 18 |
| 18 // A helper class for decoding the image data and saving decoded image data on | 19 // A helper class for decoding the image data and saving decoded image data on |
| 19 // clipboard, called from clipboard extension API. | 20 // clipboard, called from clipboard extension API. |
| 20 class ClipboardExtensionHelper { | 21 class ClipboardExtensionHelper { |
| 21 public: | 22 public: |
| 23 struct AdditionalDataItem { | |
|
Devlin
2017/04/26 18:20:15
How is this different from the generated type?
jennyz
2017/05/16 18:22:03
Not really, so removed this struct, just use the g
| |
| 24 std::string type; | |
| 25 std::string data; | |
| 26 }; | |
| 22 ClipboardExtensionHelper(); | 27 ClipboardExtensionHelper(); |
| 23 ~ClipboardExtensionHelper(); | 28 ~ClipboardExtensionHelper(); |
| 24 | 29 |
| 25 // Decodes and saves the image data on clipboard. Must run on UI thread. | 30 // Decodes and saves the image data on clipboard. Must run on UI thread. |
| 26 void DecodeAndSaveImageData( | 31 void DecodeAndSaveImageData( |
| 27 const std::vector<char>& data, | 32 const std::vector<char>& data, |
| 28 api::clipboard::ImageType type, | 33 api::clipboard::ImageType type, |
| 34 const AdditionalDataItemList& additional_items, | |
| 29 const base::Closure& success_callback, | 35 const base::Closure& success_callback, |
| 30 const base::Callback<void(const std::string&)>& error_callback); | 36 const base::Callback<void(const std::string&)>& error_callback); |
| 31 | 37 |
| 32 private: | 38 private: |
| 33 // A class to decode PNG and JPEG file. | 39 // A class to decode PNG and JPEG file. |
| 34 class ClipboardImageDataDecoder; | 40 class ClipboardImageDataDecoder; |
| 35 | 41 |
| 36 // Handles decoded image data. | 42 // Handles decoded image data. |
| 37 void OnImageDecoded(const SkBitmap& bitmap); | 43 void OnImageDecoded(const SkBitmap& bitmap); |
| 38 // Handles image decoding failure case. | 44 // Handles image decoding failure case. |
| 39 void OnImageDecodeFailure(); | 45 void OnImageDecodeFailure(); |
| 40 // Handles image decoding request cancelation case. | 46 // Handles image decoding request cancelation case. |
| 41 void OnImageDecodeCancel(); | 47 void OnImageDecodeCancel(); |
| 42 | 48 |
| 43 std::unique_ptr<ClipboardImageDataDecoder> clipboard_image_data_decoder_; | 49 std::unique_ptr<ClipboardImageDataDecoder> clipboard_image_data_decoder_; |
| 44 base::Closure image_save_success_callback_; | 50 base::Closure image_save_success_callback_; |
| 45 base::Callback<void(const std::string&)> image_save_error_callback_; | 51 base::Callback<void(const std::string&)> image_save_error_callback_; |
| 52 std::vector<AdditionalDataItem> additonal_items_; | |
| 46 | 53 |
| 47 DISALLOW_COPY_AND_ASSIGN(ClipboardExtensionHelper); | 54 DISALLOW_COPY_AND_ASSIGN(ClipboardExtensionHelper); |
| 48 }; | 55 }; |
| 49 | 56 |
| 50 } // namespace extensions | 57 } // namespace extensions |
| 51 | 58 |
| 52 #endif // CHROME_BROWSER_EXTENSIONS_CLIPBOARD_EXTENSION_HELPER_CHROMEOS_H_ | 59 #endif // CHROME_BROWSER_EXTENSIONS_CLIPBOARD_EXTENSION_HELPER_CHROMEOS_H_ |
| OLD | NEW |