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

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: review 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 <list> 7 #include <list>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/string_util.h" 10 #include "base/string_util.h"
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 // The order in which the content settings providers are created is critical, 107 // The order in which the content settings providers are created is critical,
108 // as providers that are further up in the list (i.e. added earlier) override 108 // as providers that are further up in the list (i.e. added earlier) override
109 // providers further down. 109 // providers further down.
110 content_settings_providers_.push_back(make_linked_ptr( 110 content_settings_providers_.push_back(make_linked_ptr(
111 new content_settings::PolicyProvider(profile, policy_default_provider))); 111 new content_settings::PolicyProvider(profile, policy_default_provider)));
112 ExtensionService* extension_service = profile->GetExtensionService(); 112 ExtensionService* extension_service = profile->GetExtensionService();
113 if (extension_service) { 113 if (extension_service) {
114 // |extension_service| can be NULL in unit tests. 114 // |extension_service| can be NULL in unit tests.
115 content_settings_providers_.push_back(make_linked_ptr( 115 content_settings_providers_.push_back(make_linked_ptr(
116 new content_settings::ExtensionProvider( 116 new content_settings::ExtensionProvider(
117 profile, 117 this,
118 extension_service->GetExtensionContentSettingsStore(), 118 extension_service->GetExtensionContentSettingsStore(),
119 is_off_the_record_))); 119 is_off_the_record_)));
120 } 120 }
121 content_settings_providers_.push_back( 121 content_settings_providers_.push_back(
122 make_linked_ptr(new content_settings::PrefProvider(profile))); 122 make_linked_ptr(new content_settings::PrefProvider(profile)));
123 123
124 pref_change_registrar_.Init(prefs); 124 pref_change_registrar_.Init(prefs);
125 pref_change_registrar_.Add(prefs::kBlockThirdPartyCookies, this); 125 pref_change_registrar_.Add(prefs::kBlockThirdPartyCookies, this);
126 notification_registrar_.Add(this, NotificationType::PROFILE_DESTROYED, 126 notification_registrar_.Add(this, NotificationType::PROFILE_DESTROYED,
127 Source<Profile>(profile_)); 127 Source<Profile>(profile_));
(...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after
517 ContentSettingsType content_type) const { 517 ContentSettingsType content_type) const {
518 for (ConstDefaultProviderIterator provider = 518 for (ConstDefaultProviderIterator provider =
519 default_content_settings_providers_.begin(); 519 default_content_settings_providers_.begin();
520 provider != default_content_settings_providers_.end(); ++provider) { 520 provider != default_content_settings_providers_.end(); ++provider) {
521 if ((*provider)->DefaultSettingIsManaged(content_type)) 521 if ((*provider)->DefaultSettingIsManaged(content_type))
522 return true; 522 return true;
523 } 523 }
524 return false; 524 return false;
525 } 525 }
526 526
527 void HostContentSettingsMap::ShutdownOnUIThread() {
528 for (ProviderIterator it = content_settings_providers_.begin();
529 it != content_settings_providers_.end();
530 ++it) {
531 (*it)->ShutdownOnUIThread();
532 }
533 }
534
527 void HostContentSettingsMap::UnregisterObservers() { 535 void HostContentSettingsMap::UnregisterObservers() {
528 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 536 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
529 if (!profile_) 537 if (!profile_)
530 return; 538 return;
531 pref_change_registrar_.RemoveAll(); 539 pref_change_registrar_.RemoveAll();
532 notification_registrar_.Remove(this, NotificationType::PROFILE_DESTROYED, 540 notification_registrar_.Remove(this, NotificationType::PROFILE_DESTROYED,
533 Source<Profile>(profile_)); 541 Source<Profile>(profile_));
534 profile_ = NULL; 542 profile_ = NULL;
535 } 543 }
536 544
537 void HostContentSettingsMap::MigrateObsoleteCookiePref(PrefService* prefs) { 545 void HostContentSettingsMap::MigrateObsoleteCookiePref(PrefService* prefs) {
538 if (prefs->HasPrefPath(prefs::kCookieBehavior)) { 546 if (prefs->HasPrefPath(prefs::kCookieBehavior)) {
539 int cookie_behavior = prefs->GetInteger(prefs::kCookieBehavior); 547 int cookie_behavior = prefs->GetInteger(prefs::kCookieBehavior);
540 prefs->ClearPref(prefs::kCookieBehavior); 548 prefs->ClearPref(prefs::kCookieBehavior);
541 if (!prefs->HasPrefPath(prefs::kDefaultContentSettings)) { 549 if (!prefs->HasPrefPath(prefs::kDefaultContentSettings)) {
542 SetDefaultContentSetting(CONTENT_SETTINGS_TYPE_COOKIES, 550 SetDefaultContentSetting(CONTENT_SETTINGS_TYPE_COOKIES,
543 (cookie_behavior == net::StaticCookiePolicy::BLOCK_ALL_COOKIES) ? 551 (cookie_behavior == net::StaticCookiePolicy::BLOCK_ALL_COOKIES) ?
544 CONTENT_SETTING_BLOCK : CONTENT_SETTING_ALLOW); 552 CONTENT_SETTING_BLOCK : CONTENT_SETTING_ALLOW);
545 } 553 }
546 if (!prefs->HasPrefPath(prefs::kBlockThirdPartyCookies)) { 554 if (!prefs->HasPrefPath(prefs::kBlockThirdPartyCookies)) {
547 SetBlockThirdPartyCookies(cookie_behavior == 555 SetBlockThirdPartyCookies(cookie_behavior ==
548 net::StaticCookiePolicy::BLOCK_SETTING_THIRD_PARTY_COOKIES); 556 net::StaticCookiePolicy::BLOCK_SETTING_THIRD_PARTY_COOKIES);
549 } 557 }
550 } 558 }
551 } 559 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698