diff options
author | dhollowa@chromium.org <dhollowa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-24 16:33:22 +0000 |
---|---|---|
committer | dhollowa@chromium.org <dhollowa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-24 16:33:22 +0000 |
commit | 1d6247d4ecb0714dca4d505b318d4b7c2a674598 (patch) | |
tree | d9c719b8ca76a9f0625baada83f04da05d7f0c25 /chrome/browser/net | |
parent | ac9419e95b9b08e218a83c08b198126eea5869d6 (diff) | |
download | chromium_src-1d6247d4ecb0714dca4d505b318d4b7c2a674598.zip chromium_src-1d6247d4ecb0714dca4d505b318d4b7c2a674598.tar.gz chromium_src-1d6247d4ecb0714dca4d505b318d4b7c2a674598.tar.bz2 |
Revert 42473 - Add a delegate to CookieMonster and broadcast notifications about changes to cookies.
This change will allow implementing the experimental cookie extension API, specifically the cookies.onChanged event
BUG=38398
TEST=net_unittests
Review URL: http://codereview.chromium.org/1023004
TBR=jochen@chromium.org
Review URL: http://codereview.chromium.org/1256003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@42478 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/net')
-rw-r--r-- | chrome/browser/net/chrome_cookie_notification_details.h | 22 | ||||
-rw-r--r-- | chrome/browser/net/chrome_url_request_context.cc | 101 | ||||
-rw-r--r-- | chrome/browser/net/chrome_url_request_context.h | 2 |
3 files changed, 4 insertions, 121 deletions
diff --git a/chrome/browser/net/chrome_cookie_notification_details.h b/chrome/browser/net/chrome_cookie_notification_details.h deleted file mode 100644 index a4ee4a0..0000000 --- a/chrome/browser/net/chrome_cookie_notification_details.h +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright (c) 2010 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_NOTIFICATION_DETAILS_H_ -#define CHROME_BROWSER_NET_CHROME_COOKIE_NOTIFICATION_DETAILS_H_ - -#include "net/base/cookie_monster.h" - -struct ChromeCookieDetails { - public: - ChromeCookieDetails(net::CookieMonster::CookieListPair* cookie_pair_copy, - bool is_removed) - : cookie_pair(cookie_pair_copy), - removed(is_removed) { - } - - net::CookieMonster::CookieListPair* cookie_pair; - bool removed; -}; - -#endif // CHROME_BROWSER_NET_CHROME_COOKIE_NOTIFICATION_DETAILS_H_ diff --git a/chrome/browser/net/chrome_url_request_context.cc b/chrome/browser/net/chrome_url_request_context.cc index be1e63b..f19bd08 100644 --- a/chrome/browser/net/chrome_url_request_context.cc +++ b/chrome/browser/net/chrome_url_request_context.cc @@ -11,7 +11,6 @@ #include "chrome/browser/extensions/extensions_service.h" #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_net_log.h" #include "chrome/browser/net/sqlite_persistent_cookie_store.h" #include "chrome/browser/net/dns_global.h" @@ -108,92 +107,6 @@ net::ProxyService* CreateProxyService( } // ---------------------------------------------------------------------------- -// CookieMonster::Delegate implementation -// ---------------------------------------------------------------------------- -class ChromeCookieMonsterDelegate : public net::CookieMonster::Delegate { - public: - explicit ChromeCookieMonsterDelegate(Profile* profile) { - CheckCurrentlyOnMainThread(); - profile_getter_ = new ProfileGetter(profile); - } - - // net::CookieMonster::Delegate implementation. - virtual void OnCookieChanged( - const std::string& domain_key, - const net::CookieMonster::CanonicalCookie& cookie, - bool removed) { - ChromeThread::PostTask( - ChromeThread::UI, FROM_HERE, - NewRunnableMethod(this, - &ChromeCookieMonsterDelegate::OnCookieChangedAsyncHelper, - net::CookieMonster::CookieListPair(domain_key, cookie), - removed)); - } - - private: - // This class allows us to safely access the Profile pointer. The Delegate - // itself cannot observe the PROFILE_DESTROYED notification, since it cannot - // guarantee to be deleted on the UI thread and therefore unregister from - // the notifications. All methods of ProfileGetter must be invoked on the UI - // thread. - class ProfileGetter - : public base::RefCountedThreadSafe<ProfileGetter, - ChromeThread::DeleteOnUIThread>, - public NotificationObserver { - public: - explicit ProfileGetter(Profile* profile) : profile_(profile) { - CheckCurrentlyOnMainThread(); - registrar_.Add(this, - NotificationType::PROFILE_DESTROYED, - Source<Profile>(profile_)); - } - - // NotificationObserver implementation. - void Observe(NotificationType type, - const NotificationSource& source, - const NotificationDetails& details) { - CheckCurrentlyOnMainThread(); - if (NotificationType::PROFILE_DESTROYED == type) { - Profile* profile = Source<Profile>(source).ptr(); - if (profile_ == profile) - profile_ = NULL; - } - } - - Profile* get() { - CheckCurrentlyOnMainThread(); - return profile_; - } - - private: - friend class ::ChromeThread; - friend class DeleteTask<ProfileGetter>; - - virtual ~ProfileGetter() {} - - NotificationRegistrar registrar_; - - Profile* profile_; - }; - - virtual ~ChromeCookieMonsterDelegate() {} - - void OnCookieChangedAsyncHelper( - net::CookieMonster::CookieListPair cookie_pair, - bool removed) { - if (profile_getter_->get()) { - ChromeCookieDetails cookie_details(&cookie_pair, removed); - NotificationService::current()->Notify( - NotificationType::COOKIE_CHANGED, - Source<Profile>(profile_getter_->get()), - Details<ChromeCookieDetails>(&cookie_details)); - } - } - - scoped_refptr<ProfileGetter> profile_getter_; -}; - -// ---------------------------------------------------------------------------- // Helper factories // ---------------------------------------------------------------------------- @@ -262,8 +175,7 @@ ChromeURLRequestContext* FactoryForOriginal::Create() { if (record_mode || playback_mode) { // Don't use existing cookies and use an in-memory store. - context->set_cookie_store(new net::CookieMonster(NULL, - cookie_monster_delegate_)); + context->set_cookie_store(new net::CookieMonster(NULL)); cache->set_mode( record_mode ? net::HttpCache::RECORD : net::HttpCache::PLAYBACK); } @@ -278,8 +190,7 @@ ChromeURLRequestContext* FactoryForOriginal::Create() { scoped_refptr<SQLitePersistentCookieStore> cookie_db = new SQLitePersistentCookieStore(cookie_store_path_); - context->set_cookie_store(new net::CookieMonster(cookie_db.get(), - cookie_monster_delegate_)); + context->set_cookie_store(new net::CookieMonster(cookie_db.get())); } context->set_cookie_policy( @@ -321,8 +232,7 @@ ChromeURLRequestContext* FactoryForExtensions::Create() { scoped_refptr<SQLitePersistentCookieStore> cookie_db = new SQLitePersistentCookieStore(cookie_store_path_); - net::CookieMonster* cookie_monster = - new net::CookieMonster(cookie_db.get(), NULL); + net::CookieMonster* cookie_monster = new net::CookieMonster(cookie_db.get()); // Enable cookies for extension URLs only. const char* schemes[] = {chrome::kExtensionScheme}; @@ -372,8 +282,7 @@ ChromeURLRequestContext* FactoryForOffTheRecord::Create() { context->ssl_config_service(), context->http_auth_handler_factory(), 0); - context->set_cookie_store(new net::CookieMonster(NULL, - cookie_monster_delegate_)); + context->set_cookie_store(new net::CookieMonster(NULL)); context->set_cookie_policy( new ChromeCookiePolicy(host_content_settings_map_)); context->set_http_transaction_factory(cache); @@ -956,8 +865,6 @@ ChromeURLRequestContextFactory::ChromeURLRequestContextFactory(Profile* profile) ssl_config_service_ = profile->GetSSLConfigService(); profile_dir_path_ = profile->GetPath(); - - cookie_monster_delegate_ = new ChromeCookieMonsterDelegate(profile); } ChromeURLRequestContextFactory::~ChromeURLRequestContextFactory() { diff --git a/chrome/browser/net/chrome_url_request_context.h b/chrome/browser/net/chrome_url_request_context.h index d483600..7e44d04 100644 --- a/chrome/browser/net/chrome_url_request_context.h +++ b/chrome/browser/net/chrome_url_request_context.h @@ -7,7 +7,6 @@ #include "base/file_path.h" #include "base/linked_ptr.h" -#include "net/base/cookie_monster.h" #include "net/base/cookie_policy.h" #include "chrome/browser/appcache/chrome_appcache_service.h" #include "chrome/browser/host_content_settings_map.h" @@ -385,7 +384,6 @@ class ChromeURLRequestContextFactory { scoped_refptr<Blacklist> privacy_blacklist_; scoped_refptr<net::TransportSecurityState> transport_security_state_; scoped_refptr<net::SSLConfigService> ssl_config_service_; - scoped_refptr<net::CookieMonster::Delegate> cookie_monster_delegate_; FilePath profile_dir_path_; |