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

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

Issue 689063002: Cleanup: Replace base::ASCIIToWide with base::ASCIIToUTF16. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase, fix typo Created 6 years, 1 month 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
« no previous file with comments | « tools/imagediff/image_diff.cc ('k') | win8/delegate_execute/delegate_execute_util_unittest.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_win.h" 8 #include "ui/base/clipboard/clipboard_win.h"
9 9
10 #include <shellapi.h> 10 #include <shellapi.h>
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 HGLOBAL CreateGlobalData(const std::basic_string<charT>& str) { 129 HGLOBAL CreateGlobalData(const std::basic_string<charT>& str) {
130 HGLOBAL data = 130 HGLOBAL data =
131 ::GlobalAlloc(GMEM_MOVEABLE, ((str.size() + 1) * sizeof(charT))); 131 ::GlobalAlloc(GMEM_MOVEABLE, ((str.size() + 1) * sizeof(charT)));
132 if (data) { 132 if (data) {
133 charT* raw_data = static_cast<charT*>(::GlobalLock(data)); 133 charT* raw_data = static_cast<charT*>(::GlobalLock(data));
134 memcpy(raw_data, str.data(), str.size() * sizeof(charT)); 134 memcpy(raw_data, str.data(), str.size() * sizeof(charT));
135 raw_data[str.size()] = '\0'; 135 raw_data[str.size()] = '\0';
136 ::GlobalUnlock(data); 136 ::GlobalUnlock(data);
137 } 137 }
138 return data; 138 return data;
139 }; 139 }
140 140
141 bool BitmapHasInvalidPremultipliedColors(const SkBitmap& bitmap) { 141 bool BitmapHasInvalidPremultipliedColors(const SkBitmap& bitmap) {
142 for (int x = 0; x < bitmap.width(); ++x) { 142 for (int x = 0; x < bitmap.width(); ++x) {
143 for (int y = 0; y < bitmap.height(); ++y) { 143 for (int y = 0; y < bitmap.height(); ++y) {
144 uint32_t pixel = *bitmap.getAddr32(x, y); 144 uint32_t pixel = *bitmap.getAddr32(x, y);
145 if (SkColorGetR(pixel) > SkColorGetA(pixel) || 145 if (SkColorGetR(pixel) > SkColorGetA(pixel) ||
146 SkColorGetG(pixel) > SkColorGetA(pixel) || 146 SkColorGetG(pixel) > SkColorGetA(pixel) ||
147 SkColorGetB(pixel) > SkColorGetA(pixel)) 147 SkColorGetB(pixel) > SkColorGetA(pixel))
148 return true; 148 return true;
149 } 149 }
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 231
232 bool Clipboard::FormatType::Equals(const FormatType& other) const { 232 bool Clipboard::FormatType::Equals(const FormatType& other) const {
233 return data_.cfFormat == other.data_.cfFormat; 233 return data_.cfFormat == other.data_.cfFormat;
234 } 234 }
235 235
236 // Various predefined FormatTypes. 236 // Various predefined FormatTypes.
237 // static 237 // static
238 Clipboard::FormatType Clipboard::GetFormatType( 238 Clipboard::FormatType Clipboard::GetFormatType(
239 const std::string& format_string) { 239 const std::string& format_string) {
240 return FormatType( 240 return FormatType(
241 ::RegisterClipboardFormat(base::ASCIIToWide(format_string).c_str())); 241 ::RegisterClipboardFormat(base::ASCIIToUTF16(format_string).c_str()));
242 } 242 }
243 243
244 // static 244 // static
245 const Clipboard::FormatType& Clipboard::GetUrlFormatType() { 245 const Clipboard::FormatType& Clipboard::GetUrlFormatType() {
246 CR_DEFINE_STATIC_LOCAL( 246 CR_DEFINE_STATIC_LOCAL(
247 FormatType, type, (::RegisterClipboardFormat(CFSTR_INETURLA))); 247 FormatType, type, (::RegisterClipboardFormat(CFSTR_INETURLA)));
248 return type; 248 return type;
249 } 249 }
250 250
251 // static 251 // static
(...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after
720 } 720 }
721 721
722 void ClipboardWin::WriteBookmark(const char* title_data, 722 void ClipboardWin::WriteBookmark(const char* title_data,
723 size_t title_len, 723 size_t title_len,
724 const char* url_data, 724 const char* url_data,
725 size_t url_len) { 725 size_t url_len) {
726 std::string bookmark(title_data, title_len); 726 std::string bookmark(title_data, title_len);
727 bookmark.append(1, L'\n'); 727 bookmark.append(1, L'\n');
728 bookmark.append(url_data, url_len); 728 bookmark.append(url_data, url_len);
729 729
730 base::string16 wide_bookmark = base::UTF8ToWide(bookmark); 730 base::string16 wide_bookmark = base::UTF8ToUTF16(bookmark);
731 HGLOBAL glob = CreateGlobalData(wide_bookmark); 731 HGLOBAL glob = CreateGlobalData(wide_bookmark);
732 732
733 WriteToClipboard(GetUrlWFormatType().ToFormatEtc().cfFormat, glob); 733 WriteToClipboard(GetUrlWFormatType().ToFormatEtc().cfFormat, glob);
734 } 734 }
735 735
736 void ClipboardWin::WriteWebSmartPaste() { 736 void ClipboardWin::WriteWebSmartPaste() {
737 DCHECK(clipboard_owner_->hwnd() != NULL); 737 DCHECK(clipboard_owner_->hwnd() != NULL);
738 ::SetClipboardData(GetWebKitSmartPasteFormatType().ToFormatEtc().cfFormat, 738 ::SetClipboardData(GetWebKitSmartPasteFormatType().ToFormatEtc().cfFormat,
739 NULL); 739 NULL);
740 } 740 }
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
853 if (!clipboard_owner_) 853 if (!clipboard_owner_)
854 return NULL; 854 return NULL;
855 855
856 if (clipboard_owner_->hwnd() == NULL) 856 if (clipboard_owner_->hwnd() == NULL)
857 clipboard_owner_->Create(base::Bind(&ClipboardOwnerWndProc)); 857 clipboard_owner_->Create(base::Bind(&ClipboardOwnerWndProc));
858 858
859 return clipboard_owner_->hwnd(); 859 return clipboard_owner_->hwnd();
860 } 860 }
861 861
862 } // namespace ui 862 } // namespace ui
OLDNEW
« no previous file with comments | « tools/imagediff/image_diff.cc ('k') | win8/delegate_execute/delegate_execute_util_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698