Chromium Code Reviews| 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 // This class represents the data for a single Synced Notification. | 5 // This class represents the data for a single Synced Notification. |
| 6 // It should map 1-1 to all the data in synced_notification_sepcifics.proto, | 6 // It should map 1-1 to all the data in synced_notification_sepcifics.proto, |
| 7 // and the data and render protobufs that the specifics protobuf contains. | 7 // and the data and render protobufs that the specifics protobuf contains. |
| 8 | 8 |
| 9 #ifndef CHROME_BROWSER_NOTIFICATIONS_SYNC_NOTIFIER_SYNCED_NOTIFICATION_H_ | 9 #ifndef CHROME_BROWSER_NOTIFICATIONS_SYNC_NOTIFIER_SYNCED_NOTIFICATION_H_ |
| 10 #define CHROME_BROWSER_NOTIFICATIONS_SYNC_NOTIFIER_SYNCED_NOTIFICATION_H_ | 10 #define CHROME_BROWSER_NOTIFICATIONS_SYNC_NOTIFIER_SYNCED_NOTIFICATION_H_ |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 31 enum ReadState { | 31 enum ReadState { |
| 32 kUnread = 1, | 32 kUnread = 1, |
| 33 kRead = 2, | 33 kRead = 2, |
| 34 kDismissed = 3, | 34 kDismissed = 3, |
| 35 }; | 35 }; |
| 36 | 36 |
| 37 void Update(const syncer::SyncData& sync_data); | 37 void Update(const syncer::SyncData& sync_data); |
| 38 | 38 |
| 39 // Here are some helper functions to get individual data parts out of a | 39 // Here are some helper functions to get individual data parts out of a |
| 40 // SyncedNotification. | 40 // SyncedNotification. |
| 41 // TODO(petewil): Add more types as we expand support for the protobuf. | |
| 42 std::string title() const; | 41 std::string title() const; |
| 43 std::string heading() const; | 42 std::string heading() const; |
| 44 std::string description() const; | 43 std::string description() const; |
| 45 std::string app_id() const; | 44 std::string app_id() const; |
| 46 std::string key() const; | 45 std::string key() const; |
| 47 GURL origin_url() const; | 46 GURL origin_url() const; |
| 48 GURL app_icon_url() const; | 47 GURL app_icon_url() const; |
| 49 GURL image_url() const; | 48 GURL image_url() const; |
| 50 std::string first_external_id() const; | |
| 51 std::string notification_id() const; | |
| 52 std::string text() const; | 49 std::string text() const; |
| 53 ReadState read_state() const; | 50 ReadState read_state() const; |
| 51 double creation_time() const; | |
|
dcheng
2013/03/26 07:48:50
It seems wasteful to continue adding two accessors
Pete Williamson
2013/03/26 17:18:30
I think the class is nicer to use having accessors
dcheng
2013/03/26 17:49:29
This may be nice but it's a violation of the style
Pete Williamson
2013/03/27 17:07:53
Done.
| |
| 52 int priority() const; | |
| 53 int notification_count() const; | |
| 54 int button_count() const; | |
| 55 std::string default_destination_title() const; | |
| 56 std::string default_destination_icon_url() const; | |
| 57 std::string default_destination_url() const; | |
| 58 std::string button_one_title() const; | |
| 59 std::string button_one_icon_url() const; | |
| 60 std::string button_one_url() const; | |
| 61 std::string button_two_title() const; | |
| 62 std::string button_two_icon_url() const; | |
| 63 std::string button_two_url() const; | |
| 64 std::string contained_notification_title(int index) const; | |
| 65 std::string contained_notification_message(int index) const; | |
| 54 | 66 |
| 55 bool EqualsIgnoringReadState(const SyncedNotification& other) const; | 67 bool EqualsIgnoringReadState(const SyncedNotification& other) const; |
| 56 bool IdMatches(const SyncedNotification& other) const; | 68 bool KeyMatches(const SyncedNotification& other) const; |
|
dcheng
2013/03/26 07:48:50
This is still unused outside of unit tests. If the
Pete Williamson
2013/03/26 17:18:30
Done.
| |
| 57 | 69 |
| 58 void NotificationHasBeenRead(); | |
| 59 void NotificationHasBeenDismissed(); | 70 void NotificationHasBeenDismissed(); |
| 60 | 71 |
| 61 // This gets a pointer to the SyncedNotificationSpecifics part | 72 // This gets a pointer to the SyncedNotificationSpecifics part |
| 62 // of the sync data. | 73 // of the sync data. |
| 63 sync_pb::EntitySpecifics GetEntitySpecifics() const; | 74 sync_pb::EntitySpecifics GetEntitySpecifics() const; |
| 64 | 75 |
| 65 private: | 76 private: |
| 66 // Helper function to mark a notification as read or dismissed. | 77 // Helper function to mark a notification as read or dismissed. |
| 67 void SetReadState(const ReadState& read_state); | 78 void SetReadState(const ReadState& read_state); |
| 68 | 79 |
| 69 // Parsing functions to get this information out of the sync_data and into | 80 // Parsing functions to get this information out of the sync_data and into |
| 70 // our local variables. | 81 // our local variables. |
| 71 std::string ExtractTitle() const; | 82 std::string ExtractTitle() const; |
| 72 std::string ExtractHeading() const; | 83 std::string ExtractHeading() const; |
| 73 std::string ExtractDescription() const; | 84 std::string ExtractDescription() const; |
| 74 std::string ExtractAppId() const; | 85 std::string ExtractAppId() const; |
| 75 std::string ExtractKey() const; | 86 std::string ExtractKey() const; |
| 76 GURL ExtractOriginUrl() const; | 87 GURL ExtractOriginUrl() const; |
| 77 GURL ExtractAppIconUrl() const; | 88 GURL ExtractAppIconUrl() const; |
| 78 GURL ExtractImageUrl() const; | 89 GURL ExtractImageUrl() const; |
| 79 std::string ExtractFirstExternalId() const; | |
| 80 std::string ExtractNotificationId() const; | |
| 81 std::string ExtractText() const; | 90 std::string ExtractText() const; |
| 82 ReadState ExtractReadState() const; | 91 ReadState ExtractReadState() const; |
| 92 double ExtractCreationTime() const; | |
| 93 int ExtractPriority() const; | |
| 94 std::string ExtractDefaultDestinationTitle() const; | |
| 95 std::string ExtractDefaultDestinationIconUrl() const; | |
| 96 std::string ExtractDefaultDestinationUrl() const; | |
| 97 std::string ExtractButtonOneTitle() const; | |
| 98 std::string ExtractButtonOneIconUrl() const; | |
| 99 std::string ExtractButtonOneUrl() const; | |
| 100 std::string ExtractButtonTwoTitle() const; | |
| 101 std::string ExtractButtonTwoIconUrl() const; | |
| 102 std::string ExtractButtonTwoUrl() const; | |
| 103 int ExtractNotificationCount() const; | |
| 104 int ExtractButtonCount() const; | |
| 105 std::string ExtractContainedNotificationTitle(int index) const; | |
| 106 std::string ExtractContainedNotificationMessage(int index) const; | |
| 83 | 107 |
| 84 sync_pb::SyncedNotificationSpecifics specifics_; | 108 sync_pb::SyncedNotificationSpecifics specifics_; |
| 85 | 109 |
| 86 DISALLOW_COPY_AND_ASSIGN(SyncedNotification); | 110 DISALLOW_COPY_AND_ASSIGN(SyncedNotification); |
| 87 }; | 111 }; |
| 88 | 112 |
| 89 } // namespace notifier | 113 } // namespace notifier |
| 90 | 114 |
| 91 #endif // CHROME_BROWSER_NOTIFICATIONS_SYNC_NOTIFIER_SYNCED_NOTIFICATION_H_ | 115 #endif // CHROME_BROWSER_NOTIFICATIONS_SYNC_NOTIFIER_SYNCED_NOTIFICATION_H_ |
| OLD | NEW |