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

Side by Side Diff: base/scoped_clipboard_writer.cc

Issue 194052: Clipboard:... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: fixes Created 11 years, 3 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 // This file implements the ScopedClipboardWriter class. Documentation on its 5 // This file implements the ScopedClipboardWriter class. Documentation on its
6 // purpose can be found in base/scoped_clipboard_writer.h. Documentation on the 6 // purpose can be found in base/scoped_clipboard_writer.h. Documentation on the
7 // format of the parameters for each clipboard target can be found in 7 // format of the parameters for each clipboard target can be found in
8 // base/clipboard.h. 8 // base/clipboard.h.
9 9
10 #include "base/scoped_clipboard_writer.h" 10 #include "base/scoped_clipboard_writer.h"
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 60
61 std::string utf8_markup = UTF16ToUTF8(bookmark_title); 61 std::string utf8_markup = UTF16ToUTF8(bookmark_title);
62 62
63 Clipboard::ObjectMapParams parameters; 63 Clipboard::ObjectMapParams parameters;
64 parameters.push_back(Clipboard::ObjectMapParam(utf8_markup.begin(), 64 parameters.push_back(Clipboard::ObjectMapParam(utf8_markup.begin(),
65 utf8_markup.end())); 65 utf8_markup.end()));
66 parameters.push_back(Clipboard::ObjectMapParam(url.begin(), url.end())); 66 parameters.push_back(Clipboard::ObjectMapParam(url.begin(), url.end()));
67 objects_[Clipboard::CBF_BOOKMARK] = parameters; 67 objects_[Clipboard::CBF_BOOKMARK] = parameters;
68 } 68 }
69 69
70 void ScopedClipboardWriter::WriteHyperlink(const string16& link_text, 70 void ScopedClipboardWriter::WriteHyperlink(const std::string& anchor_text,
71 const std::string& url) { 71 const std::string& url) {
72 if (link_text.empty() || url.empty()) 72 if (anchor_text.empty() || url.empty())
73 return; 73 return;
74 74
75 std::string utf8_markup = UTF16ToUTF8(link_text); 75 // Construct the hyperlink.
76 76 std::string html("<a href=\"");
77 Clipboard::ObjectMapParams parameters; 77 html.append(url);
78 parameters.push_back(Clipboard::ObjectMapParam(utf8_markup.begin(), 78 html.append("\">");
79 utf8_markup.end())); 79 html.append(anchor_text);
80 parameters.push_back(Clipboard::ObjectMapParam(url.begin(), url.end())); 80 html.append("</a>");
81 objects_[Clipboard::CBF_LINK] = parameters; 81 WriteHTML(UTF8ToUTF16(html), std::string());
82 } 82 }
83 83
84 void ScopedClipboardWriter::WriteFile(const FilePath& file) { 84 void ScopedClipboardWriter::WriteFile(const FilePath& file) {
85 WriteFiles(std::vector<FilePath>(1, file)); 85 WriteFiles(std::vector<FilePath>(1, file));
86 } 86 }
87 87
88 // Save the filenames as a string separated by nulls and terminated with an 88 // Save the filenames as a string separated by nulls and terminated with an
89 // extra null. 89 // extra null.
90 void ScopedClipboardWriter::WriteFiles(const std::vector<FilePath>& files) { 90 void ScopedClipboardWriter::WriteFiles(const std::vector<FilePath>& files) {
91 if (files.empty()) 91 if (files.empty())
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 149
150 data_parameter.resize(pickle.size()); 150 data_parameter.resize(pickle.size());
151 memcpy(const_cast<char*>(&data_parameter.front()), 151 memcpy(const_cast<char*>(&data_parameter.front()),
152 pickle.data(), pickle.size()); 152 pickle.data(), pickle.size());
153 153
154 Clipboard::ObjectMapParams parameters; 154 Clipboard::ObjectMapParams parameters;
155 parameters.push_back(format_parameter); 155 parameters.push_back(format_parameter);
156 parameters.push_back(data_parameter); 156 parameters.push_back(data_parameter);
157 objects_[Clipboard::CBF_DATA] = parameters; 157 objects_[Clipboard::CBF_DATA] = parameters;
158 } 158 }
OLDNEW
« no previous file with comments | « base/scoped_clipboard_writer.h ('k') | chrome/browser/autocomplete/autocomplete_edit_view_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698