| Index: chrome/browser/content_settings/host_content_settings_map.cc
|
| diff --git a/chrome/browser/content_settings/host_content_settings_map.cc b/chrome/browser/content_settings/host_content_settings_map.cc
|
| index 5072377d0e038a0552458cf5451292bb094a7374..47681e51dac6b9ca9f4301c177576879e73ca6a9 100644
|
| --- a/chrome/browser/content_settings/host_content_settings_map.cc
|
| +++ b/chrome/browser/content_settings/host_content_settings_map.cc
|
| @@ -7,8 +7,6 @@
|
| #include <list>
|
|
|
| #include "base/command_line.h"
|
| -#include "base/string_util.h"
|
| -#include "base/utf_string_conversions.h"
|
| #include "chrome/browser/content_settings/content_settings_details.h"
|
| #include "chrome/browser/content_settings/content_settings_extension_provider.h"
|
| #include "chrome/browser/content_settings/content_settings_observable_provider.h"
|
| @@ -19,7 +17,6 @@
|
| #include "chrome/browser/extensions/extension_service.h"
|
| #include "chrome/browser/prefs/pref_service.h"
|
| #include "chrome/browser/prefs/scoped_user_pref_update.h"
|
| -#include "chrome/browser/profiles/profile.h"
|
| #include "chrome/common/chrome_notification_types.h"
|
| #include "chrome/common/chrome_switches.h"
|
| #include "chrome/common/pref_names.h"
|
| @@ -36,19 +33,6 @@
|
|
|
| namespace {
|
|
|
| -// Returns true if we should allow all content types for this URL. This is
|
| -// true for various internal objects like chrome:// URLs, so UI and other
|
| -// things users think of as "not webpages" don't break.
|
| -static bool ShouldAllowAllContent(const GURL& url,
|
| - ContentSettingsType content_type) {
|
| - if (content_type == CONTENT_SETTINGS_TYPE_NOTIFICATIONS)
|
| - return false;
|
| - return url.SchemeIs(chrome::kChromeDevToolsScheme) ||
|
| - url.SchemeIs(chrome::kChromeInternalScheme) ||
|
| - url.SchemeIs(chrome::kChromeUIScheme) ||
|
| - url.SchemeIs(chrome::kExtensionScheme);
|
| -}
|
| -
|
| typedef linked_ptr<content_settings::DefaultProviderInterface>
|
| DefaultContentSettingsProviderPtr;
|
| typedef std::vector<DefaultContentSettingsProviderPtr>::iterator
|
| @@ -84,10 +68,7 @@ HostContentSettingsMap::HostContentSettingsMap(
|
| ExtensionService* extension_service,
|
| bool incognito)
|
| : prefs_(prefs),
|
| - is_off_the_record_(incognito),
|
| - updating_preferences_(false),
|
| - block_third_party_cookies_(false),
|
| - is_block_third_party_cookies_managed_(false) {
|
| + is_off_the_record_(incognito) {
|
| // The order in which the default content settings providers are created is
|
| // critical, as providers that are further down in the list (i.e. added later)
|
| // override providers further up.
|
| @@ -103,22 +84,7 @@ HostContentSettingsMap::HostContentSettingsMap(
|
| default_content_settings_providers_.push_back(
|
| make_linked_ptr(policy_default_provider));
|
|
|
| - // TODO(markusheintz): Discuss whether it is sensible to move migration code
|
| - // to PrefContentSettingsProvider.
|
| - MigrateObsoleteCookiePref();
|
| -
|
| // Read misc. global settings.
|
| - block_third_party_cookies_ =
|
| - prefs_->GetBoolean(prefs::kBlockThirdPartyCookies);
|
| - if (block_third_party_cookies_) {
|
| - UserMetrics::RecordAction(
|
| - UserMetricsAction("ThirdPartyCookieBlockingEnabled"));
|
| - } else {
|
| - UserMetrics::RecordAction(
|
| - UserMetricsAction("ThirdPartyCookieBlockingDisabled"));
|
| - }
|
| - is_block_third_party_cookies_managed_ =
|
| - prefs_->IsManagedPreference(prefs::kBlockThirdPartyCookies);
|
|
|
| // User defined non default content settings are provided by the PrefProvider.
|
| // The order in which the content settings providers are created is critical,
|
| @@ -140,9 +106,6 @@ HostContentSettingsMap::HostContentSettingsMap(
|
| provider = new content_settings::PrefProvider(prefs_, is_off_the_record_);
|
| provider->AddObserver(this);
|
| content_settings_providers_.push_back(make_linked_ptr(provider));
|
| -
|
| - pref_change_registrar_.Init(prefs_);
|
| - pref_change_registrar_.Add(prefs::kBlockThirdPartyCookies, this);
|
| }
|
|
|
| // static
|
| @@ -194,42 +157,6 @@ ContentSettings HostContentSettingsMap::GetDefaultContentSettings() const {
|
| return output;
|
| }
|
|
|
| -ContentSetting HostContentSettingsMap::GetCookieContentSetting(
|
| - const GURL& url,
|
| - const GURL& first_party_url,
|
| - bool setting_cookie) const {
|
| - if (ShouldAllowAllContent(first_party_url, CONTENT_SETTINGS_TYPE_COOKIES))
|
| - return CONTENT_SETTING_ALLOW;
|
| -
|
| - // First get any host-specific settings.
|
| - ContentSetting setting = GetNonDefaultContentSetting(url,
|
| - first_party_url, CONTENT_SETTINGS_TYPE_COOKIES, "");
|
| -
|
| - // If no explicit exception has been made and third-party cookies are blocked
|
| - // by default, apply that rule.
|
| - if (setting == CONTENT_SETTING_DEFAULT && BlockThirdPartyCookies()) {
|
| - bool strict = CommandLine::ForCurrentProcess()->HasSwitch(
|
| - switches::kBlockReadingThirdPartyCookies);
|
| - net::StaticCookiePolicy policy(strict ?
|
| - net::StaticCookiePolicy::BLOCK_ALL_THIRD_PARTY_COOKIES :
|
| - net::StaticCookiePolicy::BLOCK_SETTING_THIRD_PARTY_COOKIES);
|
| - int rv;
|
| - if (setting_cookie)
|
| - rv = policy.CanSetCookie(url, first_party_url);
|
| - else
|
| - rv = policy.CanGetCookies(url, first_party_url);
|
| - DCHECK_NE(net::ERR_IO_PENDING, rv);
|
| - if (rv != net::OK)
|
| - setting = CONTENT_SETTING_BLOCK;
|
| - }
|
| -
|
| - // If no other policy has changed the setting, use the default.
|
| - if (setting == CONTENT_SETTING_DEFAULT)
|
| - setting = GetDefaultContentSetting(CONTENT_SETTINGS_TYPE_COOKIES);
|
| -
|
| - return setting;
|
| -}
|
| -
|
| ContentSetting HostContentSettingsMap::GetContentSetting(
|
| const GURL& primary_url,
|
| const GURL& secondary_url,
|
| @@ -468,8 +395,6 @@ bool HostContentSettingsMap::IsSettingAllowedForType(
|
| return true;
|
| }
|
| switch (content_type) {
|
| - case CONTENT_SETTINGS_TYPE_COOKIES:
|
| - return (setting == CONTENT_SETTING_SESSION_ONLY);
|
| case CONTENT_SETTINGS_TYPE_PLUGINS:
|
| return (setting == CONTENT_SETTING_ASK &&
|
| CommandLine::ForCurrentProcess()->HasSwitch(
|
| @@ -483,32 +408,6 @@ bool HostContentSettingsMap::IsSettingAllowedForType(
|
| }
|
| }
|
|
|
| -void HostContentSettingsMap::SetBlockThirdPartyCookies(bool block) {
|
| - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
| - DCHECK(prefs_);
|
| -
|
| - // This setting may not be directly modified for OTR sessions. Instead, it
|
| - // is synced to the main profile's setting.
|
| - if (is_off_the_record_) {
|
| - NOTREACHED();
|
| - return;
|
| - }
|
| -
|
| - // If the preference block-third-party-cookies is managed then do not allow to
|
| - // change it.
|
| - if (prefs_->IsManagedPreference(prefs::kBlockThirdPartyCookies)) {
|
| - NOTREACHED();
|
| - return;
|
| - }
|
| -
|
| - {
|
| - base::AutoLock auto_lock(lock_);
|
| - block_third_party_cookies_ = block;
|
| - }
|
| -
|
| - prefs_->SetBoolean(prefs::kBlockThirdPartyCookies, block);
|
| -}
|
| -
|
| void HostContentSettingsMap::OnContentSettingChanged(
|
| ContentSettingsPattern primary_pattern,
|
| ContentSettingsPattern secondary_pattern,
|
| @@ -524,31 +423,19 @@ void HostContentSettingsMap::OnContentSettingChanged(
|
| Details<const ContentSettingsDetails>(&details));
|
| }
|
|
|
| -void HostContentSettingsMap::Observe(int type,
|
| - const NotificationSource& source,
|
| - const NotificationDetails& details) {
|
| - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
| -
|
| - if (type == chrome::NOTIFICATION_PREF_CHANGED) {
|
| - DCHECK_EQ(prefs_, Source<PrefService>(source).ptr());
|
| - if (updating_preferences_)
|
| - return;
|
| -
|
| - std::string* name = Details<std::string>(details).ptr();
|
| - if (*name == prefs::kBlockThirdPartyCookies) {
|
| - base::AutoLock auto_lock(lock_);
|
| - block_third_party_cookies_ = prefs_->GetBoolean(
|
| - prefs::kBlockThirdPartyCookies);
|
| - is_block_third_party_cookies_managed_ =
|
| - prefs_->IsManagedPreference(
|
| - prefs::kBlockThirdPartyCookies);
|
| - } else {
|
| - NOTREACHED() << "Unexpected preference observed";
|
| - return;
|
| - }
|
| - } else {
|
| - NOTREACHED() << "Unexpected notification";
|
| - }
|
| +// static
|
| +// Returns true if we should allow all content types for this URL. This is
|
| +// true for various internal objects like chrome:// URLs, so UI and other
|
| +// things users think of as "not webpages" don't break.
|
| +bool HostContentSettingsMap::ShouldAllowAllContent(
|
| + const GURL& url,
|
| + ContentSettingsType content_type) {
|
| + if (content_type == CONTENT_SETTINGS_TYPE_NOTIFICATIONS)
|
| + return false;
|
| + return url.SchemeIs(chrome::kChromeDevToolsScheme) ||
|
| + url.SchemeIs(chrome::kChromeInternalScheme) ||
|
| + url.SchemeIs(chrome::kChromeUIScheme) ||
|
| + url.SchemeIs(chrome::kExtensionScheme);
|
| }
|
|
|
| HostContentSettingsMap::~HostContentSettingsMap() {
|
| @@ -569,7 +456,7 @@ bool HostContentSettingsMap::IsDefaultContentSettingManaged(
|
| void HostContentSettingsMap::ShutdownOnUIThread() {
|
| DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
| DCHECK(prefs_);
|
| - pref_change_registrar_.RemoveAll();
|
| +
|
| prefs_ = NULL;
|
| for (ProviderIterator it = content_settings_providers_.begin();
|
| it != content_settings_providers_.end();
|
| @@ -582,19 +469,3 @@ void HostContentSettingsMap::ShutdownOnUIThread() {
|
| (*it)->ShutdownOnUIThread();
|
| }
|
| }
|
| -
|
| -void HostContentSettingsMap::MigrateObsoleteCookiePref() {
|
| - if (prefs_->HasPrefPath(prefs::kCookieBehavior)) {
|
| - int cookie_behavior = prefs_->GetInteger(prefs::kCookieBehavior);
|
| - prefs_->ClearPref(prefs::kCookieBehavior);
|
| - if (!prefs_->HasPrefPath(prefs::kDefaultContentSettings)) {
|
| - SetDefaultContentSetting(CONTENT_SETTINGS_TYPE_COOKIES,
|
| - (cookie_behavior == net::StaticCookiePolicy::BLOCK_ALL_COOKIES) ?
|
| - CONTENT_SETTING_BLOCK : CONTENT_SETTING_ALLOW);
|
| - }
|
| - if (!prefs_->HasPrefPath(prefs::kBlockThirdPartyCookies)) {
|
| - SetBlockThirdPartyCookies(cookie_behavior ==
|
| - net::StaticCookiePolicy::BLOCK_SETTING_THIRD_PARTY_COOKIES);
|
| - }
|
| - }
|
| -}
|
|
|