OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "app/clipboard/clipboard.h" | 5 #include "app/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" |
11 #include "base/mac_util.h" | 11 #include "base/mac_util.h" |
12 #include "base/scoped_cftyperef.h" | 12 #include "base/mac/scoped_cftyperef.h" |
13 #include "base/scoped_nsobject.h" | 13 #include "base/scoped_nsobject.h" |
14 #include "base/sys_string_conversions.h" | 14 #include "base/sys_string_conversions.h" |
15 #include "base/utf_string_conversions.h" | 15 #include "base/utf_string_conversions.h" |
16 #include "gfx/size.h" | 16 #include "gfx/size.h" |
17 #import "third_party/mozilla/NSPasteboard+Utils.h" | 17 #import "third_party/mozilla/NSPasteboard+Utils.h" |
18 | 18 |
19 namespace { | 19 namespace { |
20 | 20 |
21 // Would be nice if this were in UTCoreTypes.h, but it isn't | 21 // Would be nice if this were in UTCoreTypes.h, but it isn't |
22 NSString* const kUTTypeURLName = @"public.url-name"; | 22 NSString* const kUTTypeURLName = @"public.url-name"; |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 nil] | 98 nil] |
99 owner:nil]; | 99 owner:nil]; |
100 [nsurl writeToPasteboard:pb]; | 100 [nsurl writeToPasteboard:pb]; |
101 [pb setString:title forType:kUTTypeURLName]; | 101 [pb setString:title forType:kUTTypeURLName]; |
102 } | 102 } |
103 | 103 |
104 void Clipboard::WriteBitmap(const char* pixel_data, const char* size_data) { | 104 void Clipboard::WriteBitmap(const char* pixel_data, const char* size_data) { |
105 const gfx::Size* size = reinterpret_cast<const gfx::Size*>(size_data); | 105 const gfx::Size* size = reinterpret_cast<const gfx::Size*>(size_data); |
106 | 106 |
107 // Safe because the image goes away before the call returns. | 107 // Safe because the image goes away before the call returns. |
108 scoped_cftyperef<CFDataRef> data( | 108 base::win::ScopedCFTypeRef<CFDataRef> data( |
109 CFDataCreateWithBytesNoCopy(kCFAllocatorDefault, | 109 CFDataCreateWithBytesNoCopy(kCFAllocatorDefault, |
110 reinterpret_cast<const UInt8*>(pixel_data), | 110 reinterpret_cast<const UInt8*>(pixel_data), |
111 size->width()*size->height()*4, | 111 size->width()*size->height()*4, |
112 kCFAllocatorNull)); | 112 kCFAllocatorNull)); |
113 | 113 |
114 scoped_cftyperef<CGDataProviderRef> data_provider( | 114 base::win::ScopedCFTypeRef<CGDataProviderRef> data_provider( |
115 CGDataProviderCreateWithCFData(data)); | 115 CGDataProviderCreateWithCFData(data)); |
116 | 116 |
117 scoped_cftyperef<CGImageRef> cgimage( | 117 base::win::ScopedCFTypeRef<CGImageRef> cgimage( |
118 CGImageCreate(size->width(), | 118 CGImageCreate(size->width(), |
119 size->height(), | 119 size->height(), |
120 8, | 120 8, |
121 32, | 121 32, |
122 size->width()*4, | 122 size->width()*4, |
123 mac_util::GetSRGBColorSpace(), // TODO(avi): do better | 123 mac_util::GetSRGBColorSpace(), // TODO(avi): do better |
124 kCGImageAlphaPremultipliedFirst | kCGBitmapByteOrder32Host, | 124 kCGImageAlphaPremultipliedFirst | kCGBitmapByteOrder32Host, |
125 data_provider, | 125 data_provider, |
126 NULL, | 126 NULL, |
127 false, | 127 false, |
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
320 static const std::string type = base::SysNSStringToUTF8(NSTIFFPboardType); | 320 static const std::string type = base::SysNSStringToUTF8(NSTIFFPboardType); |
321 return type; | 321 return type; |
322 } | 322 } |
323 | 323 |
324 // static | 324 // static |
325 Clipboard::FormatType Clipboard::GetWebKitSmartPasteFormatType() { | 325 Clipboard::FormatType Clipboard::GetWebKitSmartPasteFormatType() { |
326 static const std::string type = | 326 static const std::string type = |
327 base::SysNSStringToUTF8(kWebSmartPastePboardType); | 327 base::SysNSStringToUTF8(kWebSmartPastePboardType); |
328 return type; | 328 return type; |
329 } | 329 } |
OLD | NEW |