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/browser_process.h" | 10 #include "chrome/browser/browser_process.h" |
(...skipping 593 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
604 // Do not touch |disabled_extension_ids_|. It will be updated at | 604 // Do not touch |disabled_extension_ids_|. It will be updated at |
605 // OnDisabledExtensionIdsChanged() which will be called when the pref changes. | 605 // OnDisabledExtensionIdsChanged() which will be called when the pref changes. |
606 ToggleListPrefItem( | 606 ToggleListPrefItem( |
607 profile_->GetPrefs(), | 607 profile_->GetPrefs(), |
608 prefs::kMessageCenterDisabledSystemComponentIds, | 608 prefs::kMessageCenterDisabledSystemComponentIds, |
609 message_center::ToString(type), | 609 message_center::ToString(type), |
610 !enabled); | 610 !enabled); |
611 } | 611 } |
612 | 612 |
613 void DesktopNotificationService::OnDisabledSystemComponentIdsChanged() { | 613 void DesktopNotificationService::OnDisabledSystemComponentIdsChanged() { |
614 disabled_extension_ids_.clear(); | 614 disabled_system_component_ids_.clear(); |
615 CopySetFromPrefToMemory(profile_->GetPrefs(), | 615 CopySetFromPrefToMemory(profile_->GetPrefs(), |
616 prefs::kMessageCenterDisabledSystemComponentIds, | 616 prefs::kMessageCenterDisabledSystemComponentIds, |
617 &disabled_system_component_ids_); | 617 &disabled_system_component_ids_); |
618 } | 618 } |
619 #endif | 619 #endif |
620 | 620 |
621 WebKit::WebNotificationPresenter::Permission | 621 WebKit::WebNotificationPresenter::Permission |
622 DesktopNotificationService::HasPermission(const GURL& origin) { | 622 DesktopNotificationService::HasPermission(const GURL& origin) { |
623 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 623 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
624 HostContentSettingsMap* host_content_settings_map = | 624 HostContentSettingsMap* host_content_settings_map = |
625 profile_->GetHostContentSettingsMap(); | 625 profile_->GetHostContentSettingsMap(); |
626 ContentSetting setting = host_content_settings_map->GetContentSetting( | 626 ContentSetting setting = host_content_settings_map->GetContentSetting( |
627 origin, | 627 origin, |
628 origin, | 628 origin, |
629 CONTENT_SETTINGS_TYPE_NOTIFICATIONS, | 629 CONTENT_SETTINGS_TYPE_NOTIFICATIONS, |
630 NO_RESOURCE_IDENTIFIER); | 630 NO_RESOURCE_IDENTIFIER); |
631 | 631 |
632 if (setting == CONTENT_SETTING_ALLOW) | 632 if (setting == CONTENT_SETTING_ALLOW) |
633 return WebKit::WebNotificationPresenter::PermissionAllowed; | 633 return WebKit::WebNotificationPresenter::PermissionAllowed; |
634 if (setting == CONTENT_SETTING_BLOCK) | 634 if (setting == CONTENT_SETTING_BLOCK) |
635 return WebKit::WebNotificationPresenter::PermissionDenied; | 635 return WebKit::WebNotificationPresenter::PermissionDenied; |
636 if (setting == CONTENT_SETTING_ASK) | 636 if (setting == CONTENT_SETTING_ASK) |
637 return WebKit::WebNotificationPresenter::PermissionNotAllowed; | 637 return WebKit::WebNotificationPresenter::PermissionNotAllowed; |
638 NOTREACHED() << "Invalid notifications settings value: " << setting; | 638 NOTREACHED() << "Invalid notifications settings value: " << setting; |
639 return WebKit::WebNotificationPresenter::PermissionNotAllowed; | 639 return WebKit::WebNotificationPresenter::PermissionNotAllowed; |
640 } | 640 } |
OLD | NEW |