Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(91)

Side by Side Diff: content/renderer/clipboard_utils.cc

Issue 2658573003: Use explicit WebString conversions in clipboard and drag-and-drop code (Closed)
Patch Set: Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | content/renderer/drop_data_builder.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/renderer/clipboard_utils.h" 5 #include "content/renderer/clipboard_utils.h"
6 6
7 #include "base/strings/utf_string_conversions.h" 7 #include "base/strings/utf_string_conversions.h"
8 #include "net/base/escape.h" 8 #include "net/base/escape.h"
9 #include "third_party/WebKit/public/platform/WebString.h" 9 #include "third_party/WebKit/public/platform/WebString.h"
10 #include "third_party/WebKit/public/platform/WebURL.h" 10 #include "third_party/WebKit/public/platform/WebURL.h"
11 11
12 namespace content { 12 namespace content {
13 13
14 std::string URLToMarkup(const blink::WebURL& url, 14 std::string URLToMarkup(const blink::WebURL& url,
15 const blink::WebString& title) { 15 const blink::WebString& title) {
16 std::string markup("<a href=\""); 16 std::string markup("<a href=\"");
17 markup.append(url.string().utf8()); 17 markup.append(url.string().utf8());
18 markup.append("\">"); 18 markup.append("\">");
19 // TODO(darin): HTML escape this 19 // TODO(darin): HTML escape this
20 markup.append( 20 markup.append(net::EscapeForHTML(title.utf8()));
21 net::EscapeForHTML(base::UTF16ToUTF8(base::StringPiece16(title))));
22 markup.append("</a>"); 21 markup.append("</a>");
23 return markup; 22 return markup;
24 } 23 }
25 24
26 std::string URLToImageMarkup(const blink::WebURL& url, 25 std::string URLToImageMarkup(const blink::WebURL& url,
27 const blink::WebString& title) { 26 const blink::WebString& title) {
28 std::string markup("<img src=\""); 27 std::string markup("<img src=\"");
29 markup.append(net::EscapeForHTML(url.string().utf8())); 28 markup.append(net::EscapeForHTML(url.string().utf8()));
30 markup.append("\""); 29 markup.append("\"");
31 if (!title.isEmpty()) { 30 if (!title.isEmpty()) {
32 markup.append(" alt=\""); 31 markup.append(" alt=\"");
33 markup.append( 32 markup.append(net::EscapeForHTML(title.utf8()));
34 net::EscapeForHTML(base::UTF16ToUTF8(base::StringPiece16(title))));
35 markup.append("\""); 33 markup.append("\"");
36 } 34 }
37 markup.append("/>"); 35 markup.append("/>");
38 return markup; 36 return markup;
39 } 37 }
40 38
41 } // namespace content 39 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/renderer/drop_data_builder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698