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

Side by Side Diff: base/clipboard_win.cc

Issue 174367: Change the ChromiumPasteboard to have a notion of an alternate clipboard... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' 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
« no previous file with comments | « base/clipboard_unittest.cc ('k') | chrome/browser/autocomplete/autocomplete_edit_view_mac.mm » ('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) 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 // Many of these functions are based on those found in 5 // Many of these functions are based on those found in
6 // webkit/port/platform/PasteboardWin.cpp 6 // webkit/port/platform/PasteboardWin.cpp
7 7
8 #include "base/clipboard.h" 8 #include "base/clipboard.h"
9 9
10 #include <shlobj.h> 10 #include <shlobj.h>
(...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after
390 } 390 }
391 391
392 void Clipboard::WriteToClipboard(unsigned int format, HANDLE handle) { 392 void Clipboard::WriteToClipboard(unsigned int format, HANDLE handle) {
393 DCHECK(clipboard_owner_); 393 DCHECK(clipboard_owner_);
394 if (handle && !::SetClipboardData(format, handle)) { 394 if (handle && !::SetClipboardData(format, handle)) {
395 DCHECK(ERROR_CLIPBOARD_NOT_OPEN != GetLastError()); 395 DCHECK(ERROR_CLIPBOARD_NOT_OPEN != GetLastError());
396 FreeData(format, handle); 396 FreeData(format, handle);
397 } 397 }
398 } 398 }
399 399
400 bool Clipboard::IsFormatAvailable(const Clipboard::FormatType& format) const { 400 bool Clipboard::IsFormatAvailable(const Clipboard::FormatType& format,
401 Clipboard::Buffer buffer) const {
402 DCHECK_EQ(buffer, BUFFER_STANDARD);
401 return ::IsClipboardFormatAvailable(StringToInt(format)) != FALSE; 403 return ::IsClipboardFormatAvailable(StringToInt(format)) != FALSE;
402 } 404 }
403 405
404 bool Clipboard::IsFormatAvailableByString( 406 bool Clipboard::IsFormatAvailableByString(
405 const std::string& ascii_format) const { 407 const std::string& ascii_format, Clipboard::Buffer buffer) const {
408 DCHECK_EQ(buffer, BUFFER_STANDARD);
406 std::wstring wide_format = ASCIIToWide(ascii_format); 409 std::wstring wide_format = ASCIIToWide(ascii_format);
407 CLIPFORMAT format = ::RegisterClipboardFormat(wide_format.c_str()); 410 CLIPFORMAT format = ::RegisterClipboardFormat(wide_format.c_str());
408 return ::IsClipboardFormatAvailable(format) != FALSE; 411 return ::IsClipboardFormatAvailable(format) != FALSE;
409 } 412 }
410 413
411 void Clipboard::ReadText(string16* result) const { 414 void Clipboard::ReadText(Clipboard::Buffer buffer, string16* result) const {
415 DCHECK_EQ(buffer, BUFFER_STANDARD);
412 if (!result) { 416 if (!result) {
413 NOTREACHED(); 417 NOTREACHED();
414 return; 418 return;
415 } 419 }
416 420
417 result->clear(); 421 result->clear();
418 422
419 // Acquire the clipboard. 423 // Acquire the clipboard.
420 ScopedClipboard clipboard; 424 ScopedClipboard clipboard;
421 if (!clipboard.Acquire(GetClipboardWindow())) 425 if (!clipboard.Acquire(GetClipboardWindow()))
422 return; 426 return;
423 427
424 HANDLE data = ::GetClipboardData(CF_UNICODETEXT); 428 HANDLE data = ::GetClipboardData(CF_UNICODETEXT);
425 if (!data) 429 if (!data)
426 return; 430 return;
427 431
428 result->assign(static_cast<const char16*>(::GlobalLock(data))); 432 result->assign(static_cast<const char16*>(::GlobalLock(data)));
429 ::GlobalUnlock(data); 433 ::GlobalUnlock(data);
430 } 434 }
431 435
432 void Clipboard::ReadAsciiText(std::string* result) const { 436 void Clipboard::ReadAsciiText(Clipboard::Buffer buffer,
437 std::string* result) const {
438 DCHECK_EQ(buffer, BUFFER_STANDARD);
433 if (!result) { 439 if (!result) {
434 NOTREACHED(); 440 NOTREACHED();
435 return; 441 return;
436 } 442 }
437 443
438 result->clear(); 444 result->clear();
439 445
440 // Acquire the clipboard. 446 // Acquire the clipboard.
441 ScopedClipboard clipboard; 447 ScopedClipboard clipboard;
442 if (!clipboard.Acquire(GetClipboardWindow())) 448 if (!clipboard.Acquire(GetClipboardWindow()))
443 return; 449 return;
444 450
445 HANDLE data = ::GetClipboardData(CF_TEXT); 451 HANDLE data = ::GetClipboardData(CF_TEXT);
446 if (!data) 452 if (!data)
447 return; 453 return;
448 454
449 result->assign(static_cast<const char*>(::GlobalLock(data))); 455 result->assign(static_cast<const char*>(::GlobalLock(data)));
450 ::GlobalUnlock(data); 456 ::GlobalUnlock(data);
451 } 457 }
452 458
453 void Clipboard::ReadHTML(string16* markup, std::string* src_url) const { 459 void Clipboard::ReadHTML(Clipboard::Buffer buffer, string16* markup,
460 std::string* src_url) const {
461 DCHECK_EQ(buffer, BUFFER_STANDARD);
454 if (markup) 462 if (markup)
455 markup->clear(); 463 markup->clear();
456 464
457 if (src_url) 465 if (src_url)
458 src_url->clear(); 466 src_url->clear();
459 467
460 // Acquire the clipboard. 468 // Acquire the clipboard.
461 ScopedClipboard clipboard; 469 ScopedClipboard clipboard;
462 if (!clipboard.Acquire(GetClipboardWindow())) 470 if (!clipboard.Acquire(GetClipboardWindow()))
463 return; 471 return;
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
690 HWND Clipboard::GetClipboardWindow() const { 698 HWND Clipboard::GetClipboardWindow() const {
691 if (!clipboard_owner_ && create_window_) { 699 if (!clipboard_owner_ && create_window_) {
692 clipboard_owner_ = ::CreateWindow(L"ClipboardOwnerWindowClass", 700 clipboard_owner_ = ::CreateWindow(L"ClipboardOwnerWindowClass",
693 L"ClipboardOwnerWindow", 701 L"ClipboardOwnerWindow",
694 0, 0, 0, 0, 0, 702 0, 0, 0, 0, 0,
695 HWND_MESSAGE, 703 HWND_MESSAGE,
696 0, 0, 0); 704 0, 0, 0);
697 } 705 }
698 return clipboard_owner_; 706 return clipboard_owner_;
699 } 707 }
OLDNEW
« no previous file with comments | « base/clipboard_unittest.cc ('k') | chrome/browser/autocomplete/autocomplete_edit_view_mac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698