Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 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, | |
| 7 // and the data and render protobufs that the specifics protobuf contains. | |
| 8 | |
| 9 #ifndef CHROME_BROWSER_NOTIFIER_SYNCED_NOTIFICATION_H_ | |
| 10 #define CHROME_BROWSER_NOTIFIER_SYNCED_NOTIFICATION_H_ | |
| 11 | |
| 12 #include <string> | |
| 13 | |
| 14 #include "googleurl/src/gurl.h" | |
| 15 #include "sync/api/sync_data.h" | |
| 16 #include "sync/protocol/sync.pb.h" | |
| 17 #include "sync/protocol/synced_notification_specifics.pb.h" | |
|
Nicolas Zea
2013/01/29 01:17:02
I think you can forward declare any protobuffers n
Pete Williamson
2013/01/29 02:10:37
Done.
| |
| 18 | |
| 19 namespace notifier { | |
| 20 | |
| 21 class SyncedNotification { | |
| 22 public: | |
| 23 explicit SyncedNotification(const syncer::SyncData& sync_data); | |
| 24 | |
| 25 ~SyncedNotification(); | |
| 26 | |
| 27 // Here are some helper functions to get individual data parts out of a | |
| 28 // SyncedNotification. | |
| 29 const std::string& title() const { return title_; } | |
| 30 const std::string& app_id() const { return app_id_; } | |
| 31 const std::string& coalescing_key() const { return coalescing_key_; } | |
| 32 const GURL& origin_url() const { return origin_url_; } | |
| 33 const GURL& icon_url() const { return icon_url_; } | |
| 34 const GURL& image_url() const { return image_url_; } | |
| 35 const std::string& first_external_id() const { return first_external_id_; } | |
| 36 const std::string& notification_id() const { return notification_id_; } | |
| 37 const std::string& body() const { return body_; } | |
| 38 | |
| 39 bool Equals(const SyncedNotification& other) const; | |
| 40 | |
| 41 void set_has_local_changes(bool has_local_changes) { | |
| 42 has_local_changes_ = has_local_changes; | |
| 43 } | |
| 44 | |
| 45 bool has_local_changes() const { | |
| 46 return has_local_changes_; | |
| 47 } | |
| 48 | |
| 49 const syncer::SyncData* sync_data() const { | |
| 50 return &sync_data_; | |
| 51 } | |
| 52 | |
| 53 void NotificationHasBeenRead(); | |
| 54 | |
| 55 void NotificationHasBeenDeleted(); | |
| 56 | |
| 57 // This gets a pointer to the SyncedNotificationSpecifics part | |
| 58 // of the sync data. This is owned by the SyncedNotification class | |
| 59 // (actually refcounted, so it is jointly owned with sync). | |
| 60 // Don't free this pointer! | |
| 61 const sync_pb::SyncedNotificationSpecifics* GetSyncedNotificationSpecifics(); | |
| 62 | |
| 63 private: | |
| 64 // helper function to mark a notification as read or dismissed. | |
|
Nicolas Zea
2013/01/29 01:17:02
helper -> Helper
Pete Williamson
2013/01/29 02:10:37
Done.
| |
| 65 bool SetReadState( | |
| 66 sync_pb::CoalescedSyncedNotification_ReadState readState); | |
|
Nicolas Zea
2013/01/29 01:17:02
pass as const ref
dcheng
2013/01/29 01:33:48
Btw... I missed this, but naming (should be read_s
Pete Williamson
2013/01/29 02:10:37
Done.
Pete Williamson
2013/01/29 02:10:37
Done.
| |
| 67 | |
| 68 // Parsing functions to get this information out of the sync_data and into | |
| 69 // our local variables. | |
| 70 std::string ExtractTitle(const syncer::SyncData& sync_data) const; | |
| 71 std::string ExtractAppId(const syncer::SyncData& sync_data) const; | |
| 72 std::string ExtractCoalescingKey(const syncer::SyncData& sync_data) const; | |
| 73 GURL ExtractOriginUrl(const syncer::SyncData& sync_data) const; | |
| 74 GURL ExtractIconUrl(const syncer::SyncData& sync_data) const; | |
| 75 GURL ExtractImageUrl(const syncer::SyncData& sync_data) const; | |
| 76 std::string ExtractFirstExternalId(const syncer::SyncData& sync_data) const; | |
| 77 std::string ExtractNotificationId(const syncer::SyncData& sync_data) const; | |
| 78 std::string ExtractBody(const syncer::SyncData& sync_data) const; | |
| 79 | |
| 80 // Set this to true if we make any changes to the client data. | |
| 81 bool has_local_changes_; | |
| 82 | |
| 83 // We need to hold onto the sync data object because GetAllSyncData | |
| 84 // may ask for it back. | |
| 85 syncer::SyncData sync_data_; | |
| 86 | |
| 87 // TODO(petewil): this list is not all inclusive, add the remaining fields. | |
| 88 const std::string title_; | |
| 89 const std::string app_id_; | |
| 90 const std::string coalescing_key_; | |
| 91 const std::string first_external_id_; | |
| 92 const std::string notification_id_; | |
| 93 const std::string body_; | |
| 94 const GURL origin_url_; | |
| 95 const GURL icon_url_; | |
| 96 const GURL image_url_; | |
| 97 | |
| 98 DISALLOW_COPY_AND_ASSIGN(SyncedNotification); | |
| 99 }; | |
| 100 | |
| 101 } // namespace notifier | |
| 102 | |
| 103 #endif // CHROME_BROWSER_NOTIFIER_SYNCED_NOTIFICATION_H_ | |
| OLD | NEW |