| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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/notifications/notification.h" | 10 #include "chrome/browser/notifications/notification.h" |
| 11 #include "chrome/browser/notifications/notification_ui_manager.h" | 11 #include "chrome/browser/notifications/notification_ui_manager.h" |
| 12 #include "chrome/browser/ui/views/ash/balloon_collection_impl_ash.h" | 12 #include "chrome/browser/ui/views/ash/balloon_collection_impl_ash.h" |
| 13 #include "chrome/browser/ui/webui/web_ui_util.h" | 13 #include "chrome/browser/ui/webui/web_ui_util.h" |
| 14 #include "chromeos/dbus/dbus_thread_manager.h" | 14 #include "chromeos/dbus/dbus_thread_manager.h" |
| 15 | 15 |
| 16 namespace chromeos { | 16 namespace chromeos { |
| 17 | 17 |
| 18 void SystemNotification::Init(int icon_resource_id) { | 18 void SystemNotification::Init(int icon_resource_id) { |
| 19 DBusThreadManager::Get()->GetPowerManagerClient()->AddObserver(this); | 19 DBusThreadManager::Get()->GetSessionManagerClient()->AddObserver(this); |
| 20 collection_ = static_cast<BalloonCollectionImplAsh*>( | 20 collection_ = static_cast<BalloonCollectionImplAsh*>( |
| 21 g_browser_process->notification_ui_manager()->balloon_collection()); | 21 g_browser_process->notification_ui_manager()->balloon_collection()); |
| 22 std::string url = web_ui_util::GetImageDataUrlFromResource(icon_resource_id); | 22 std::string url = web_ui_util::GetImageDataUrlFromResource(icon_resource_id); |
| 23 DCHECK(!url.empty()); | 23 DCHECK(!url.empty()); |
| 24 GURL tmp_gurl(url); | 24 GURL tmp_gurl(url); |
| 25 icon_.Swap(&tmp_gurl); | 25 icon_.Swap(&tmp_gurl); |
| 26 } | 26 } |
| 27 | 27 |
| 28 SystemNotification::SystemNotification(Profile* profile, | 28 SystemNotification::SystemNotification(Profile* profile, |
| 29 NotificationDelegate* delegate, | 29 NotificationDelegate* delegate, |
| (...skipping 19 matching lines...) Expand all Loading... |
| 49 delegate_(new Delegate(id)), | 49 delegate_(new Delegate(id)), |
| 50 title_(title), | 50 title_(title), |
| 51 visible_(false), | 51 visible_(false), |
| 52 sticky_(false), | 52 sticky_(false), |
| 53 urgent_(false), | 53 urgent_(false), |
| 54 show_on_unlock_(false) { | 54 show_on_unlock_(false) { |
| 55 Init(icon_resource_id); | 55 Init(icon_resource_id); |
| 56 } | 56 } |
| 57 | 57 |
| 58 SystemNotification::~SystemNotification() { | 58 SystemNotification::~SystemNotification() { |
| 59 DBusThreadManager::Get()->GetPowerManagerClient()->RemoveObserver(this); | 59 DBusThreadManager::Get()->GetSessionManagerClient()->RemoveObserver(this); |
| 60 } | 60 } |
| 61 | 61 |
| 62 void SystemNotification::UnlockScreen() { | 62 void SystemNotification::UnlockScreen() { |
| 63 if (show_on_unlock_) { | 63 if (show_on_unlock_) { |
| 64 DCHECK(!visible_); | 64 DCHECK(!visible_); |
| 65 Notification notify = SystemNotificationFactory::Create( | 65 Notification notify = SystemNotificationFactory::Create( |
| 66 icon_, title_, message_, link_, delegate_.get()); | 66 icon_, title_, message_, link_, delegate_.get()); |
| 67 ShowNotification(notify); | 67 ShowNotification(notify); |
| 68 } | 68 } |
| 69 } | 69 } |
| 70 | 70 |
| 71 void SystemNotification::Show(const string16& message, | 71 void SystemNotification::Show(const string16& message, |
| 72 bool urgent, | 72 bool urgent, |
| 73 bool sticky) { | 73 bool sticky) { |
| 74 Show(message, string16(), BalloonViewHost::MessageCallback(), urgent, sticky); | 74 Show(message, string16(), BalloonViewHost::MessageCallback(), urgent, sticky); |
| 75 } | 75 } |
| 76 | 76 |
| 77 void SystemNotification::Show(const string16& message, | 77 void SystemNotification::Show(const string16& message, |
| 78 const string16& link, | 78 const string16& link, |
| 79 const BalloonViewHost::MessageCallback& callback, | 79 const BalloonViewHost::MessageCallback& callback, |
| 80 bool urgent, | 80 bool urgent, |
| 81 bool sticky) { | 81 bool sticky) { |
| 82 message_ = message; | 82 message_ = message; |
| 83 link_ = link; | 83 link_ = link; |
| 84 callback_ = callback; | 84 callback_ = callback; |
| 85 sticky_ = sticky; | 85 sticky_ = sticky; |
| 86 | 86 |
| 87 if (DBusThreadManager::Get()->GetPowerManagerClient()->GetIsScreenLocked()) { | 87 if (DBusThreadManager::Get()->GetSessionManagerClient()-> |
| 88 GetIsScreenLocked()) { |
| 88 if (visible_ && urgent && !urgent_) { | 89 if (visible_ && urgent && !urgent_) { |
| 89 // Hide the notification so that we show/update it on unlock. | 90 // Hide the notification so that we show/update it on unlock. |
| 90 Hide(); | 91 Hide(); |
| 91 urgent_ = true; | 92 urgent_ = true; |
| 92 } | 93 } |
| 93 if (!visible_) | 94 if (!visible_) |
| 94 show_on_unlock_ = true; | 95 show_on_unlock_ = true; |
| 95 return; | 96 return; |
| 96 } | 97 } |
| 97 | 98 |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 } | 138 } |
| 138 | 139 |
| 139 content::RenderViewHost* | 140 content::RenderViewHost* |
| 140 SystemNotification::Delegate::GetRenderViewHost() const { | 141 SystemNotification::Delegate::GetRenderViewHost() const { |
| 141 return NULL; | 142 return NULL; |
| 142 } | 143 } |
| 143 | 144 |
| 144 SystemNotification::Delegate::~Delegate() {} | 145 SystemNotification::Delegate::~Delegate() {} |
| 145 | 146 |
| 146 } // namespace chromeos | 147 } // namespace chromeos |
| OLD | NEW |