summaryrefslogtreecommitdiffstats
path: root/chrome/browser/browsing_data
diff options
context:
space:
mode:
authorajwong@chromium.org <ajwong@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-08-27 05:56:17 +0000
committerajwong@chromium.org <ajwong@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-08-27 05:56:17 +0000
commit44080e71f9994cfa0c52c470196e7993a4cb9482 (patch)
tree776f2765d6c45b2a57158e0490b070ce3afb5f55 /chrome/browser/browsing_data
parent50f92668f15f6da453389e6e8705e3aef9ae1a07 (diff)
downloadchromium_src-44080e71f9994cfa0c52c470196e7993a4cb9482.zip
chromium_src-44080e71f9994cfa0c52c470196e7993a4cb9482.tar.gz
chromium_src-44080e71f9994cfa0c52c470196e7993a4cb9482.tar.bz2
Remove the Extensions URLRequestContext.
Though chrome-extension: scheme URLs support cookies, they do not share a namespace with http: and https:. In particular, chrome-extension://a and http://a should not have the same set of cookies. To enforce this, previously the code created a completely separate URLRequestContext for servicing chrome-extension: schemes. However, the code really only used this object as a method for conveying the correct cookie jar from Profile creation to a few spots where cookies were accessed; the rest of the URLRequestContext functionality was unused. This CL removes the Extensions URLRequestContext code and replaces it with APIs that directly expose the needed net::CookieStore. Lastly, CookieMonster::EnableFileScheme() is removed and CookieMonster::Delegate is renamed CookieMonsterDelegate. EnableFileScheme is an inherently racy API because CookieMonsters are creatable on all threads and this function sets an unprotected global flag. CookieMonsterDelegate is preferable to the nested interface because it can now be forward declared. TBRing darin and sky to cover the rest of the mechanical unittest changes. TBR=darin,sky BUG=158386,159193,57884 Review URL: https://chromiumcodereview.appspot.com/12546016 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@219709 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/browsing_data')
-rw-r--r--chrome/browser/browsing_data/browsing_data_cookie_helper_unittest.cc29
-rw-r--r--chrome/browser/browsing_data/browsing_data_remover_unittest.cc14
2 files changed, 29 insertions, 14 deletions
diff --git a/chrome/browser/browsing_data/browsing_data_cookie_helper_unittest.cc b/chrome/browser/browsing_data/browsing_data_cookie_helper_unittest.cc
index 7e02b83..532d89e 100644
--- a/chrome/browser/browsing_data/browsing_data_cookie_helper_unittest.cc
+++ b/chrome/browser/browsing_data/browsing_data_cookie_helper_unittest.cc
@@ -7,6 +7,8 @@
#include "base/bind.h"
#include "base/run_loop.h"
#include "chrome/test/base/testing_profile.h"
+#include "content/public/browser/storage_partition.h"
+#include "content/public/common/url_constants.h"
#include "content/public/test/test_browser_thread_bundle.h"
#include "net/cookies/canonical_cookie.h"
#include "net/cookies/parsed_cookie.h"
@@ -21,25 +23,32 @@ class BrowsingDataCookieHelperTest : public testing::Test {
: testing_profile_(new TestingProfile()) {
}
+ net::CookieMonster* GetCookieMonster(const GURL& origin) {
+ using content::BrowserContext;
+ // Since it's a unittest, assume default StoragePartition.
+ return BrowserContext::GetDefaultStoragePartition(testing_profile_.get())->
+ GetCookieStoreForScheme(origin.scheme())->GetCookieMonster();
+ }
+
void CreateCookiesForTest() {
- scoped_refptr<net::CookieMonster> cookie_monster =
- testing_profile_->GetCookieMonster();
- cookie_monster->SetCookieWithOptionsAsync(
- GURL("http://www.google.com"), "A=1", net::CookieOptions(),
+ GURL origin1("http://www.google.com");
+ GURL origin2("http://www.gmail.google.com");
+ GetCookieMonster(origin1)->SetCookieWithOptionsAsync(
+ origin1, "A=1", net::CookieOptions(),
net::CookieMonster::SetCookiesCallback());
- cookie_monster->SetCookieWithOptionsAsync(
- GURL("http://www.gmail.google.com"), "B=1", net::CookieOptions(),
+ GetCookieMonster(origin2)->SetCookieWithOptionsAsync(
+ origin2, "B=1", net::CookieOptions(),
net::CookieMonster::SetCookiesCallback());
}
void CreateCookiesForDomainCookieTest() {
- scoped_refptr<net::CookieMonster> cookie_monster =
- testing_profile_->GetCookieMonster();
+ GURL origin("http://www.google.com");
+ scoped_refptr<net::CookieMonster> cookie_monster = GetCookieMonster(origin);
cookie_monster->SetCookieWithOptionsAsync(
- GURL("http://www.google.com"), "A=1", net::CookieOptions(),
+ origin, "A=1", net::CookieOptions(),
net::CookieMonster::SetCookiesCallback());
cookie_monster->SetCookieWithOptionsAsync(
- GURL("http://www.google.com"), "A=2; Domain=.www.google.com ",
+ origin, "A=2; Domain=.www.google.com ",
net::CookieOptions(), net::CookieMonster::SetCookiesCallback());
}
diff --git a/chrome/browser/browsing_data/browsing_data_remover_unittest.cc b/chrome/browser/browsing_data/browsing_data_remover_unittest.cc
index 3de958d..7ec7e48 100644
--- a/chrome/browser/browsing_data/browsing_data_remover_unittest.cc
+++ b/chrome/browser/browsing_data/browsing_data_remover_unittest.cc
@@ -31,12 +31,15 @@
#include "components/autofill/core/browser/credit_card.h"
#include "components/autofill/core/browser/personal_data_manager.h"
#include "components/autofill/core/browser/personal_data_manager_observer.h"
+#include "content/public/browser/browser_context.h"
+#include "content/public/browser/cookie_store_factory.h"
#include "content/public/browser/dom_storage_context.h"
#include "content/public/browser/local_storage_usage_info.h"
#include "content/public/browser/notification_service.h"
#include "content/public/browser/storage_partition.h"
-#include "content/public/test/test_browser_thread.h"
+#include "content/public/common/url_constants.h"
#include "content/public/test/test_browser_thread_bundle.h"
+#include "content/public/test/test_utils.h"
#include "net/cookies/cookie_monster.h"
#include "net/ssl/server_bound_cert_service.h"
#include "net/ssl/server_bound_cert_store.h"
@@ -223,8 +226,9 @@ class RemoveCookieTester {
class RemoveProfileCookieTester : public RemoveCookieTester {
public:
explicit RemoveProfileCookieTester(TestingProfile* profile) {
- SetMonster(profile->GetRequestContext()->GetURLRequestContext()->
- cookie_store()->GetCookieMonster());
+ SetMonster(
+ content::BrowserContext::GetDefaultStoragePartition(profile)->
+ GetCookieStoreForScheme(chrome::kHttpScheme)->GetCookieMonster());
}
};
@@ -241,7 +245,9 @@ class RemoveSafeBrowsingCookieTester : public RemoveCookieTester {
// Create a cookiemonster that does not have persistant storage, and replace
// the SafeBrowsingService created one with it.
- net::CookieStore* monster = new net::CookieMonster(NULL, NULL);
+ net::CookieStore* monster =
+ content::CreateCookieStore(content::CookieStoreConfig())->
+ GetCookieMonster();
sb_service->url_request_context()->GetURLRequestContext()->
set_cookie_store(monster);
SetMonster(monster);