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 "googleurl/src/gurl.h" | |
| 13 #include "sync/api/sync_data.h" | |
| 14 #include "sync/protocol/sync.pb.h" | |
| 15 #include "sync/protocol/synced_notification_specifics.pb.h" | |
| 16 | |
| 17 namespace notifier { | |
| 18 | |
| 19 class SyncedNotification { | |
| 20 public: | |
| 21 explicit SyncedNotification(const syncer::SyncData& sync_data); | |
| 22 | |
| 23 ~SyncedNotification(); | |
| 24 | |
| 25 // Here are some helper functions to get individual data parts out of a | |
| 26 // SyncedNotification. | |
| 27 const std::string& title() const { return title_; } | |
| 28 const std::string& app_id() const { return app_id_; } | |
| 29 const std::string& coalescing_key() const { return coalescing_key_; } | |
| 30 const GURL& origin_url() const { return origin_url_; } | |
| 31 const GURL& icon_url() const { return icon_url_; } | |
| 32 const GURL& image_url() const { return image_url_; } | |
| 33 const std::string& first_external_id() const { return first_external_id_; } | |
| 34 const std::string& notification_id() const { return notification_id_; } | |
| 35 const std::string& body() const { return body_; } | |
|
dcheng
2013/01/25 22:23:48
Formatting.
Pete Williamson
2013/01/26 02:17:09
Done.
| |
| 36 | |
| 37 bool Equals(const SyncedNotification& other) const; | |
| 38 | |
| 39 void set_has_local_changes(bool has_local_changes) { | |
| 40 has_local_changes_ = has_local_changes; | |
| 41 } | |
| 42 | |
| 43 bool has_local_changes() const { | |
| 44 return has_local_changes_; | |
| 45 } | |
| 46 | |
| 47 const syncer::SyncData* sync_data() const { | |
| 48 return &sync_data_; | |
| 49 } | |
| 50 | |
| 51 void NotificationHasBeenRead(); | |
| 52 | |
| 53 void NotificationHasBeenDeleted(); | |
| 54 | |
| 55 // This gets a pointer to the SyncedNotificationSpecifics part | |
| 56 // of the sync data. This is owned by the SyncedNotification class | |
| 57 // (actually refcounted, so it is jointly owned with sync). | |
| 58 // Don't free this pointer! | |
| 59 const sync_pb::SyncedNotificationSpecifics* GetSyncedNotificationSpecifics(); | |
| 60 | |
| 61 private: | |
| 62 // helper function to mark a notification as read or dismissed. | |
| 63 bool SetReadState( | |
| 64 sync_pb::CoalescedSyncedNotification_ReadState readState); | |
| 65 | |
| 66 // Parsing functions to get this information out of the sync_data and into | |
| 67 // our local variables. | |
|
dcheng
2013/01/25 22:23:48
Probably should be called ExtractFoo or ParseFoo t
Pete Williamson
2013/01/26 02:17:09
Done.
| |
| 68 std::string GetTitle(const syncer::SyncData& sync_data) const; | |
| 69 std::string GetAppId(const syncer::SyncData& sync_data) const; | |
| 70 std::string GetCoalescingKey(const syncer::SyncData& sync_data) const; | |
| 71 GURL GetOriginUrl(const syncer::SyncData& sync_data) const; | |
| 72 GURL GetIconUrl(const syncer::SyncData& sync_data) const; | |
| 73 GURL GetImageUrl(const syncer::SyncData& sync_data) const; | |
| 74 std::string GetFirstExternalId(const syncer::SyncData& sync_data) const; | |
| 75 std::string GetNotificationId(const syncer::SyncData& sync_data) const; | |
| 76 std::string GetBody(const syncer::SyncData& sync_data) const; | |
| 77 | |
| 78 // Set this to true if we make any changes to the client data. | |
| 79 bool has_local_changes_; | |
| 80 | |
| 81 // We need to hold onto the sync data object because GetAllSyncData | |
| 82 // may ask for it back. | |
| 83 syncer::SyncData sync_data_; | |
| 84 | |
| 85 // TODO(petewil): this list is not all inclusive, add the remaining fields. | |
| 86 std::string title_; | |
| 87 std::string app_id_; | |
| 88 std::string coalescing_key_; | |
| 89 std::string first_external_id_; | |
| 90 std::string notification_id_; | |
| 91 std::string body_; | |
| 92 GURL origin_url_; | |
| 93 GURL icon_url_; | |
| 94 GURL image_url_; | |
| 95 | |
| 96 DISALLOW_COPY_AND_ASSIGN(SyncedNotification); | |
| 97 }; | |
| 98 | |
| 99 } // namespace notifier | |
| 100 | |
| 101 #endif // CHROME_BROWSER_NOTIFIER_SYNCED_NOTIFICATION_H_ | |
| OLD | NEW |