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