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

Side by Side Diff: chrome/browser/content_settings/host_content_settings_map.cc

Issue 7275018: Make ExtensionContentSettingsStore refcounted. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: comments Created 9 years, 5 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/content_settings/host_content_settings_map.h" 5 #include "chrome/browser/content_settings/host_content_settings_map.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/string_util.h" 8 #include "base/string_util.h"
9 #include "base/utf_string_conversions.h" 9 #include "base/utf_string_conversions.h"
10 #include "chrome/browser/content_settings/content_settings_extension_provider.h" 10 #include "chrome/browser/content_settings/content_settings_extension_provider.h"
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 // The order in which the content settings providers are created is critical, 99 // The order in which the content settings providers are created is critical,
100 // as providers that are further up in the list (i.e. added earlier) override 100 // as providers that are further up in the list (i.e. added earlier) override
101 // providers further down. 101 // providers further down.
102 content_settings_providers_.push_back(make_linked_ptr( 102 content_settings_providers_.push_back(make_linked_ptr(
103 new content_settings::PolicyProvider(profile, policy_default_provider))); 103 new content_settings::PolicyProvider(profile, policy_default_provider)));
104 ExtensionService* extension_service = profile->GetExtensionService(); 104 ExtensionService* extension_service = profile->GetExtensionService();
105 if (extension_service) { 105 if (extension_service) {
106 // |extension_service| can be NULL in unit tests. 106 // |extension_service| can be NULL in unit tests.
107 content_settings_providers_.push_back(make_linked_ptr( 107 content_settings_providers_.push_back(make_linked_ptr(
108 new content_settings::ExtensionProvider( 108 new content_settings::ExtensionProvider(
109 profile, 109 this,
110 extension_service->GetExtensionContentSettingsStore(), 110 extension_service->GetExtensionContentSettingsStore(),
111 is_off_the_record_))); 111 is_off_the_record_)));
112 } 112 }
113 content_settings_providers_.push_back( 113 content_settings_providers_.push_back(
114 make_linked_ptr(new content_settings::PrefProvider(profile))); 114 make_linked_ptr(new content_settings::PrefProvider(profile)));
115 115
116 pref_change_registrar_.Init(prefs); 116 pref_change_registrar_.Init(prefs);
117 pref_change_registrar_.Add(prefs::kBlockThirdPartyCookies, this); 117 pref_change_registrar_.Add(prefs::kBlockThirdPartyCookies, this);
118 notification_registrar_.Add(this, NotificationType::PROFILE_DESTROYED, 118 notification_registrar_.Add(this, NotificationType::PROFILE_DESTROYED,
119 Source<Profile>(profile_)); 119 Source<Profile>(profile_));
(...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after
515 ContentSettingsType content_type) const { 515 ContentSettingsType content_type) const {
516 for (ConstDefaultProviderIterator provider = 516 for (ConstDefaultProviderIterator provider =
517 default_content_settings_providers_.begin(); 517 default_content_settings_providers_.begin();
518 provider != default_content_settings_providers_.end(); ++provider) { 518 provider != default_content_settings_providers_.end(); ++provider) {
519 if ((*provider)->DefaultSettingIsManaged(content_type)) 519 if ((*provider)->DefaultSettingIsManaged(content_type))
520 return true; 520 return true;
521 } 521 }
522 return false; 522 return false;
523 } 523 }
524 524
525 void HostContentSettingsMap::ShutdownOnUIThread() {
526 for (ProviderIterator it = content_settings_providers_.begin();
527 it != content_settings_providers_.end();
528 ++it) {
529 (*it)->ShutdownOnUIThread();
530 }
531 }
532
525 void HostContentSettingsMap::UnregisterObservers() { 533 void HostContentSettingsMap::UnregisterObservers() {
526 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 534 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
527 if (!profile_) 535 if (!profile_)
528 return; 536 return;
529 pref_change_registrar_.RemoveAll(); 537 pref_change_registrar_.RemoveAll();
530 notification_registrar_.Remove(this, NotificationType::PROFILE_DESTROYED, 538 notification_registrar_.Remove(this, NotificationType::PROFILE_DESTROYED,
531 Source<Profile>(profile_)); 539 Source<Profile>(profile_));
532 profile_ = NULL; 540 profile_ = NULL;
533 } 541 }
534 542
535 void HostContentSettingsMap::MigrateObsoleteCookiePref(PrefService* prefs) { 543 void HostContentSettingsMap::MigrateObsoleteCookiePref(PrefService* prefs) {
536 if (prefs->HasPrefPath(prefs::kCookieBehavior)) { 544 if (prefs->HasPrefPath(prefs::kCookieBehavior)) {
537 int cookie_behavior = prefs->GetInteger(prefs::kCookieBehavior); 545 int cookie_behavior = prefs->GetInteger(prefs::kCookieBehavior);
538 prefs->ClearPref(prefs::kCookieBehavior); 546 prefs->ClearPref(prefs::kCookieBehavior);
539 if (!prefs->HasPrefPath(prefs::kDefaultContentSettings)) { 547 if (!prefs->HasPrefPath(prefs::kDefaultContentSettings)) {
540 SetDefaultContentSetting(CONTENT_SETTINGS_TYPE_COOKIES, 548 SetDefaultContentSetting(CONTENT_SETTINGS_TYPE_COOKIES,
541 (cookie_behavior == net::StaticCookiePolicy::BLOCK_ALL_COOKIES) ? 549 (cookie_behavior == net::StaticCookiePolicy::BLOCK_ALL_COOKIES) ?
542 CONTENT_SETTING_BLOCK : CONTENT_SETTING_ALLOW); 550 CONTENT_SETTING_BLOCK : CONTENT_SETTING_ALLOW);
543 } 551 }
544 if (!prefs->HasPrefPath(prefs::kBlockThirdPartyCookies)) { 552 if (!prefs->HasPrefPath(prefs::kBlockThirdPartyCookies)) {
545 SetBlockThirdPartyCookies(cookie_behavior == 553 SetBlockThirdPartyCookies(cookie_behavior ==
546 net::StaticCookiePolicy::BLOCK_SETTING_THIRD_PARTY_COOKIES); 554 net::StaticCookiePolicy::BLOCK_SETTING_THIRD_PARTY_COOKIES);
547 } 555 }
548 } 556 }
549 } 557 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698