| 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_details.h" | 10 #include "chrome/browser/content_settings/content_settings_details.h" |
| 11 #include "chrome/browser/content_settings/content_settings_provider.h" | 11 #include "chrome/browser/content_settings/content_settings_provider.h" |
| 12 #include "chrome/browser/content_settings/host_content_settings_map.h" | 12 #include "chrome/browser/content_settings/host_content_settings_map.h" |
| 13 #include "chrome/browser/extensions/extension_service.h" | 13 #include "chrome/browser/extensions/extension_service.h" |
| 14 #include "chrome/browser/infobars/infobar_tab_helper.h" | 14 #include "chrome/browser/infobars/infobar_tab_helper.h" |
| 15 #include "chrome/browser/notifications/desktop_notification_service_factory.h" | 15 #include "chrome/browser/notifications/desktop_notification_service_factory.h" |
| 16 #include "chrome/browser/notifications/notification.h" | 16 #include "chrome/browser/notifications/notification.h" |
| 17 #include "chrome/browser/notifications/notification_object_proxy.h" | 17 #include "chrome/browser/notifications/notification_object_proxy.h" |
| 18 #include "chrome/browser/notifications/notification_ui_manager.h" | 18 #include "chrome/browser/notifications/notification_ui_manager.h" |
| 19 #include "chrome/browser/prefs/pref_service.h" | 19 #include "chrome/browser/prefs/pref_service.h" |
| 20 #include "chrome/browser/prefs/scoped_user_pref_update.h" | 20 #include "chrome/browser/prefs/scoped_user_pref_update.h" |
| 21 #include "chrome/browser/profiles/profile.h" | 21 #include "chrome/browser/profiles/profile.h" |
| 22 #include "chrome/browser/tab_contents/confirm_infobar_delegate.h" | 22 #include "chrome/browser/tab_contents/confirm_infobar_delegate.h" |
| 23 #include "chrome/browser/ui/browser_list.h" | 23 #include "chrome/browser/ui/browser_list.h" |
| 24 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 24 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
| 25 #include "chrome/common/chrome_notification_types.h" | 25 #include "chrome/common/chrome_notification_types.h" |
| 26 #include "chrome/common/content_settings.h" |
| 26 #include "chrome/common/content_settings_pattern.h" | 27 #include "chrome/common/content_settings_pattern.h" |
| 27 #include "chrome/common/pref_names.h" | 28 #include "chrome/common/pref_names.h" |
| 28 #include "chrome/common/url_constants.h" | 29 #include "chrome/common/url_constants.h" |
| 29 #include "content/browser/browser_child_process_host.h" | 30 #include "content/browser/browser_child_process_host.h" |
| 30 #include "content/browser/browser_thread.h" | 31 #include "content/browser/browser_thread.h" |
| 31 #include "content/browser/renderer_host/render_process_host.h" | 32 #include "content/browser/renderer_host/render_process_host.h" |
| 32 #include "content/browser/renderer_host/render_view_host.h" | 33 #include "content/browser/renderer_host/render_view_host.h" |
| 33 #include "content/browser/site_instance.h" | 34 #include "content/browser/site_instance.h" |
| 34 #include "content/browser/worker_host/worker_process_host.h" | 35 #include "content/browser/worker_host/worker_process_host.h" |
| 35 #include "content/common/desktop_notification_messages.h" | 36 #include "content/common/desktop_notification_messages.h" |
| (...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 288 return profile_->GetHostContentSettingsMap()->IsDefaultContentSettingManaged( | 289 return profile_->GetHostContentSettingsMap()->IsDefaultContentSettingManaged( |
| 289 CONTENT_SETTINGS_TYPE_NOTIFICATIONS); | 290 CONTENT_SETTINGS_TYPE_NOTIFICATIONS); |
| 290 } | 291 } |
| 291 | 292 |
| 292 void DesktopNotificationService::ResetToDefaultContentSetting() { | 293 void DesktopNotificationService::ResetToDefaultContentSetting() { |
| 293 profile_->GetHostContentSettingsMap()->SetDefaultContentSetting( | 294 profile_->GetHostContentSettingsMap()->SetDefaultContentSetting( |
| 294 CONTENT_SETTINGS_TYPE_NOTIFICATIONS, CONTENT_SETTING_DEFAULT); | 295 CONTENT_SETTINGS_TYPE_NOTIFICATIONS, CONTENT_SETTING_DEFAULT); |
| 295 } | 296 } |
| 296 | 297 |
| 297 void DesktopNotificationService::GetNotificationsSettings( | 298 void DesktopNotificationService::GetNotificationsSettings( |
| 298 HostContentSettingsMap::SettingsForOneType* settings) { | 299 ContentSettingsForOneType* settings) { |
| 299 profile_->GetHostContentSettingsMap()->GetSettingsForOneType( | 300 profile_->GetHostContentSettingsMap()->GetSettingsForOneType( |
| 300 CONTENT_SETTINGS_TYPE_NOTIFICATIONS, | 301 CONTENT_SETTINGS_TYPE_NOTIFICATIONS, |
| 301 NO_RESOURCE_IDENTIFIER, | 302 NO_RESOURCE_IDENTIFIER, |
| 302 settings); | 303 settings); |
| 303 } | 304 } |
| 304 | 305 |
| 305 void DesktopNotificationService::ClearSetting( | 306 void DesktopNotificationService::ClearSetting( |
| 306 const ContentSettingsPattern& pattern) { | 307 const ContentSettingsPattern& pattern) { |
| 307 profile_->GetHostContentSettingsMap()->SetContentSetting( | 308 profile_->GetHostContentSettingsMap()->SetContentSetting( |
| 308 pattern, | 309 pattern, |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 437 | 438 |
| 438 if (setting == CONTENT_SETTING_ALLOW) | 439 if (setting == CONTENT_SETTING_ALLOW) |
| 439 return WebKit::WebNotificationPresenter::PermissionAllowed; | 440 return WebKit::WebNotificationPresenter::PermissionAllowed; |
| 440 if (setting == CONTENT_SETTING_BLOCK) | 441 if (setting == CONTENT_SETTING_BLOCK) |
| 441 return WebKit::WebNotificationPresenter::PermissionDenied; | 442 return WebKit::WebNotificationPresenter::PermissionDenied; |
| 442 if (setting == CONTENT_SETTING_ASK) | 443 if (setting == CONTENT_SETTING_ASK) |
| 443 return WebKit::WebNotificationPresenter::PermissionNotAllowed; | 444 return WebKit::WebNotificationPresenter::PermissionNotAllowed; |
| 444 NOTREACHED() << "Invalid notifications settings value: " << setting; | 445 NOTREACHED() << "Invalid notifications settings value: " << setting; |
| 445 return WebKit::WebNotificationPresenter::PermissionNotAllowed; | 446 return WebKit::WebNotificationPresenter::PermissionNotAllowed; |
| 446 } | 447 } |
| OLD | NEW |