1 // Copyright 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.
5 #include "webkit/renderer/clipboard_utils.h"
7 #include "base/strings/utf_string_conversions.h"
8 #include "net/base/escape.h"
9 #include "third_party/WebKit/public/platform/WebString.h"
10 #include "third_party/WebKit/public/platform/WebURL.h"
12 namespace webkit_clipboard
{
14 std::string
URLToMarkup(const WebKit::WebURL
& url
,
15 const WebKit::WebString
& title
) {
16 std::string
markup("<a href=\"");
17 markup
.append(url
.spec());
19 // TODO(darin): HTML escape this
20 markup
.append(net::EscapeForHTML(UTF16ToUTF8(title
)));
21 markup
.append("</a>");
25 std::string
URLToImageMarkup(const WebKit::WebURL
& url
,
26 const WebKit::WebString
& title
) {
27 std::string
markup("<img src=\"");
28 markup
.append(url
.spec());
30 if (!title
.isEmpty()) {
31 markup
.append(" alt=\"");
32 markup
.append(net::EscapeForHTML(UTF16ToUTF8(title
)));
39 } // namespace webkit_clipboard