blob: 8fd7743c55fa0bf3cc1646341e28c52ee9b97589 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
// Copyright (c) 2011 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.
#ifndef CHROME_BROWSER_EXTENSIONS_APP_NOTIFICATION_H_
#define CHROME_BROWSER_EXTENSIONS_APP_NOTIFICATION_H_
#pragma once
#include <string>
#include <vector>
#include "base/memory/linked_ptr.h"
#include "base/values.h"
#include "googleurl/src/gurl.h"
// This class is used to represent a notification for an installed app, to be
// displayed on the New Tab Page.
class AppNotification {
public:
AppNotification(const std::string& title, const std::string& body);
~AppNotification();
// Setters for optional properties.
void set_link_url(const GURL& url) { link_url_ = url; }
void set_link_text(const std::string& text) { link_text_ = text; }
// Accessors.
const std::string& title() const { return title_; }
const std::string& body() const { return body_; }
const GURL& link_url() const { return link_url_; }
const std::string& link_text() const { return link_text_; }
// Useful methods for serialization.
void ToDictionaryValue(DictionaryValue* result);
static AppNotification* FromDictionaryValue(const DictionaryValue& value);
// Return whether |other| is equal to this object. Useful for tests.
bool Equals(const AppNotification& other) const;
private:
// If you add to the list of data members, make sure to add appropriate checks
// to the Equals and {To,From}DictionaryValue methods, keeping in mind
// backwards compatibility.
std::string title_;
std::string body_;
GURL link_url_;
std::string link_text_;
DISALLOW_COPY_AND_ASSIGN(AppNotification);
};
// A list of AppNotification's.
typedef std::vector<linked_ptr<AppNotification> > AppNotificationList;
#endif // CHROME_BROWSER_EXTENSIONS_APP_NOTIFICATION_H_
|