OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 // |
| 5 |
| 6 #include "webkit/renderer/clipboard_utils.h" |
| 7 |
| 8 #include "base/strings/utf_string_conversions.h" |
| 9 #include "net/base/escape.h" |
| 10 |
| 11 namespace webkit_clipboard { |
| 12 |
| 13 // Static |
| 14 std::string URLToMarkup(const WebURL& url, const WebString& title) { |
| 15 std::string markup("<a href=\""); |
| 16 markup.append(url.spec()); |
| 17 markup.append("\">"); |
| 18 // TODO(darin): HTML escape this |
| 19 markup.append(net::EscapeForHTML(UTF16ToUTF8(title))); |
| 20 markup.append("</a>"); |
| 21 return markup; |
| 22 } |
| 23 |
| 24 std::string URLToImageMarkup(const WebURL& url, const WebString& title) { |
| 25 std::string markup("<img src=\""); |
| 26 markup.append(url.spec()); |
| 27 markup.append("\""); |
| 28 if (!title.isEmpty()) { |
| 29 markup.append(" alt=\""); |
| 30 markup.append(net::EscapeForHTML(UTF16ToUTF8(title))); |
| 31 markup.append("\""); |
| 32 } |
| 33 markup.append("/>"); |
| 34 return markup; |
| 35 } |
| 36 |
| 37 } // webkit_clipboard |
| 38 |
OLD | NEW |