Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(140)

Side by Side Diff: components/content_settings/core/browser/host_content_settings_map.cc

Issue 2536993002: Remove support for the keygen tag (Closed)
Patch Set: Rebased Created 3 years, 12 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 // wouldn't be needed except that we used to allow settings to be stored for 203 // wouldn't be needed except that we used to allow settings to be stored for
204 // the guest profile and so we need to ensure those get cleared. 204 // the guest profile and so we need to ensure those get cleared.
205 if (is_guest_profile) 205 if (is_guest_profile)
206 pref_provider_->ClearPrefs(); 206 pref_provider_->ClearPrefs();
207 207
208 auto default_provider = base::MakeUnique<content_settings::DefaultProvider>( 208 auto default_provider = base::MakeUnique<content_settings::DefaultProvider>(
209 prefs_, is_incognito_); 209 prefs_, is_incognito_);
210 default_provider->AddObserver(this); 210 default_provider->AddObserver(this);
211 content_settings_providers_[DEFAULT_PROVIDER] = std::move(default_provider); 211 content_settings_providers_[DEFAULT_PROVIDER] = std::move(default_provider);
212 212
213 MigrateKeygenSettings();
214 MigrateDomainScopedSettings(false); 213 MigrateDomainScopedSettings(false);
215 RecordExceptionMetrics(); 214 RecordExceptionMetrics();
216 } 215 }
217 216
218 // static 217 // static
219 void HostContentSettingsMap::RegisterProfilePrefs( 218 void HostContentSettingsMap::RegisterProfilePrefs(
220 user_prefs::PrefRegistrySyncable* registry) { 219 user_prefs::PrefRegistrySyncable* registry) {
221 // Ensure the content settings are all registered. 220 // Ensure the content settings are all registered.
222 content_settings::ContentSettingsRegistry::GetInstance(); 221 content_settings::ContentSettingsRegistry::GetInstance();
223 222
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after
494 493
495 ContentSettingsPattern primary_pattern = patterns.first; 494 ContentSettingsPattern primary_pattern = patterns.first;
496 ContentSettingsPattern secondary_pattern = patterns.second; 495 ContentSettingsPattern secondary_pattern = patterns.second;
497 if (!primary_pattern.IsValid() || !secondary_pattern.IsValid()) 496 if (!primary_pattern.IsValid() || !secondary_pattern.IsValid())
498 return; 497 return;
499 498
500 SetContentSettingCustomScope(primary_pattern, secondary_pattern, content_type, 499 SetContentSettingCustomScope(primary_pattern, secondary_pattern, content_type,
501 resource_identifier, setting); 500 resource_identifier, setting);
502 } 501 }
503 502
504 void HostContentSettingsMap::MigrateKeygenSettings() {
505 const content_settings::ContentSettingsInfo* info =
506 content_settings::ContentSettingsRegistry::GetInstance()->Get(
507 CONTENT_SETTINGS_TYPE_KEYGEN);
508 if (info) {
509 ContentSettingsForOneType settings;
510 GetSettingsForOneType(CONTENT_SETTINGS_TYPE_KEYGEN, std::string(),
511 &settings);
512
513 for (const ContentSettingPatternSource& setting_entry : settings) {
514 // Migrate user preference settings only.
515 if (setting_entry.source != "preference")
516 continue;
517 // Migrate old-format settings only.
518 if (setting_entry.secondary_pattern !=
519 ContentSettingsPattern::Wildcard()) {
520 GURL url(setting_entry.primary_pattern.ToString());
521 // Pull out the value of the old-format setting. Only do this if the
522 // patterns are as we expect them to be, otherwise the setting will just
523 // be removed for safety.
524 ContentSetting content_setting = CONTENT_SETTING_DEFAULT;
525 if (setting_entry.primary_pattern == setting_entry.secondary_pattern &&
526 url.is_valid()) {
527 content_setting = GetContentSetting(
528 url, url, CONTENT_SETTINGS_TYPE_KEYGEN, std::string());
529 }
530 // Remove the old pattern.
531 SetContentSettingCustomScope(setting_entry.primary_pattern,
532 setting_entry.secondary_pattern,
533 CONTENT_SETTINGS_TYPE_KEYGEN,
534 std::string(), CONTENT_SETTING_DEFAULT);
535 // Set the new pattern.
536 SetContentSettingDefaultScope(url, GURL(), CONTENT_SETTINGS_TYPE_KEYGEN,
537 std::string(), content_setting);
538 }
539 }
540 }
541 }
542
543 void HostContentSettingsMap::MigrateDomainScopedSettings(bool after_sync) { 503 void HostContentSettingsMap::MigrateDomainScopedSettings(bool after_sync) {
544 DomainToOriginMigrationStatus status = 504 DomainToOriginMigrationStatus status =
545 static_cast<DomainToOriginMigrationStatus>( 505 static_cast<DomainToOriginMigrationStatus>(
546 prefs_->GetInteger(prefs::kDomainToOriginMigrationStatus)); 506 prefs_->GetInteger(prefs::kDomainToOriginMigrationStatus));
547 if (status == MIGRATED_AFTER_SYNC) 507 if (status == MIGRATED_AFTER_SYNC)
548 return; 508 return;
549 if (status == MIGRATED_BEFORE_SYNC && !after_sync) 509 if (status == MIGRATED_BEFORE_SYNC && !after_sync)
550 return; 510 return;
551 DCHECK(status != NOT_MIGRATED || !after_sync); 511 DCHECK(status != NOT_MIGRATED || !after_sync);
552 512
(...skipping 470 matching lines...) Expand 10 before | Expand all | Expand 10 after
1023 if (primary_pattern) 983 if (primary_pattern)
1024 *primary_pattern = rule.primary_pattern; 984 *primary_pattern = rule.primary_pattern;
1025 if (secondary_pattern) 985 if (secondary_pattern)
1026 *secondary_pattern = rule.secondary_pattern; 986 *secondary_pattern = rule.secondary_pattern;
1027 return base::WrapUnique(rule.value.get()->DeepCopy()); 987 return base::WrapUnique(rule.value.get()->DeepCopy());
1028 } 988 }
1029 } 989 }
1030 } 990 }
1031 return std::unique_ptr<base::Value>(); 991 return std::unique_ptr<base::Value>();
1032 } 992 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698