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 #include "webkit/glue/webclipboard_impl.h" | 5 #include "webkit/glue/webclipboard_impl.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
10 #include "googleurl/src/gurl.h" | 10 #include "googleurl/src/gurl.h" |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 return markup; | 60 return markup; |
61 } | 61 } |
62 | 62 |
63 WebClipboardImpl::~WebClipboardImpl() { | 63 WebClipboardImpl::~WebClipboardImpl() { |
64 } | 64 } |
65 | 65 |
66 bool WebClipboardImpl::isFormatAvailable(Format format, Buffer buffer) { | 66 bool WebClipboardImpl::isFormatAvailable(Format format, Buffer buffer) { |
67 ui::Clipboard::FormatType format_type; | 67 ui::Clipboard::FormatType format_type; |
68 ui::Clipboard::Buffer buffer_type; | 68 ui::Clipboard::Buffer buffer_type; |
69 | 69 |
| 70 if (!ConvertBufferType(buffer, &buffer_type)) |
| 71 return false; |
| 72 |
70 switch (format) { | 73 switch (format) { |
| 74 case FormatPlainText: |
| 75 return ClipboardIsFormatAvailable(ui::Clipboard::GetPlainTextFormatType(), |
| 76 buffer_type) || |
| 77 ClipboardIsFormatAvailable(ui::Clipboard::GetPlainTextWFormatType(), |
| 78 buffer_type); |
71 case FormatHTML: | 79 case FormatHTML: |
72 format_type = ui::Clipboard::GetHtmlFormatType(); | 80 format_type = ui::Clipboard::GetHtmlFormatType(); |
73 break; | 81 break; |
74 case FormatSmartPaste: | 82 case FormatSmartPaste: |
75 format_type = ui::Clipboard::GetWebKitSmartPasteFormatType(); | 83 format_type = ui::Clipboard::GetWebKitSmartPasteFormatType(); |
76 break; | 84 break; |
77 case FormatBookmark: | 85 case FormatBookmark: |
78 #if defined(OS_WIN) || defined(OS_MACOSX) | 86 #if defined(OS_WIN) || defined(OS_MACOSX) |
79 format_type = ui::Clipboard::GetUrlWFormatType(); | 87 format_type = ui::Clipboard::GetUrlWFormatType(); |
80 break; | 88 break; |
81 #endif | 89 #endif |
82 default: | 90 default: |
83 NOTREACHED(); | 91 NOTREACHED(); |
84 return false; | 92 return false; |
85 } | 93 } |
86 | 94 |
87 if (!ConvertBufferType(buffer, &buffer_type)) | |
88 return false; | |
89 | |
90 return ClipboardIsFormatAvailable(format_type, buffer_type); | 95 return ClipboardIsFormatAvailable(format_type, buffer_type); |
91 } | 96 } |
92 | 97 |
93 WebString WebClipboardImpl::readPlainText(Buffer buffer) { | 98 WebString WebClipboardImpl::readPlainText(Buffer buffer) { |
94 ui::Clipboard::Buffer buffer_type; | 99 ui::Clipboard::Buffer buffer_type; |
95 if (!ConvertBufferType(buffer, &buffer_type)) | 100 if (!ConvertBufferType(buffer, &buffer_type)) |
96 return WebString(); | 101 return WebString(); |
97 | 102 |
98 if (ClipboardIsFormatAvailable(ui::Clipboard::GetPlainTextWFormatType(), | 103 if (ClipboardIsFormatAvailable(ui::Clipboard::GetPlainTextWFormatType(), |
99 buffer_type)) { | 104 buffer_type)) { |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
239 break; | 244 break; |
240 #endif | 245 #endif |
241 default: | 246 default: |
242 NOTREACHED(); | 247 NOTREACHED(); |
243 return false; | 248 return false; |
244 } | 249 } |
245 return true; | 250 return true; |
246 } | 251 } |
247 | 252 |
248 } // namespace webkit_glue | 253 } // namespace webkit_glue |
OLD | NEW |