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#include "chrome/browser/notifications/notification.h" 6 7Notification::Notification(const GURL& origin_url, 8 const GURL& icon_url, 9 const base::string16& title, 10 const base::string16& body, 11 blink::WebTextDirection dir, 12 const base::string16& display_source, 13 const base::string16& replace_id, 14 NotificationDelegate* delegate) 15 : message_center::Notification(message_center::NOTIFICATION_TYPE_SIMPLE, 16 delegate->id(), 17 title, 18 body, 19 gfx::Image(), 20 display_source, 21 message_center::NotifierId(origin_url), 22 message_center::RichNotificationData(), 23 delegate), 24 origin_url_(origin_url), 25 icon_url_(icon_url), 26 replace_id_(replace_id), 27 delegate_(delegate) {} 28 29Notification::Notification( 30 message_center::NotificationType type, 31 const GURL& origin_url, 32 const base::string16& title, 33 const base::string16& body, 34 const gfx::Image& icon, 35 blink::WebTextDirection dir, 36 const message_center::NotifierId& notifier_id, 37 const base::string16& display_source, 38 const base::string16& replace_id, 39 const message_center::RichNotificationData& rich_notification_data, 40 NotificationDelegate* delegate) 41 : message_center::Notification(type, 42 delegate->id(), 43 title, 44 body, 45 icon, 46 display_source, 47 notifier_id, 48 rich_notification_data, 49 delegate), 50 origin_url_(origin_url), 51 replace_id_(replace_id), 52 delegate_(delegate) { 53 // It's important to leave |icon_url_| empty with rich notifications enabled, 54 // to prevent "Downloading" the data url and overwriting the existing |icon|. 55} 56 57Notification::Notification(const Notification& notification) 58 : message_center::Notification(notification), 59 origin_url_(notification.origin_url()), 60 icon_url_(notification.icon_url()), 61 button_one_icon_url_(notification.button_one_icon_url()), 62 button_two_icon_url_(notification.button_two_icon_url()), 63 image_url_(notification.image_url()), 64 replace_id_(notification.replace_id()), 65 delegate_(notification.delegate()) {} 66 67Notification::~Notification() {} 68 69Notification& Notification::operator=(const Notification& notification) { 70 message_center::Notification::operator=(notification); 71 origin_url_ = notification.origin_url(); 72 icon_url_ = notification.icon_url(); 73 button_one_icon_url_ = notification.button_one_icon_url(); 74 button_two_icon_url_ = notification.button_two_icon_url(); 75 image_url_ = notification.image_url(); 76 replace_id_ = notification.replace_id(); 77 delegate_ = notification.delegate(); 78 return *this; 79} 80