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 #if defined(OS_ANDROID) | |
389 // Disallow arbitrary wildcard notification content setting updates on | |
390 // Android. The primary_pattern must either identify a specific origin | |
391 // or apply globally (for the default notifications toggle). | |
392 DCHECK(content_type != CONTENT_SETTINGS_TYPE_NOTIFICATIONS || | |
393 GURL(primary_pattern.ToString()).is_valid() || | |
394 primary_pattern.MatchesAllHosts()); | |
395 // Disallow notification content setting updates for specific origins that are | |
396 // not ALLOW/BLOCK/DEFAULT on Android. | |
397 DCHECK(content_type != CONTENT_SETTINGS_TYPE_NOTIFICATIONS || | |
398 primary_pattern.MatchesAllHosts() || | |
399 content_settings::ValueToContentSetting(value.get()) == | |
400 CONTENT_SETTING_ALLOW || | |
401 content_settings::ValueToContentSetting(value.get()) == | |
402 CONTENT_SETTING_BLOCK || | |
403 content_settings::ValueToContentSetting(value.get()) == | |
404 CONTENT_SETTING_DEFAULT); | |
405 #endif | |
Peter Beverloo
2017/06/05 15:11:31
This is getting really complicated to read. What a
awdf
2017/06/05 17:06:56
Ooh, I didn't know about DCHECK_IS_ON. thanks!
Do
| |
406 | |
387 UsedContentSettingsProviders(); | 407 UsedContentSettingsProviders(); |
388 | 408 |
389 for (const auto& provider_pair : content_settings_providers_) { | 409 for (const auto& provider_pair : content_settings_providers_) { |
390 if (provider_pair.second->SetWebsiteSetting( | 410 if (provider_pair.second->SetWebsiteSetting( |
391 primary_pattern, secondary_pattern, content_type, | 411 primary_pattern, secondary_pattern, content_type, |
392 resource_identifier, value.get())) { | 412 resource_identifier, value.get())) { |
393 // If successful then ownership is passed to the provider. | 413 // If successful then ownership is passed to the provider. |
394 ignore_result(value.release()); | 414 ignore_result(value.release()); |
395 return; | 415 return; |
396 } | 416 } |
(...skipping 506 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
903 return base::WrapUnique(rule.value.get()->DeepCopy()); | 923 return base::WrapUnique(rule.value.get()->DeepCopy()); |
904 } | 924 } |
905 } | 925 } |
906 } | 926 } |
907 return std::unique_ptr<base::Value>(); | 927 return std::unique_ptr<base::Value>(); |
908 } | 928 } |
909 | 929 |
910 void HostContentSettingsMap::SetClockForTesting( | 930 void HostContentSettingsMap::SetClockForTesting( |
911 std::unique_ptr<base::Clock> clock) { | 931 std::unique_ptr<base::Clock> clock) { |
912 pref_provider_->SetClockForTesting(std::move(clock)); | 932 pref_provider_->SetClockForTesting(std::move(clock)); |
913 } | 933 } |
OLD | NEW |