diff options
author | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-05-12 15:51:23 +0000 |
---|---|---|
committer | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-05-12 15:51:23 +0000 |
commit | 9025016cccf554e56096e0ba220cb6e38e9c57ce (patch) | |
tree | 830d15fa74ef752e787c3984eb23aee4c3bdc32c /chrome | |
parent | d91aaac40c25cbd3f289453191539834e5e97427 (diff) | |
download | chromium_src-9025016cccf554e56096e0ba220cb6e38e9c57ce.zip chromium_src-9025016cccf554e56096e0ba220cb6e38e9c57ce.tar.gz chromium_src-9025016cccf554e56096e0ba220cb6e38e9c57ce.tar.bz2 |
Get rid of net::CookiePolicy, now that all code that uses it (except WebSocketJob, which appears to be unused and which I updated in this cl) is switched over to use ContentBrowserClient.
BUG=76793
Review URL: http://codereview.chromium.org/6973011
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@85136 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/browser/net/chrome_cookie_policy.cc | 77 | ||||
-rw-r--r-- | chrome/browser/net/chrome_cookie_policy.h | 44 | ||||
-rw-r--r-- | chrome/browser/net/chrome_cookie_policy_unittest.cc | 149 | ||||
-rw-r--r-- | chrome/browser/net/chrome_url_request_context.cc | 5 | ||||
-rw-r--r-- | chrome/browser/net/chrome_url_request_context.h | 1 | ||||
-rw-r--r-- | chrome/browser/profiles/off_the_record_profile_io_data.cc | 3 | ||||
-rw-r--r-- | chrome/browser/profiles/profile_impl_io_data.cc | 4 | ||||
-rw-r--r-- | chrome/browser/profiles/profile_io_data.cc | 5 | ||||
-rw-r--r-- | chrome/browser/profiles/profile_io_data.h | 5 | ||||
-rw-r--r-- | chrome/browser/ui/browser.cc | 1 | ||||
-rw-r--r-- | chrome/chrome_browser.gypi | 2 | ||||
-rw-r--r-- | chrome/chrome_tests.gypi | 1 | ||||
-rw-r--r-- | chrome/service/net/service_url_request_context.cc | 1 | ||||
-rw-r--r-- | chrome/service/net/service_url_request_context.h | 1 |
14 files changed, 0 insertions, 299 deletions
diff --git a/chrome/browser/net/chrome_cookie_policy.cc b/chrome/browser/net/chrome_cookie_policy.cc deleted file mode 100644 index 142aedd..0000000 --- a/chrome/browser/net/chrome_cookie_policy.cc +++ /dev/null @@ -1,77 +0,0 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "chrome/browser/net/chrome_cookie_policy.h" - -#include "base/command_line.h" -#include "base/string_util.h" -#include "chrome/browser/content_settings/host_content_settings_map.h" -#include "chrome/browser/ui/browser_list.h" -#include "chrome/common/chrome_switches.h" -#include "content/browser/browser_thread.h" -#include "net/base/net_errors.h" -#include "net/base/static_cookie_policy.h" - -// ---------------------------------------------------------------------------- - -ChromeCookiePolicy::ChromeCookiePolicy(HostContentSettingsMap* map) - : host_content_settings_map_(map), - strict_third_party_blocking_( - CommandLine::ForCurrentProcess()->HasSwitch( - switches::kBlockReadingThirdPartyCookies)) {} - -ChromeCookiePolicy::~ChromeCookiePolicy() {} - -int ChromeCookiePolicy::CanGetCookies(const GURL& url, - const GURL& first_party) const { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); - - if (host_content_settings_map_->BlockThirdPartyCookies()) { - net::StaticCookiePolicy policy(strict_third_party_blocking_ ? - net::StaticCookiePolicy::BLOCK_ALL_THIRD_PARTY_COOKIES : - net::StaticCookiePolicy::BLOCK_SETTING_THIRD_PARTY_COOKIES); - int rv = policy.CanGetCookies(url, first_party); - DCHECK_NE(net::ERR_IO_PENDING, rv); - if (rv != net::OK) - return rv; - } - - int policy = CheckPolicy(url); - if (policy == net::OK_FOR_SESSION_ONLY) - policy = net::OK; - DCHECK_NE(net::ERR_IO_PENDING, policy); - return policy; -} - -int ChromeCookiePolicy::CanSetCookie(const GURL& url, - const GURL& first_party, - const std::string& cookie_line) const { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); - - if (host_content_settings_map_->BlockThirdPartyCookies()) { - net::StaticCookiePolicy policy(strict_third_party_blocking_ ? - net::StaticCookiePolicy::BLOCK_ALL_THIRD_PARTY_COOKIES : - net::StaticCookiePolicy::BLOCK_SETTING_THIRD_PARTY_COOKIES); - int rv = policy.CanSetCookie(url, first_party, cookie_line); - if (rv != net::OK) - return rv; - } - - int policy = CheckPolicy(url); - DCHECK_NE(net::ERR_IO_PENDING, policy); - return policy; -} - -int ChromeCookiePolicy::CheckPolicy(const GURL& url) const { - ContentSetting setting = host_content_settings_map_->GetContentSetting( - url, CONTENT_SETTINGS_TYPE_COOKIES, ""); - if (setting == CONTENT_SETTING_BLOCK) - return net::ERR_ACCESS_DENIED; - if (setting == CONTENT_SETTING_ALLOW) - return net::OK; - if (setting == CONTENT_SETTING_SESSION_ONLY) - return net::OK_FOR_SESSION_ONLY; - NOTREACHED(); - return net::ERR_ACCESS_DENIED; -} diff --git a/chrome/browser/net/chrome_cookie_policy.h b/chrome/browser/net/chrome_cookie_policy.h deleted file mode 100644 index 907fb5e..0000000 --- a/chrome/browser/net/chrome_cookie_policy.h +++ /dev/null @@ -1,44 +0,0 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CHROME_BROWSER_NET_CHROME_COOKIE_POLICY_H_ -#define CHROME_BROWSER_NET_CHROME_COOKIE_POLICY_H_ -#pragma once - -#include <map> -#include <string> -#include <vector> - -#include "base/memory/ref_counted.h" -#include "googleurl/src/gurl.h" -#include "net/base/cookie_policy.h" - -class HostContentSettingsMap; - -// Implements CookiePolicy that uses HostContentSettingsMap and -// net::StaticCookiePolicy to decide if the cookie should be blocked. -class ChromeCookiePolicy : public net::CookiePolicy { - public: - explicit ChromeCookiePolicy(HostContentSettingsMap* map); - virtual ~ChromeCookiePolicy(); - - // CookiePolicy methods: - virtual int CanGetCookies(const GURL& url, const GURL& first_party) const; - virtual int CanSetCookie(const GURL& url, - const GURL& first_party, - const std::string& cookie_line) const; - - private: - int CheckPolicy(const GURL& url) const; - - const scoped_refptr<HostContentSettingsMap> host_content_settings_map_; - - // True if blocking third-party cookies also applies to reading them. - bool strict_third_party_blocking_; - - friend class ChromeCookiePolicyTest; - DISALLOW_COPY_AND_ASSIGN(ChromeCookiePolicy); -}; - -#endif // CHROME_BROWSER_NET_CHROME_COOKIE_POLICY_H_ diff --git a/chrome/browser/net/chrome_cookie_policy_unittest.cc b/chrome/browser/net/chrome_cookie_policy_unittest.cc deleted file mode 100644 index 4721076..0000000 --- a/chrome/browser/net/chrome_cookie_policy_unittest.cc +++ /dev/null @@ -1,149 +0,0 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "chrome/browser/net/chrome_cookie_policy.h" - -#include "chrome/browser/content_settings/content_settings_pattern.h" -#include "chrome/browser/content_settings/host_content_settings_map.h" -#include "chrome/common/content_settings.h" -#include "chrome/common/content_settings_types.h" -#include "chrome/test/testing_profile.h" -#include "content/browser/browser_thread.h" -#include "googleurl/src/gurl.h" -#include "net/base/net_errors.h" -#include "testing/gtest/include/gtest/gtest.h" - -static const GURL kBlockedSite = GURL("http://ads.thirdparty.com"); -static const GURL kAllowedSite = GURL("http://good.allays.com"); -static const GURL kFirstPartySite = GURL("http://cool.things.com"); - -class ChromeCookiePolicyTest : public testing::Test { - public: - ChromeCookiePolicyTest() - : ui_thread_(BrowserThread::UI, &message_loop_), - io_thread_(BrowserThread::IO, &message_loop_), - cookie_policy_(settings()) { - } - - TestingProfile* profile() { return &profile_; } - - HostContentSettingsMap* settings() { - return profile()->GetHostContentSettingsMap(); - } - - ChromeCookiePolicy* policy() { return &cookie_policy_; } - - void set_strict_third_party_blocking(bool flag) { - policy()->strict_third_party_blocking_ = flag; - } - - void SetException(const GURL& url, ContentSetting setting) { - settings()->AddExceptionForURL(url, CONTENT_SETTINGS_TYPE_COOKIES, "", - setting); - } - - private: - // HostContentSettingsMap can only operate and be deleted on the UI thread. - // Give it a fake one. - MessageLoop message_loop_; - BrowserThread ui_thread_; - BrowserThread io_thread_; - - TestingProfile profile_; - ChromeCookiePolicy cookie_policy_; -}; - -namespace { - -TEST_F(ChromeCookiePolicyTest, BlockSingle) { - SetException(kBlockedSite, CONTENT_SETTING_BLOCK); - EXPECT_EQ(net::ERR_ACCESS_DENIED, - policy()->CanGetCookies(kBlockedSite, kBlockedSite)); -} - -TEST_F(ChromeCookiePolicyTest, BlockThirdParty) { - settings()->SetBlockThirdPartyCookies(true); - EXPECT_EQ(net::OK, - policy()->CanGetCookies(kBlockedSite, kFirstPartySite)); - EXPECT_EQ(net::ERR_ACCESS_DENIED, - policy()->CanSetCookie(kBlockedSite, kFirstPartySite, "")); - - set_strict_third_party_blocking(true); - EXPECT_EQ(net::ERR_ACCESS_DENIED, - policy()->CanGetCookies(kBlockedSite, kFirstPartySite)); -} - -TEST_F(ChromeCookiePolicyTest, AllowThirdParty) { - settings()->SetBlockThirdPartyCookies(false); - EXPECT_EQ(net::OK, policy()->CanGetCookies(kBlockedSite, kFirstPartySite)); - EXPECT_EQ(net::OK, policy()->CanSetCookie(kBlockedSite, kFirstPartySite, "")); -} - -TEST_F(ChromeCookiePolicyTest, ExplicitBlockSingleThirdParty) { - SetException(kBlockedSite, CONTENT_SETTING_BLOCK); - settings()->SetBlockThirdPartyCookies(false); - - EXPECT_EQ(net::ERR_ACCESS_DENIED, - policy()->CanGetCookies(kBlockedSite, kFirstPartySite)); - EXPECT_EQ(net::ERR_ACCESS_DENIED, - policy()->CanSetCookie(kBlockedSite, kFirstPartySite, "")); - EXPECT_EQ(net::OK, - policy()->CanSetCookie(kAllowedSite, kFirstPartySite, "")); -} - -TEST_F(ChromeCookiePolicyTest, ExplicitSessionOnly) { - SetException(kBlockedSite, CONTENT_SETTING_SESSION_ONLY); - - settings()->SetBlockThirdPartyCookies(false); - EXPECT_EQ(net::OK, policy()->CanGetCookies(kBlockedSite, kFirstPartySite)); - EXPECT_EQ(net::OK_FOR_SESSION_ONLY, - policy()->CanSetCookie(kBlockedSite, kFirstPartySite, "")); - - settings()->SetBlockThirdPartyCookies(true); - EXPECT_EQ(net::OK, policy()->CanGetCookies(kBlockedSite, kFirstPartySite)); - EXPECT_EQ(net::ERR_ACCESS_DENIED, - policy()->CanSetCookie(kBlockedSite, kFirstPartySite, "")); -} - -TEST_F(ChromeCookiePolicyTest, ThirdPartyAlwaysBlocked) { - SetException(kAllowedSite, CONTENT_SETTING_ALLOW); - - settings()->SetBlockThirdPartyCookies(true); - EXPECT_EQ(net::OK, - policy()->CanGetCookies(kAllowedSite, kFirstPartySite)); - EXPECT_EQ(net::ERR_ACCESS_DENIED, - policy()->CanSetCookie(kAllowedSite, kFirstPartySite, "")); - - set_strict_third_party_blocking(true); - EXPECT_EQ(net::ERR_ACCESS_DENIED, - policy()->CanGetCookies(kAllowedSite, kFirstPartySite)); -} - -TEST_F(ChromeCookiePolicyTest, BlockEverything) { - settings()->SetDefaultContentSetting(CONTENT_SETTINGS_TYPE_COOKIES, - CONTENT_SETTING_BLOCK); - EXPECT_EQ(net::ERR_ACCESS_DENIED, - policy()->CanGetCookies(kFirstPartySite, kFirstPartySite)); - EXPECT_EQ(net::ERR_ACCESS_DENIED, - policy()->CanSetCookie(kFirstPartySite, kFirstPartySite, "")); - EXPECT_EQ(net::ERR_ACCESS_DENIED, - policy()->CanSetCookie(kAllowedSite, kFirstPartySite, "")); -} - -TEST_F(ChromeCookiePolicyTest, BlockEverythingExceptAllowed) { - settings()->SetDefaultContentSetting(CONTENT_SETTINGS_TYPE_COOKIES, - CONTENT_SETTING_BLOCK); - SetException(kAllowedSite, CONTENT_SETTING_ALLOW); - - EXPECT_EQ(net::ERR_ACCESS_DENIED, - policy()->CanGetCookies(kFirstPartySite, kFirstPartySite)); - EXPECT_EQ(net::ERR_ACCESS_DENIED, - policy()->CanSetCookie(kFirstPartySite, kFirstPartySite, "")); - EXPECT_EQ(net::OK, policy()->CanGetCookies(kAllowedSite, kFirstPartySite)); - EXPECT_EQ(net::OK, policy()->CanSetCookie(kAllowedSite, kFirstPartySite, "")); - EXPECT_EQ(net::OK, policy()->CanGetCookies(kAllowedSite, kAllowedSite)); - EXPECT_EQ(net::OK, policy()->CanSetCookie(kAllowedSite, kAllowedSite, "")); -} - -} diff --git a/chrome/browser/net/chrome_url_request_context.cc b/chrome/browser/net/chrome_url_request_context.cc index 9273ba8..0216f81 100644 --- a/chrome/browser/net/chrome_url_request_context.cc +++ b/chrome/browser/net/chrome_url_request_context.cc @@ -410,11 +410,6 @@ ChromeURLRequestContext::~ChromeURLRequestContext() { NotificationType::URL_REQUEST_CONTEXT_RELEASED, Source<net::URLRequestContext>(this), NotificationService::NoDetails()); - - // cookie_policy_'s lifetime is auto-managed by chrome_cookie_policy_. We - // null this out here to avoid a dangling reference to chrome_cookie_policy_ - // when ~net::URLRequestContext runs. - set_cookie_policy(NULL); } const std::string& ChromeURLRequestContext::GetUserAgent( diff --git a/chrome/browser/net/chrome_url_request_context.h b/chrome/browser/net/chrome_url_request_context.h index 7b2c287..bb9d72e 100644 --- a/chrome/browser/net/chrome_url_request_context.h +++ b/chrome/browser/net/chrome_url_request_context.h @@ -20,7 +20,6 @@ #include "content/browser/chrome_blob_storage_context.h" #include "content/common/notification_observer.h" #include "content/common/notification_registrar.h" -#include "net/base/cookie_policy.h" #include "net/url_request/url_request_context.h" #include "net/url_request/url_request_context_getter.h" #include "webkit/fileapi/file_system_context.h" diff --git a/chrome/browser/profiles/off_the_record_profile_io_data.cc b/chrome/browser/profiles/off_the_record_profile_io_data.cc index a2d5a99..644dbfe 100644 --- a/chrome/browser/profiles/off_the_record_profile_io_data.cc +++ b/chrome/browser/profiles/off_the_record_profile_io_data.cc @@ -129,9 +129,6 @@ void OffTheRecordProfileIOData::LazyInitializeInternal( ApplyProfileParamsToContext(main_context); ApplyProfileParamsToContext(extensions_context); - main_context->set_cookie_policy(cookie_policy()); - extensions_context->set_cookie_policy(cookie_policy()); - main_context->set_net_log(io_thread->net_log()); extensions_context->set_net_log(io_thread->net_log()); diff --git a/chrome/browser/profiles/profile_impl_io_data.cc b/chrome/browser/profiles/profile_impl_io_data.cc index b295fc2..33bd8b8 100644 --- a/chrome/browser/profiles/profile_impl_io_data.cc +++ b/chrome/browser/profiles/profile_impl_io_data.cc @@ -182,10 +182,6 @@ void ProfileImplIOData::LazyInitializeInternal( ApplyProfileParamsToContext(media_request_context_); ApplyProfileParamsToContext(extensions_context); - main_context->set_cookie_policy(cookie_policy()); - media_request_context_->set_cookie_policy(cookie_policy()); - extensions_context->set_cookie_policy(cookie_policy()); - main_context->set_net_log(io_thread->net_log()); media_request_context_->set_net_log(io_thread->net_log()); extensions_context->set_net_log(io_thread->net_log()); diff --git a/chrome/browser/profiles/profile_io_data.cc b/chrome/browser/profiles/profile_io_data.cc index efdb752..e12daa4 100644 --- a/chrome/browser/profiles/profile_io_data.cc +++ b/chrome/browser/profiles/profile_io_data.cc @@ -18,7 +18,6 @@ #include "chrome/browser/extensions/user_script_master.h" #include "chrome/browser/io_thread.h" #include "chrome/browser/net/chrome_cookie_notification_details.h" -#include "chrome/browser/net/chrome_cookie_policy.h" #include "chrome/browser/net/chrome_dns_cert_provenance_checker_factory.h" #include "chrome/browser/net/chrome_net_log.h" #include "chrome/browser/net/chrome_network_delegate.h" @@ -292,10 +291,6 @@ void ProfileIOData::LazyInitialize() const { profile_params_->appcache_service->set_request_context(main_request_context_); - // Create objects pointed to by URLRequestContext. - cookie_policy_.reset( - new ChromeCookiePolicy(profile_params_->host_content_settings_map)); - network_delegate_.reset(new ChromeNetworkDelegate( io_thread_globals->extension_event_router_forwarder.get(), profile_params_->profile_id, diff --git a/chrome/browser/profiles/profile_io_data.h b/chrome/browser/profiles/profile_io_data.h index addee5b..a46d142 100644 --- a/chrome/browser/profiles/profile_io_data.h +++ b/chrome/browser/profiles/profile_io_data.h @@ -157,10 +157,6 @@ class ProfileIOData : public base::RefCountedThreadSafe<ProfileIOData> { return proxy_service_.get(); } - net::CookiePolicy* cookie_policy() const { - return cookie_policy_.get(); - } - ChromeURLRequestContext* main_request_context() const { return main_request_context_; } @@ -218,7 +214,6 @@ class ProfileIOData : public base::RefCountedThreadSafe<ProfileIOData> { mutable scoped_ptr<net::NetworkDelegate> network_delegate_; mutable scoped_ptr<net::DnsCertProvenanceChecker> dns_cert_checker_; mutable scoped_ptr<net::ProxyService> proxy_service_; - mutable scoped_ptr<net::CookiePolicy> cookie_policy_; // Pointed to by ResourceContext. mutable scoped_refptr<webkit_database::DatabaseTracker> database_tracker_; diff --git a/chrome/browser/ui/browser.cc b/chrome/browser/ui/browser.cc index 240bcf0..cb03148 100644 --- a/chrome/browser/ui/browser.cc +++ b/chrome/browser/ui/browser.cc @@ -124,7 +124,6 @@ #include "net/base/cookie_monster.h" #include "net/base/net_util.h" #include "net/base/registry_controlled_domain.h" -#include "net/base/static_cookie_policy.h" #include "net/url_request/url_request_context.h" #include "ui/base/animation/animation.h" #include "ui/base/l10n/l10n_util.h" diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi index 20ef26a..edd0a82 100644 --- a/chrome/chrome_browser.gypi +++ b/chrome/chrome_browser.gypi @@ -1314,8 +1314,6 @@ 'browser/net/browser_url_util.cc', 'browser/net/browser_url_util.h', 'browser/net/chrome_cookie_notification_details.h', - 'browser/net/chrome_cookie_policy.cc', - 'browser/net/chrome_cookie_policy.h', 'browser/net/chrome_dns_cert_provenance_checker.cc', 'browser/net/chrome_dns_cert_provenance_checker.h', 'browser/net/chrome_dns_cert_provenance_checker_factory.cc', diff --git a/chrome/chrome_tests.gypi b/chrome/chrome_tests.gypi index c5f9599..9c64759 100644 --- a/chrome/chrome_tests.gypi +++ b/chrome/chrome_tests.gypi @@ -1395,7 +1395,6 @@ 'browser/mock_keychain_mac.h', 'browser/mock_plugin_exceptions_table_model.cc', 'browser/mock_plugin_exceptions_table_model.h', - 'browser/net/chrome_cookie_policy_unittest.cc', 'browser/net/chrome_net_log_unittest.cc', 'browser/net/connection_tester_unittest.cc', 'browser/net/gaia/token_service_unittest.cc', diff --git a/chrome/service/net/service_url_request_context.cc b/chrome/service/net/service_url_request_context.cc index 577d2b2..b17b3b5 100644 --- a/chrome/service/net/service_url_request_context.cc +++ b/chrome/service/net/service_url_request_context.cc @@ -16,7 +16,6 @@ #include "chrome/service/service_process.h" #include "net/base/cert_verifier.h" #include "net/base/cookie_monster.h" -#include "net/base/cookie_policy.h" #include "net/base/dnsrr_resolver.h" #include "net/base/host_resolver.h" #include "net/base/ssl_config_service_defaults.h" diff --git a/chrome/service/net/service_url_request_context.h b/chrome/service/net/service_url_request_context.h index 5cb896d..1b13f5a 100644 --- a/chrome/service/net/service_url_request_context.h +++ b/chrome/service/net/service_url_request_context.h @@ -10,7 +10,6 @@ #include "base/memory/scoped_ptr.h" #include "net/base/cookie_monster.h" -#include "net/base/cookie_policy.h" #include "net/base/host_resolver.h" #include "net/base/ssl_config_service_defaults.h" #include "net/disk_cache/disk_cache.h" |