OLD | NEW |
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_mac.h" | 5 #include "ui/base/clipboard/clipboard_mac.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 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 std::string Clipboard::FormatType::Serialize() const { | 82 std::string Clipboard::FormatType::Serialize() const { |
83 return base::SysNSStringToUTF8(data_); | 83 return base::SysNSStringToUTF8(data_); |
84 } | 84 } |
85 | 85 |
86 // static | 86 // static |
87 Clipboard::FormatType Clipboard::FormatType::Deserialize( | 87 Clipboard::FormatType Clipboard::FormatType::Deserialize( |
88 const std::string& serialization) { | 88 const std::string& serialization) { |
89 return FormatType(base::SysUTF8ToNSString(serialization)); | 89 return FormatType(base::SysUTF8ToNSString(serialization)); |
90 } | 90 } |
91 | 91 |
92 #if defined(TOOLKIT_VIEWS) | |
93 bool Clipboard::FormatType::operator<(const FormatType& other) const { | 92 bool Clipboard::FormatType::operator<(const FormatType& other) const { |
94 return [data_ compare:other.data_] == NSOrderedAscending; | 93 return [data_ compare:other.data_] == NSOrderedAscending; |
95 } | 94 } |
96 #endif | |
97 | 95 |
98 // Various predefined FormatTypes. | 96 // Various predefined FormatTypes. |
99 // static | 97 // static |
100 Clipboard::FormatType Clipboard::GetFormatType( | 98 Clipboard::FormatType Clipboard::GetFormatType( |
101 const std::string& format_string) { | 99 const std::string& format_string) { |
102 return FormatType::Deserialize(format_string); | 100 return FormatType::Deserialize(format_string); |
103 } | 101 } |
104 | 102 |
105 // static | 103 // static |
106 const Clipboard::FormatType& Clipboard::GetUrlFormatType() { | 104 const Clipboard::FormatType& Clipboard::GetUrlFormatType() { |
(...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
450 // Write an extra flavor that signifies WebKit was the last to modify the | 448 // Write an extra flavor that signifies WebKit was the last to modify the |
451 // pasteboard. This flavor has no data. | 449 // pasteboard. This flavor has no data. |
452 void ClipboardMac::WriteWebSmartPaste() { | 450 void ClipboardMac::WriteWebSmartPaste() { |
453 NSPasteboard* pb = GetPasteboard(); | 451 NSPasteboard* pb = GetPasteboard(); |
454 NSString* format = GetWebKitSmartPasteFormatType().ToNSString(); | 452 NSString* format = GetWebKitSmartPasteFormatType().ToNSString(); |
455 [pb addTypes:[NSArray arrayWithObject:format] owner:nil]; | 453 [pb addTypes:[NSArray arrayWithObject:format] owner:nil]; |
456 [pb setData:nil forType:format]; | 454 [pb setData:nil forType:format]; |
457 } | 455 } |
458 | 456 |
459 } // namespace ui | 457 } // namespace ui |
OLD | NEW |