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" |
11 #include "base/utf_string_conversions.h" | 11 #include "base/utf_string_conversions.h" |
12 #include "chrome/browser/browser_child_process_host.h" | 12 #include "chrome/browser/browser_child_process_host.h" |
13 #include "chrome/browser/browser_thread.h" | 13 #include "chrome/browser/browser_thread.h" |
14 #include "chrome/browser/extensions/extensions_service.h" | 14 #include "chrome/browser/extensions/extension_service.h" |
15 #include "chrome/browser/notifications/notification.h" | 15 #include "chrome/browser/notifications/notification.h" |
16 #include "chrome/browser/notifications/notification_object_proxy.h" | 16 #include "chrome/browser/notifications/notification_object_proxy.h" |
17 #include "chrome/browser/notifications/notification_ui_manager.h" | 17 #include "chrome/browser/notifications/notification_ui_manager.h" |
18 #include "chrome/browser/notifications/notifications_prefs_cache.h" | 18 #include "chrome/browser/notifications/notifications_prefs_cache.h" |
19 #include "chrome/browser/prefs/pref_service.h" | 19 #include "chrome/browser/prefs/pref_service.h" |
20 #include "chrome/browser/prefs/scoped_pref_update.h" | 20 #include "chrome/browser/prefs/scoped_pref_update.h" |
21 #include "chrome/browser/profiles/profile.h" | 21 #include "chrome/browser/profiles/profile.h" |
22 #include "chrome/browser/renderer_host/render_process_host.h" | 22 #include "chrome/browser/renderer_host/render_process_host.h" |
23 #include "chrome/browser/renderer_host/render_view_host.h" | 23 #include "chrome/browser/renderer_host/render_view_host.h" |
24 #include "chrome/browser/renderer_host/site_instance.h" | 24 #include "chrome/browser/renderer_host/site_instance.h" |
(...skipping 583 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
608 origin, contents, DisplayNameForOrigin(origin), | 608 origin, contents, DisplayNameForOrigin(origin), |
609 params.replace_id, proxy); | 609 params.replace_id, proxy); |
610 ShowNotification(notification); | 610 ShowNotification(notification); |
611 return true; | 611 return true; |
612 } | 612 } |
613 | 613 |
614 string16 DesktopNotificationService::DisplayNameForOrigin( | 614 string16 DesktopNotificationService::DisplayNameForOrigin( |
615 const GURL& origin) { | 615 const GURL& origin) { |
616 // If the source is an extension, lookup the display name. | 616 // If the source is an extension, lookup the display name. |
617 if (origin.SchemeIs(chrome::kExtensionScheme)) { | 617 if (origin.SchemeIs(chrome::kExtensionScheme)) { |
618 ExtensionsService* ext_service = profile_->GetExtensionsService(); | 618 ExtensionService* ext_service = profile_->GetExtensionService(); |
619 if (ext_service) { | 619 if (ext_service) { |
620 const Extension* extension = ext_service->GetExtensionByURL(origin); | 620 const Extension* extension = ext_service->GetExtensionByURL(origin); |
621 if (extension) | 621 if (extension) |
622 return UTF8ToUTF16(extension->name()); | 622 return UTF8ToUTF16(extension->name()); |
623 } | 623 } |
624 } | 624 } |
625 return UTF8ToUTF16(origin.host()); | 625 return UTF8ToUTF16(origin.host()); |
626 } | 626 } |
627 | 627 |
628 void DesktopNotificationService::NotifySettingsChange() { | 628 void DesktopNotificationService::NotifySettingsChange() { |
629 NotificationService::current()->Notify( | 629 NotificationService::current()->Notify( |
630 NotificationType::DESKTOP_NOTIFICATION_SETTINGS_CHANGED, | 630 NotificationType::DESKTOP_NOTIFICATION_SETTINGS_CHANGED, |
631 Source<DesktopNotificationService>(this), | 631 Source<DesktopNotificationService>(this), |
632 NotificationService::NoDetails()); | 632 NotificationService::NoDetails()); |
633 } | 633 } |
OLD | NEW |