| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/message_center_settings_controller.h" | 5 #include "chrome/browser/notifications/message_center_settings_controller.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/i18n/string_compare.h" | 10 #include "base/i18n/string_compare.h" |
| 11 #include "base/strings/utf_string_conversions.h" | 11 #include "base/strings/utf_string_conversions.h" |
| 12 #include "base/task/cancelable_task_tracker.h" | 12 #include "base/task/cancelable_task_tracker.h" |
| 13 #include "base/thread_task_runner_handle.h" | 13 #include "base/thread_task_runner_handle.h" |
| 14 #include "chrome/browser/browser_process.h" | 14 #include "chrome/browser/browser_process.h" |
| 15 #include "chrome/browser/chrome_notification_types.h" | 15 #include "chrome/browser/chrome_notification_types.h" |
| 16 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" |
| 16 #include "chrome/browser/extensions/app_icon_loader_impl.h" | 17 #include "chrome/browser/extensions/app_icon_loader_impl.h" |
| 17 #include "chrome/browser/favicon/favicon_service_factory.h" | 18 #include "chrome/browser/favicon/favicon_service_factory.h" |
| 18 #include "chrome/browser/notifications/desktop_notification_profile_util.h" | 19 #include "chrome/browser/notifications/desktop_notification_profile_util.h" |
| 19 #include "chrome/browser/notifications/notifier_state_tracker.h" | 20 #include "chrome/browser/notifications/notifier_state_tracker.h" |
| 20 #include "chrome/browser/notifications/notifier_state_tracker_factory.h" | 21 #include "chrome/browser/notifications/notifier_state_tracker_factory.h" |
| 21 #include "chrome/browser/profiles/profile.h" | 22 #include "chrome/browser/profiles/profile.h" |
| 22 #include "chrome/browser/profiles/profile_info_cache.h" | 23 #include "chrome/browser/profiles/profile_info_cache.h" |
| 23 #include "chrome/browser/profiles/profile_manager.h" | 24 #include "chrome/browser/profiles/profile_manager.h" |
| 24 #include "chrome/common/extensions/api/notifications.h" | 25 #include "chrome/common/extensions/api/notifications.h" |
| 25 #include "chrome/common/extensions/extension_constants.h" | 26 #include "chrome/common/extensions/extension_constants.h" |
| (...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 304 const Notifier& notifier, | 305 const Notifier& notifier, |
| 305 bool enabled) { | 306 bool enabled) { |
| 306 DCHECK_LT(current_notifier_group_, notifier_groups_.size()); | 307 DCHECK_LT(current_notifier_group_, notifier_groups_.size()); |
| 307 Profile* profile = notifier_groups_[current_notifier_group_]->profile(); | 308 Profile* profile = notifier_groups_[current_notifier_group_]->profile(); |
| 308 | 309 |
| 309 if (notifier.notifier_id.type == NotifierId::WEB_PAGE) { | 310 if (notifier.notifier_id.type == NotifierId::WEB_PAGE) { |
| 310 // WEB_PAGE notifier cannot handle in DesktopNotificationService | 311 // WEB_PAGE notifier cannot handle in DesktopNotificationService |
| 311 // since it has the exact URL pattern. | 312 // since it has the exact URL pattern. |
| 312 // TODO(mukai): fix this. | 313 // TODO(mukai): fix this. |
| 313 ContentSetting default_setting = | 314 ContentSetting default_setting = |
| 314 profile->GetHostContentSettingsMap()->GetDefaultContentSetting( | 315 HostContentSettingsMapFactory::GetForProfile(profile) |
| 315 CONTENT_SETTINGS_TYPE_NOTIFICATIONS, NULL); | 316 ->GetDefaultContentSetting(CONTENT_SETTINGS_TYPE_NOTIFICATIONS, NULL); |
| 316 | 317 |
| 317 DCHECK(default_setting == CONTENT_SETTING_ALLOW || | 318 DCHECK(default_setting == CONTENT_SETTING_ALLOW || |
| 318 default_setting == CONTENT_SETTING_BLOCK || | 319 default_setting == CONTENT_SETTING_BLOCK || |
| 319 default_setting == CONTENT_SETTING_ASK); | 320 default_setting == CONTENT_SETTING_ASK); |
| 320 | 321 |
| 321 // The content setting for notifications needs to clear when it changes to | 322 // The content setting for notifications needs to clear when it changes to |
| 322 // the default value or get explicitly set when it differs from the default. | 323 // the default value or get explicitly set when it differs from the default. |
| 323 bool differs_from_default_value = | 324 bool differs_from_default_value = |
| 324 (default_setting != CONTENT_SETTING_ALLOW && enabled) || | 325 (default_setting != CONTENT_SETTING_ALLOW && enabled) || |
| 325 (default_setting == CONTENT_SETTING_ALLOW && !enabled); | 326 (default_setting == CONTENT_SETTING_ALLOW && !enabled); |
| (...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 552 weak_factory_.GetWeakPtr())); | 553 weak_factory_.GetWeakPtr())); |
| 553 } | 554 } |
| 554 #endif | 555 #endif |
| 555 | 556 |
| 556 if (notify) { | 557 if (notify) { |
| 557 FOR_EACH_OBSERVER(message_center::NotifierSettingsObserver, | 558 FOR_EACH_OBSERVER(message_center::NotifierSettingsObserver, |
| 558 observers_, | 559 observers_, |
| 559 NotifierGroupChanged()); | 560 NotifierGroupChanged()); |
| 560 } | 561 } |
| 561 } | 562 } |
| OLD | NEW |