OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/file_path.h" | 9 #include "base/file_path.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
246 DCHECK_EQ(buffer, BUFFER_STANDARD); | 246 DCHECK_EQ(buffer, BUFFER_STANDARD); |
247 | 247 |
248 scoped_nsobject<NSImage> image( | 248 scoped_nsobject<NSImage> image( |
249 [[NSImage alloc] initWithPasteboard:GetPasteboard()]); | 249 [[NSImage alloc] initWithPasteboard:GetPasteboard()]); |
250 if (image.get()) { | 250 if (image.get()) { |
251 [image setFlipped:YES]; | 251 [image setFlipped:YES]; |
252 int width = [image size].width; | 252 int width = [image size].width; |
253 int height = [image size].height; | 253 int height = [image size].height; |
254 | 254 |
255 gfx::CanvasSkia canvas(width, height, false); | 255 gfx::CanvasSkia canvas(width, height, false); |
256 CGContextRef gc = canvas.beginPlatformPaint(); | 256 skia::ScopedPlatformPaint scoped_platform_paint(&canvas); |
| 257 CGContextRef gc = scoped_platform_paint.GetPlatformSurface(); |
257 NSGraphicsContext* cocoa_gc = | 258 NSGraphicsContext* cocoa_gc = |
258 [NSGraphicsContext graphicsContextWithGraphicsPort:gc flipped:NO]; | 259 [NSGraphicsContext graphicsContextWithGraphicsPort:gc flipped:NO]; |
259 [NSGraphicsContext setCurrentContext:cocoa_gc]; | 260 [NSGraphicsContext setCurrentContext:cocoa_gc]; |
260 [image drawInRect:NSMakeRect(0, 0, width, height) | 261 [image drawInRect:NSMakeRect(0, 0, width, height) |
261 fromRect:NSZeroRect | 262 fromRect:NSZeroRect |
262 operation:NSCompositeCopy | 263 operation:NSCompositeCopy |
263 fraction:1.0]; | 264 fraction:1.0]; |
264 [NSGraphicsContext restoreGraphicsState]; | 265 [NSGraphicsContext restoreGraphicsState]; |
265 canvas.endPlatformPaint(); | |
266 return canvas.ExtractBitmap(); | 266 return canvas.ExtractBitmap(); |
267 } | 267 } |
268 return SkBitmap(); | 268 return SkBitmap(); |
269 } | 269 } |
270 | 270 |
271 void Clipboard::ReadBookmark(string16* title, std::string* url) const { | 271 void Clipboard::ReadBookmark(string16* title, std::string* url) const { |
272 NSPasteboard* pb = GetPasteboard(); | 272 NSPasteboard* pb = GetPasteboard(); |
273 | 273 |
274 if (title) { | 274 if (title) { |
275 NSString* contents = [pb stringForType:kUTTypeURLName]; | 275 NSString* contents = [pb stringForType:kUTTypeURLName]; |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
370 } | 370 } |
371 | 371 |
372 // static | 372 // static |
373 Clipboard::FormatType Clipboard::GetWebKitSmartPasteFormatType() { | 373 Clipboard::FormatType Clipboard::GetWebKitSmartPasteFormatType() { |
374 static const std::string type = | 374 static const std::string type = |
375 base::SysNSStringToUTF8(kWebSmartPastePboardType); | 375 base::SysNSStringToUTF8(kWebSmartPastePboardType); |
376 return type; | 376 return type; |
377 } | 377 } |
378 | 378 |
379 } // namespace ui | 379 } // namespace ui |
OLD | NEW |