OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 // This file implements the ScopedClipboardWriter class. Documentation on its | 5 // This file implements the ScopedClipboardWriter class. Documentation on its |
6 // purpose can be found in our header. Documentation on the format of the | 6 // purpose can be found in our header. Documentation on the format of the |
7 // parameters for each clipboard target can be found in clipboard.h. | 7 // parameters for each clipboard target can be found in clipboard.h. |
8 | 8 |
9 #include "ui/base/clipboard/scoped_clipboard_writer.h" | 9 #include "ui/base/clipboard/scoped_clipboard_writer.h" |
10 | 10 |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 WriteHTML(UTF8ToUTF16(html), std::string()); | 81 WriteHTML(UTF8ToUTF16(html), std::string()); |
82 } | 82 } |
83 | 83 |
84 void ScopedClipboardWriter::WriteWebSmartPaste() { | 84 void ScopedClipboardWriter::WriteWebSmartPaste() { |
85 objects_[Clipboard::CBF_WEBKIT] = Clipboard::ObjectMapParams(); | 85 objects_[Clipboard::CBF_WEBKIT] = Clipboard::ObjectMapParams(); |
86 } | 86 } |
87 | 87 |
88 void ScopedClipboardWriter::WriteBitmapFromPixels(const void* pixels, | 88 void ScopedClipboardWriter::WriteBitmapFromPixels(const void* pixels, |
89 const gfx::Size& size) { | 89 const gfx::Size& size) { |
90 Clipboard::ObjectMapParam pixels_parameter, size_parameter; | 90 Clipboard::ObjectMapParam pixels_parameter, size_parameter; |
91 const char* pixels_data = reinterpret_cast<const char*>(pixels); | 91 const char* pixels_data = static_cast<const char*>(pixels); |
92 size_t pixels_length = 4 * size.width() * size.height(); | 92 size_t pixels_length = 4 * size.width() * size.height(); |
93 for (size_t i = 0; i < pixels_length; i++) | 93 for (size_t i = 0; i < pixels_length; i++) |
94 pixels_parameter.push_back(pixels_data[i]); | 94 pixels_parameter.push_back(pixels_data[i]); |
95 | 95 |
96 const char* size_data = reinterpret_cast<const char*>(&size); | 96 const char* size_data = reinterpret_cast<const char*>(&size); |
97 size_t size_length = sizeof(gfx::Size); | 97 size_t size_length = sizeof(gfx::Size); |
98 for (size_t i = 0; i < size_length; i++) | 98 for (size_t i = 0; i < size_length; i++) |
99 size_parameter.push_back(size_data[i]); | 99 size_parameter.push_back(size_data[i]); |
100 | 100 |
101 Clipboard::ObjectMapParams parameters; | 101 Clipboard::ObjectMapParams parameters; |
(...skipping 29 matching lines...) Expand all Loading... |
131 objects_[Clipboard::CBF_TEXT] = parameters; | 131 objects_[Clipboard::CBF_TEXT] = parameters; |
132 | 132 |
133 if (is_url) { | 133 if (is_url) { |
134 url_text_ = utf8_text; | 134 url_text_ = utf8_text; |
135 } else { | 135 } else { |
136 url_text_.clear(); | 136 url_text_.clear(); |
137 } | 137 } |
138 } | 138 } |
139 | 139 |
140 } // namespace ui | 140 } // namespace ui |
OLD | NEW |