| 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/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/api/infobars/confirm_infobar_delegate.h" | 10 #include "chrome/browser/api/infobars/confirm_infobar_delegate.h" |
| 11 #include "chrome/browser/api/infobars/infobar_service.h" | 11 #include "chrome/browser/api/infobars/infobar_service.h" |
| 12 #include "chrome/browser/browser_process.h" | 12 #include "chrome/browser/browser_process.h" |
| 13 #include "chrome/browser/content_settings/content_settings_details.h" | 13 #include "chrome/browser/content_settings/content_settings_details.h" |
| 14 #include "chrome/browser/content_settings/content_settings_provider.h" | 14 #include "chrome/browser/content_settings/content_settings_provider.h" |
| 15 #include "chrome/browser/content_settings/host_content_settings_map.h" | 15 #include "chrome/browser/content_settings/host_content_settings_map.h" |
| 16 #include "chrome/browser/extensions/extension_service.h" | 16 #include "chrome/browser/extensions/extension_service.h" |
| 17 #include "chrome/browser/extensions/extension_system.h" | 17 #include "chrome/browser/extensions/extension_system.h" |
| 18 #include "chrome/browser/notifications/desktop_notification_service_factory.h" | 18 #include "chrome/browser/notifications/desktop_notification_service_factory.h" |
| 19 #include "chrome/browser/notifications/notification.h" | 19 #include "chrome/browser/notifications/notification.h" |
| 20 #include "chrome/browser/notifications/notification_object_proxy.h" | 20 #include "chrome/browser/notifications/notification_object_proxy.h" |
| 21 #include "chrome/browser/notifications/notification_ui_manager.h" | 21 #include "chrome/browser/notifications/notification_ui_manager.h" |
| 22 #include "chrome/browser/prefs/pref_service.h" | 22 #include "chrome/browser/prefs/pref_registry_syncable.h" |
| 23 #include "chrome/browser/prefs/scoped_user_pref_update.h" | 23 #include "chrome/browser/prefs/scoped_user_pref_update.h" |
| 24 #include "chrome/browser/profiles/profile.h" | 24 #include "chrome/browser/profiles/profile.h" |
| 25 #include "chrome/browser/ui/browser.h" | 25 #include "chrome/browser/ui/browser.h" |
| 26 #include "chrome/common/chrome_notification_types.h" | 26 #include "chrome/common/chrome_notification_types.h" |
| 27 #include "chrome/common/content_settings.h" | 27 #include "chrome/common/content_settings.h" |
| 28 #include "chrome/common/content_settings_pattern.h" | 28 #include "chrome/common/content_settings_pattern.h" |
| 29 #include "chrome/common/pref_names.h" | 29 #include "chrome/common/pref_names.h" |
| 30 #include "chrome/common/url_constants.h" | 30 #include "chrome/common/url_constants.h" |
| 31 #include "content/public/browser/browser_thread.h" | 31 #include "content/public/browser/browser_thread.h" |
| 32 #include "content/public/browser/notification_service.h" | 32 #include "content/public/browser/notification_service.h" |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 185 UMA_HISTOGRAM_COUNTS("NotificationPermissionRequest.Denied", 1); | 185 UMA_HISTOGRAM_COUNTS("NotificationPermissionRequest.Denied", 1); |
| 186 notification_service_->DenyPermission(origin_); | 186 notification_service_->DenyPermission(origin_); |
| 187 action_taken_ = true; | 187 action_taken_ = true; |
| 188 return true; | 188 return true; |
| 189 } | 189 } |
| 190 | 190 |
| 191 | 191 |
| 192 // DesktopNotificationService ------------------------------------------------- | 192 // DesktopNotificationService ------------------------------------------------- |
| 193 | 193 |
| 194 // static | 194 // static |
| 195 void DesktopNotificationService::RegisterUserPrefs(PrefServiceSyncable* prefs) { | 195 void DesktopNotificationService::RegisterUserPrefs( |
| 196 PrefRegistrySyncable* registry) { |
| 196 #if defined(OS_CHROMEOS) || defined(ENABLE_MESSAGE_CENTER) | 197 #if defined(OS_CHROMEOS) || defined(ENABLE_MESSAGE_CENTER) |
| 197 prefs->RegisterListPref(prefs::kMessageCenterDisabledExtensionIds, | 198 registry->RegisterListPref(prefs::kMessageCenterDisabledExtensionIds, |
| 198 PrefServiceSyncable::SYNCABLE_PREF); | 199 PrefRegistrySyncable::SYNCABLE_PREF); |
| 199 #endif | 200 #endif |
| 200 } | 201 } |
| 201 | 202 |
| 202 // static | 203 // static |
| 203 string16 DesktopNotificationService::CreateDataUrl( | 204 string16 DesktopNotificationService::CreateDataUrl( |
| 204 const GURL& icon_url, const string16& title, const string16& body, | 205 const GURL& icon_url, const string16& title, const string16& body, |
| 205 WebTextDirection dir) { | 206 WebTextDirection dir) { |
| 206 int resource; | 207 int resource; |
| 207 std::vector<std::string> subst; | 208 std::vector<std::string> subst; |
| 208 if (icon_url.is_valid()) { | 209 if (icon_url.is_valid()) { |
| (...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 601 | 602 |
| 602 if (setting == CONTENT_SETTING_ALLOW) | 603 if (setting == CONTENT_SETTING_ALLOW) |
| 603 return WebKit::WebNotificationPresenter::PermissionAllowed; | 604 return WebKit::WebNotificationPresenter::PermissionAllowed; |
| 604 if (setting == CONTENT_SETTING_BLOCK) | 605 if (setting == CONTENT_SETTING_BLOCK) |
| 605 return WebKit::WebNotificationPresenter::PermissionDenied; | 606 return WebKit::WebNotificationPresenter::PermissionDenied; |
| 606 if (setting == CONTENT_SETTING_ASK) | 607 if (setting == CONTENT_SETTING_ASK) |
| 607 return WebKit::WebNotificationPresenter::PermissionNotAllowed; | 608 return WebKit::WebNotificationPresenter::PermissionNotAllowed; |
| 608 NOTREACHED() << "Invalid notifications settings value: " << setting; | 609 NOTREACHED() << "Invalid notifications settings value: " << setting; |
| 609 return WebKit::WebNotificationPresenter::PermissionNotAllowed; | 610 return WebKit::WebNotificationPresenter::PermissionNotAllowed; |
| 610 } | 611 } |
| OLD | NEW |