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 "components/content_settings/core/browser/host_content_settings_map.h" | 5 #include "components/content_settings/core/browser/host_content_settings_map.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 struct ProviderNamesSourceMapEntry { | 48 struct ProviderNamesSourceMapEntry { |
49 const char* provider_name; | 49 const char* provider_name; |
50 content_settings::SettingSource provider_source; | 50 content_settings::SettingSource provider_source; |
51 }; | 51 }; |
52 | 52 |
53 const ProviderNamesSourceMapEntry kProviderNamesSourceMap[] = { | 53 const ProviderNamesSourceMapEntry kProviderNamesSourceMap[] = { |
54 {"platform_app", content_settings::SETTING_SOURCE_EXTENSION}, | 54 {"platform_app", content_settings::SETTING_SOURCE_EXTENSION}, |
55 {"policy", content_settings::SETTING_SOURCE_POLICY}, | 55 {"policy", content_settings::SETTING_SOURCE_POLICY}, |
56 {"supervised_user", content_settings::SETTING_SOURCE_SUPERVISED}, | 56 {"supervised_user", content_settings::SETTING_SOURCE_SUPERVISED}, |
57 {"extension", content_settings::SETTING_SOURCE_EXTENSION}, | 57 {"extension", content_settings::SETTING_SOURCE_EXTENSION}, |
| 58 {"notification_android", content_settings::SETTING_SOURCE_USER}, |
58 {"preference", content_settings::SETTING_SOURCE_USER}, | 59 {"preference", content_settings::SETTING_SOURCE_USER}, |
59 {"default", content_settings::SETTING_SOURCE_USER}, | 60 {"default", content_settings::SETTING_SOURCE_USER}, |
60 }; | 61 }; |
61 | 62 |
62 // Enum describing the status of domain to origin migration of content settings. | 63 // Enum describing the status of domain to origin migration of content settings. |
63 // Migration will be done twice: once upon construction of the | 64 // Migration will be done twice: once upon construction of the |
64 // HostContentSettingsMap (before syncing any content settings) and once after | 65 // HostContentSettingsMap (before syncing any content settings) and once after |
65 // sync has finished. We always migrate before sync to ensure that settings will | 66 // sync has finished. We always migrate before sync to ensure that settings will |
66 // get migrated even if a user doesn't have sync enabled. We migrate after sync | 67 // get migrated even if a user doesn't have sync enabled. We migrate after sync |
67 // to ensure that any sync'd settings will be migrated. Once these events have | 68 // to ensure that any sync'd settings will be migrated. Once these events have |
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
377 } | 378 } |
378 | 379 |
379 void HostContentSettingsMap::SetWebsiteSettingCustomScope( | 380 void HostContentSettingsMap::SetWebsiteSettingCustomScope( |
380 const ContentSettingsPattern& primary_pattern, | 381 const ContentSettingsPattern& primary_pattern, |
381 const ContentSettingsPattern& secondary_pattern, | 382 const ContentSettingsPattern& secondary_pattern, |
382 ContentSettingsType content_type, | 383 ContentSettingsType content_type, |
383 const std::string& resource_identifier, | 384 const std::string& resource_identifier, |
384 std::unique_ptr<base::Value> value) { | 385 std::unique_ptr<base::Value> value) { |
385 DCHECK(SupportsResourceIdentifier(content_type) || | 386 DCHECK(SupportsResourceIdentifier(content_type) || |
386 resource_identifier.empty()); | 387 resource_identifier.empty()); |
| 388 // TODO(crbug.com/731126): Verify that assumptions for notification content |
| 389 // settings are met. |
387 UsedContentSettingsProviders(); | 390 UsedContentSettingsProviders(); |
388 | 391 |
389 for (const auto& provider_pair : content_settings_providers_) { | 392 for (const auto& provider_pair : content_settings_providers_) { |
390 if (provider_pair.second->SetWebsiteSetting( | 393 if (provider_pair.second->SetWebsiteSetting( |
391 primary_pattern, secondary_pattern, content_type, | 394 primary_pattern, secondary_pattern, content_type, |
392 resource_identifier, value.get())) { | 395 resource_identifier, value.get())) { |
393 // If successful then ownership is passed to the provider. | 396 // If successful then ownership is passed to the provider. |
394 ignore_result(value.release()); | 397 ignore_result(value.release()); |
395 return; | 398 return; |
396 } | 399 } |
(...skipping 506 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
903 return base::WrapUnique(rule.value.get()->DeepCopy()); | 906 return base::WrapUnique(rule.value.get()->DeepCopy()); |
904 } | 907 } |
905 } | 908 } |
906 } | 909 } |
907 return std::unique_ptr<base::Value>(); | 910 return std::unique_ptr<base::Value>(); |
908 } | 911 } |
909 | 912 |
910 void HostContentSettingsMap::SetClockForTesting( | 913 void HostContentSettingsMap::SetClockForTesting( |
911 std::unique_ptr<base::Clock> clock) { | 914 std::unique_ptr<base::Clock> clock) { |
912 pref_provider_->SetClockForTesting(std::move(clock)); | 915 pref_provider_->SetClockForTesting(std::move(clock)); |
913 } | 916 } |
OLD | NEW |