5
5
#include < string>
6
6
#include < vector>
7
7
8
+ #include " atom/common/native_mate_converters/image_converter.h"
8
9
#include " atom/common/native_mate_converters/string16_converter.h"
9
10
#include " native_mate/dictionary.h"
11
+ #include " third_party/skia/include/core/SkBitmap.h"
10
12
#include " ui/base/clipboard/clipboard.h"
11
13
#include " ui/base/clipboard/scoped_clipboard_writer.h"
14
+ #include " ui/gfx/image/image.h"
12
15
13
16
#include " atom/common/node_includes.h"
14
17
15
18
namespace mate {
16
19
17
20
template <>
18
21
struct Converter <ui::ClipboardType> {
19
- static bool FromV8 (v8::Isolate* isolate,
20
- v8::Handle <v8::Value> val,
22
+ static bool FromV8 (v8::Isolate* isolate, v8::Handle <v8::Value> val,
21
23
ui::ClipboardType* out) {
22
24
std::string type;
23
25
if (!Converter<std::string>::FromV8 (isolate, val, &type))
@@ -62,6 +64,11 @@ void WriteText(const base::string16& text, ui::ClipboardType type) {
62
64
writer.WriteText (text);
63
65
}
64
66
67
+ gfx::Image ReadImage (ui::ClipboardType type) {
68
+ SkBitmap bitmap = ui::Clipboard::GetForCurrentThread ()->ReadImage (type);
69
+ return gfx::Image::CreateFrom1xBitmap (bitmap);
70
+ }
71
+
65
72
void Clear (ui::ClipboardType type) {
66
73
ui::Clipboard::GetForCurrentThread ()->Clear (type);
67
74
}
@@ -73,6 +80,7 @@ void Initialize(v8::Handle<v8::Object> exports, v8::Handle<v8::Value> unused,
73
80
dict.SetMethod (" _read" , &Read);
74
81
dict.SetMethod (" _readText" , &ReadText);
75
82
dict.SetMethod (" _writeText" , &WriteText);
83
+ dict.SetMethod (" _readImage" , &ReadImage);
76
84
dict.SetMethod (" _clear" , &Clear);
77
85
}
78
86
0 commit comments