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

Side by Side Diff: ui/base/clipboard/clipboard_win.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_mac.mm ('k') | ui/base/clipboard/scoped_clipboard_writer.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 // 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 "ui/base/clipboard/clipboard.h" 8 #include "ui/base/clipboard/clipboard.h"
9 9
10 #include <shellapi.h> 10 #include <shellapi.h>
(...skipping 659 matching lines...) Expand 10 before | Expand all | Expand 10 after
670 if (url) { 670 if (url) {
671 const size_t url_start = bookmark.find_first_not_of(kDelim, title_end); 671 const size_t url_start = bookmark.find_first_not_of(kDelim, title_end);
672 if (url_start != base::string16::npos) { 672 if (url_start != base::string16::npos) {
673 *url = base::UTF16ToUTF8( 673 *url = base::UTF16ToUTF8(
674 bookmark.substr(url_start, base::string16::npos)); 674 bookmark.substr(url_start, base::string16::npos));
675 } 675 }
676 } 676 }
677 } 677 }
678 678
679 // static 679 // static
680 Clipboard::FormatType Clipboard::GetFormatType( 680 Clipboard::FormatType Clipboard::GetFormatTypeInternal(
681 const std::string& format_string) { 681 const std::string& format_string) {
682 return FormatType( 682 return FormatType(
683 ::RegisterClipboardFormat(base::ASCIIToWide(format_string).c_str())); 683 ::RegisterClipboardFormat(base::ASCIIToWide(format_string).c_str()));
684 } 684 }
685 685
686 // static 686 // static
687 const Clipboard::FormatType& Clipboard::GetUrlFormatType() { 687 const Clipboard::FormatType& Clipboard::GetUrlFormatType() {
688 CR_DEFINE_STATIC_LOCAL( 688 CR_DEFINE_STATIC_LOCAL(
689 FormatType, type, (::RegisterClipboardFormat(CFSTR_INETURLA))); 689 FormatType, type, (::RegisterClipboardFormat(CFSTR_INETURLA)));
690 return type; 690 return type;
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
795 (::RegisterClipboardFormat(L"WebKit Smart Paste Format"))); 795 (::RegisterClipboardFormat(L"WebKit Smart Paste Format")));
796 return type; 796 return type;
797 } 797 }
798 798
799 // static 799 // static
800 const Clipboard::FormatType& Clipboard::GetWebCustomDataFormatType() { 800 const Clipboard::FormatType& Clipboard::GetWebCustomDataFormatType() {
801 // TODO(dcheng): This name is temporary. See http://crbug.com/106449. 801 // TODO(dcheng): This name is temporary. See http://crbug.com/106449.
802 CR_DEFINE_STATIC_LOCAL( 802 CR_DEFINE_STATIC_LOCAL(
803 FormatType, 803 FormatType,
804 type, 804 type,
805 (::RegisterClipboardFormat(L"Chromium Web Custom MIME Data Format"))); 805 (GetFormatType("Chromium Web Custom MIME Data Format")));
806 return type; 806 return type;
807 } 807 }
808 808
809 // static 809 // static
810 const Clipboard::FormatType& Clipboard::GetPepperCustomDataFormatType() { 810 const Clipboard::FormatType& Clipboard::GetPepperCustomDataFormatType() {
811 CR_DEFINE_STATIC_LOCAL( 811 CR_DEFINE_STATIC_LOCAL(
812 FormatType, 812 FormatType,
813 type, 813 type,
814 (::RegisterClipboardFormat(L"Chromium Pepper MIME Data Format"))); 814 (GetFormatType("Chromium Pepper MIME Data Format")));
815 return type; 815 return type;
816 } 816 }
817 817
818 // static 818 // static
819 void Clipboard::FreeData(unsigned int format, HANDLE data) { 819 void Clipboard::FreeData(unsigned int format, HANDLE data) {
820 if (format == CF_BITMAP) 820 if (format == CF_BITMAP)
821 ::DeleteObject(static_cast<HBITMAP>(data)); 821 ::DeleteObject(static_cast<HBITMAP>(data));
822 else 822 else
823 ::GlobalFree(data); 823 ::GlobalFree(data);
824 } 824 }
825 825
826 HWND Clipboard::GetClipboardWindow() const { 826 HWND Clipboard::GetClipboardWindow() const {
827 if (!clipboard_owner_) 827 if (!clipboard_owner_)
828 return NULL; 828 return NULL;
829 829
830 if (clipboard_owner_->hwnd() == NULL) 830 if (clipboard_owner_->hwnd() == NULL)
831 clipboard_owner_->Create(base::Bind(&ClipboardOwnerWndProc)); 831 clipboard_owner_->Create(base::Bind(&ClipboardOwnerWndProc));
832 832
833 return clipboard_owner_->hwnd(); 833 return clipboard_owner_->hwnd();
834 } 834 }
835 835
836 } // namespace ui 836 } // namespace ui
OLDNEW
« no previous file with comments | « ui/base/clipboard/clipboard_mac.mm ('k') | ui/base/clipboard/scoped_clipboard_writer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698