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

Side by Side Diff: ui/base/clipboard/clipboard_mac.mm

Issue 117983002: Prefix string16 with base:: in ui/. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: merge Created 7 years 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_aurax11.cc ('k') | ui/base/clipboard/clipboard_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 #include "ui/base/clipboard/clipboard.h" 5 #include "ui/base/clipboard/clipboard.h"
6 6
7 #import <Cocoa/Cocoa.h> 7 #import <Cocoa/Cocoa.h>
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 216
217 void Clipboard::Clear(ClipboardType type) { 217 void Clipboard::Clear(ClipboardType type) {
218 DCHECK(CalledOnValidThread()); 218 DCHECK(CalledOnValidThread());
219 DCHECK_EQ(type, CLIPBOARD_TYPE_COPY_PASTE); 219 DCHECK_EQ(type, CLIPBOARD_TYPE_COPY_PASTE);
220 220
221 NSPasteboard* pb = GetPasteboard(); 221 NSPasteboard* pb = GetPasteboard();
222 [pb declareTypes:[NSArray array] owner:nil]; 222 [pb declareTypes:[NSArray array] owner:nil];
223 } 223 }
224 224
225 void Clipboard::ReadAvailableTypes(ClipboardType type, 225 void Clipboard::ReadAvailableTypes(ClipboardType type,
226 std::vector<string16>* types, 226 std::vector<base::string16>* types,
227 bool* contains_filenames) const { 227 bool* contains_filenames) const {
228 DCHECK(CalledOnValidThread()); 228 DCHECK(CalledOnValidThread());
229 types->clear(); 229 types->clear();
230 if (IsFormatAvailable(Clipboard::GetPlainTextFormatType(), type)) 230 if (IsFormatAvailable(Clipboard::GetPlainTextFormatType(), type))
231 types->push_back(UTF8ToUTF16(kMimeTypeText)); 231 types->push_back(UTF8ToUTF16(kMimeTypeText));
232 if (IsFormatAvailable(Clipboard::GetHtmlFormatType(), type)) 232 if (IsFormatAvailable(Clipboard::GetHtmlFormatType(), type))
233 types->push_back(UTF8ToUTF16(kMimeTypeHTML)); 233 types->push_back(UTF8ToUTF16(kMimeTypeHTML));
234 if (IsFormatAvailable(Clipboard::GetRtfFormatType(), type)) 234 if (IsFormatAvailable(Clipboard::GetRtfFormatType(), type))
235 types->push_back(UTF8ToUTF16(kMimeTypeRTF)); 235 types->push_back(UTF8ToUTF16(kMimeTypeRTF));
236 if ([NSImage canInitWithPasteboard:GetPasteboard()]) 236 if ([NSImage canInitWithPasteboard:GetPasteboard()])
237 types->push_back(UTF8ToUTF16(kMimeTypePNG)); 237 types->push_back(UTF8ToUTF16(kMimeTypePNG));
238 *contains_filenames = false; 238 *contains_filenames = false;
239 239
240 NSPasteboard* pb = GetPasteboard(); 240 NSPasteboard* pb = GetPasteboard();
241 if ([[pb types] containsObject:kWebCustomDataPboardType]) { 241 if ([[pb types] containsObject:kWebCustomDataPboardType]) {
242 NSData* data = [pb dataForType:kWebCustomDataPboardType]; 242 NSData* data = [pb dataForType:kWebCustomDataPboardType];
243 if ([data length]) 243 if ([data length])
244 ReadCustomDataTypes([data bytes], [data length], types); 244 ReadCustomDataTypes([data bytes], [data length], types);
245 } 245 }
246 } 246 }
247 247
248 void Clipboard::ReadText(ClipboardType type, string16* result) const { 248 void Clipboard::ReadText(ClipboardType type, base::string16* result) const {
249 DCHECK(CalledOnValidThread()); 249 DCHECK(CalledOnValidThread());
250 DCHECK_EQ(type, CLIPBOARD_TYPE_COPY_PASTE); 250 DCHECK_EQ(type, CLIPBOARD_TYPE_COPY_PASTE);
251 NSPasteboard* pb = GetPasteboard(); 251 NSPasteboard* pb = GetPasteboard();
252 NSString* contents = [pb stringForType:NSStringPboardType]; 252 NSString* contents = [pb stringForType:NSStringPboardType];
253 253
254 UTF8ToUTF16([contents UTF8String], 254 UTF8ToUTF16([contents UTF8String],
255 [contents lengthOfBytesUsingEncoding:NSUTF8StringEncoding], 255 [contents lengthOfBytesUsingEncoding:NSUTF8StringEncoding],
256 result); 256 result);
257 } 257 }
258 258
259 void Clipboard::ReadAsciiText(ClipboardType type, std::string* result) const { 259 void Clipboard::ReadAsciiText(ClipboardType type, std::string* result) const {
260 DCHECK(CalledOnValidThread()); 260 DCHECK(CalledOnValidThread());
261 DCHECK_EQ(type, CLIPBOARD_TYPE_COPY_PASTE); 261 DCHECK_EQ(type, CLIPBOARD_TYPE_COPY_PASTE);
262 NSPasteboard* pb = GetPasteboard(); 262 NSPasteboard* pb = GetPasteboard();
263 NSString* contents = [pb stringForType:NSStringPboardType]; 263 NSString* contents = [pb stringForType:NSStringPboardType];
264 264
265 if (!contents) 265 if (!contents)
266 result->clear(); 266 result->clear();
267 else 267 else
268 result->assign([contents UTF8String]); 268 result->assign([contents UTF8String]);
269 } 269 }
270 270
271 void Clipboard::ReadHTML(ClipboardType type, 271 void Clipboard::ReadHTML(ClipboardType type,
272 string16* markup, 272 base::string16* markup,
273 std::string* src_url, 273 std::string* src_url,
274 uint32* fragment_start, 274 uint32* fragment_start,
275 uint32* fragment_end) const { 275 uint32* fragment_end) const {
276 DCHECK(CalledOnValidThread()); 276 DCHECK(CalledOnValidThread());
277 DCHECK_EQ(type, CLIPBOARD_TYPE_COPY_PASTE); 277 DCHECK_EQ(type, CLIPBOARD_TYPE_COPY_PASTE);
278 278
279 // TODO(avi): src_url? 279 // TODO(avi): src_url?
280 markup->clear(); 280 markup->clear();
281 if (src_url) 281 if (src_url)
282 src_url->clear(); 282 src_url->clear();
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
320 })); 320 }));
321 SkBitmap bitmap; 321 SkBitmap bitmap;
322 if (image.get()) { 322 if (image.get()) {
323 bitmap = gfx::NSImageToSkBitmapWithColorSpace( 323 bitmap = gfx::NSImageToSkBitmapWithColorSpace(
324 image.get(), /*is_opaque=*/ false, base::mac::GetSystemColorSpace()); 324 image.get(), /*is_opaque=*/ false, base::mac::GetSystemColorSpace());
325 } 325 }
326 return bitmap; 326 return bitmap;
327 } 327 }
328 328
329 void Clipboard::ReadCustomData(ClipboardType clipboard_type, 329 void Clipboard::ReadCustomData(ClipboardType clipboard_type,
330 const string16& type, 330 const base::string16& type,
331 string16* result) const { 331 base::string16* result) const {
332 DCHECK(CalledOnValidThread()); 332 DCHECK(CalledOnValidThread());
333 DCHECK_EQ(clipboard_type, CLIPBOARD_TYPE_COPY_PASTE); 333 DCHECK_EQ(clipboard_type, CLIPBOARD_TYPE_COPY_PASTE);
334 334
335 NSPasteboard* pb = GetPasteboard(); 335 NSPasteboard* pb = GetPasteboard();
336 if ([[pb types] containsObject:kWebCustomDataPboardType]) { 336 if ([[pb types] containsObject:kWebCustomDataPboardType]) {
337 NSData* data = [pb dataForType:kWebCustomDataPboardType]; 337 NSData* data = [pb dataForType:kWebCustomDataPboardType];
338 if ([data length]) 338 if ([data length])
339 ReadCustomDataForType([data bytes], [data length], type, result); 339 ReadCustomDataForType([data bytes], [data length], type, result);
340 } 340 }
341 } 341 }
342 342
343 void Clipboard::ReadBookmark(string16* title, std::string* url) const { 343 void Clipboard::ReadBookmark(base::string16* title, std::string* url) const {
344 DCHECK(CalledOnValidThread()); 344 DCHECK(CalledOnValidThread());
345 NSPasteboard* pb = GetPasteboard(); 345 NSPasteboard* pb = GetPasteboard();
346 346
347 if (title) { 347 if (title) {
348 NSString* contents = [pb stringForType:kUTTypeURLName]; 348 NSString* contents = [pb stringForType:kUTTypeURLName];
349 UTF8ToUTF16([contents UTF8String], 349 UTF8ToUTF16([contents UTF8String],
350 [contents lengthOfBytesUsingEncoding:NSUTF8StringEncoding], 350 [contents lengthOfBytesUsingEncoding:NSUTF8StringEncoding],
351 title); 351 title);
352 } 352 }
353 353
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
437 return type; 437 return type;
438 } 438 }
439 439
440 // static 440 // static
441 const Clipboard::FormatType& Clipboard::GetPepperCustomDataFormatType() { 441 const Clipboard::FormatType& Clipboard::GetPepperCustomDataFormatType() {
442 CR_DEFINE_STATIC_LOCAL(FormatType, type, (kPepperCustomDataPboardType)); 442 CR_DEFINE_STATIC_LOCAL(FormatType, type, (kPepperCustomDataPboardType));
443 return type; 443 return type;
444 } 444 }
445 445
446 } // namespace ui 446 } // namespace ui
OLDNEW
« no previous file with comments | « ui/base/clipboard/clipboard_aurax11.cc ('k') | ui/base/clipboard/clipboard_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698