OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #include "ui/base/clipboard/clipboard_aura.h" | 5 #include "ui/base/clipboard/clipboard_aura.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include <limits> | 9 #include <limits> |
10 #include <list> | 10 #include <list> |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 } | 84 } |
85 | 85 |
86 const std::string& bookmark_url() const { return bookmark_url_; } | 86 const std::string& bookmark_url() const { return bookmark_url_; } |
87 void set_bookmark_url(const std::string& bookmark_url) { | 87 void set_bookmark_url(const std::string& bookmark_url) { |
88 bookmark_url_ = bookmark_url; | 88 bookmark_url_ = bookmark_url; |
89 format_ |= BOOKMARK; | 89 format_ |= BOOKMARK; |
90 } | 90 } |
91 | 91 |
92 const SkBitmap& bitmap() const { return bitmap_; } | 92 const SkBitmap& bitmap() const { return bitmap_; } |
93 void SetBitmapData(const SkBitmap& bitmap) { | 93 void SetBitmapData(const SkBitmap& bitmap) { |
94 bitmap.copyTo(&bitmap_); | 94 if (bitmap_.tryAllocPixels(bitmap.info())) { |
| 95 bitmap.readPixels(bitmap_.info(), bitmap_.getPixels(), bitmap_.rowBytes(), |
| 96 0, 0); |
| 97 } |
95 format_ |= BITMAP; | 98 format_ |= BITMAP; |
96 } | 99 } |
97 | 100 |
98 const std::string& custom_data_format() const { return custom_data_format_; } | 101 const std::string& custom_data_format() const { return custom_data_format_; } |
99 const std::string& custom_data_data() const { return custom_data_data_; } | 102 const std::string& custom_data_data() const { return custom_data_data_; } |
100 void SetCustomData(const std::string& data_format, | 103 void SetCustomData(const std::string& data_format, |
101 const std::string& data_data) { | 104 const std::string& data_data) { |
102 if (data_data.size() == 0) { | 105 if (data_data.size() == 0) { |
103 custom_data_data_.clear(); | 106 custom_data_data_.clear(); |
104 custom_data_format_.clear(); | 107 custom_data_format_.clear(); |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
243 } | 246 } |
244 | 247 |
245 // Reads image from the data at the top of clipboard stack. | 248 // Reads image from the data at the top of clipboard stack. |
246 SkBitmap ReadImage() const { | 249 SkBitmap ReadImage() const { |
247 SkBitmap img; | 250 SkBitmap img; |
248 if (!HasFormat(BITMAP)) | 251 if (!HasFormat(BITMAP)) |
249 return img; | 252 return img; |
250 | 253 |
251 // A shallow copy should be fine here, but just to be safe... | 254 // A shallow copy should be fine here, but just to be safe... |
252 const SkBitmap& clipboard_bitmap = GetData()->bitmap(); | 255 const SkBitmap& clipboard_bitmap = GetData()->bitmap(); |
253 clipboard_bitmap.copyTo(&img); | 256 if (img.tryAllocPixels(clipboard_bitmap.info())) { |
| 257 clipboard_bitmap.readPixels(img.info(), img.getPixels(), img.rowBytes(), |
| 258 0, 0); |
| 259 } |
254 return img; | 260 return img; |
255 } | 261 } |
256 | 262 |
257 // Reads data of type |type| from the data at the top of clipboard stack. | 263 // Reads data of type |type| from the data at the top of clipboard stack. |
258 void ReadCustomData(const base::string16& type, | 264 void ReadCustomData(const base::string16& type, |
259 base::string16* result) const { | 265 base::string16* result) const { |
260 result->clear(); | 266 result->clear(); |
261 const ClipboardData* data = GetData(); | 267 const ClipboardData* data = GetData(); |
262 if (!HasFormat(CUSTOM)) | 268 if (!HasFormat(CUSTOM)) |
263 return; | 269 return; |
(...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
687 ClipboardDataBuilder::WriteBitmap(bitmap); | 693 ClipboardDataBuilder::WriteBitmap(bitmap); |
688 } | 694 } |
689 | 695 |
690 void ClipboardAura::WriteData(const FormatType& format, | 696 void ClipboardAura::WriteData(const FormatType& format, |
691 const char* data_data, | 697 const char* data_data, |
692 size_t data_len) { | 698 size_t data_len) { |
693 ClipboardDataBuilder::WriteData(format.ToString(), data_data, data_len); | 699 ClipboardDataBuilder::WriteData(format.ToString(), data_data, data_len); |
694 } | 700 } |
695 | 701 |
696 } // namespace ui | 702 } // namespace ui |
OLD | NEW |