| 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/notifications/desktop_notification_service.h" | 5 #include "chrome/browser/notifications/desktop_notification_service.h" |
| 6 | 6 |
| 7 #include "app/l10n_util.h" | 7 #include "app/l10n_util.h" |
| 8 #include "app/resource_bundle.h" | 8 #include "app/resource_bundle.h" |
| 9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
| 10 #include "base/thread.h" | 10 #include "base/thread.h" |
| (...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 310 | 310 |
| 311 void DesktopNotificationService::Observe(NotificationType type, | 311 void DesktopNotificationService::Observe(NotificationType type, |
| 312 const NotificationSource& source, | 312 const NotificationSource& source, |
| 313 const NotificationDetails& details) { | 313 const NotificationDetails& details) { |
| 314 if (NotificationType::PREF_CHANGED == type) { | 314 if (NotificationType::PREF_CHANGED == type) { |
| 315 const std::string& name = *Details<std::string>(details).ptr(); | 315 const std::string& name = *Details<std::string>(details).ptr(); |
| 316 OnPrefsChanged(name); | 316 OnPrefsChanged(name); |
| 317 } else if (NotificationType::EXTENSION_UNLOADED == type) { | 317 } else if (NotificationType::EXTENSION_UNLOADED == type) { |
| 318 // Remove all notifications currently shown or queued by the extension | 318 // Remove all notifications currently shown or queued by the extension |
| 319 // which was unloaded. | 319 // which was unloaded. |
| 320 Extension* extension = Details<Extension>(details).ptr(); | 320 const Extension* extension = |
| 321 Details<UnloadedExtensionInfo>(details)->extension; |
| 321 if (extension) | 322 if (extension) |
| 322 ui_manager_->CancelAllBySourceOrigin(extension->url()); | 323 ui_manager_->CancelAllBySourceOrigin(extension->url()); |
| 323 } else if (NotificationType::PROFILE_DESTROYED == type) { | 324 } else if (NotificationType::PROFILE_DESTROYED == type) { |
| 324 StopObserving(); | 325 StopObserving(); |
| 325 } | 326 } |
| 326 } | 327 } |
| 327 | 328 |
| 328 void DesktopNotificationService::OnPrefsChanged(const std::string& pref_name) { | 329 void DesktopNotificationService::OnPrefsChanged(const std::string& pref_name) { |
| 329 PrefService* prefs = profile_->GetPrefs(); | 330 PrefService* prefs = profile_->GetPrefs(); |
| 330 | 331 |
| (...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 629 } | 630 } |
| 630 return UTF8ToUTF16(origin.host()); | 631 return UTF8ToUTF16(origin.host()); |
| 631 } | 632 } |
| 632 | 633 |
| 633 void DesktopNotificationService::NotifySettingsChange() { | 634 void DesktopNotificationService::NotifySettingsChange() { |
| 634 NotificationService::current()->Notify( | 635 NotificationService::current()->Notify( |
| 635 NotificationType::DESKTOP_NOTIFICATION_SETTINGS_CHANGED, | 636 NotificationType::DESKTOP_NOTIFICATION_SETTINGS_CHANGED, |
| 636 Source<DesktopNotificationService>(this), | 637 Source<DesktopNotificationService>(this), |
| 637 NotificationService::NoDetails()); | 638 NotificationService::NoDetails()); |
| 638 } | 639 } |
| OLD | NEW |