Add ICU message format support
[chromium-blink-merge.git] / content / renderer / clipboard_utils.cc
blob6fd8542e10d22b61cb62051f5ab2cadeeefa544d
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 "content/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 content {
14 std::string URLToMarkup(const blink::WebURL& url,
15 const blink::WebString& title) {
16 std::string markup("<a href=\"");
17 markup.append(url.spec());
18 markup.append("\">");
19 // TODO(darin): HTML escape this
20 markup.append(
21 net::EscapeForHTML(base::UTF16ToUTF8(base::StringPiece16(title))));
22 markup.append("</a>");
23 return markup;
26 std::string URLToImageMarkup(const blink::WebURL& url,
27 const blink::WebString& title) {
28 std::string markup("<img src=\"");
29 markup.append(net::EscapeForHTML(url.spec()));
30 markup.append("\"");
31 if (!title.isEmpty()) {
32 markup.append(" alt=\"");
33 markup.append(
34 net::EscapeForHTML(base::UTF16ToUTF8(base::StringPiece16(title))));
35 markup.append("\"");
37 markup.append("/>");
38 return markup;
41 } // namespace content