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

Side by Side Diff: ui/base/clipboard/scoped_clipboard_writer.cc

Issue 199763002: Verify FormatType in ScopedClipboardWriter::WritePickledData. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix Linux GTK Created 6 years, 9 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
« no previous file with comments | « ui/base/clipboard/clipboard_win.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 our header. Documentation on the format of the 6 // purpose can be found in our header. Documentation on the format of the
7 // parameters for each clipboard target can be found in clipboard.h. 7 // parameters for each clipboard target can be found in clipboard.h.
8 8
9 #include "ui/base/clipboard/scoped_clipboard_writer.h" 9 #include "ui/base/clipboard/scoped_clipboard_writer.h"
10 10
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 html.append("</a>"); 84 html.append("</a>");
85 WriteHTML(base::UTF8ToUTF16(html), std::string()); 85 WriteHTML(base::UTF8ToUTF16(html), std::string());
86 } 86 }
87 87
88 void ScopedClipboardWriter::WriteWebSmartPaste() { 88 void ScopedClipboardWriter::WriteWebSmartPaste() {
89 objects_[Clipboard::CBF_WEBKIT] = Clipboard::ObjectMapParams(); 89 objects_[Clipboard::CBF_WEBKIT] = Clipboard::ObjectMapParams();
90 } 90 }
91 91
92 void ScopedClipboardWriter::WritePickledData( 92 void ScopedClipboardWriter::WritePickledData(
93 const Pickle& pickle, const Clipboard::FormatType& format) { 93 const Pickle& pickle, const Clipboard::FormatType& format) {
94 // |format| may originate from the renderer, so sanity check it.
95 if (!Clipboard::IsRegisteredFormatType(format))
96 return;
97
94 std::string format_string = format.Serialize(); 98 std::string format_string = format.Serialize();
95 Clipboard::ObjectMapParam format_parameter(format_string.begin(), 99 Clipboard::ObjectMapParam format_parameter(format_string.begin(),
96 format_string.end()); 100 format_string.end());
97 Clipboard::ObjectMapParam data_parameter; 101 Clipboard::ObjectMapParam data_parameter;
98 102
99 data_parameter.resize(pickle.size()); 103 data_parameter.resize(pickle.size());
100 memcpy(const_cast<char*>(&data_parameter.front()), 104 memcpy(const_cast<char*>(&data_parameter.front()),
101 pickle.data(), pickle.size()); 105 pickle.data(), pickle.size());
102 106
103 Clipboard::ObjectMapParams parameters; 107 Clipboard::ObjectMapParams parameters;
(...skipping 17 matching lines...) Expand all
121 objects_[Clipboard::CBF_TEXT] = parameters; 125 objects_[Clipboard::CBF_TEXT] = parameters;
122 126
123 if (is_url) { 127 if (is_url) {
124 url_text_ = utf8_text; 128 url_text_ = utf8_text;
125 } else { 129 } else {
126 url_text_.clear(); 130 url_text_.clear();
127 } 131 }
128 } 132 }
129 133
130 } // namespace ui 134 } // namespace ui
OLDNEW
« no previous file with comments | « ui/base/clipboard/clipboard_win.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698