OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/chromeos/notifications/system_notification.h" | 5 #include "chrome/browser/chromeos/notifications/system_notification.h" |
6 | 6 |
7 #include "base/callback.h" | 7 #include "base/callback.h" |
8 #include "chrome/browser/browser_process.h" | 8 #include "chrome/browser/browser_process.h" |
9 #include "chrome/browser/chromeos/notifications/system_notification_factory.h" | 9 #include "chrome/browser/chromeos/notifications/system_notification_factory.h" |
10 #include "chrome/browser/dom_ui/dom_ui_util.h" | 10 #include "chrome/browser/dom_ui/dom_ui_util.h" |
11 #include "chrome/browser/notifications/notification.h" | 11 #include "chrome/browser/notifications/notification.h" |
12 #include "chrome/browser/notifications/notification_ui_manager.h" | 12 #include "chrome/browser/notifications/notification_ui_manager.h" |
13 | 13 |
14 namespace chromeos { | 14 namespace chromeos { |
15 | 15 |
| 16 void SystemNotification::Init(int icon_resource_id) { |
| 17 collection_ = static_cast<BalloonCollectionImpl*>( |
| 18 g_browser_process->notification_ui_manager()->balloon_collection()); |
| 19 std::string url = dom_ui_util::GetImageDataUrlFromResource(icon_resource_id); |
| 20 DCHECK(!url.empty()); |
| 21 GURL tmp_gurl(url); |
| 22 icon_.Swap(&tmp_gurl); |
| 23 } |
| 24 |
| 25 SystemNotification::SystemNotification(Profile* profile, |
| 26 NotificationDelegate* delegate, |
| 27 int icon_resource_id, |
| 28 const string16& title) |
| 29 : profile_(profile), |
| 30 collection_(NULL), |
| 31 delegate_(delegate), |
| 32 title_(title), |
| 33 visible_(false), |
| 34 urgent_(false) { |
| 35 Init(icon_resource_id); |
| 36 } |
| 37 |
16 SystemNotification::SystemNotification(Profile* profile, | 38 SystemNotification::SystemNotification(Profile* profile, |
17 const std::string& id, | 39 const std::string& id, |
18 int icon_resource_id, | 40 int icon_resource_id, |
19 const string16& title) | 41 const string16& title) |
20 : profile_(profile), | 42 : profile_(profile), |
21 collection_(static_cast<BalloonCollectionImpl*>( | 43 collection_(NULL), |
22 g_browser_process->notification_ui_manager()->balloon_collection())), | |
23 delegate_(new Delegate(id)), | 44 delegate_(new Delegate(id)), |
24 title_(title), | 45 title_(title), |
25 visible_(false), | 46 visible_(false), |
26 urgent_(false) { | 47 urgent_(false) { |
27 std::string url = dom_ui_util::GetImageDataUrlFromResource(icon_resource_id); | 48 Init(icon_resource_id); |
28 DCHECK(!url.empty()); | |
29 GURL tmp_gurl(url); | |
30 icon_.Swap(&tmp_gurl); | |
31 } | 49 } |
32 | 50 |
33 SystemNotification::~SystemNotification() { | 51 SystemNotification::~SystemNotification() { |
34 } | 52 } |
35 | 53 |
36 void SystemNotification::Show(const string16& message, | 54 void SystemNotification::Show(const string16& message, |
37 bool urgent, | 55 bool urgent, |
38 bool sticky) { | 56 bool sticky) { |
39 Show(message, string16(), NULL, urgent, sticky); | 57 Show(message, string16(), NULL, urgent, sticky); |
40 } | 58 } |
(...skipping 24 matching lines...) Expand all Loading... |
65 | 83 |
66 void SystemNotification::Hide() { | 84 void SystemNotification::Hide() { |
67 if (visible_) { | 85 if (visible_) { |
68 collection_->RemoveById(delegate_->id()); | 86 collection_->RemoveById(delegate_->id()); |
69 visible_ = false; | 87 visible_ = false; |
70 urgent_ = false; | 88 urgent_ = false; |
71 } | 89 } |
72 } | 90 } |
73 | 91 |
74 } // namespace chromeos | 92 } // namespace chromeos |
OLD | NEW |