blob: 81976b77137df78aae7b02f2181a070df28d28d3 (
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
|
// Copyright (c) 2010 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_CHROMEOS_NOTIFICATIONS_SYSTEM_NOTIFICATION_H_
#define CHROME_BROWSER_CHROMEOS_NOTIFICATIONS_SYSTEM_NOTIFICATION_H_
#pragma once
#include <string>
#include "base/basictypes.h"
#include "base/ref_counted.h"
#include "base/string16.h"
#include "chrome/browser/chromeos/notifications/balloon_collection_impl.h"
#include "chrome/browser/notifications/notification_delegate.h"
#include "googleurl/src/gurl.h"
class MessageCallback;
class Profile;
namespace chromeos {
// The system notification object handles the display of a system notification
class SystemNotification {
public:
// The profile is the current user profile. The id is any string used
// to uniquely identify this notification. The title is the title of
// the message to be displayed. On creation, the message is hidden.
SystemNotification(Profile* profile, const std::string& id,
int icon_resource_id,
const string16& title);
virtual ~SystemNotification();
void set_title(const string16& title) { title_ = title; }
// Show will show or update the message for this notification
// on a transition to urgent, the notification will be shown if it was
// previously hidden or minimized by the user.
void Show(const string16& message, bool urgent, bool sticky);
// Same as Show() above with a footer link at the bottom and a callback
// for when the link is clicked.
void Show(const string16& message, const string16& link_text,
MessageCallback* callback, bool urgent, bool sticky);
// Hide will dismiss the notification, if the notification is already
// hidden it does nothing
void Hide();
// Current visibility state for this notification.
bool visible() const { return visible_; }
// Current urgent state for this notification.
bool urgent() const { return urgent_; }
private:
class Delegate : public NotificationDelegate {
public:
explicit Delegate(const std::string& id) : id_(id) {}
void Display() {}
void Error() {}
void Close(bool by_user) {}
void Click() {}
std::string id() const { return id_; }
private:
std::string id_;
DISALLOW_COPY_AND_ASSIGN(Delegate);
};
Profile* profile_;
BalloonCollectionImpl* collection_;
scoped_refptr<Delegate> delegate_;
GURL icon_;
string16 title_;
bool visible_;
bool urgent_;
DISALLOW_COPY_AND_ASSIGN(SystemNotification);
};
} // namespace chromeos
#endif // CHROME_BROWSER_CHROMEOS_NOTIFICATIONS_SYSTEM_NOTIFICATION_H_
|