| OLD | NEW | 
|    1 /* |    1 /* | 
|    2  * Copyright (c) 2008, 2009, Google Inc. All rights reserved. |    2  * Copyright (c) 2008, 2009, Google Inc. All rights reserved. | 
|    3  * |    3  * | 
|    4  * Redistribution and use in source and binary forms, with or without |    4  * Redistribution and use in source and binary forms, with or without | 
|    5  * modification, are permitted provided that the following conditions are |    5  * modification, are permitted provided that the following conditions are | 
|    6  * met: |    6  * met: | 
|    7  * |    7  * | 
|    8  *     * Redistributions of source code must retain the above copyright |    8  *     * Redistributions of source code must retain the above copyright | 
|    9  * notice, this list of conditions and the following disclaimer. |    9  * notice, this list of conditions and the following disclaimer. | 
|   10  *     * Redistributions in binary form must reproduce the above |   10  *     * Redistributions in binary form must reproduce the above | 
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   44  |   44  | 
|   45 namespace blink { |   45 namespace blink { | 
|   46  |   46  | 
|   47 Pasteboard* Pasteboard::generalPasteboard() |   47 Pasteboard* Pasteboard::generalPasteboard() | 
|   48 { |   48 { | 
|   49     static Pasteboard* pasteboard = new Pasteboard; |   49     static Pasteboard* pasteboard = new Pasteboard; | 
|   50     return pasteboard; |   50     return pasteboard; | 
|   51 } |   51 } | 
|   52  |   52  | 
|   53 Pasteboard::Pasteboard() |   53 Pasteboard::Pasteboard() | 
|   54     : m_buffer(blink::WebClipboard::BufferStandard) |   54     : m_buffer(WebClipboard::BufferStandard) | 
|   55 { |   55 { | 
|   56 } |   56 } | 
|   57  |   57  | 
|   58 bool Pasteboard::isSelectionMode() const |   58 bool Pasteboard::isSelectionMode() const | 
|   59 { |   59 { | 
|   60     return m_buffer == blink::WebClipboard::BufferSelection; |   60     return m_buffer == WebClipboard::BufferSelection; | 
|   61 } |   61 } | 
|   62  |   62  | 
|   63 void Pasteboard::setSelectionMode(bool selectionMode) |   63 void Pasteboard::setSelectionMode(bool selectionMode) | 
|   64 { |   64 { | 
|   65     m_buffer = selectionMode ? blink::WebClipboard::BufferSelection : blink::Web
     Clipboard::BufferStandard; |   65     m_buffer = selectionMode ? WebClipboard::BufferSelection : WebClipboard::Buf
     ferStandard; | 
|   66 } |   66 } | 
|   67  |   67  | 
|   68 void Pasteboard::writePlainText(const String& text, SmartReplaceOption) |   68 void Pasteboard::writePlainText(const String& text, SmartReplaceOption) | 
|   69 { |   69 { | 
|   70     // FIXME: add support for smart replace |   70     // FIXME: add support for smart replace | 
|   71 #if OS(WIN) |   71 #if OS(WIN) | 
|   72     String plainText(text); |   72     String plainText(text); | 
|   73     replaceNewlinesWithWindowsStyleNewlines(plainText); |   73     replaceNewlinesWithWindowsStyleNewlines(plainText); | 
|   74     blink::Platform::current()->clipboard()->writePlainText(plainText); |   74     Platform::current()->clipboard()->writePlainText(plainText); | 
|   75 #else |   75 #else | 
|   76     blink::Platform::current()->clipboard()->writePlainText(text); |   76     Platform::current()->clipboard()->writePlainText(text); | 
|   77 #endif |   77 #endif | 
|   78 } |   78 } | 
|   79  |   79  | 
|   80 void Pasteboard::writeImage(Image* image, const KURL& url, const String& title) |   80 void Pasteboard::writeImage(Image* image, const KURL& url, const String& title) | 
|   81 { |   81 { | 
|   82     ASSERT(image); |   82     ASSERT(image); | 
|   83  |   83  | 
|   84     SkBitmap bitmap; |   84     SkBitmap bitmap; | 
|   85     if (!image->bitmapForCurrentFrame(&bitmap)) |   85     if (!image->bitmapForCurrentFrame(&bitmap)) | 
|   86         return; |   86         return; | 
|   87  |   87  | 
|   88     blink::WebImage webImage = bitmap; |   88     WebImage webImage = bitmap; | 
|   89     blink::Platform::current()->clipboard()->writeImage(webImage, blink::WebURL(
     url), blink::WebString(title)); |   89     Platform::current()->clipboard()->writeImage(webImage, WebURL(url), WebStrin
     g(title)); | 
|   90 } |   90 } | 
|   91  |   91  | 
|   92 void Pasteboard::writeDataObject(DataObject* dataObject) |   92 void Pasteboard::writeDataObject(DataObject* dataObject) | 
|   93 { |   93 { | 
|   94     blink::Platform::current()->clipboard()->writeDataObject(dataObject->toWebDr
     agData()); |   94     Platform::current()->clipboard()->writeDataObject(dataObject->toWebDragData(
     )); | 
|   95 } |   95 } | 
|   96  |   96  | 
|   97 bool Pasteboard::canSmartReplace() |   97 bool Pasteboard::canSmartReplace() | 
|   98 { |   98 { | 
|   99     return blink::Platform::current()->clipboard()->isFormatAvailable(blink::Web
     Clipboard::FormatSmartPaste, m_buffer); |   99     return Platform::current()->clipboard()->isFormatAvailable(WebClipboard::For
     matSmartPaste, m_buffer); | 
|  100 } |  100 } | 
|  101  |  101  | 
|  102 bool Pasteboard::isHTMLAvailable() |  102 bool Pasteboard::isHTMLAvailable() | 
|  103 { |  103 { | 
|  104     return blink::Platform::current()->clipboard()->isFormatAvailable(blink::Web
     Clipboard::FormatHTML, m_buffer); |  104     return Platform::current()->clipboard()->isFormatAvailable(WebClipboard::For
     matHTML, m_buffer); | 
|  105 } |  105 } | 
|  106  |  106  | 
|  107 String Pasteboard::plainText() |  107 String Pasteboard::plainText() | 
|  108 { |  108 { | 
|  109     return blink::Platform::current()->clipboard()->readPlainText(m_buffer); |  109     return Platform::current()->clipboard()->readPlainText(m_buffer); | 
|  110 } |  110 } | 
|  111  |  111  | 
|  112 String Pasteboard::readHTML(KURL& url, unsigned& fragmentStart, unsigned& fragme
     ntEnd) |  112 String Pasteboard::readHTML(KURL& url, unsigned& fragmentStart, unsigned& fragme
     ntEnd) | 
|  113 { |  113 { | 
|  114     blink::WebURL webURL; |  114     WebURL webURL; | 
|  115     blink::WebString markup = blink::Platform::current()->clipboard()->readHTML(
     m_buffer, &webURL, &fragmentStart, &fragmentEnd); |  115     WebString markup = Platform::current()->clipboard()->readHTML(m_buffer, &web
     URL, &fragmentStart, &fragmentEnd); | 
|  116     if (!markup.isEmpty()) { |  116     if (!markup.isEmpty()) { | 
|  117         url = webURL; |  117         url = webURL; | 
|  118         // fragmentStart and fragmentEnd are populated by WebClipboard::readHTML
     . |  118         // fragmentStart and fragmentEnd are populated by WebClipboard::readHTML
     . | 
|  119     } else { |  119     } else { | 
|  120         url = KURL(); |  120         url = KURL(); | 
|  121         fragmentStart = 0; |  121         fragmentStart = 0; | 
|  122         fragmentEnd = 0; |  122         fragmentEnd = 0; | 
|  123     } |  123     } | 
|  124     return markup; |  124     return markup; | 
|  125 } |  125 } | 
|  126  |  126  | 
|  127 void Pasteboard::writeHTML(const String& markup, const KURL& documentURL, const 
     String& plainText, bool canSmartCopyOrDelete) |  127 void Pasteboard::writeHTML(const String& markup, const KURL& documentURL, const 
     String& plainText, bool canSmartCopyOrDelete) | 
|  128 { |  128 { | 
|  129     String text = plainText; |  129     String text = plainText; | 
|  130 #if OS(WIN) |  130 #if OS(WIN) | 
|  131     replaceNewlinesWithWindowsStyleNewlines(text); |  131     replaceNewlinesWithWindowsStyleNewlines(text); | 
|  132 #endif |  132 #endif | 
|  133     replaceNBSPWithSpace(text); |  133     replaceNBSPWithSpace(text); | 
|  134  |  134  | 
|  135     blink::Platform::current()->clipboard()->writeHTML(markup, documentURL, text
     , canSmartCopyOrDelete); |  135     Platform::current()->clipboard()->writeHTML(markup, documentURL, text, canSm
     artCopyOrDelete); | 
|  136 } |  136 } | 
|  137  |  137  | 
|  138 } // namespace blink |  138 } // namespace blink | 
| OLD | NEW |