Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(166)

Side by Side Diff: chrome/browser/notifications/sync_notifier/synced_notification.h

Issue 11745024: Synced Notification Sync Change Processor (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Synced Notification Change Processor - remove unused header Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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_NOTIFICATIONS_SYNC_NOTIFIER_SYNCED_NOTIFICATION_H_
10 #define CHROME_BROWSER_NOTIFICATIONS_SYNC_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/synced_notification_specifics.pb.h"
17
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;
30 const std::string& app_id() const;
31 const std::string& coalescing_key() const;
32 const GURL& origin_url() const;
33 const GURL& icon_url() const;
34 const GURL& image_url() const;
35 const std::string& first_external_id() const;
36 const std::string& notification_id() const;
37 const std::string& body() const;
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.
65 bool SetReadState(
66 const sync_pb::CoalescedSyncedNotification_ReadState& read_state);
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 // We need to hold onto the sync data object because GetAllSyncData
81 // may ask for it back.
82 syncer::SyncData sync_data_;
83
84 // Set this to true if we make any changes to the client data.
85 bool has_local_changes_;
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_NOTIFICATIONS_SYNC_NOTIFIER_SYNCED_NOTIFICATION_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698