| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 "app/clipboard/clipboard.h" | 5 #include "app/clipboard/clipboard.h" |
| 6 | 6 |
| 7 #include <gtk/gtk.h> | 7 #include <gtk/gtk.h> |
| 8 #include <map> | 8 #include <map> |
| 9 #include <set> | 9 #include <set> |
| 10 #include <string> | 10 #include <string> |
| 11 #include <utility> | 11 #include <utility> |
| 12 | 12 |
| 13 #include "base/file_path.h" | 13 #include "base/file_path.h" |
| 14 #include "base/logging.h" | 14 #include "base/logging.h" |
| 15 #include "base/scoped_ptr.h" | 15 #include "base/scoped_ptr.h" |
| 16 #include "base/linux_util.h" | 16 #include "app/gtk_util.h" |
| 17 #include "base/utf_string_conversions.h" | 17 #include "base/utf_string_conversions.h" |
| 18 #include "gfx/size.h" | 18 #include "gfx/size.h" |
| 19 | 19 |
| 20 namespace { | 20 namespace { |
| 21 | 21 |
| 22 const char kMimeBmp[] = "image/bmp"; | 22 const char kMimeBmp[] = "image/bmp"; |
| 23 const char kMimeHtml[] = "text/html"; | 23 const char kMimeHtml[] = "text/html"; |
| 24 const char kMimeText[] = "text/plain"; | 24 const char kMimeText[] = "text/plain"; |
| 25 const char kMimeURI[] = "text/uri-list"; | 25 const char kMimeURI[] = "text/uri-list"; |
| 26 const char kMimeWebkitSmartPaste[] = "chromium/x-webkit-paste"; | 26 const char kMimeWebkitSmartPaste[] = "chromium/x-webkit-paste"; |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 182 | 182 |
| 183 // Write an extra flavor that signifies WebKit was the last to modify the | 183 // Write an extra flavor that signifies WebKit was the last to modify the |
| 184 // pasteboard. This flavor has no data. | 184 // pasteboard. This flavor has no data. |
| 185 void Clipboard::WriteWebSmartPaste() { | 185 void Clipboard::WriteWebSmartPaste() { |
| 186 InsertMapping(kMimeWebkitSmartPaste, NULL, 0); | 186 InsertMapping(kMimeWebkitSmartPaste, NULL, 0); |
| 187 } | 187 } |
| 188 | 188 |
| 189 void Clipboard::WriteBitmap(const char* pixel_data, const char* size_data) { | 189 void Clipboard::WriteBitmap(const char* pixel_data, const char* size_data) { |
| 190 const gfx::Size* size = reinterpret_cast<const gfx::Size*>(size_data); | 190 const gfx::Size* size = reinterpret_cast<const gfx::Size*>(size_data); |
| 191 | 191 |
| 192 guchar* data = base::BGRAToRGBA(reinterpret_cast<const uint8_t*>(pixel_data), | 192 guchar* data = |
| 193 size->width(), size->height(), 0); | 193 gtk_util::BGRAToRGBA(reinterpret_cast<const uint8_t*>(pixel_data), |
| 194 size->width(), size->height(), 0); |
| 194 | 195 |
| 195 GdkPixbuf* pixbuf = | 196 GdkPixbuf* pixbuf = |
| 196 gdk_pixbuf_new_from_data(data, GDK_COLORSPACE_RGB, TRUE, | 197 gdk_pixbuf_new_from_data(data, GDK_COLORSPACE_RGB, TRUE, |
| 197 8, size->width(), size->height(), | 198 8, size->width(), size->height(), |
| 198 size->width() * 4, GdkPixbufFree, NULL); | 199 size->width() * 4, GdkPixbufFree, NULL); |
| 199 // We store the GdkPixbuf*, and the size_t half of the pair is meaningless. | 200 // We store the GdkPixbuf*, and the size_t half of the pair is meaningless. |
| 200 // Note that this contrasts with the vast majority of entries in our target | 201 // Note that this contrasts with the vast majority of entries in our target |
| 201 // map, which directly store the data and its length. | 202 // map, which directly store the data and its length. |
| 202 InsertMapping(kMimeBmp, reinterpret_cast<char*>(pixbuf), 0); | 203 InsertMapping(kMimeBmp, reinterpret_cast<char*>(pixbuf), 0); |
| 203 } | 204 } |
| (...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 399 switch (clipboard) { | 400 switch (clipboard) { |
| 400 case BUFFER_STANDARD: | 401 case BUFFER_STANDARD: |
| 401 return clipboard_; | 402 return clipboard_; |
| 402 case BUFFER_SELECTION: | 403 case BUFFER_SELECTION: |
| 403 return primary_selection_; | 404 return primary_selection_; |
| 404 default: | 405 default: |
| 405 NOTREACHED(); | 406 NOTREACHED(); |
| 406 return NULL; | 407 return NULL; |
| 407 } | 408 } |
| 408 } | 409 } |
| OLD | NEW |