| OLD | NEW |
| 1 // Copyright (c) 2008 The Chromium Authors. All rights reserved. Use of this | 1 // Copyright (c) 2008 The Chromium Authors. All rights reserved. Use of this |
| 2 // source code is governed by a BSD-style license that can be found in the | 2 // source code is governed by a BSD-style license that can be found in the |
| 3 // LICENSE file. | 3 // LICENSE file. |
| 4 | 4 |
| 5 #include "config.h" | 5 #include "config.h" |
| 6 #include "ChromiumBridge.h" | 6 #include "ChromiumBridge.h" |
| 7 | 7 |
| 8 #include "ClipboardUtilitiesChromium.h" | 8 #include "ClipboardUtilitiesChromium.h" |
| 9 #include "Cursor.h" | 9 #include "Cursor.h" |
| 10 #include "Frame.h" | 10 #include "Frame.h" |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 | 73 |
| 74 namespace WebCore { | 74 namespace WebCore { |
| 75 | 75 |
| 76 bool ChromiumBridge::clipboardIsFormatAvailable( | 76 bool ChromiumBridge::clipboardIsFormatAvailable( |
| 77 PasteboardPrivate::ClipboardFormat format) { | 77 PasteboardPrivate::ClipboardFormat format) { |
| 78 switch (format) { | 78 switch (format) { |
| 79 case PasteboardPrivate::HTMLFormat: | 79 case PasteboardPrivate::HTMLFormat: |
| 80 return webkit_glue::ClipboardIsFormatAvailable( | 80 return webkit_glue::ClipboardIsFormatAvailable( |
| 81 ::Clipboard::GetHtmlFormatType()); | 81 ::Clipboard::GetHtmlFormatType()); |
| 82 | 82 |
| 83 case PasteboardPrivate::WebSmartPasteFormat: |
| 84 return webkit_glue::ClipboardIsFormatAvailable( |
| 85 ::Clipboard::GetWebKitSmartPasteFormatType()); |
| 86 |
| 83 case PasteboardPrivate::BookmarkFormat: | 87 case PasteboardPrivate::BookmarkFormat: |
| 84 #if defined(OS_WIN) || defined(OS_MACOSX) | 88 #if defined(OS_WIN) || defined(OS_MACOSX) |
| 85 return webkit_glue::ClipboardIsFormatAvailable( | 89 return webkit_glue::ClipboardIsFormatAvailable( |
| 86 ::Clipboard::GetUrlWFormatType()); | 90 ::Clipboard::GetUrlWFormatType()); |
| 87 #endif | 91 #endif |
| 88 | 92 |
| 89 #if defined(OS_WIN) | |
| 90 // TODO(tc): This should work for linux/mac too. | |
| 91 case PasteboardPrivate::WebSmartPasteFormat: | |
| 92 return webkit_glue::ClipboardIsFormatAvailable( | |
| 93 ::Clipboard::GetWebKitSmartPasteFormatType()); | |
| 94 #endif | |
| 95 | |
| 96 default: | 93 default: |
| 97 NOTREACHED(); | 94 NOTREACHED(); |
| 98 return false; | 95 return false; |
| 99 } | 96 } |
| 100 } | 97 } |
| 101 | 98 |
| 102 String ChromiumBridge::clipboardReadPlainText() { | 99 String ChromiumBridge::clipboardReadPlainText() { |
| 103 if (webkit_glue::ClipboardIsFormatAvailable( | 100 if (webkit_glue::ClipboardIsFormatAvailable( |
| 104 ::Clipboard::GetPlainTextWFormatType())) { | 101 ::Clipboard::GetPlainTextWFormatType())) { |
| 105 std::wstring text; | 102 std::wstring text; |
| (...skipping 23 matching lines...) Expand all Loading... |
| 129 | 126 |
| 130 void ChromiumBridge::clipboardWriteSelection(const String& html, | 127 void ChromiumBridge::clipboardWriteSelection(const String& html, |
| 131 const KURL& url, | 128 const KURL& url, |
| 132 const String& plain_text, | 129 const String& plain_text, |
| 133 bool can_smart_copy_or_delete) { | 130 bool can_smart_copy_or_delete) { |
| 134 ScopedClipboardWriterGlue scw(webkit_glue::ClipboardGetClipboard()); | 131 ScopedClipboardWriterGlue scw(webkit_glue::ClipboardGetClipboard()); |
| 135 scw.WriteHTML(webkit_glue::StringToStdWString(html), | 132 scw.WriteHTML(webkit_glue::StringToStdWString(html), |
| 136 webkit_glue::CStringToStdString(url.utf8String())); | 133 webkit_glue::CStringToStdString(url.utf8String())); |
| 137 scw.WriteText(webkit_glue::StringToStdWString(plain_text)); | 134 scw.WriteText(webkit_glue::StringToStdWString(plain_text)); |
| 138 | 135 |
| 139 #if defined(OS_WIN) | |
| 140 if (can_smart_copy_or_delete) | 136 if (can_smart_copy_or_delete) |
| 141 scw.WriteWebSmartPaste(); | 137 scw.WriteWebSmartPaste(); |
| 142 #endif | |
| 143 } | 138 } |
| 144 | 139 |
| 145 void ChromiumBridge::clipboardWriteURL(const KURL& url, const String& title) { | 140 void ChromiumBridge::clipboardWriteURL(const KURL& url, const String& title) { |
| 146 ScopedClipboardWriterGlue scw(webkit_glue::ClipboardGetClipboard()); | 141 ScopedClipboardWriterGlue scw(webkit_glue::ClipboardGetClipboard()); |
| 147 | 142 |
| 148 GURL gurl = webkit_glue::KURLToGURL(url); | 143 GURL gurl = webkit_glue::KURLToGURL(url); |
| 149 scw.WriteBookmark(webkit_glue::StringToStdWString(title), gurl.spec()); | 144 scw.WriteBookmark(webkit_glue::StringToStdWString(title), gurl.spec()); |
| 150 | 145 |
| 151 std::wstring link(webkit_glue::StringToStdWString(urlToMarkup(url, title))); | 146 std::wstring link(webkit_glue::StringToStdWString(urlToMarkup(url, title))); |
| 152 scw.WriteHTML(link, ""); | 147 scw.WriteHTML(link, ""); |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 287 chrome_client->SetCursor(WebCursor(cursor.impl())); | 282 chrome_client->SetCursor(WebCursor(cursor.impl())); |
| 288 } | 283 } |
| 289 | 284 |
| 290 void ChromiumBridge::widgetSetFocus(Widget* widget) { | 285 void ChromiumBridge::widgetSetFocus(Widget* widget) { |
| 291 ChromeClientImpl* chrome_client = ToChromeClient(widget); | 286 ChromeClientImpl* chrome_client = ToChromeClient(widget); |
| 292 if (chrome_client) | 287 if (chrome_client) |
| 293 chrome_client->focus(); | 288 chrome_client->focus(); |
| 294 } | 289 } |
| 295 | 290 |
| 296 } // namespace WebCore | 291 } // namespace WebCore |
| OLD | NEW |