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

Side by Side Diff: remoting/host/clipboard_win.cc

Issue 121123002: Update uses of UTF conversions in ppapi/, printing/, remoting/, rlz/, sandbox/, skia/, sql/, sync/,… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 12 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 | « remoting/base/breakpad_win_unittest.cc ('k') | remoting/host/desktop_session_win.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 (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 #include "remoting/host/clipboard.h" 5 #include "remoting/host/clipboard.h"
6 6
7 #include <windows.h> 7 #include <windows.h>
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 return; 188 return;
189 189
190 // Currently we only handle UTF-8 text. 190 // Currently we only handle UTF-8 text.
191 if (event.mime_type().compare(kMimeTypeTextUtf8) != 0) 191 if (event.mime_type().compare(kMimeTypeTextUtf8) != 0)
192 return; 192 return;
193 if (!StringIsUtf8(event.data().c_str(), event.data().length())) { 193 if (!StringIsUtf8(event.data().c_str(), event.data().length())) {
194 LOG(ERROR) << "ClipboardEvent: data is not UTF-8 encoded."; 194 LOG(ERROR) << "ClipboardEvent: data is not UTF-8 encoded.";
195 return; 195 return;
196 } 196 }
197 197
198 base::string16 text = UTF8ToUTF16(ReplaceLfByCrLf(event.data())); 198 base::string16 text = base::UTF8ToUTF16(ReplaceLfByCrLf(event.data()));
199 199
200 ScopedClipboard clipboard; 200 ScopedClipboard clipboard;
201 if (!clipboard.Init(window_->hwnd())) { 201 if (!clipboard.Init(window_->hwnd())) {
202 LOG(WARNING) << "Couldn't open the clipboard."; 202 LOG(WARNING) << "Couldn't open the clipboard.";
203 return; 203 return;
204 } 204 }
205 205
206 clipboard.Empty(); 206 clipboard.Empty();
207 207
208 HGLOBAL text_global = 208 HGLOBAL text_global =
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 base::win::ScopedHGlobal<WCHAR> text_lock(text_global); 245 base::win::ScopedHGlobal<WCHAR> text_lock(text_global);
246 if (!text_lock.get()) { 246 if (!text_lock.get()) {
247 LOG(WARNING) << "Couldn't lock clipboard data: " << GetLastError(); 247 LOG(WARNING) << "Couldn't lock clipboard data: " << GetLastError();
248 return; 248 return;
249 } 249 }
250 text.assign(text_lock.get()); 250 text.assign(text_lock.get());
251 } 251 }
252 252
253 protocol::ClipboardEvent event; 253 protocol::ClipboardEvent event;
254 event.set_mime_type(kMimeTypeTextUtf8); 254 event.set_mime_type(kMimeTypeTextUtf8);
255 event.set_data(ReplaceCrLfByLf(UTF16ToUTF8(text))); 255 event.set_data(ReplaceCrLfByLf(base::UTF16ToUTF8(text)));
256 256
257 if (client_clipboard_.get()) { 257 if (client_clipboard_.get()) {
258 client_clipboard_->InjectClipboardEvent(event); 258 client_clipboard_->InjectClipboardEvent(event);
259 } 259 }
260 } 260 }
261 } 261 }
262 262
263 bool ClipboardWin::HandleMessage( 263 bool ClipboardWin::HandleMessage(
264 UINT message, WPARAM wparam, LPARAM lparam, LRESULT* result) { 264 UINT message, WPARAM wparam, LPARAM lparam, LRESULT* result) {
265 if (message == WM_CLIPBOARDUPDATE) { 265 if (message == WM_CLIPBOARDUPDATE) {
266 OnClipboardUpdate(); 266 OnClipboardUpdate();
267 *result = 0; 267 *result = 0;
268 return true; 268 return true;
269 } 269 }
270 270
271 return false; 271 return false;
272 } 272 }
273 273
274 scoped_ptr<Clipboard> Clipboard::Create() { 274 scoped_ptr<Clipboard> Clipboard::Create() {
275 return scoped_ptr<Clipboard>(new ClipboardWin()); 275 return scoped_ptr<Clipboard>(new ClipboardWin());
276 } 276 }
277 277
278 } // namespace remoting 278 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/base/breakpad_win_unittest.cc ('k') | remoting/host/desktop_session_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698