Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / notifications / notification.h
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 #ifndef CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_H_
6 #define CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_H_
7
8 #include <string>
9
10 #include "base/basictypes.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "base/strings/string16.h"
13 #include "base/values.h"
14 #include "chrome/browser/notifications/notification_delegate.h"
15 #include "third_party/WebKit/public/web/WebTextDirection.h"
16 #include "ui/message_center/notification.h"
17 #include "ui/message_center/notification_types.h"
18 #include "url/gurl.h"
19
20 namespace gfx {
21 class Image;
22 }
23
24 // Representation of a notification to be shown to the user.
25 class Notification : public message_center::Notification {
26  public:
27   Notification(const GURL& origin_url,
28                const base::string16& title,
29                const base::string16& body,
30                const gfx::Image& icon,
31                const base::string16& display_source,
32                const base::string16& replace_id,
33                NotificationDelegate* delegate);
34
35   Notification(
36       message_center::NotificationType type,
37       const GURL& origin_url,
38       const base::string16& title,
39       const base::string16& body,
40       const gfx::Image& icon,
41       blink::WebTextDirection dir,
42       const message_center::NotifierId& notifier_id,
43       const base::string16& display_source,
44       const base::string16& replace_id,
45       const message_center::RichNotificationData& rich_notification_data,
46       NotificationDelegate* delegate);
47
48   Notification(const std::string& id, const Notification& notification);
49
50   Notification(const Notification& notification);
51   ~Notification() override;
52   Notification& operator=(const Notification& notification);
53
54   // The origin URL of the script which requested the notification.
55   const GURL& origin_url() const { return origin_url_; }
56
57   // A unique identifier used to update (replace) or remove a notification.
58   const base::string16& replace_id() const { return replace_id_; }
59
60   // Id of the delegate embedded inside this instance.
61   std::string delegate_id() const { return delegate()->id(); }
62
63   NotificationDelegate* delegate() const { return delegate_.get(); }
64
65  private:
66   // The Origin of the page/worker which created this notification.
67   GURL origin_url_;
68
69   // The user-supplied replace ID for the notification.
70   base::string16 replace_id_;
71
72   // A proxy object that allows access back to the JavaScript object that
73   // represents the notification, for firing events.
74   scoped_refptr<NotificationDelegate> delegate_;
75 };
76
77 #endif  // CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_H_