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

Side by Side Diff: chrome/browser/extensions/app_notification.h

Issue 8567018: Limit number of notifications that can be received by the client. (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: '' Created 9 years, 1 month 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 #ifndef CHROME_BROWSER_EXTENSIONS_APP_NOTIFICATION_H_ 5 #ifndef CHROME_BROWSER_EXTENSIONS_APP_NOTIFICATION_H_
6 #define CHROME_BROWSER_EXTENSIONS_APP_NOTIFICATION_H_ 6 #define CHROME_BROWSER_EXTENSIONS_APP_NOTIFICATION_H_
7 #pragma once 7 #pragma once
8 8
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/time.h"
12 #include "base/memory/linked_ptr.h" 13 #include "base/memory/linked_ptr.h"
13 #include "base/values.h" 14 #include "base/values.h"
14 #include "googleurl/src/gurl.h" 15 #include "googleurl/src/gurl.h"
15 16
16 // This class is used to represent a notification for an installed app, to be 17 // This class is used to represent a notification for an installed app, to be
17 // displayed on the New Tab Page. 18 // displayed on the New Tab Page.
18 class AppNotification { 19 class AppNotification {
19 public: 20 public:
20 // Creates an instance with the given properties. 21 // Creates an instance with the given properties.
21 // If |is_local| is true, notification is not synced. 22 // If |is_local| is true, notification is not synced.
22 // If |guid| is empty, a new guid is automatically created. 23 // If |guid| is empty, a new guid is automatically created.
23 AppNotification(bool is_local, 24 AppNotification(bool is_local,
25 const base::Time creation_time,
asargent_no_longer_on_chrome 2011/11/17 23:40:14 nit: make this "const base::Time&"
elvin 2011/11/18 00:10:18 Done.
24 const std::string& guid, 26 const std::string& guid,
25 const std::string& extension_id, 27 const std::string& extension_id,
26 const std::string& title, 28 const std::string& title,
27 const std::string& body); 29 const std::string& body);
28 ~AppNotification(); 30 ~AppNotification();
29 31
30 // Returns a new object that is a copy of this one. 32 // Returns a new object that is a copy of this one.
31 // Caller owns the returned instance. 33 // Caller owns the returned instance.
32 AppNotification* Copy(); 34 AppNotification* Copy();
33 35
34 // Setters for optional properties. 36 // Setters for optional properties.
35 void set_link_url(const GURL& url) { link_url_ = url; } 37 void set_link_url(const GURL& url) { link_url_ = url; }
36 void set_link_text(const std::string& text) { link_text_ = text; } 38 void set_link_text(const std::string& text) { link_text_ = text; }
39 void set_creation_time(const base::Time& creation_time) {
40 creation_time_ = creation_time;
41 }
37 42
38 // Accessors. 43 // Accessors.
39 bool is_local() const { return is_local_; } 44 bool is_local() const { return is_local_; }
45 const base::Time creation_time() const { return creation_time_; }
40 const std::string& guid() const { return guid_; } 46 const std::string& guid() const { return guid_; }
41 const std::string& extension_id() const { return extension_id_; } 47 const std::string& extension_id() const { return extension_id_; }
42 const std::string& title() const { return title_; } 48 const std::string& title() const { return title_; }
43 const std::string& body() const { return body_; } 49 const std::string& body() const { return body_; }
44 const GURL& link_url() const { return link_url_; } 50 const GURL& link_url() const { return link_url_; }
45 const std::string& link_text() const { return link_text_; } 51 const std::string& link_text() const { return link_text_; }
46 52
47 // Useful methods for serialization. 53 // Useful methods for serialization.
48 void ToDictionaryValue(DictionaryValue* result); 54 void ToDictionaryValue(DictionaryValue* result);
49 static AppNotification* FromDictionaryValue(const DictionaryValue& value); 55 static AppNotification* FromDictionaryValue(const DictionaryValue& value);
50 56
51 // Return whether |other| is equal to this object. Useful for tests. 57 // Return whether |other| is equal to this object. Useful for tests.
52 bool Equals(const AppNotification& other) const; 58 bool Equals(const AppNotification& other) const;
53 59
54 private: 60 private:
55 // If you add to the list of data members, make sure to add appropriate checks 61 // If you add to the list of data members, make sure to add appropriate checks
56 // to the Equals, Copy and {To,From}DictionaryValue methods, keeping in mind 62 // to the Equals, Copy and {To,From}DictionaryValue methods, keeping in mind
57 // backwards compatibility. 63 // backwards compatibility.
58 64
59 // Whether notification is local only, which means it is not synced 65 // Whether notification is local only, which means it is not synced
60 // across machines. 66 // across machines.
61 bool is_local_; 67 bool is_local_;
68 base::Time creation_time_;
62 std::string guid_; 69 std::string guid_;
63 std::string extension_id_; 70 std::string extension_id_;
64 std::string title_; 71 std::string title_;
65 std::string body_; 72 std::string body_;
66 GURL link_url_; 73 GURL link_url_;
67 std::string link_text_; 74 std::string link_text_;
68 75
69 DISALLOW_COPY_AND_ASSIGN(AppNotification); 76 DISALLOW_COPY_AND_ASSIGN(AppNotification);
70 }; 77 };
71 78
72 // A list of AppNotification's. 79 // A list of AppNotification's.
73 typedef std::vector<linked_ptr<AppNotification> > AppNotificationList; 80 typedef std::vector<linked_ptr<AppNotification> > AppNotificationList;
74 81
75 // A way to copy an AppNotificationList, which uses AppNotification::Copy on 82 // A way to copy an AppNotificationList, which uses AppNotification::Copy on
76 // each element. 83 // each element.
77 // Caller owns the returned instance. 84 // Caller owns the returned instance.
78 AppNotificationList* CopyAppNotificationList(const AppNotificationList& source); 85 AppNotificationList* CopyAppNotificationList(const AppNotificationList& source);
79 86
80 #endif // CHROME_BROWSER_EXTENSIONS_APP_NOTIFICATION_H_ 87 #endif // CHROME_BROWSER_EXTENSIONS_APP_NOTIFICATION_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/extensions/app_notification.cc » ('j') | chrome/browser/extensions/app_notification.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698