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