OLD | NEW |
| (Empty) |
1 // Copyright 2016 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_NOTIFICATIONS_NOTIFICATION_BUILDER_MAC_H_ | |
6 #define CHROME_BROWSER_UI_COCOA_NOTIFICATIONS_NOTIFICATION_BUILDER_MAC_H_ | |
7 | |
8 #import <Foundation/Foundation.h> | |
9 | |
10 #include "base/mac/scoped_nsobject.h" | |
11 | |
12 @class NSUserNotification; | |
13 | |
14 namespace notification_builder { | |
15 | |
16 extern NSString* const kNotificationOrigin; | |
17 extern NSString* const kNotificationId; | |
18 extern NSString* const kNotificationProfileId; | |
19 extern NSString* const kNotificationIncognito; | |
20 | |
21 } // notification_builder | |
22 | |
23 // Provides a marshallable way for storing the information required to construct | |
24 // a NSUSerNotification that is to be displayed on the system. | |
25 // | |
26 // A quick example: | |
27 // base::scoped_nsobject<NotificationBuilder> builder( | |
28 // [[NotificationBuilder alloc] init]); | |
29 // [builder setTitle:@"Hello"]; | |
30 // | |
31 // // Build a notification out of the data. | |
32 // NSUserNotification* notification = | |
33 // [builder buildUserNotification]; | |
34 // | |
35 // // Serialize a notification out of the data. | |
36 // NSDictionary* notificationData = [builder buildDictionary]; | |
37 // | |
38 // // Deserialize the |notificationData| in to a new builder. | |
39 // base::scoped_nsobject<NotificationBuilder> finalBuilder( | |
40 // [[NotificationBuilder alloc] initWithData:notificationData]); | |
41 @interface NotificationBuilder : NSObject | |
42 | |
43 // Initializes an empty builder. | |
44 - (instancetype)init; | |
45 | |
46 // Initializes a builder by deserializing |data|. The |data| must have been | |
47 // generated by calling the buildDictionary function on another builder | |
48 // instance. | |
49 - (instancetype)initWithDictionary:(NSDictionary*)data; | |
50 | |
51 // Setters | |
52 // Note for XPC users. Always use the setters from Chrome's main app. Do not | |
53 // attempt to use them from XPC since some of the default strings and other | |
54 // defaults are not available from the xpc service. | |
55 - (void)setTitle:(NSString*)title; | |
56 - (void)setSubTitle:(NSString*)subTitle; | |
57 - (void)setContextMessage:(NSString*)contextMessage; | |
58 - (void)setIcon:(NSImage*)icon; | |
59 - (void)setButtons:(NSString*)primaryButton | |
60 secondaryButton:(NSString*)secondaryButton; | |
61 - (void)setTag:(NSString*)tag; | |
62 - (void)setOrigin:(NSString*)origin; | |
63 - (void)setNotificationId:(NSString*)notificationId; | |
64 - (void)setProfileId:(NSString*)profileId; | |
65 - (void)setIncognito:(BOOL)incognito; | |
66 | |
67 // Returns a notification ready to be displayed out of the provided | |
68 // |notificationData|. | |
69 - (NSUserNotification*)buildUserNotification; | |
70 | |
71 // Returns a representation of a notification that can be serialized. | |
72 // Another instance of NotificationBuilder can read this directly and generate | |
73 // a notification out of it via the |buildbuildUserNotification| method. | |
74 - (NSDictionary*)buildDictionary; | |
75 | |
76 @end | |
77 | |
78 #endif // CHROME_BROWSER_UI_COCOA_NOTIFICATIONS_NOTIFICATION_BUILDER_MAC_H_ | |
OLD | NEW |