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 #include <string> | 8 #include <string> |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
343 if (iter != patterns_.end()) { | 343 if (iter != patterns_.end()) { |
344 pattern = iter->second; | 344 pattern = iter->second; |
345 } else if (notifier.notifier_id.url.is_valid()) { | 345 } else if (notifier.notifier_id.url.is_valid()) { |
346 pattern = | 346 pattern = |
347 ContentSettingsPattern::FromURLNoWildcard(notifier.notifier_id.url); | 347 ContentSettingsPattern::FromURLNoWildcard(notifier.notifier_id.url); |
348 } else { | 348 } else { |
349 LOG(ERROR) << "Invalid url pattern: " | 349 LOG(ERROR) << "Invalid url pattern: " |
350 << notifier.notifier_id.url.spec(); | 350 << notifier.notifier_id.url.spec(); |
351 } | 351 } |
352 | 352 |
353 if (pattern.IsValid()) | 353 if (pattern.IsValid()) { |
354 DesktopNotificationProfileUtil::ClearSetting(profile, pattern); | 354 // Note that we don't use DesktopNotificationProfileUtil::ClearSetting() |
| 355 // here because pattern might be from user manual input and not match |
| 356 // the default one used by ClearSetting(). |
| 357 HostContentSettingsMapFactory::GetForProfile(profile) |
| 358 ->SetContentSetting(pattern, ContentSettingsPattern::Wildcard(), |
| 359 CONTENT_SETTINGS_TYPE_NOTIFICATIONS, |
| 360 content_settings::ResourceIdentifier(), |
| 361 CONTENT_SETTING_DEFAULT); |
| 362 } |
355 } | 363 } |
356 } else { | 364 } else { |
357 NotifierStateTrackerFactory::GetForProfile(profile) | 365 NotifierStateTrackerFactory::GetForProfile(profile) |
358 ->SetNotifierEnabled(notifier.notifier_id, enabled); | 366 ->SetNotifierEnabled(notifier.notifier_id, enabled); |
359 } | 367 } |
360 FOR_EACH_OBSERVER(message_center::NotifierSettingsObserver, | 368 FOR_EACH_OBSERVER(message_center::NotifierSettingsObserver, |
361 observers_, | 369 observers_, |
362 NotifierEnabledChanged(notifier.notifier_id, enabled)); | 370 NotifierEnabledChanged(notifier.notifier_id, enabled)); |
363 } | 371 } |
364 | 372 |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
555 weak_factory_.GetWeakPtr())); | 563 weak_factory_.GetWeakPtr())); |
556 } | 564 } |
557 #endif | 565 #endif |
558 | 566 |
559 if (notify) { | 567 if (notify) { |
560 FOR_EACH_OBSERVER(message_center::NotifierSettingsObserver, | 568 FOR_EACH_OBSERVER(message_center::NotifierSettingsObserver, |
561 observers_, | 569 observers_, |
562 NotifierGroupChanged()); | 570 NotifierGroupChanged()); |
563 } | 571 } |
564 } | 572 } |
OLD | NEW |