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

Side by Side Diff: chrome/browser/extensions/clipboard_extension_helper.h

Issue 2379573008: Add SetImageData api to chrome.clipboard. (Closed)
Patch Set: Address code review comments and add test cases. Created 4 years 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 unified diff | Download patch
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_EXTENSIONS_CLIPBOARD_EXTENSION_HELPER_H_
6 #define CHROME_BROWSER_EXTENSIONS_CLIPBOARD_EXTENSION_HELPER_H_
7
8 #include <string>
9 #include <vector>
10
11 #include "base/callback.h"
12 #include "base/memory/weak_ptr.h"
13 #include "extensions/common/api/clipboard.h"
14 #include "ui/gfx/image/image_skia.h"
15
16 namespace ui {
17 class ScopedClipboardWriter;
18 }
19
20 namespace extensions {
21
22 // A helper class for decoding the image data and saving decoded image data on
23 // clipboard, called from clipboard extension API.
24 class ClipboardExtensionHelper {
25 public:
26 ClipboardExtensionHelper();
27 ~ClipboardExtensionHelper();
28
29 // Decodes and saves the image data on clipboard. Must run on UI thread.
30 void DecodeAndSaveImageData(const std::vector<char>& data,
31 api::clipboard::ImageType type,
32 const base::Closure& success_callback,
33 const base::Closure& error_callback);
34
35 protected:
36 // A class to decode PNG and JPEG file.
37 class ClipboardImageDataDecoder;
38
39 static ClipboardImageDataDecoder* clipboard_image_data_decoder_;
40
41 private:
42 // Handles decoded image data.
43 void OnImageDecoded(const SkBitmap& bitmap);
44 // Handles image decoding failure case.
45 void OnImageDecodeFailure();
46 // Handles image decoding request cancelation case.
47 void OnImageDecodeCancel();
48
49 base::Closure image_save_success_callback_;
50 base::Closure image_save_error_callback_;
51 std::unique_ptr<ui::ScopedClipboardWriter> clipboard_writer_;
52 base::WeakPtrFactory<ClipboardExtensionHelper> weak_factory_;
53
54 DISALLOW_COPY_AND_ASSIGN(ClipboardExtensionHelper);
55 };
56
57 } // namespace extensions
58
59 #endif // CHROME_BROWSER_EXTENSIONS_CLIPBOARD_EXTENSION_HELPER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698