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_NOTIFICATIONS_NOTIFICATION_BUILDER_MAC_H_ | |
6 #define CHROME_BROWSER_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 extern NSString* const kNotificationOrigin; | |
16 extern NSString* const kNotificationId; | |
17 extern NSString* const kNotificationProfileId; | |
18 extern NSString* const kNotificationIncognito; | |
19 } // notification_builder | |
20 | |
21 // Provides a marshallable way for storing the information required to construct | |
22 // a NSUSerNotification that is to be displayed on the system. | |
23 // | |
24 // A quick example: | |
25 // base::scoped_nsobject<NotificationBuilder> builder( | |
26 // [[NotificationBuilder alloc] init]); | |
27 // [builder setTitle:@"Hello"]; | |
28 // | |
29 // // Build a notification out of the data. | |
30 // NSUserNotification* notification = | |
31 // [builder buildUserNotification]; | |
32 // | |
33 // // Serialize a notification out of the data. | |
34 // NSDictionary* notificationData = [builder buildDictionary]; | |
35 // | |
36 // // Deserialize the |notificationData| in to a new builder. | |
37 // base::scoped_nsobject<NotificationBuilder> finalBuilder( | |
38 // [[NotificationBuilder alloc] initWithData:notificationData]); | |
39 @interface NotificationBuilder : NSObject | |
40 | |
41 // Initializes an empty builder. | |
42 - (instancetype)init; | |
43 | |
44 // Initializes a builder by deserializing |data|. The |data| must have been | |
45 // generated by calling the buildDictionary function on another builder | |
46 // instance. | |
47 - (instancetype)initWithDictionary:(NSDictionary*)data; | |
48 | |
49 // Setters | |
50 - (void)setTitle:(NSString*)title; | |
51 - (void)setSubTitle:(NSString*)subTitle; | |
52 - (void)setContextMessage:(NSString*)contextMessage; | |
53 - (void)setIcon:(NSImage*)icon; | |
54 - (void)setButtons:(NSString*)primaryButton | |
55 secondaryButton:(NSString*)secondaryButton; | |
56 - (void)setTag:(NSString*)tag; | |
57 - (void)setOrigin:(NSString*)origin; | |
58 - (void)setNotificationId:(NSString*)notificationId; | |
59 - (void)setProfileId:(NSString*)profileId; | |
60 - (void)setIncognito:(BOOL)incognito; | |
61 | |
62 // Returns a notification ready to be displayed out of the provided | |
63 // |notificationData|. | |
64 - (NSUserNotification*)buildUserNotification; | |
65 | |
66 // Returns a representation of a notification that can be serialized. | |
67 // Another instance of NotificationBuilder can read this directly and generate | |
68 // a notification out of it via the |buildbuildUserNotification| method. | |
69 - (NSDictionary*)buildDictionary; | |
70 | |
71 @end | |
72 | |
73 #endif // CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_BUILDER_MAC_H_ | |
OLD | NEW |