| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "base/metrics/histogram.h" | 7 #include "base/metrics/histogram.h" |
| 8 #include "base/threading/thread.h" | 8 #include "base/threading/thread.h" |
| 9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
| 10 #include "chrome/browser/content_settings/content_settings_provider.h" | 10 #include "chrome/browser/content_settings/content_settings_provider.h" |
| 11 #include "chrome/browser/extensions/extension_service.h" | 11 #include "chrome/browser/extensions/extension_service.h" |
| 12 #include "chrome/browser/notifications/desktop_notification_service_factory.h" | |
| 13 #include "chrome/browser/notifications/notification.h" | 12 #include "chrome/browser/notifications/notification.h" |
| 14 #include "chrome/browser/notifications/notification_object_proxy.h" | 13 #include "chrome/browser/notifications/notification_object_proxy.h" |
| 15 #include "chrome/browser/notifications/notification_ui_manager.h" | 14 #include "chrome/browser/notifications/notification_ui_manager.h" |
| 16 #include "chrome/browser/notifications/notifications_prefs_cache.h" | 15 #include "chrome/browser/notifications/notifications_prefs_cache.h" |
| 17 #include "chrome/browser/prefs/pref_service.h" | 16 #include "chrome/browser/prefs/pref_service.h" |
| 18 #include "chrome/browser/prefs/scoped_user_pref_update.h" | 17 #include "chrome/browser/prefs/scoped_user_pref_update.h" |
| 19 #include "chrome/browser/profiles/profile.h" | 18 #include "chrome/browser/profiles/profile.h" |
| 20 #include "chrome/browser/tab_contents/confirm_infobar_delegate.h" | 19 #include "chrome/browser/tab_contents/confirm_infobar_delegate.h" |
| 21 #include "chrome/browser/ui/browser_list.h" | 20 #include "chrome/browser/ui/browser_list.h" |
| 22 #include "chrome/common/pref_names.h" | 21 #include "chrome/common/pref_names.h" |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 181 } | 180 } |
| 182 | 181 |
| 183 string16 NotificationPermissionInfoBarDelegate::GetButtonLabel( | 182 string16 NotificationPermissionInfoBarDelegate::GetButtonLabel( |
| 184 InfoBarButton button) const { | 183 InfoBarButton button) const { |
| 185 return l10n_util::GetStringUTF16((button == BUTTON_OK) ? | 184 return l10n_util::GetStringUTF16((button == BUTTON_OK) ? |
| 186 IDS_NOTIFICATION_PERMISSION_YES : IDS_NOTIFICATION_PERMISSION_NO); | 185 IDS_NOTIFICATION_PERMISSION_YES : IDS_NOTIFICATION_PERMISSION_NO); |
| 187 } | 186 } |
| 188 | 187 |
| 189 bool NotificationPermissionInfoBarDelegate::Accept() { | 188 bool NotificationPermissionInfoBarDelegate::Accept() { |
| 190 UMA_HISTOGRAM_COUNTS("NotificationPermissionRequest.Allowed", 1); | 189 UMA_HISTOGRAM_COUNTS("NotificationPermissionRequest.Allowed", 1); |
| 191 DesktopNotificationServiceFactory::GetForProfile(profile_)-> | 190 profile_->GetDesktopNotificationService()->GrantPermission(origin_); |
| 192 GrantPermission(origin_); | |
| 193 action_taken_ = true; | 191 action_taken_ = true; |
| 194 return true; | 192 return true; |
| 195 } | 193 } |
| 196 | 194 |
| 197 bool NotificationPermissionInfoBarDelegate::Cancel() { | 195 bool NotificationPermissionInfoBarDelegate::Cancel() { |
| 198 UMA_HISTOGRAM_COUNTS("NotificationPermissionRequest.Denied", 1); | 196 UMA_HISTOGRAM_COUNTS("NotificationPermissionRequest.Denied", 1); |
| 199 DesktopNotificationServiceFactory::GetForProfile(profile_)-> | 197 profile_->GetDesktopNotificationService()->DenyPermission(origin_); |
| 200 DenyPermission(origin_); | |
| 201 action_taken_ = true; | 198 action_taken_ = true; |
| 202 return true; | 199 return true; |
| 203 } | 200 } |
| 204 | 201 |
| 205 | 202 |
| 206 // DesktopNotificationService ------------------------------------------------- | 203 // DesktopNotificationService ------------------------------------------------- |
| 207 | 204 |
| 208 // static | 205 // static |
| 209 string16 DesktopNotificationService::CreateDataUrl( | 206 string16 DesktopNotificationService::CreateDataUrl( |
| 210 const GURL& icon_url, const string16& title, const string16& body, | 207 const GURL& icon_url, const string16& title, const string16& body, |
| (...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 585 } | 582 } |
| 586 return UTF8ToUTF16(origin.host()); | 583 return UTF8ToUTF16(origin.host()); |
| 587 } | 584 } |
| 588 | 585 |
| 589 void DesktopNotificationService::NotifySettingsChange() { | 586 void DesktopNotificationService::NotifySettingsChange() { |
| 590 NotificationService::current()->Notify( | 587 NotificationService::current()->Notify( |
| 591 NotificationType::DESKTOP_NOTIFICATION_SETTINGS_CHANGED, | 588 NotificationType::DESKTOP_NOTIFICATION_SETTINGS_CHANGED, |
| 592 Source<DesktopNotificationService>(this), | 589 Source<DesktopNotificationService>(this), |
| 593 NotificationService::NoDetails()); | 590 NotificationService::NoDetails()); |
| 594 } | 591 } |
| OLD | NEW |