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 #ifndef UI_BASE_COCOA_FIND_PASTEBOARD_H_ | 5 #ifndef UI_BASE_COCOA_FIND_PASTEBOARD_H_ |
6 #define UI_BASE_COCOA_FIND_PASTEBOARD_H_ | 6 #define UI_BASE_COCOA_FIND_PASTEBOARD_H_ |
7 | 7 |
8 #include "base/strings/string16.h" | 8 #include "base/strings/string16.h" |
9 | 9 |
10 #ifdef __OBJC__ | 10 #ifdef __OBJC__ |
11 | 11 |
12 #import <Cocoa/Cocoa.h> | 12 #import <Cocoa/Cocoa.h> |
13 | 13 |
14 #include "base/memory/scoped_nsobject.h" | 14 #include "base/mac/scoped_nsobject.h" |
15 #include "ui/base/ui_export.h" | 15 #include "ui/base/ui_export.h" |
16 | 16 |
17 UI_EXPORT extern NSString* kFindPasteboardChangedNotification; | 17 UI_EXPORT extern NSString* kFindPasteboardChangedNotification; |
18 | 18 |
19 // Manages the find pasteboard. Use this to copy text to the find pasteboard, | 19 // Manages the find pasteboard. Use this to copy text to the find pasteboard, |
20 // to get the text currently on the find pasteboard, and to receive | 20 // to get the text currently on the find pasteboard, and to receive |
21 // notifications when the text on the find pasteboard has changed. You should | 21 // notifications when the text on the find pasteboard has changed. You should |
22 // always use this class instead of accessing | 22 // always use this class instead of accessing |
23 // [NSPasteboard pasteboardWithName:NSFindPboard] directly. | 23 // [NSPasteboard pasteboardWithName:NSFindPboard] directly. |
24 // | 24 // |
25 // This is not thread-safe and must be used on the main thread. | 25 // This is not thread-safe and must be used on the main thread. |
26 // | 26 // |
27 // This is supposed to be a singleton. | 27 // This is supposed to be a singleton. |
28 UI_EXPORT | 28 UI_EXPORT |
29 @interface FindPasteboard : NSObject { | 29 @interface FindPasteboard : NSObject { |
30 @private | 30 @private |
31 scoped_nsobject<NSString> findText_; | 31 base::scoped_nsobject<NSString> findText_; |
32 } | 32 } |
33 | 33 |
34 // Returns the singleton instance of this class. | 34 // Returns the singleton instance of this class. |
35 + (FindPasteboard*)sharedInstance; | 35 + (FindPasteboard*)sharedInstance; |
36 | 36 |
37 // Returns the current find text. This is never nil; if there is no text on the | 37 // Returns the current find text. This is never nil; if there is no text on the |
38 // find pasteboard, this returns an empty string. | 38 // find pasteboard, this returns an empty string. |
39 - (NSString*)findText; | 39 - (NSString*)findText; |
40 | 40 |
41 // Sets the current find text to |newText| and sends a | 41 // Sets the current find text to |newText| and sends a |
42 // |kFindPasteboardChangedNotification| to the default notification center if | 42 // |kFindPasteboardChangedNotification| to the default notification center if |
43 // it the new text different from the current text. |newText| must not be nil. | 43 // it the new text different from the current text. |newText| must not be nil. |
44 - (void)setFindText:(NSString*)newText; | 44 - (void)setFindText:(NSString*)newText; |
45 @end | 45 @end |
46 | 46 |
47 @interface FindPasteboard (TestingAPI) | 47 @interface FindPasteboard (TestingAPI) |
48 - (void)loadTextFromPasteboard:(NSNotification*)notification; | 48 - (void)loadTextFromPasteboard:(NSNotification*)notification; |
49 | 49 |
50 // This methods is meant to be overridden in tests. | 50 // This methods is meant to be overridden in tests. |
51 - (NSPasteboard*)findPboard; | 51 - (NSPasteboard*)findPboard; |
52 @end | 52 @end |
53 | 53 |
54 #endif // __OBJC__ | 54 #endif // __OBJC__ |
55 | 55 |
56 // Also provide a c++ interface | 56 // Also provide a c++ interface |
57 UI_EXPORT string16 GetFindPboardText(); | 57 UI_EXPORT string16 GetFindPboardText(); |
58 | 58 |
59 #endif // UI_BASE_COCOA_FIND_PASTEBOARD_H_ | 59 #endif // UI_BASE_COCOA_FIND_PASTEBOARD_H_ |
OLD | NEW |