15821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Copyright (c) 2012 The Chromium Authors. All rights reserved. 25821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be 35821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// found in the LICENSE file. 45821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 55821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#ifndef CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_H_ 65821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_H_ 75821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 85821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include <string> 95821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "base/basictypes.h" 115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "base/memory/scoped_ptr.h" 12868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#include "base/strings/string16.h" 135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "base/values.h" 145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/browser/notifications/notification_delegate.h" 157d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)#include "third_party/WebKit/public/web/WebTextDirection.h" 16868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#include "ui/message_center/notification.h" 172a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "ui/message_center/notification_types.h" 18eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch#include "url/gurl.h" 195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 201320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tuccinamespace gfx { 211320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucciclass Image; 221320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci} 231320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci 245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Representation of a notification to be shown to the user. 255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// On non-Ash platforms these are rendered as HTML, sometimes described by a 265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// data url converted from text + icon data. On Ash they are rendered as 275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// formated text and icon data. 28868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)class Notification : public message_center::Notification { 295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) public: 305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Initializes a notification with text content. On non-ash platforms, this 315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // creates an HTML representation using a data: URL for display. 325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) Notification(const GURL& origin_url, 335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) const GURL& icon_url, 34a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) const base::string16& title, 35a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) const base::string16& body, 36f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) blink::WebTextDirection dir, 37a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) const base::string16& display_source, 38a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) const base::string16& replace_id, 395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) NotificationDelegate* delegate); 405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 41868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) Notification( 42868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) message_center::NotificationType type, 43868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) const GURL& origin_url, 44a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) const base::string16& title, 45a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) const base::string16& body, 46868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) const gfx::Image& icon, 47f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) blink::WebTextDirection dir, 48424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) const message_center::NotifierId& notifier_id, 49a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) const base::string16& display_source, 50a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) const base::string16& replace_id, 51868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) const message_center::RichNotificationData& rich_notification_data, 52868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) NotificationDelegate* delegate); 53868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) Notification(const Notification& notification); 55868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) virtual ~Notification(); 565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) Notification& operator=(const Notification& notification); 575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // The origin URL of the script which requested the notification. 595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) const GURL& origin_url() const { return origin_url_; } 605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // A url for the icon to be shown (optional). 625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) const GURL& icon_url() const { return icon_url_; } 635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // A unique identifier used to update (replace) or remove a notification. 65a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) const base::string16& replace_id() const { return replace_id_; } 665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 67868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) // A url for the button icons to be shown (optional). 68868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) const GURL& button_one_icon_url() const { return button_one_icon_url_; } 69868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) const GURL& button_two_icon_url() const { return button_two_icon_url_; } 705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 71868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) // A url for the image to be shown (optional). 72868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) const GURL& image_url() const { return image_url_; } 735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 746d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) // Id of the delegate embedded inside this instance. 756d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles) std::string delegate_id() const { return delegate()->id(); } 765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) NotificationDelegate* delegate() const { return delegate_.get(); } 785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 7990dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) private: 805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // The Origin of the page/worker which created this notification. 815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) GURL origin_url_; 825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // URL for the icon associated with the notification. Requires delegate_ 845821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // to have a non NULL RenderViewHost. 855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) GURL icon_url_; 865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 87868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) // The URLs of the button images for a rich notification. 88868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) GURL button_one_icon_url_; 89868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) GURL button_two_icon_url_; 905821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 91868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) // The URL of a large image to be displayed for a a rich notification. 92868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) GURL image_url_; 935821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 94868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) // The user-supplied replace ID for the notification. 95a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) base::string16 replace_id_; 965821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 975821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // A proxy object that allows access back to the JavaScript object that 985821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // represents the notification, for firing events. 995821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) scoped_refptr<NotificationDelegate> delegate_; 1005821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}; 1015821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif // CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_H_ 103