Chromium Code Reviews| Index: chrome/browser/notifier/synced_notification.h |
| diff --git a/chrome/browser/notifier/synced_notification.h b/chrome/browser/notifier/synced_notification.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..35a9d118ad4a6e5105c4f6bdc092de74cb5aeecb |
| --- /dev/null |
| +++ b/chrome/browser/notifier/synced_notification.h |
| @@ -0,0 +1,101 @@ |
| +// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +// This class represents the data for a single Synced Notification. |
| +// It should map 1-1 to all the data in synced_notification_sepcifics.proto, |
| +// and the data and render protobufs that the specifics protobuf contains. |
| + |
| +#ifndef CHROME_BROWSER_NOTIFIER_SYNCED_NOTIFICATION_H_ |
| +#define CHROME_BROWSER_NOTIFIER_SYNCED_NOTIFICATION_H_ |
| + |
| +#include "googleurl/src/gurl.h" |
| +#include "sync/api/sync_data.h" |
| +#include "sync/protocol/sync.pb.h" |
| +#include "sync/protocol/synced_notification_specifics.pb.h" |
| + |
| +namespace notifier { |
| + |
| +class SyncedNotification { |
| + public: |
| + explicit SyncedNotification(const syncer::SyncData& sync_data); |
| + |
| + ~SyncedNotification(); |
| + |
| + // Here are some helper functions to get individual data parts out of a |
| + // SyncedNotification. |
| + const std::string& title() const { return title_; } |
| + const std::string& app_id() const { return app_id_; } |
| + const std::string& coalescing_key() const { return coalescing_key_; } |
| + const GURL& origin_url() const { return origin_url_; } |
| + const GURL& icon_url() const { return icon_url_; } |
| + const GURL& image_url() const { return image_url_; } |
| + const std::string& first_external_id() const { return first_external_id_; } |
| +const std::string& notification_id() const { return notification_id_; } |
| +const std::string& body() const { return body_; } |
|
dcheng
2013/01/25 22:23:48
Formatting.
Pete Williamson
2013/01/26 02:17:09
Done.
|
| + |
| + bool Equals(const SyncedNotification& other) const; |
| + |
| + void set_has_local_changes(bool has_local_changes) { |
| + has_local_changes_ = has_local_changes; |
| + } |
| + |
| + bool has_local_changes() const { |
| + return has_local_changes_; |
| + } |
| + |
| + const syncer::SyncData* sync_data() const { |
| + return &sync_data_; |
| + } |
| + |
| + void NotificationHasBeenRead(); |
| + |
| + void NotificationHasBeenDeleted(); |
| + |
| + // This gets a pointer to the SyncedNotificationSpecifics part |
| + // of the sync data. This is owned by the SyncedNotification class |
| + // (actually refcounted, so it is jointly owned with sync). |
| + // Don't free this pointer! |
| + const sync_pb::SyncedNotificationSpecifics* GetSyncedNotificationSpecifics(); |
| + |
| + private: |
| + // helper function to mark a notification as read or dismissed. |
| + bool SetReadState( |
| + sync_pb::CoalescedSyncedNotification_ReadState readState); |
| + |
| + // Parsing functions to get this information out of the sync_data and into |
| + // 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.
|
| + std::string GetTitle(const syncer::SyncData& sync_data) const; |
| + std::string GetAppId(const syncer::SyncData& sync_data) const; |
| + std::string GetCoalescingKey(const syncer::SyncData& sync_data) const; |
| + GURL GetOriginUrl(const syncer::SyncData& sync_data) const; |
| + GURL GetIconUrl(const syncer::SyncData& sync_data) const; |
| + GURL GetImageUrl(const syncer::SyncData& sync_data) const; |
| + std::string GetFirstExternalId(const syncer::SyncData& sync_data) const; |
| + std::string GetNotificationId(const syncer::SyncData& sync_data) const; |
| + std::string GetBody(const syncer::SyncData& sync_data) const; |
| + |
| + // Set this to true if we make any changes to the client data. |
| + bool has_local_changes_; |
| + |
| + // We need to hold onto the sync data object because GetAllSyncData |
| + // may ask for it back. |
| + syncer::SyncData sync_data_; |
| + |
| + // TODO(petewil): this list is not all inclusive, add the remaining fields. |
| + std::string title_; |
| + std::string app_id_; |
| + std::string coalescing_key_; |
| + std::string first_external_id_; |
| + std::string notification_id_; |
| + std::string body_; |
| + GURL origin_url_; |
| + GURL icon_url_; |
| + GURL image_url_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(SyncedNotification); |
| +}; |
| + |
| +} // namespace notifier |
| + |
| +#endif // CHROME_BROWSER_NOTIFIER_SYNCED_NOTIFICATION_H_ |