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 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
285 profile_->GetHostContentSettingsMap()->SetDefaultContentSetting( | 286 profile_->GetHostContentSettingsMap()->SetDefaultContentSetting( |
286 CONTENT_SETTINGS_TYPE_NOTIFICATIONS, setting); | 287 CONTENT_SETTINGS_TYPE_NOTIFICATIONS, setting); |
287 } | 288 } |
288 | 289 |
289 void DesktopNotificationService::ResetToDefaultContentSetting() { | 290 void DesktopNotificationService::ResetToDefaultContentSetting() { |
290 profile_->GetHostContentSettingsMap()->SetDefaultContentSetting( | 291 profile_->GetHostContentSettingsMap()->SetDefaultContentSetting( |
291 CONTENT_SETTINGS_TYPE_NOTIFICATIONS, CONTENT_SETTING_DEFAULT); | 292 CONTENT_SETTINGS_TYPE_NOTIFICATIONS, CONTENT_SETTING_DEFAULT); |
292 } | 293 } |
293 | 294 |
294 void DesktopNotificationService::GetNotificationsSettings( | 295 void DesktopNotificationService::GetNotificationsSettings( |
295 HostContentSettingsMap::SettingsForOneType* settings) { | 296 ContentSettingsForOneType* settings) { |
296 profile_->GetHostContentSettingsMap()->GetSettingsForOneType( | 297 profile_->GetHostContentSettingsMap()->GetSettingsForOneType( |
297 CONTENT_SETTINGS_TYPE_NOTIFICATIONS, | 298 CONTENT_SETTINGS_TYPE_NOTIFICATIONS, |
298 NO_RESOURCE_IDENTIFIER, | 299 NO_RESOURCE_IDENTIFIER, |
299 settings); | 300 settings); |
300 } | 301 } |
301 | 302 |
302 void DesktopNotificationService::ClearSetting( | 303 void DesktopNotificationService::ClearSetting( |
303 const ContentSettingsPattern& pattern) { | 304 const ContentSettingsPattern& pattern) { |
304 profile_->GetHostContentSettingsMap()->SetContentSetting( | 305 profile_->GetHostContentSettingsMap()->SetContentSetting( |
305 pattern, | 306 pattern, |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
434 | 435 |
435 if (setting == CONTENT_SETTING_ALLOW) | 436 if (setting == CONTENT_SETTING_ALLOW) |
436 return WebKit::WebNotificationPresenter::PermissionAllowed; | 437 return WebKit::WebNotificationPresenter::PermissionAllowed; |
437 if (setting == CONTENT_SETTING_BLOCK) | 438 if (setting == CONTENT_SETTING_BLOCK) |
438 return WebKit::WebNotificationPresenter::PermissionDenied; | 439 return WebKit::WebNotificationPresenter::PermissionDenied; |
439 if (setting == CONTENT_SETTING_ASK) | 440 if (setting == CONTENT_SETTING_ASK) |
440 return WebKit::WebNotificationPresenter::PermissionNotAllowed; | 441 return WebKit::WebNotificationPresenter::PermissionNotAllowed; |
441 NOTREACHED() << "Invalid notifications settings value: " << setting; | 442 NOTREACHED() << "Invalid notifications settings value: " << setting; |
442 return WebKit::WebNotificationPresenter::PermissionNotAllowed; | 443 return WebKit::WebNotificationPresenter::PermissionNotAllowed; |
443 } | 444 } |
OLD | NEW |