summaryrefslogtreecommitdiffstats
path: root/content
diff options
context:
space:
mode:
authorearthdok@chromium.org <earthdok@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-08-27 14:39:08 +0000
committerearthdok@chromium.org <earthdok@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-08-27 14:39:08 +0000
commit33ad6ce948e24e01ec1634af63001dda4ac0506a (patch)
tree71daec231014a7b05e1a213e2ac0a9a41f4ca52a /content
parentd0a60eea5c90a5b594604c91654859a493e1b5cb (diff)
downloadchromium_src-33ad6ce948e24e01ec1634af63001dda4ac0506a.zip
chromium_src-33ad6ce948e24e01ec1634af63001dda4ac0506a.tar.gz
chromium_src-33ad6ce948e24e01ec1634af63001dda4ac0506a.tar.bz2
Revert 219709 "Remove the Extensions URLRequestContext."
Reverted due to crashes under memory tools. BUG=280138 > 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 TBR=ajwong@chromium.org Review URL: https://codereview.chromium.org/23551005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@219787 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content')
-rw-r--r--content/browser/appcache/chrome_appcache_service_unittest.cc67
-rw-r--r--content/browser/browser_context.cc7
-rw-r--r--content/browser/fileapi/fileapi_message_filter_unittest.cc28
-rw-r--r--content/browser/loader/resource_dispatcher_host_unittest.cc38
-rw-r--r--content/browser/loader/resource_message_filter.h1
-rw-r--r--content/browser/net/cookie_store_map.cc104
-rw-r--r--content/browser/net/cookie_store_map.h62
-rw-r--r--content/browser/net/sqlite_persistent_cookie_store.cc50
-rw-r--r--content/browser/renderer_host/render_message_filter.cc73
-rw-r--r--content/browser/renderer_host/render_message_filter.h14
-rw-r--r--content/browser/renderer_host/render_process_host_impl.cc3
-rw-r--r--content/browser/storage_partition_impl.cc81
-rw-r--r--content/browser/storage_partition_impl.h22
-rw-r--r--content/browser/storage_partition_impl_map.cc90
-rw-r--r--content/browser/storage_partition_impl_map.h5
-rw-r--r--content/browser/storage_partition_impl_unittest.cc5
-rw-r--r--content/content_browser.gypi2
-rw-r--r--content/public/browser/browser_context.h27
-rw-r--r--content/public/browser/content_browser_client.cc5
-rw-r--r--content/public/browser/content_browser_client.h10
-rw-r--r--content/public/browser/cookie_store_factory.h40
-rw-r--r--content/public/browser/storage_partition.h15
-rw-r--r--content/public/common/content_constants.cc3
-rw-r--r--content/public/common/content_constants.h2
-rw-r--r--content/public/common/content_switches.cc4
-rw-r--r--content/public/common/content_switches.h1
-rw-r--r--content/public/test/mock_resource_context.cc10
-rw-r--r--content/public/test/mock_resource_context.h4
-rw-r--r--content/public/test/test_browser_context.cc10
-rw-r--r--content/shell/app/shell_main_delegate.cc2
-rw-r--r--content/shell/browser/shell_browser_context.cc1
-rw-r--r--content/shell/browser/shell_url_request_context_getter.cc4
-rw-r--r--content/test/test_content_browser_client.cc9
-rw-r--r--content/test/test_content_browser_client.h7
34 files changed, 245 insertions, 561 deletions
diff --git a/content/browser/appcache/chrome_appcache_service_unittest.cc b/content/browser/appcache/chrome_appcache_service_unittest.cc
index 6ebb163..a4e895c 100644
--- a/content/browser/appcache/chrome_appcache_service_unittest.cc
+++ b/content/browser/appcache/chrome_appcache_service_unittest.cc
@@ -6,12 +6,11 @@
#include "base/file_util.h"
#include "base/files/scoped_temp_dir.h"
#include "base/memory/ref_counted.h"
-#include "base/run_loop.h"
+#include "base/message_loop/message_loop.h"
#include "content/browser/appcache/chrome_appcache_service.h"
-#include "content/public/browser/browser_thread.h"
+#include "content/browser/browser_thread_impl.h"
#include "content/public/browser/resource_context.h"
#include "content/public/test/test_browser_context.h"
-#include "content/public/test/test_browser_thread_bundle.h"
#include "net/url_request/url_request_context_getter.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "webkit/browser/appcache/appcache_database.h"
@@ -34,29 +33,63 @@ const char kProtectedManifest[] = "http://www.protected.com/cache.manifest";
const char kNormalManifest[] = "http://www.normal.com/cache.manifest";
const char kSessionOnlyManifest[] = "http://www.sessiononly.com/cache.manifest";
+class MockURLRequestContextGetter : public net::URLRequestContextGetter {
+ public:
+ MockURLRequestContextGetter(
+ net::URLRequestContext* context,
+ base::MessageLoopProxy* message_loop_proxy)
+ : context_(context), message_loop_proxy_(message_loop_proxy) {
+ }
+
+ virtual net::URLRequestContext* GetURLRequestContext() OVERRIDE {
+ return context_;
+ }
+
+ virtual scoped_refptr<base::SingleThreadTaskRunner>
+ GetNetworkTaskRunner() const OVERRIDE {
+ return message_loop_proxy_;
+ }
+
+ protected:
+ virtual ~MockURLRequestContextGetter() {}
+
+ private:
+ net::URLRequestContext* context_;
+ scoped_refptr<base::SingleThreadTaskRunner> message_loop_proxy_;
+};
+
} // namespace
class ChromeAppCacheServiceTest : public testing::Test {
- protected:
+ public:
ChromeAppCacheServiceTest()
- : thread_bundle_(TestBrowserThreadBundle::IO_MAINLOOP),
+ : message_loop_(base::MessageLoop::TYPE_IO),
kProtectedManifestURL(kProtectedManifest),
kNormalManifestURL(kNormalManifest),
- kSessionOnlyManifestURL(kSessionOnlyManifest) {
- }
+ kSessionOnlyManifestURL(kSessionOnlyManifest),
+ file_thread_(BrowserThread::FILE, &message_loop_),
+ file_user_blocking_thread_(BrowserThread::FILE_USER_BLOCKING,
+ &message_loop_),
+ cache_thread_(BrowserThread::CACHE, &message_loop_),
+ io_thread_(BrowserThread::IO, &message_loop_) {}
+ protected:
scoped_refptr<ChromeAppCacheService> CreateAppCacheService(
const base::FilePath& appcache_path,
bool init_storage);
void InsertDataIntoAppCache(ChromeAppCacheService* appcache_service);
- TestBrowserThreadBundle thread_bundle_;
+ base::MessageLoop message_loop_;
base::ScopedTempDir temp_dir_;
const GURL kProtectedManifestURL;
const GURL kNormalManifestURL;
const GURL kSessionOnlyManifestURL;
private:
+ BrowserThreadImpl file_thread_;
+ BrowserThreadImpl file_user_blocking_thread_;
+ BrowserThreadImpl cache_thread_;
+ BrowserThreadImpl io_thread_;
TestBrowserContext browser_context_;
};
@@ -70,6 +103,10 @@ ChromeAppCacheServiceTest::CreateAppCacheService(
new quota::MockSpecialStoragePolicy;
mock_policy->AddProtected(kProtectedManifestURL.GetOrigin());
mock_policy->AddSessionOnly(kSessionOnlyManifestURL.GetOrigin());
+ scoped_refptr<MockURLRequestContextGetter> mock_request_context_getter =
+ new MockURLRequestContextGetter(
+ browser_context_.GetResourceContext()->GetRequestContext(),
+ message_loop_.message_loop_proxy().get());
BrowserThread::PostTask(
BrowserThread::IO,
FROM_HERE,
@@ -77,17 +114,17 @@ ChromeAppCacheServiceTest::CreateAppCacheService(
appcache_service.get(),
appcache_path,
browser_context_.GetResourceContext(),
- make_scoped_refptr(browser_context_.GetRequestContext()),
+ mock_request_context_getter,
mock_policy));
// Steps needed to initialize the storage of AppCache data.
- base::RunLoop().RunUntilIdle();
+ message_loop_.RunUntilIdle();
if (init_storage) {
appcache::AppCacheStorageImpl* storage =
static_cast<appcache::AppCacheStorageImpl*>(
appcache_service->storage());
storage->database_->db_connection();
storage->disk_cache();
- base::RunLoop().RunUntilIdle();
+ message_loop_.RunUntilIdle();
}
return appcache_service;
}
@@ -123,7 +160,7 @@ TEST_F(ChromeAppCacheServiceTest, KeepOnDestruction) {
// Test: delete the ChromeAppCacheService
appcache_service = NULL;
- base::RunLoop().RunUntilIdle();
+ message_loop_.RunUntilIdle();
// Recreate the appcache (for reading the data back)
appcache_service = CreateAppCacheService(appcache_path, false);
@@ -143,7 +180,7 @@ TEST_F(ChromeAppCacheServiceTest, KeepOnDestruction) {
// Delete and let cleanup tasks run prior to returning.
appcache_service = NULL;
- base::RunLoop().RunUntilIdle();
+ message_loop_.RunUntilIdle();
}
TEST_F(ChromeAppCacheServiceTest, SaveSessionState) {
@@ -163,7 +200,7 @@ TEST_F(ChromeAppCacheServiceTest, SaveSessionState) {
// Test: delete the ChromeAppCacheService
appcache_service = NULL;
- base::RunLoop().RunUntilIdle();
+ message_loop_.RunUntilIdle();
// Recreate the appcache (for reading the data back)
appcache_service = CreateAppCacheService(appcache_path, false);
@@ -183,7 +220,7 @@ TEST_F(ChromeAppCacheServiceTest, SaveSessionState) {
// Delete and let cleanup tasks run prior to returning.
appcache_service = NULL;
- base::RunLoop().RunUntilIdle();
+ message_loop_.RunUntilIdle();
}
} // namespace content
diff --git a/content/browser/browser_context.cc b/content/browser/browser_context.cc
index d6cfe9f..2e76dc0 100644
--- a/content/browser/browser_context.cc
+++ b/content/browser/browser_context.cc
@@ -93,9 +93,6 @@ void PurgeMemoryOnIOThread(appcache::AppCacheService* appcache_service) {
} // namespace
-// Choose something that isn't a legal URI scheme for the kDefaultCookieScheme.
-const char BrowserContext::kDefaultCookieScheme[] = "1 default scheme";
-
// static
void BrowserContext::AsyncObliterateStoragePartition(
BrowserContext* browser_context,
@@ -276,8 +273,4 @@ BrowserContext::~BrowserContext() {
#endif
}
-bool BrowserContext::IsOffTheRecord() const {
- return false;
-}
-
} // namespace content
diff --git a/content/browser/fileapi/fileapi_message_filter_unittest.cc b/content/browser/fileapi/fileapi_message_filter_unittest.cc
index 4858cff..06b112b 100644
--- a/content/browser/fileapi/fileapi_message_filter_unittest.cc
+++ b/content/browser/fileapi/fileapi_message_filter_unittest.cc
@@ -9,8 +9,8 @@
#include "base/memory/ref_counted.h"
#include "base/memory/shared_memory.h"
+#include "base/message_loop/message_loop.h"
#include "base/process/process.h"
-#include "base/run_loop.h"
#include "content/browser/child_process_security_policy_impl.h"
#include "content/browser/fileapi/chrome_blob_storage_context.h"
#include "content/browser/streams/stream_registry.h"
@@ -20,7 +20,7 @@
#include "content/public/common/common_param_traits.h"
#include "content/public/test/mock_render_process_host.h"
#include "content/public/test/test_browser_context.h"
-#include "content/public/test/test_browser_thread_bundle.h"
+#include "content/public/test/test_browser_thread.h"
#include "net/base/io_buffer.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "webkit/browser/blob/blob_storage_controller.h"
@@ -42,6 +42,11 @@ const char kFakeContentType[] = "fake/type";
} // namespace
class FileAPIMessageFilterTest : public testing::Test {
+ public:
+ FileAPIMessageFilterTest()
+ : io_browser_thread_(BrowserThread::IO, &message_loop_) {
+ }
+
protected:
virtual void SetUp() OVERRIDE {
file_system_context_ =
@@ -67,7 +72,7 @@ class FileAPIMessageFilterTest : public testing::Test {
stream_context_);
// Complete initialization.
- base::RunLoop().RunUntilIdle();
+ message_loop_.RunUntilIdle();
}
// Tests via OnMessageReceived(const IPC::Message&). The channel proxy calls
@@ -79,7 +84,8 @@ class FileAPIMessageFilterTest : public testing::Test {
return casted_filter->OnMessageReceived(message);
}
- TestBrowserThreadBundle thread_bundle_;
+ base::MessageLoop message_loop_;
+ TestBrowserThread io_browser_thread_;
TestBrowserContext browser_context_;
scoped_refptr<fileapi::FileSystemContext> file_system_context_;
@@ -128,7 +134,7 @@ TEST_F(FileAPIMessageFilterTest, CloseChannelWithInflightRequest) {
filter->OnChannelConnected(0);
// Complete initialization.
- base::RunLoop().RunUntilIdle();
+ message_loop_.RunUntilIdle();
IPC::ChannelProxy::MessageFilter* casted_filter =
static_cast<IPC::ChannelProxy::MessageFilter*>(filter.get());
@@ -142,7 +148,7 @@ TEST_F(FileAPIMessageFilterTest, CloseChannelWithInflightRequest) {
filter->OnChannelClosing();
// This shouldn't cause DCHECK failure.
- base::RunLoop().RunUntilIdle();
+ message_loop_.RunUntilIdle();
}
TEST_F(FileAPIMessageFilterTest, MultipleFilters) {
@@ -164,7 +170,7 @@ TEST_F(FileAPIMessageFilterTest, MultipleFilters) {
filter2->OnChannelConnected(1);
// Complete initialization.
- base::RunLoop().RunUntilIdle();
+ message_loop_.RunUntilIdle();
IPC::ChannelProxy::MessageFilter* casted_filter =
static_cast<IPC::ChannelProxy::MessageFilter*>(filter1.get());
@@ -178,7 +184,7 @@ TEST_F(FileAPIMessageFilterTest, MultipleFilters) {
filter2->OnChannelClosing();
// This shouldn't cause DCHECK failure.
- base::RunLoop().RunUntilIdle();
+ message_loop_.RunUntilIdle();
}
TEST_F(FileAPIMessageFilterTest, BuildEmptyStream) {
@@ -221,7 +227,7 @@ TEST_F(FileAPIMessageFilterTest, BuildEmptyStream) {
EXPECT_EQ(0, bytes_read);
// Run loop to finish transfer.
- base::RunLoop().RunUntilIdle();
+ message_loop_.RunUntilIdle();
EXPECT_EQ(Stream::STREAM_COMPLETE,
stream->ReadRawData(buffer.get(), kBufferSize, &bytes_read));
@@ -251,7 +257,7 @@ TEST_F(FileAPIMessageFilterTest, BuildNonEmptyStream) {
EXPECT_TRUE(InvokeOnMessageReceived(finish_message));
// Run loop to finish transfer and commit finalize command.
- base::RunLoop().RunUntilIdle();
+ message_loop_.RunUntilIdle();
scoped_refptr<net::IOBuffer> buffer(new net::IOBuffer(kFakeData.size()));
int bytes_read = 0;
@@ -299,7 +305,7 @@ TEST_F(FileAPIMessageFilterTest, BuildStreamWithSharedMemory) {
EXPECT_TRUE(InvokeOnMessageReceived(finish_message));
// Run loop to finish transfer and commit finalize command.
- base::RunLoop().RunUntilIdle();
+ message_loop_.RunUntilIdle();
scoped_refptr<net::IOBuffer> buffer(new net::IOBuffer(kFakeData.size()));
int bytes_read = 0;
diff --git a/content/browser/loader/resource_dispatcher_host_unittest.cc b/content/browser/loader/resource_dispatcher_host_unittest.cc
index 1885fe9..be46339 100644
--- a/content/browser/loader/resource_dispatcher_host_unittest.cc
+++ b/content/browser/loader/resource_dispatcher_host_unittest.cc
@@ -33,7 +33,6 @@
#include "net/http/http_util.h"
#include "net/url_request/url_request.h"
#include "net/url_request/url_request_context.h"
-#include "net/url_request/url_request_context_getter.h"
#include "net/url_request/url_request_job.h"
#include "net/url_request/url_request_simple_job.h"
#include "net/url_request/url_request_test_job.h"
@@ -183,14 +182,13 @@ class MockURLRequestContextSelector
class ForwardingFilter : public ResourceMessageFilter {
public:
explicit ForwardingFilter(IPC::Sender* dest,
- ResourceContext* resource_context,
- net::URLRequestContextGetter* request_context)
+ ResourceContext* resource_context)
: ResourceMessageFilter(
ChildProcessHostImpl::GenerateChildProcessUniqueId(),
PROCESS_TYPE_RENDERER,
resource_context, NULL, NULL, NULL,
new MockURLRequestContextSelector(
- request_context->GetURLRequestContext())),
+ resource_context->GetRequestContext())),
dest_(dest) {
OnChannelConnected(base::GetCurrentProcId());
}
@@ -535,8 +533,7 @@ class ResourceDispatcherHostTest : public testing::Test,
BrowserContext::EnsureResourceContextInitialized(browser_context_.get());
message_loop_.RunUntilIdle();
filter_ = new ForwardingFilter(
- this, browser_context_->GetResourceContext(),
- browser_context_->GetRequestContext());
+ this, browser_context_->GetResourceContext());
}
virtual ~ResourceDispatcherHostTest() {
@@ -1053,9 +1050,8 @@ TEST_F(ResourceDispatcherHostTest, CancelInDelegate) {
// pending and some canceled.
class TestFilter : public ForwardingFilter {
public:
- explicit TestFilter(ResourceContext* resource_context,
- net::URLRequestContextGetter* url_request_context)
- : ForwardingFilter(NULL, resource_context, url_request_context),
+ explicit TestFilter(ResourceContext* resource_context)
+ : ForwardingFilter(NULL, resource_context),
has_canceled_(false),
received_after_canceled_(0) {
}
@@ -1079,8 +1075,7 @@ class TestFilter : public ForwardingFilter {
// Tests CancelRequestsForProcess
TEST_F(ResourceDispatcherHostTest, TestProcessCancel) {
scoped_refptr<TestFilter> test_filter = new TestFilter(
- browser_context_->GetResourceContext(),
- browser_context_->GetRequestContext());
+ browser_context_->GetResourceContext());
// request 1 goes to the test delegate
ResourceHostMsg_Request request = CreateResourceRequest(
@@ -1223,8 +1218,7 @@ TEST_F(ResourceDispatcherHostTest, TestBlockingCancelingRequests) {
TEST_F(ResourceDispatcherHostTest, TestBlockedRequestsProcessDies) {
// This second filter is used to emulate a second process.
scoped_refptr<ForwardingFilter> second_filter = new ForwardingFilter(
- this, browser_context_->GetResourceContext(),
- browser_context_->GetRequestContext());
+ this, browser_context_->GetResourceContext());
host_.BlockRequestsForRoute(second_filter->child_id(), 0);
@@ -1261,8 +1255,7 @@ TEST_F(ResourceDispatcherHostTest, TestBlockedRequestsProcessDies) {
TEST_F(ResourceDispatcherHostTest, TestBlockedRequestsDontLeak) {
// This second filter is used to emulate a second process.
scoped_refptr<ForwardingFilter> second_filter = new ForwardingFilter(
- this, browser_context_->GetResourceContext(),
- browser_context_->GetRequestContext());
+ this, browser_context_->GetResourceContext());
host_.BlockRequestsForRoute(filter_->child_id(), 1);
host_.BlockRequestsForRoute(filter_->child_id(), 2);
@@ -1329,8 +1322,7 @@ TEST_F(ResourceDispatcherHostTest, TooMuchOutstandingRequestsMemory) {
// This second filter is used to emulate a second process.
scoped_refptr<ForwardingFilter> second_filter = new ForwardingFilter(
- this, browser_context_->GetResourceContext(),
- browser_context_->GetRequestContext());
+ this, browser_context_->GetResourceContext());
// Saturate the number of outstanding requests for our process.
for (size_t i = 0; i < kMaxRequests; ++i) {
@@ -1394,11 +1386,9 @@ TEST_F(ResourceDispatcherHostTest, TooManyOutstandingRequests) {
// Needed to emulate additional processes.
scoped_refptr<ForwardingFilter> second_filter = new ForwardingFilter(
- this, browser_context_->GetResourceContext(),
- browser_context_->GetRequestContext());
+ this, browser_context_->GetResourceContext());
scoped_refptr<ForwardingFilter> third_filter = new ForwardingFilter(
- this, browser_context_->GetResourceContext(),
- browser_context_->GetRequestContext());
+ this, browser_context_->GetResourceContext());
// Saturate the number of outstanding requests for our process.
for (size_t i = 0; i < kMaxRequestsPerProcess; ++i) {
@@ -1738,8 +1728,7 @@ TEST_F(ResourceDispatcherHostTest, TransferNavigation) {
// This second filter is used to emulate a second process.
scoped_refptr<ForwardingFilter> second_filter = new ForwardingFilter(
- this, browser_context_->GetResourceContext(),
- browser_context_->GetRequestContext());
+ this, browser_context_->GetResourceContext());
int new_render_view_id = 1;
int new_request_id = 2;
@@ -1800,8 +1789,7 @@ TEST_F(ResourceDispatcherHostTest, TransferNavigationAndThenRedirect) {
// This second filter is used to emulate a second process.
scoped_refptr<ForwardingFilter> second_filter = new ForwardingFilter(
- this, browser_context_->GetResourceContext(),
- browser_context_->GetRequestContext());
+ this, browser_context_->GetResourceContext());
int new_render_view_id = 1;
int new_request_id = 2;
diff --git a/content/browser/loader/resource_message_filter.h b/content/browser/loader/resource_message_filter.h
index a4b9bd4..2c56af0 100644
--- a/content/browser/loader/resource_message_filter.h
+++ b/content/browser/loader/resource_message_filter.h
@@ -32,7 +32,6 @@ class ResourceContext;
class CONTENT_EXPORT ResourceMessageFilter : public BrowserMessageFilter {
public:
// Allows selecting the net::URLRequestContext used to service requests.
- // TODO(ajwong): Delete class after http://crbug.com/159193 is resolved.
class URLRequestContextSelector {
public:
URLRequestContextSelector() {}
diff --git a/content/browser/net/cookie_store_map.cc b/content/browser/net/cookie_store_map.cc
deleted file mode 100644
index a36aec3..0000000
--- a/content/browser/net/cookie_store_map.cc
+++ /dev/null
@@ -1,104 +0,0 @@
-// Copyright 2013 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 "content/browser/net/cookie_store_map.h"
-
-#include "base/bind.h"
-#include "base/bind_helpers.h"
-#include "base/callback.h"
-#include "base/logging.h"
-#include "base/threading/thread_checker.h"
-#include "net/cookies/cookie_monster.h"
-#include "net/cookies/cookie_store.h"
-#include "url/gurl.h"
-
-namespace {
-
-class CookieClearBarrier {
- public:
- CookieClearBarrier(int n, const base::Closure& done)
- : left_(n),
- all_done_(done) {
- }
-
- void OnCookieCleared(int num_deleted) {
- DCHECK(thread_checker_.CalledOnValidThread());
-
- // We don't care how many are deleted.
- DCHECK_GT(left_, 0);
-
- if (--left_ == 0) {
- all_done_.Run();
- all_done_.Reset();
- }
- }
-
- static base::Callback<void(int)> NewBarrierClosure(
- int n, const base::Closure& done) {
- DCHECK_GT(n, 0);
- CookieClearBarrier* barrier = new CookieClearBarrier(n, done);
- return base::Bind(&CookieClearBarrier::OnCookieCleared,
- base::Owned(barrier));
- }
-
- private:
- int left_;
- base::Closure all_done_;
- base::ThreadChecker thread_checker_;
-};
-
-} // namespace
-
-namespace content {
-
-CookieStoreMap::CookieStoreMap() {
-}
-
-CookieStoreMap::~CookieStoreMap() {
-}
-
-net::CookieStore* CookieStoreMap::GetForScheme(
- const std::string& scheme) const {
- MapType::const_iterator it = scheme_map_.find(scheme);
- if (it == scheme_map_.end())
- return NULL;
- return it->second;
-}
-
-void CookieStoreMap::SetForScheme(const std::string& scheme,
- net::CookieStore* cookie_store) {
- DCHECK(scheme_map_.find(scheme) == scheme_map_.end());
- DCHECK(cookie_store);
- scheme_map_[scheme] = cookie_store;
-}
-
-void CookieStoreMap::DeleteCookies(const GURL& origin,
- const base::Time begin,
- const base::Time end,
- const base::Closure& done) {
- if (origin.is_empty()) {
- net::CookieStore::DeleteCallback on_delete =
- CookieClearBarrier::NewBarrierClosure(scheme_map_.size(), done);
- for (MapType::const_iterator it = scheme_map_.begin();
- it != scheme_map_.end(); ++it) {
- it->second->DeleteAllCreatedBetweenAsync(begin, end, on_delete);
- }
- } else {
- net::CookieStore* cookie_store = GetForScheme(origin.scheme());
- if (!cookie_store) {
- done.Run();
- return;
- }
- cookie_store->GetCookieMonster()->DeleteAllCreatedBetweenForHostAsync(
- begin, end, origin, CookieClearBarrier::NewBarrierClosure(1, done));
- }
-}
-
-CookieStoreMap* CookieStoreMap::Clone() const {
- CookieStoreMap* cloned_map = new CookieStoreMap();
- cloned_map->scheme_map_ = scheme_map_;
- return cloned_map;
-}
-
-} // namespace content
diff --git a/content/browser/net/cookie_store_map.h b/content/browser/net/cookie_store_map.h
deleted file mode 100644
index b2be30f..0000000
--- a/content/browser/net/cookie_store_map.h
+++ /dev/null
@@ -1,62 +0,0 @@
-// Copyright 2013 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 CONTENT_BROWSER_NET_COOKIE_STORE_MAP_H_
-#define CONTENT_BROWSER_NET_COOKIE_STORE_MAP_H_
-
-#include <map>
-#include <string>
-
-#include "base/callback_forward.h"
-#include "base/compiler_specific.h"
-#include "base/memory/ref_counted.h"
-#include "base/time/time.h"
-#include "content/common/content_export.h"
-
-class GURL;
-
-namespace net {
-class CookieStore;
-} // namespace net
-
-namespace content {
-
-// CookieStoreMap allows associating different CookieStore objects with
-// different schemes. It is mainly a convenience class.
-class CookieStoreMap {
- public:
- CookieStoreMap();
- virtual ~CookieStoreMap();
-
- // Returns the CookieStore associated with |scheme|.
- CONTENT_EXPORT net::CookieStore* GetForScheme(
- const std::string& scheme) const;
-
- // Associates a |cookie_store| with the given |scheme|. Should only be called
- // once for any given |scheme|. |cookie_store| must be non-NULL. The
- // CookieStoreMap will retain the |cookie_store| object.
- void SetForScheme(const std::string& scheme, net::CookieStore* cookie_store);
-
- // Clears cookies matching the specified parameters from all CookieStores
- // contained in this map. Calls |done| when all CookieStores have been
- // cleared. |done| is guaranteed to be run on the calling thread.
- void DeleteCookies(const GURL& origin,
- const base::Time begin,
- const base::Time end,
- const base::Closure& done);
-
- // Makes a clone of the map. Useful if the map needs to be copied to another
- // thread.
- CookieStoreMap* Clone() const;
-
- private:
- typedef std::map<std::string, scoped_refptr<net::CookieStore> > MapType;
- MapType scheme_map_;
-
- DISALLOW_COPY_AND_ASSIGN(CookieStoreMap);
-};
-
-} // namespace content
-
-#endif // CONTENT_BROWSER_NET_COOKIE_STORE_MAP_H_
diff --git a/content/browser/net/sqlite_persistent_cookie_store.cc b/content/browser/net/sqlite_persistent_cookie_store.cc
index 55be9e9d..c23692d 100644
--- a/content/browser/net/sqlite_persistent_cookie_store.cc
+++ b/content/browser/net/sqlite_persistent_cookie_store.cc
@@ -12,7 +12,6 @@
#include "base/basictypes.h"
#include "base/bind.h"
#include "base/callback.h"
-#include "base/command_line.h"
#include "base/file_util.h"
#include "base/files/file_path.h"
#include "base/location.h"
@@ -29,7 +28,6 @@
#include "base/time/time.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/cookie_store_factory.h"
-#include "content/public/common/content_switches.h"
#include "net/base/registry_controlled_domains/registry_controlled_domain.h"
#include "net/cookies/canonical_cookie.h"
#include "net/cookies/cookie_constants.h"
@@ -1196,60 +1194,28 @@ SQLitePersistentCookieStore::~SQLitePersistentCookieStore() {
// a reference if the background runner has not run Close() yet.
}
-CookieStoreConfig::CookieStoreConfig(
+net::CookieStore* CreatePersistentCookieStore(
const base::FilePath& path,
- SessionCookieMode session_cookie_mode,
+ bool restore_old_session_cookies,
quota::SpecialStoragePolicy* storage_policy,
- net::CookieMonsterDelegate* cookie_delegate)
- : path(path),
- session_cookie_mode(session_cookie_mode),
- storage_policy(storage_policy),
- cookie_delegate(cookie_delegate) {
- CHECK(!path.empty() || session_cookie_mode == EPHEMERAL_SESSION_COOKIES);
-}
-
-CookieStoreConfig::CookieStoreConfig()
- : session_cookie_mode(EPHEMERAL_SESSION_COOKIES) {
- // Default to an in-memory cookie store.
-}
-
-CookieStoreConfig::~CookieStoreConfig() {
-}
-
-net::CookieStore* CreateCookieStore(const CookieStoreConfig& config) {
- if (config.path.empty()) {
- return new net::CookieMonster(NULL, config.cookie_delegate);
- }
-
+ net::CookieMonster::Delegate* cookie_monster_delegate) {
SQLitePersistentCookieStore* persistent_store =
new SQLitePersistentCookieStore(
- config.path,
+ path,
BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO),
BrowserThread::GetBlockingPool()->GetSequencedTaskRunner(
BrowserThread::GetBlockingPool()->GetSequenceToken()),
- (config.session_cookie_mode ==
- CookieStoreConfig::RESTORED_SESSION_COOKIES),
- config.storage_policy);
+ restore_old_session_cookies,
+ storage_policy);
net::CookieMonster* cookie_monster =
- new net::CookieMonster(persistent_store, config.cookie_delegate);
- if ((config.session_cookie_mode ==
- CookieStoreConfig::PERSISTANT_SESSION_COOKIES) ||
- (config.session_cookie_mode ==
- CookieStoreConfig::RESTORED_SESSION_COOKIES)) {
- cookie_monster->SetPersistSessionCookies(true);
- }
-
- if (CommandLine::ForCurrentProcess()->HasSwitch(
- switches::kEnableFileCookies)) {
- cookie_monster->SetEnableFileScheme(true);
- }
+ new net::CookieMonster(persistent_store, cookie_monster_delegate);
const std::string cookie_priority_experiment_group =
base::FieldTrialList::FindFullName("CookieRetentionPriorityStudy");
cookie_monster->SetPriorityAwareGarbageCollection(
cookie_priority_experiment_group == "ExperimentOn");
- return cookie_monster;
+ return cookie_monster;
}
} // namespace content
diff --git a/content/browser/renderer_host/render_message_filter.cc b/content/browser/renderer_host/render_message_filter.cc
index 571e57b..fc84eab 100644
--- a/content/browser/renderer_host/render_message_filter.cc
+++ b/content/browser/renderer_host/render_message_filter.cc
@@ -22,7 +22,6 @@
#include "content/browser/gpu/gpu_data_manager_impl.h"
#include "content/browser/loader/resource_dispatcher_host_impl.h"
#include "content/browser/media/media_internals.h"
-#include "content/browser/net/cookie_store_map.h"
#include "content/browser/plugin_process_host.h"
#include "content/browser/plugin_service_impl.h"
#include "content/browser/ppapi_plugin_process_host.h"
@@ -86,6 +85,8 @@
#include "media/base/android/webaudio_media_codec_bridge.h"
#endif
+using net::CookieStore;
+
namespace content {
namespace {
@@ -291,7 +292,6 @@ RenderMessageFilter::RenderMessageFilter(
PluginServiceImpl* plugin_service,
BrowserContext* browser_context,
net::URLRequestContextGetter* request_context,
- const CookieStoreMap& cookie_store_map,
RenderWidgetHelper* render_widget_helper,
media::AudioManager* audio_manager,
MediaInternals* media_internals,
@@ -300,7 +300,6 @@ RenderMessageFilter::RenderMessageFilter(
plugin_service_(plugin_service),
profile_data_directory_(browser_context->GetPath()),
request_context_(request_context),
- cookie_store_map_(cookie_store_map.Clone()),
resource_context_(browser_context->GetResourceContext()),
render_widget_helper_(render_widget_helper),
incognito_(browser_context->IsOffTheRecord()),
@@ -542,15 +541,9 @@ void RenderMessageFilter::OnSetCookie(const IPC::Message& message,
url, first_party_for_cookies, cookie,
resource_context_, render_process_id_, message.routing_id(),
&options)) {
+ net::URLRequestContext* context = GetRequestContextForURL(url);
// Pass a null callback since we don't care about when the 'set' completes.
- net::CookieStore* cookie_store =
- cookie_store_map_->GetForScheme(url.scheme());
-
- // Handle requests for non-cookieable schemes.
- if (!cookie_store)
- return;
-
- cookie_store->SetCookieWithOptionsAsync(
+ context->cookie_store()->SetCookieWithOptionsAsync(
url, cookie, options, net::CookieMonster::SetCookiesCallback());
}
}
@@ -571,15 +564,10 @@ void RenderMessageFilter::OnGetCookies(const GURL& url,
base::strlcpy(url_buf, url.spec().c_str(), arraysize(url_buf));
base::debug::Alias(url_buf);
- // Handle requests for non-cookieable schemes.
- net::CookieStore* cookie_store = cookie_store_map_->GetForScheme(
- url.scheme());
- if (!cookie_store) {
- SendGetCookiesResponse(reply_msg, std::string());
- return;
- }
-
- cookie_store->GetCookieMonster()->GetAllCookiesForURLAsync(
+ net::URLRequestContext* context = GetRequestContextForURL(url);
+ net::CookieMonster* cookie_monster =
+ context->cookie_store()->GetCookieMonster();
+ cookie_monster->GetAllCookiesForURLAsync(
url, base::Bind(&RenderMessageFilter::CheckPolicyForCookies, this, url,
first_party_for_cookies, reply_msg));
}
@@ -594,24 +582,19 @@ void RenderMessageFilter::OnGetRawCookies(
// not targeted to an an external host like ChromeFrame.
// TODO(ananta) We need to support retreiving raw cookies from external
// hosts.
- //
- // We check policy here to avoid sending back cookies that would not normally
- // be applied to outbound requests for the given URL. Since this cookie info
- // is visible in the developer tools, it is helpful to make it match reality.
if (!policy->CanReadRawCookies(render_process_id_) ||
!policy->CanAccessCookiesForOrigin(render_process_id_, url)) {
SendGetRawCookiesResponse(reply_msg, net::CookieList());
return;
}
- // Handle requests for non-cookieable schemes.
- net::CookieStore* cookie_store =
- cookie_store_map_->GetForScheme(url.scheme());
- if (!cookie_store) {
- SendGetRawCookiesResponse(reply_msg, net::CookieList());
- return;
- }
- cookie_store->GetCookieMonster()->GetAllCookiesForURLAsync(
+ // We check policy here to avoid sending back cookies that would not normally
+ // be applied to outbound requests for the given URL. Since this cookie info
+ // is visible in the developer tools, it is helpful to make it match reality.
+ net::URLRequestContext* context = GetRequestContextForURL(url);
+ net::CookieMonster* cookie_monster =
+ context->cookie_store()->GetCookieMonster();
+ cookie_monster->GetAllCookiesForURLAsync(
url, base::Bind(&RenderMessageFilter::SendGetRawCookiesResponse,
this, reply_msg));
}
@@ -623,12 +606,8 @@ void RenderMessageFilter::OnDeleteCookie(const GURL& url,
if (!policy->CanAccessCookiesForOrigin(render_process_id_, url))
return;
- // Handle requests for non-cookieable schemes.
- net::CookieStore* cookie_store =
- cookie_store_map_->GetForScheme(url.scheme());
- if (!cookie_store)
- return;
- cookie_store->DeleteCookieAsync(url, cookie_name, base::Closure());
+ net::URLRequestContext* context = GetRequestContextForURL(url);
+ context->cookie_store()->DeleteCookieAsync(url, cookie_name, base::Closure());
}
void RenderMessageFilter::OnCookiesEnabled(
@@ -887,6 +866,19 @@ void RenderMessageFilter::OnAllocateSharedMemory(
buffer_size, PeerHandle(), handle);
}
+net::URLRequestContext* RenderMessageFilter::GetRequestContextForURL(
+ const GURL& url) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
+
+ net::URLRequestContext* context =
+ GetContentClient()->browser()->OverrideRequestContextForURL(
+ url, resource_context_);
+ if (!context)
+ context = request_context_->GetURLRequestContext();
+
+ return context;
+}
+
#if defined(OS_POSIX) && !defined(TOOLKIT_GTK) && !defined(OS_ANDROID)
void RenderMessageFilter::OnAllocTransportDIB(
uint32 size, bool cache_in_browser, TransportDIB::Handle* handle) {
@@ -1033,15 +1025,14 @@ void RenderMessageFilter::CheckPolicyForCookies(
const GURL& first_party_for_cookies,
IPC::Message* reply_msg,
const net::CookieList& cookie_list) {
+ net::URLRequestContext* context = GetRequestContextForURL(url);
// Check the policy for get cookies, and pass cookie_list to the
// TabSpecificContentSetting for logging purpose.
if (GetContentClient()->browser()->AllowGetCookie(
url, first_party_for_cookies, cookie_list, resource_context_,
render_process_id_, reply_msg->routing_id())) {
- net::CookieStore* cookie_store =
- cookie_store_map_->GetForScheme(url.scheme());
// Gets the cookies from cookie store if allowed.
- cookie_store->GetCookiesWithOptionsAsync(
+ context->cookie_store()->GetCookiesWithOptionsAsync(
url, net::CookieOptions(),
base::Bind(&RenderMessageFilter::SendGetCookiesResponse,
this, reply_msg));
diff --git a/content/browser/renderer_host/render_message_filter.h b/content/browser/renderer_host/render_message_filter.h
index 06a8f40..4eb9864 100644
--- a/content/browser/renderer_host/render_message_filter.h
+++ b/content/browser/renderer_host/render_message_filter.h
@@ -60,12 +60,12 @@ struct MediaLogEvent;
}
namespace net {
+class URLRequestContext;
class URLRequestContextGetter;
}
namespace content {
class BrowserContext;
-class CookieStoreMap;
class DOMStorageContextWrapper;
class MediaInternals;
class PluginServiceImpl;
@@ -85,7 +85,6 @@ class RenderMessageFilter : public BrowserMessageFilter {
PluginServiceImpl * plugin_service,
BrowserContext* browser_context,
net::URLRequestContextGetter* request_context,
- const CookieStoreMap& cookie_store_map,
RenderWidgetHelper* render_widget_helper,
media::AudioManager* audio_manager,
MediaInternals* media_internals,
@@ -106,6 +105,11 @@ class RenderMessageFilter : public BrowserMessageFilter {
int render_process_id() const { return render_process_id_; }
+ // Returns the correct net::URLRequestContext depending on what type of url is
+ // given.
+ // Only call on the IO thread.
+ net::URLRequestContext* GetRequestContextForURL(const GURL& url);
+
private:
friend class BrowserThread;
friend class base::DeleteHelper<RenderMessageFilter>;
@@ -268,12 +272,6 @@ class RenderMessageFilter : public BrowserMessageFilter {
// Contextual information to be used for requests created here.
scoped_refptr<net::URLRequestContextGetter> request_context_;
- // Map of schemes to the CookieStore instance that services those schemes.
- // We store a clone of the CookieStoreMap passed in the constructor in
- // order to avoid having 2 threads access the same object. Is is assumed
- // that the source map never changes after we make the clone.
- scoped_ptr<CookieStoreMap> cookie_store_map_;
-
// The ResourceContext which is to be used on the IO thread.
ResourceContext* resource_context_;
diff --git a/content/browser/renderer_host/render_process_host_impl.cc b/content/browser/renderer_host/render_process_host_impl.cc
index 6872d22..bafb4a8 100644
--- a/content/browser/renderer_host/render_process_host_impl.cc
+++ b/content/browser/renderer_host/render_process_host_impl.cc
@@ -554,8 +554,7 @@ void RenderProcessHostImpl::CreateMessageFilters() {
NULL,
#endif
GetBrowserContext(),
- storage_partition_impl_->GetURLRequestContext(),
- storage_partition_impl_->GetCookieStoreMap(),
+ GetBrowserContext()->GetRequestContextForRenderProcess(GetID()),
widget_helper_.get(),
audio_manager,
media_internals,
diff --git a/content/browser/storage_partition_impl.cc b/content/browser/storage_partition_impl.cc
index 12368ff..d68b174 100644
--- a/content/browser/storage_partition_impl.cc
+++ b/content/browser/storage_partition_impl.cc
@@ -9,7 +9,6 @@
#include "content/browser/browser_main_loop.h"
#include "content/browser/fileapi/browser_file_system_helper.h"
#include "content/browser/gpu/shader_disk_cache.h"
-#include "content/browser/net/cookie_store_map.h"
#include "content/common/dom_storage/dom_storage_types.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/browser_thread.h"
@@ -17,7 +16,6 @@
#include "content/public/browser/indexed_db_context.h"
#include "content/public/browser/local_storage_usage_info.h"
#include "content/public/browser/session_storage_usage_info.h"
-#include "content/public/common/url_constants.h"
#include "net/base/completion_callback.h"
#include "net/base/net_errors.h"
#include "net/cookies/cookie_monster.h"
@@ -45,6 +43,40 @@ int GenerateQuotaClientMask(uint32 remove_mask) {
return quota_client_mask;
}
+void OnClearedCookies(const base::Closure& callback, int num_deleted) {
+ // The final callback needs to happen from UI thread.
+ if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) {
+ BrowserThread::PostTask(
+ BrowserThread::UI, FROM_HERE,
+ base::Bind(&OnClearedCookies, callback, num_deleted));
+ return;
+ }
+
+ callback.Run();
+}
+
+void ClearCookiesOnIOThread(
+ const scoped_refptr<net::URLRequestContextGetter>& rq_context,
+ const base::Time begin,
+ const base::Time end,
+ const GURL& remove_origin,
+ const base::Closure& callback) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
+ net::CookieStore* cookie_store = rq_context->
+ GetURLRequestContext()->cookie_store();
+ if (remove_origin.is_empty()) {
+ cookie_store->GetCookieMonster()->DeleteAllCreatedBetweenAsync(
+ begin,
+ end,
+ base::Bind(&OnClearedCookies, callback));
+ } else {
+ cookie_store->GetCookieMonster()->DeleteAllCreatedBetweenForHostAsync(
+ begin,
+ end,
+ remove_origin, base::Bind(&OnClearedCookies, callback));
+ }
+}
+
void OnQuotaManagedOriginDeleted(const GURL& origin,
quota::StorageType type,
size_t* origins_to_delete_count,
@@ -216,7 +248,7 @@ struct StoragePartitionImpl::DataDeletionHelper {
uint32 quota_storage_remove_mask,
const GURL& remove_origin,
const base::FilePath& path,
- CookieStoreMap* cookie_store_map,
+ net::URLRequestContextGetter* rq_context,
DOMStorageContextWrapper* dom_storage_context,
quota::QuotaManager* quota_manager,
WebRTCIdentityStore* webrtc_identity_store,
@@ -252,7 +284,6 @@ StoragePartitionImpl::StoragePartitionImpl(
webkit_database::DatabaseTracker* database_tracker,
DOMStorageContextWrapper* dom_storage_context,
IndexedDBContextImpl* indexed_db_context,
- scoped_ptr<CookieStoreMap> cookie_store_map,
WebRTCIdentityStore* webrtc_identity_store)
: partition_path_(partition_path),
quota_manager_(quota_manager),
@@ -261,9 +292,7 @@ StoragePartitionImpl::StoragePartitionImpl(
database_tracker_(database_tracker),
dom_storage_context_(dom_storage_context),
indexed_db_context_(indexed_db_context),
- cookie_store_map_(cookie_store_map.Pass()),
- webrtc_identity_store_(webrtc_identity_store) {
-}
+ webrtc_identity_store_(webrtc_identity_store) {}
StoragePartitionImpl::~StoragePartitionImpl() {
// These message loop checks are just to avoid leaks in unittests.
@@ -287,8 +316,7 @@ StoragePartitionImpl::~StoragePartitionImpl() {
StoragePartitionImpl* StoragePartitionImpl::Create(
BrowserContext* context,
bool in_memory,
- const base::FilePath& partition_path,
- scoped_ptr<CookieStoreMap> cookie_store_map) {
+ const base::FilePath& partition_path) {
// Ensure that these methods are called on the UI thread, except for
// unittests where a UI thread might not have been created.
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI) ||
@@ -352,7 +380,6 @@ StoragePartitionImpl* StoragePartitionImpl::Create(
database_tracker.get(),
dom_storage_context.get(),
indexed_db_context.get(),
- cookie_store_map.Pass(),
webrtc_identity_store.get());
}
@@ -393,15 +420,11 @@ IndexedDBContextImpl* StoragePartitionImpl::GetIndexedDBContext() {
return indexed_db_context_.get();
}
-net::CookieStore* StoragePartitionImpl::GetCookieStoreForScheme(
- const std::string& scheme) {
- return GetCookieStoreMap().GetForScheme(scheme);
-}
-
void StoragePartitionImpl::ClearDataImpl(
uint32 remove_mask,
uint32 quota_storage_remove_mask,
const GURL& remove_origin,
+ net::URLRequestContextGetter* rq_context,
const base::Time begin,
const base::Time end,
const base::Closure& callback) {
@@ -411,7 +434,7 @@ void StoragePartitionImpl::ClearDataImpl(
// DataDeletionHelper::DecrementTaskCountOnUI().
helper->ClearDataOnUIThread(
remove_mask, quota_storage_remove_mask, remove_origin,
- GetPath(), cookie_store_map_.get(), dom_storage_context_, quota_manager_,
+ GetPath(), rq_context, dom_storage_context_, quota_manager_,
webrtc_identity_store_, begin, end);
}
@@ -524,7 +547,7 @@ void StoragePartitionImpl::DataDeletionHelper::ClearDataOnUIThread(
uint32 quota_storage_remove_mask,
const GURL& remove_origin,
const base::FilePath& path,
- CookieStoreMap* cookie_store_map,
+ net::URLRequestContextGetter* rq_context,
DOMStorageContextWrapper* dom_storage_context,
quota::QuotaManager* quota_manager,
WebRTCIdentityStore* webrtc_identity_store,
@@ -540,8 +563,11 @@ void StoragePartitionImpl::DataDeletionHelper::ClearDataOnUIThread(
if (remove_mask & REMOVE_DATA_MASK_COOKIES) {
// Handle the cookies.
IncrementTaskCountOnUI();
- cookie_store_map->DeleteCookies(remove_origin, begin, end,
- decrement_callback);
+ BrowserThread::PostTask(
+ BrowserThread::IO, FROM_HERE,
+ base::Bind(&ClearCookiesOnIOThread,
+ make_scoped_refptr(rq_context), begin, end, remove_origin,
+ decrement_callback));
}
if (remove_mask & REMOVE_DATA_MASK_INDEXEDDB ||
@@ -600,17 +626,20 @@ void StoragePartitionImpl::DataDeletionHelper::ClearDataOnUIThread(
void StoragePartitionImpl::ClearDataForOrigin(
uint32 remove_mask,
uint32 quota_storage_remove_mask,
- const GURL& storage_origin) {
+ const GURL& storage_origin,
+ net::URLRequestContextGetter* request_context_getter) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
ClearDataImpl(remove_mask, quota_storage_remove_mask, storage_origin,
- base::Time(), base::Time::Max(), base::Bind(&base::DoNothing));
+ request_context_getter, base::Time(), base::Time::Max(),
+ base::Bind(&base::DoNothing));
}
void StoragePartitionImpl::ClearDataForUnboundedRange(
uint32 remove_mask,
uint32 quota_storage_remove_mask) {
ClearDataImpl(remove_mask, quota_storage_remove_mask, GURL(),
- base::Time(), base::Time::Max(), base::Bind(&base::DoNothing));
+ GetURLRequestContext(), base::Time(), base::Time::Max(),
+ base::Bind(&base::DoNothing));
}
void StoragePartitionImpl::ClearDataForRange(uint32 remove_mask,
@@ -618,18 +647,14 @@ void StoragePartitionImpl::ClearDataForRange(uint32 remove_mask,
const base::Time& begin,
const base::Time& end,
const base::Closure& callback) {
- ClearDataImpl(remove_mask, quota_storage_remove_mask, GURL(), begin, end,
- callback);
+ ClearDataImpl(remove_mask, quota_storage_remove_mask, GURL(),
+ GetURLRequestContext(), begin, end, callback);
}
WebRTCIdentityStore* StoragePartitionImpl::GetWebRTCIdentityStore() {
return webrtc_identity_store_.get();
}
-const CookieStoreMap& StoragePartitionImpl::GetCookieStoreMap() {
- return *cookie_store_map_;
-}
-
void StoragePartitionImpl::SetURLRequestContext(
net::URLRequestContextGetter* url_request_context) {
url_request_context_ = url_request_context;
diff --git a/content/browser/storage_partition_impl.h b/content/browser/storage_partition_impl.h
index 0d3c7c5..e59347c 100644
--- a/content/browser/storage_partition_impl.h
+++ b/content/browser/storage_partition_impl.h
@@ -12,7 +12,6 @@
#include "content/browser/dom_storage/dom_storage_context_wrapper.h"
#include "content/browser/indexed_db/indexed_db_context_impl.h"
#include "content/browser/media/webrtc_identity_store.h"
-#include "content/browser/net/cookie_store_map.h"
#include "content/common/content_export.h"
#include "content/public/browser/storage_partition.h"
@@ -32,12 +31,12 @@ class StoragePartitionImpl : public StoragePartition {
virtual webkit_database::DatabaseTracker* GetDatabaseTracker() OVERRIDE;
virtual DOMStorageContextWrapper* GetDOMStorageContext() OVERRIDE;
virtual IndexedDBContextImpl* GetIndexedDBContext() OVERRIDE;
- virtual net::CookieStore* GetCookieStoreForScheme(
- const std::string& scheme) OVERRIDE;
+
virtual void ClearDataForOrigin(
uint32 remove_mask,
uint32 quota_storage_remove_mask,
- const GURL& storage_origin) OVERRIDE;
+ const GURL& storage_origin,
+ net::URLRequestContextGetter* request_context_getter) OVERRIDE;
virtual void ClearDataForUnboundedRange(
uint32 remove_mask,
uint32 quota_storage_remove_mask) OVERRIDE;
@@ -48,7 +47,6 @@ class StoragePartitionImpl : public StoragePartition {
const base::Closure& callback) OVERRIDE;
WebRTCIdentityStore* GetWebRTCIdentityStore();
- CONTENT_EXPORT const CookieStoreMap& GetCookieStoreMap();
struct DataDeletionHelper;
struct QuotaManagedDataDeletionHelper;
@@ -60,14 +58,12 @@ class StoragePartitionImpl : public StoragePartition {
// The |partition_path| is the absolute path to the root of this
// StoragePartition's on-disk storage.
//
- // If |in_memory| is true, the |profile_path| is (ab)used as a way of
+ // If |in_memory| is true, the |partition_path| is (ab)used as a way of
// distinguishing different in-memory partitions, but nothing is persisted
// on to disk.
- static StoragePartitionImpl* Create(
- BrowserContext* context,
- bool in_memory,
- const base::FilePath& profile_path,
- scoped_ptr<CookieStoreMap> cookie_store_map);
+ static StoragePartitionImpl* Create(BrowserContext* context,
+ bool in_memory,
+ const base::FilePath& profile_path);
// Quota managed data uses a different bitmask for types than
// StoragePartition uses. This method generates that mask.
@@ -81,13 +77,12 @@ class StoragePartitionImpl : public StoragePartition {
webkit_database::DatabaseTracker* database_tracker,
DOMStorageContextWrapper* dom_storage_context,
IndexedDBContextImpl* indexed_db_context,
- scoped_ptr<CookieStoreMap> cookie_store_map,
WebRTCIdentityStore* webrtc_identity_store);
- // Use an empty |remove_origin| to delete data from all origins.
void ClearDataImpl(uint32 remove_mask,
uint32 quota_storage_remove_mask,
const GURL& remove_origin,
+ net::URLRequestContextGetter* rq_context,
const base::Time begin,
const base::Time end,
const base::Closure& callback);
@@ -117,7 +112,6 @@ class StoragePartitionImpl : public StoragePartition {
scoped_refptr<webkit_database::DatabaseTracker> database_tracker_;
scoped_refptr<DOMStorageContextWrapper> dom_storage_context_;
scoped_refptr<IndexedDBContextImpl> indexed_db_context_;
- scoped_ptr<CookieStoreMap> cookie_store_map_;
scoped_refptr<WebRTCIdentityStore> webrtc_identity_store_;
DISALLOW_COPY_AND_ASSIGN(StoragePartitionImpl);
diff --git a/content/browser/storage_partition_impl_map.cc b/content/browser/storage_partition_impl_map.cc
index eba0f4b..c5721ae 100644
--- a/content/browser/storage_partition_impl_map.cc
+++ b/content/browser/storage_partition_impl_map.cc
@@ -18,7 +18,6 @@
#include "content/browser/fileapi/browser_file_system_helper.h"
#include "content/browser/fileapi/chrome_blob_storage_context.h"
#include "content/browser/loader/resource_request_info_impl.h"
-#include "content/browser/net/cookie_store_map.h"
#include "content/browser/resource_context_impl.h"
#include "content/browser/storage_partition_impl.h"
#include "content/browser/streams/stream.h"
@@ -29,12 +28,10 @@
#include "content/public/browser/browser_context.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/content_browser_client.h"
-#include "content/public/browser/cookie_store_factory.h"
#include "content/public/browser/storage_partition.h"
#include "content/public/common/content_constants.h"
#include "content/public/common/url_constants.h"
#include "crypto/sha2.h"
-#include "net/cookies/cookie_monster.h"
#include "net/url_request/url_request_context.h"
#include "net/url_request/url_request_context_getter.h"
#include "webkit/browser/blob/blob_url_request_job_factory.h"
@@ -349,14 +346,6 @@ void BlockingGarbageCollect(
base::Bind(base::IgnoreResult(&base::DeleteFile), trash_directory, true));
}
-void AttachDefaultCookieStoreOnIOThread(
- const scoped_refptr<net::URLRequestContextGetter>& url_request_context,
- const scoped_refptr<net::CookieStore> cookie_store) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
- url_request_context->GetURLRequestContext()->set_cookie_store(
- cookie_store.get());
-}
-
} // namespace
// static
@@ -414,16 +403,9 @@ StoragePartitionImpl* StoragePartitionImplMap::Get(
base::FilePath partition_path =
browser_context_->GetPath().Append(
GetStoragePartitionPath(partition_domain, partition_name));
-
- // Create the cookie stores.
- scoped_ptr<CookieStoreMap> cookie_store_map(
- CreateCookieStores(partition_path,
- in_memory,
- partition_domain.empty()));
-
StoragePartitionImpl* partition =
StoragePartitionImpl::Create(browser_context_, in_memory,
- partition_path, cookie_store_map.Pass());
+ partition_path);
partitions_[partition_config] = partition;
ChromeBlobStorageContext* blob_storage_context =
@@ -586,29 +568,8 @@ void StoragePartitionImplMap::PostCreateInitialization(
InitializeResourceContext(browser_context_);
}
- // In unittests, BrowserThread::IO may not be valid which would yield a
- // memory leak on a PostTask. Also, in content_unittests, the
- // URLRequestContext is NULL.
- //
- // TODO(ajwong): Should default ContentBrowserClient return a non-null
- // URLRequestContext?
- if (BrowserThread::IsMessageLoopValid(BrowserThread::IO) &&
- partition->GetURLRequestContext()) {
- // The main URLRequestContextGetter was first created just before
- // PostCreateInitialization() is called thus attaching the CookieStore here
- // is guaranteed to occur before anyone else can see the main request
- // context including the media request context.
- //
- // We pass the cookie store for chrome::kHttpScheme because we know this
- // will return the default cookie store.
- BrowserThread::PostTask(
- BrowserThread::IO, FROM_HERE,
- base::Bind(&AttachDefaultCookieStoreOnIOThread,
- make_scoped_refptr(partition->GetURLRequestContext()),
- make_scoped_refptr(
- partition->GetCookieStoreMap().GetForScheme(
- chrome::kHttpScheme))));
-
+ // Check first to avoid memory leak in unittests.
+ if (BrowserThread::IsMessageLoopValid(BrowserThread::IO)) {
BrowserThread::PostTask(
BrowserThread::IO, FROM_HERE,
base::Bind(&ChromeAppCacheService::InitializeOnIOThread,
@@ -620,7 +581,7 @@ void StoragePartitionImplMap::PostCreateInitialization(
make_scoped_refptr(
browser_context_->GetSpecialStoragePolicy())));
- // We do not initialize the AppCacheService for media contexts because,
+ // We do not call InitializeURLRequestContext() for media contexts because,
// other than the HTTP cache, the media contexts share the same backing
// objects as their associated "normal" request context. Thus, the previous
// call serves to initialize the media request context for this storage
@@ -628,47 +589,4 @@ void StoragePartitionImplMap::PostCreateInitialization(
}
}
-scoped_ptr<CookieStoreMap> StoragePartitionImplMap::CreateCookieStores(
- const base::FilePath& partition_path,
- bool in_memory_partition,
- bool is_default_partition) {
- scoped_ptr<CookieStoreMap> cookie_store_map(new CookieStoreMap());
- std::map<std::string, CookieStoreConfig> cookie_store_configs;
- cookie_store_configs[BrowserContext::kDefaultCookieScheme] =
- CookieStoreConfig();
-
- browser_context_->OverrideCookieStoreConfigs(
- partition_path, in_memory_partition, is_default_partition,
- &cookie_store_configs);
-
- for (std::map<std::string, CookieStoreConfig>::const_iterator it =
- cookie_store_configs.begin();
- it != cookie_store_configs.end();
- ++it) {
- scoped_refptr<net::CookieStore> cookie_store =
- CreateCookieStore(it->second);
- if (it->first == BrowserContext::kDefaultCookieScheme) {
- cookie_store_map->SetForScheme(chrome::kHttpScheme, cookie_store);
- cookie_store_map->SetForScheme(content::kHttpsScheme, cookie_store);
-
- // If file scheme is enabled, share the same cookie store as http. This is
- // legacy behavior. A complete valid, alternate approach is to use a
- // different cookie database. See comments inside CookieMonster about
- // separating out file cookies into their own CookieMonster.
- if ((cookie_store_configs.find(chrome::kFileScheme) ==
- cookie_store_configs.end())
- && cookie_store->GetCookieMonster()->IsCookieableScheme(
- chrome::kFileScheme)) {
- cookie_store_map->SetForScheme(chrome::kFileScheme, cookie_store);
- }
- } else {
- const char* schemes[] = { it->first.c_str() };
- cookie_store->GetCookieMonster()->SetCookieableSchemes(schemes, 1);
- cookie_store_map->SetForScheme(it->first, cookie_store);
- }
- }
-
- return cookie_store_map.Pass();
-}
-
} // namespace content
diff --git a/content/browser/storage_partition_impl_map.h b/content/browser/storage_partition_impl_map.h
index b6a65c5..972335a 100644
--- a/content/browser/storage_partition_impl_map.h
+++ b/content/browser/storage_partition_impl_map.h
@@ -118,11 +118,6 @@ class StoragePartitionImplMap : public base::SupportsUserData::Data {
void PostCreateInitialization(StoragePartitionImpl* partition,
bool in_memory);
- scoped_ptr<CookieStoreMap> CreateCookieStores(
- const base::FilePath& partition_path,
- bool in_memory_partition,
- bool is_default_partition);
-
BrowserContext* browser_context_; // Not Owned.
scoped_refptr<base::SequencedTaskRunner> file_access_runner_;
PartitionMap partitions_;
diff --git a/content/browser/storage_partition_impl_unittest.cc b/content/browser/storage_partition_impl_unittest.cc
index c14a7d4..a8b47bc 100644
--- a/content/browser/storage_partition_impl_unittest.cc
+++ b/content/browser/storage_partition_impl_unittest.cc
@@ -8,7 +8,6 @@
#include "base/threading/thread.h"
#include "content/browser/browser_thread_impl.h"
#include "content/browser/gpu/shader_disk_cache.h"
-#include "content/browser/net/cookie_store_map.h"
#include "content/browser/storage_partition_impl.h"
#include "content/public/browser/storage_partition.h"
#include "content/public/test/test_browser_thread_bundle.h"
@@ -110,8 +109,8 @@ TEST_F(StoragePartitionShaderClearTest, ClearShaderCache) {
EXPECT_EQ(1u, Size());
TestClosureCallback clear_cb;
- StoragePartitionImpl sp(cache_path(), NULL, NULL, NULL, NULL, NULL, NULL,
- scoped_ptr<CookieStoreMap>(), NULL);
+ StoragePartitionImpl sp(
+ cache_path(), NULL, NULL, NULL, NULL, NULL, NULL, NULL);
base::MessageLoop::current()->PostTask(
FROM_HERE, base::Bind(&ClearData, &sp, clear_cb.callback()));
clear_cb.WaitForResult();
diff --git a/content/content_browser.gypi b/content/content_browser.gypi
index 8fc2eab..064a12e 100644
--- a/content/content_browser.gypi
+++ b/content/content_browser.gypi
@@ -718,8 +718,6 @@
'browser/mime_registry_message_filter.h',
'browser/net/browser_online_state_observer.cc',
'browser/net/browser_online_state_observer.h',
- 'browser/net/cookie_store_map.cc',
- 'browser/net/cookie_store_map.h',
'browser/net/sqlite_persistent_cookie_store.cc',
'browser/net/sqlite_persistent_cookie_store.h',
'browser/net/view_blob_internals_job_factory.cc',
diff --git a/content/public/browser/browser_context.h b/content/public/browser/browser_context.h
index d1066e3..cbac82f 100644
--- a/content/public/browser/browser_context.h
+++ b/content/public/browser/browser_context.h
@@ -38,14 +38,10 @@ class IndexedDBContext;
class ResourceContext;
class SiteInstance;
class StoragePartition;
-struct CookieStoreConfig;
// This class holds the context needed for a browsing session.
// It lives on the UI thread. All these methods must only be called on the UI
// thread.
-//
-// TODO(jam): Pure virtual methods should be converted to ones with empty or
-// trivial default implementations.
class CONTENT_EXPORT BrowserContext : public base::SupportsUserData {
public:
static DownloadManager* GetDownloadManager(BrowserContext* browser_context);
@@ -75,9 +71,8 @@ class CONTENT_EXPORT BrowserContext : public base::SupportsUserData {
scoped_ptr<base::hash_set<base::FilePath> > active_paths,
const base::Closure& done);
- // Prefer GetStoragePartition() or GetStoragePartitionForSite() above. Only
- // use this if it is 100% certain that the cookie store, cache, etc., that
- // is returned by this will be the correct one.
+ // DON'T USE THIS. GetDefaultStoragePartition() is going away.
+ // Use GetStoragePartition() instead. Ask ajwong@ if you have problems.
static content::StoragePartition* GetDefaultStoragePartition(
BrowserContext* browser_context);
@@ -101,23 +96,7 @@ class CONTENT_EXPORT BrowserContext : public base::SupportsUserData {
virtual base::FilePath GetPath() const = 0;
// Return whether this context is incognito. Default is false.
- virtual bool IsOffTheRecord() const;
-
- // kDefaultCookieScheme is used in place of a scheme to specify the
- // CookieStoreConfig for the http, https, and possibly file scheme.
- //
- // The http and https scheme must share a single cookie jar in order for
- // the web to function properly. The legacy setup also has the file scheme
- // share the same cookie jar when file cookies are enabled.
- static const char kDefaultCookieScheme[];
- typedef std::map<std::string, CookieStoreConfig> CookieSchemeMap;
-
- // Allows embedder to change how the Cookie stores are configured.
- virtual void OverrideCookieStoreConfigs(
- const base::FilePath& partition_path,
- bool in_memory_partition,
- bool is_default_partition,
- CookieSchemeMap* configs) {}
+ virtual bool IsOffTheRecord() const = 0;
// Returns the request context information associated with this context. Call
// this only on the UI thread, since it can send notifications that should
diff --git a/content/public/browser/content_browser_client.cc b/content/public/browser/content_browser_client.cc
index f5419be..c2bf137 100644
--- a/content/public/browser/content_browser_client.cc
+++ b/content/public/browser/content_browser_client.cc
@@ -163,6 +163,11 @@ QuotaPermissionContext* ContentBrowserClient::CreateQuotaPermissionContext() {
return NULL;
}
+net::URLRequestContext* ContentBrowserClient::OverrideRequestContextForURL(
+ const GURL& url, ResourceContext* context) {
+ return NULL;
+}
+
std::string ContentBrowserClient::GetStoragePartitionIdForSite(
BrowserContext* browser_context,
const GURL& site) {
diff --git a/content/public/browser/content_browser_client.h b/content/public/browser/content_browser_client.h
index 4380f28..1f5e836 100644
--- a/content/public/browser/content_browser_client.h
+++ b/content/public/browser/content_browser_client.h
@@ -22,7 +22,6 @@
#include "content/public/common/window_container_type.h"
#include "net/base/mime_util.h"
#include "net/cookies/canonical_cookie.h"
-#include "net/cookies/cookie_store.h"
#include "net/url_request/url_request_job_factory.h"
#include "third_party/WebKit/public/web/WebNotificationPresenter.h"
#include "ui/base/window_open_disposition.h"
@@ -54,12 +53,12 @@ class ImageSkia;
namespace net {
class CookieOptions;
-class CookieStore;
class HttpNetworkSession;
class NetLog;
class SSLCertRequestInfo;
class SSLInfo;
class URLRequest;
+class URLRequestContext;
class URLRequestContextGetter;
class X509Certificate;
}
@@ -329,6 +328,13 @@ class CONTENT_EXPORT ContentBrowserClient {
ResourceContext* context,
const std::vector<std::pair<int, int> >& render_views);
+ // Allow the embedder to override the request context based on the URL for
+ // certain operations, like cookie access. Returns NULL to indicate the
+ // regular request context should be used.
+ // This is called on the IO thread.
+ virtual net::URLRequestContext* OverrideRequestContextForURL(
+ const GURL& url, ResourceContext* context);
+
// Allow the embedder to specify a string version of the storage partition
// config with a site.
virtual std::string GetStoragePartitionIdForSite(
diff --git a/content/public/browser/cookie_store_factory.h b/content/public/browser/cookie_store_factory.h
index 2b6e879..c7a9c6e 100644
--- a/content/public/browser/cookie_store_factory.h
+++ b/content/public/browser/cookie_store_factory.h
@@ -5,48 +5,24 @@
#ifndef CONTENT_PUBLIC_BROWSER_COOKIE_STORE_FACTORY_H_
#define CONTENT_PUBLIC_BROWSER_COOKIE_STORE_FACTORY_H_
-#include "base/files/file_path.h"
-#include "base/memory/ref_counted.h"
#include "content/common/content_export.h"
-#include "webkit/browser/quota/special_storage_policy.h"
+#include "net/cookies/cookie_monster.h"
namespace base {
class FilePath;
}
-namespace net {
-class CookieMonsterDelegate;
-class CookieStore;
+namespace quota {
+class SpecialStoragePolicy;
}
namespace content {
-struct CONTENT_EXPORT CookieStoreConfig {
- // Specifies how session cookies are persisted in the backing data store.
- enum SessionCookieMode {
- EPHEMERAL_SESSION_COOKIES,
- PERSISTANT_SESSION_COOKIES,
- RESTORED_SESSION_COOKIES
- };
-
- // If |path| is empty, then this specifies an in-memory cookie store.
- // With in-memory cookie stores, |session_cookie_mode| must be
- // EPHEMERAL_SESSION_COOKIES.
- CookieStoreConfig();
- CookieStoreConfig(const base::FilePath& path,
- SessionCookieMode session_cookie_mode,
- quota::SpecialStoragePolicy* storage_policy,
- net::CookieMonsterDelegate* cookie_delegate);
- ~CookieStoreConfig();
-
- base::FilePath path;
- SessionCookieMode session_cookie_mode;
- scoped_refptr<quota::SpecialStoragePolicy> storage_policy;
- scoped_refptr<net::CookieMonsterDelegate> cookie_delegate;
-};
-
-CONTENT_EXPORT net::CookieStore* CreateCookieStore(
- const CookieStoreConfig& config);
+CONTENT_EXPORT net::CookieStore* CreatePersistentCookieStore(
+ const base::FilePath& path,
+ bool restore_old_session_cookies,
+ quota::SpecialStoragePolicy* storage_policy,
+ net::CookieMonster::Delegate* cookie_monster_delegate);
} // namespace content
diff --git a/content/public/browser/storage_partition.h b/content/public/browser/storage_partition.h
index 60242f6..b30ca42 100644
--- a/content/public/browser/storage_partition.h
+++ b/content/public/browser/storage_partition.h
@@ -21,7 +21,6 @@ class FileSystemContext;
}
namespace net {
-class CookieStore;
class URLRequestContextGetter;
}
@@ -36,9 +35,8 @@ class DatabaseTracker;
namespace content {
class BrowserContext;
-class CookieStoreMap;
-class DOMStorageContext;
class IndexedDBContext;
+class DOMStorageContext;
// Defines what persistent state a child process can access.
//
@@ -57,8 +55,6 @@ class StoragePartition {
virtual webkit_database::DatabaseTracker* GetDatabaseTracker() = 0;
virtual DOMStorageContext* GetDOMStorageContext() = 0;
virtual IndexedDBContext* GetIndexedDBContext() = 0;
- virtual net::CookieStore* GetCookieStoreForScheme(
- const std::string& scheme) = 0;
enum RemoveDataMask {
REMOVE_DATA_MASK_APPCACHE = 1 << 0,
@@ -90,9 +86,16 @@ class StoragePartition {
// inside this StoragePartition for the given |storage_origin|.
// Note session dom storage is not cleared even if you specify
// REMOVE_DATA_MASK_LOCAL_STORAGE.
+ //
+ // TODO(ajwong): Right now, the embedder may have some
+ // URLRequestContextGetter objects that the StoragePartition does not know
+ // about. This will no longer be the case when we resolve
+ // http://crbug.com/159193. Remove |request_context_getter| when that bug
+ // is fixed.
virtual void ClearDataForOrigin(uint32 remove_mask,
uint32 quota_storage_remove_mask,
- const GURL& storage_origin) = 0;
+ const GURL& storage_origin,
+ net::URLRequestContextGetter* rq_context) = 0;
// Similar to ClearDataForOrigin(), but deletes all data out of the
// StoragePartition rather than just the data related to this origin.
diff --git a/content/public/common/content_constants.cc b/content/public/common/content_constants.cc
index fa19eaa..75e9273 100644
--- a/content/public/common/content_constants.cc
+++ b/content/public/common/content_constants.cc
@@ -11,9 +11,6 @@ const base::FilePath::CharType kAppCacheDirname[] =
const base::FilePath::CharType kPepperDataDirname[] =
FILE_PATH_LITERAL("Pepper Data");
-const base::FilePath::CharType kCookieFilename[] =
- FILE_PATH_LITERAL("Cookies");
-
const char kBrowserPluginMimeType[] = "application/browser-plugin";
const char kFlashPluginName[] = "Shockwave Flash";
diff --git a/content/public/common/content_constants.h b/content/public/common/content_constants.h
index a5de2b7..012b00f 100644
--- a/content/public/common/content_constants.h
+++ b/content/public/common/content_constants.h
@@ -21,8 +21,6 @@ CONTENT_EXPORT extern const base::FilePath::CharType kAppCacheDirname[];
// data is put.
CONTENT_EXPORT extern const base::FilePath::CharType kPepperDataDirname[];
-CONTENT_EXPORT extern const base::FilePath::CharType kCookieFilename[];
-
// The MIME type used for the browser plugin.
CONTENT_EXPORT extern const char kBrowserPluginMimeType[];
diff --git a/content/public/common/content_switches.cc b/content/public/common/content_switches.cc
index 92e1111..bcf7820 100644
--- a/content/public/common/content_switches.cc
+++ b/content/public/common/content_switches.cc
@@ -63,10 +63,6 @@ const char kDebugPluginLoading[] = "debug-plugin-loading";
const char kDefaultTileWidth[] = "default-tile-width";
const char kDefaultTileHeight[] = "default-tile-height";
-// By default, cookies are not allowed on file://. They are needed for testing,
-// for example page cycler and layout tests. See bug 1157243.
-const char kEnableFileCookies[] = "enable-file-cookies";
-
// Disable antialiasing on 2d canvas.
const char kDisable2dCanvasAntialiasing[] = "disable-canvas-aa";
diff --git a/content/public/common/content_switches.h b/content/public/common/content_switches.h
index 29d798c..e0da3ef 100644
--- a/content/public/common/content_switches.h
+++ b/content/public/common/content_switches.h
@@ -30,7 +30,6 @@ CONTENT_EXPORT extern const char kBrowserSubprocessPath[];
extern const char kDebugPluginLoading[];
extern const char kDefaultTileWidth[];
extern const char kDefaultTileHeight[];
-CONTENT_EXPORT extern const char kEnableFileCookies[];
CONTENT_EXPORT extern const char kDisable2dCanvasAntialiasing[];
CONTENT_EXPORT extern const char kDisable3DAPIs[];
CONTENT_EXPORT extern const char kDisableAccelerated2dCanvas[];
diff --git a/content/public/test/mock_resource_context.cc b/content/public/test/mock_resource_context.cc
index bcea128..342766c 100644
--- a/content/public/test/mock_resource_context.cc
+++ b/content/public/test/mock_resource_context.cc
@@ -9,12 +9,12 @@
namespace content {
MockResourceContext::MockResourceContext()
- : request_context_(NULL) {
+ : test_request_context_(NULL) {
}
MockResourceContext::MockResourceContext(
- net::URLRequestContext* request_context)
- : request_context_(request_context),
+ net::URLRequestContext* test_request_context)
+ : test_request_context_(test_request_context),
mic_allowed_(false),
camera_allowed_(false) {
}
@@ -26,8 +26,8 @@ net::HostResolver* MockResourceContext::GetHostResolver() {
}
net::URLRequestContext* MockResourceContext::GetRequestContext() {
- CHECK(request_context_);
- return request_context_;
+ CHECK(test_request_context_);
+ return test_request_context_;
}
bool MockResourceContext::AllowMicAccess(const GURL& origin) {
diff --git a/content/public/test/mock_resource_context.h b/content/public/test/mock_resource_context.h
index 934b20e..8f1791a 100644
--- a/content/public/test/mock_resource_context.h
+++ b/content/public/test/mock_resource_context.h
@@ -21,7 +21,7 @@ class MockResourceContext : public ResourceContext {
MockResourceContext();
// Does not take ownership of |test_request_context|.
- explicit MockResourceContext(net::URLRequestContext* request_context);
+ explicit MockResourceContext(net::URLRequestContext* test_request_context);
virtual ~MockResourceContext();
@@ -42,7 +42,7 @@ class MockResourceContext : public ResourceContext {
}
private:
- net::URLRequestContext* request_context_;
+ net::URLRequestContext* test_request_context_;
bool mic_allowed_;
bool camera_allowed_;
diff --git a/content/public/test/test_browser_context.cc b/content/public/test/test_browser_context.cc
index b75817f..907f748 100644
--- a/content/public/test/test_browser_context.cc
+++ b/content/public/test/test_browser_context.cc
@@ -6,8 +6,6 @@
#include "base/files/file_path.h"
#include "base/test/null_task_runner.h"
-#include "content/public/browser/cookie_store_factory.h"
-#include "content/public/browser/storage_partition.h"
#include "content/public/test/mock_resource_context.h"
#include "net/url_request/url_request_context.h"
#include "net/url_request/url_request_context_getter.h"
@@ -72,7 +70,10 @@ DownloadManagerDelegate* TestBrowserContext::GetDownloadManagerDelegate() {
}
net::URLRequestContextGetter* TestBrowserContext::GetRequestContext() {
- return GetDefaultStoragePartition(this)->GetURLRequestContext();
+ if (!request_context_.get()) {
+ request_context_ = new TestContextURLRequestContextGetter();
+ }
+ return request_context_.get();
}
net::URLRequestContextGetter*
@@ -108,7 +109,8 @@ void TestBrowserContext::RequestMIDISysExPermission(
ResourceContext* TestBrowserContext::GetResourceContext() {
if (!resource_context_)
- resource_context_.reset(new MockResourceContext());
+ resource_context_.reset(new MockResourceContext(
+ GetRequestContext()->GetURLRequestContext()));
return resource_context_.get();
}
diff --git a/content/shell/app/shell_main_delegate.cc b/content/shell/app/shell_main_delegate.cc
index f3f7002..8e60a32 100644
--- a/content/shell/app/shell_main_delegate.cc
+++ b/content/shell/app/shell_main_delegate.cc
@@ -149,6 +149,8 @@ bool ShellMainDelegate::BasicStartupComplete(int* exit_code) {
command_line.AppendSwitch(switches::kEnableInbandTextTracks);
command_line.AppendSwitch(switches::kMuteAudio);
+ net::CookieMonster::EnableFileScheme();
+
// Unless/until WebM files are added to the media layout tests, we need to
// avoid removing MP4/H264/AAC so that layout tests can run on Android.
#if !defined(OS_ANDROID)
diff --git a/content/shell/browser/shell_browser_context.cc b/content/shell/browser/shell_browser_context.cc
index 4334b6c..c6dbb99 100644
--- a/content/shell/browser/shell_browser_context.cc
+++ b/content/shell/browser/shell_browser_context.cc
@@ -12,7 +12,6 @@
#include "base/path_service.h"
#include "base/threading/thread.h"
#include "content/public/browser/browser_thread.h"
-#include "content/public/browser/cookie_store_factory.h"
#include "content/public/browser/resource_context.h"
#include "content/public/browser/storage_partition.h"
#include "content/public/common/content_switches.h"
diff --git a/content/shell/browser/shell_url_request_context_getter.cc b/content/shell/browser/shell_url_request_context_getter.cc
index 6ddfa14..dfdb852 100644
--- a/content/shell/browser/shell_url_request_context_getter.cc
+++ b/content/shell/browser/shell_url_request_context_getter.cc
@@ -12,7 +12,6 @@
#include "base/threading/sequenced_worker_pool.h"
#include "base/threading/worker_pool.h"
#include "content/public/browser/browser_thread.h"
-#include "content/public/browser/cookie_store_factory.h"
#include "content/public/common/content_switches.h"
#include "content/public/common/url_constants.h"
#include "content/shell/browser/shell_network_delegate.h"
@@ -102,8 +101,7 @@ net::URLRequestContext* ShellURLRequestContextGetter::GetURLRequestContext() {
url_request_context_->set_network_delegate(network_delegate_.get());
storage_.reset(
new net::URLRequestContextStorage(url_request_context_.get()));
- storage_->set_cookie_store(
- content::CreateCookieStore(content::CookieStoreConfig()));
+ storage_->set_cookie_store(new net::CookieMonster(NULL, NULL));
storage_->set_server_bound_cert_service(new net::ServerBoundCertService(
new net::DefaultServerBoundCertStore(NULL),
base::WorkerPool::GetTaskRunner(true)));
diff --git a/content/test/test_content_browser_client.cc b/content/test/test_content_browser_client.cc
index 9780f27..7b9d368 100644
--- a/content/test/test_content_browser_client.cc
+++ b/content/test/test_content_browser_client.cc
@@ -8,9 +8,7 @@
#include "base/files/file_path.h"
#include "base/logging.h"
-#include "content/public/browser/browser_thread.h"
#include "content/test/test_web_contents_view.h"
-#include "net/url_request/url_request_test_util.h"
namespace content {
@@ -32,13 +30,6 @@ WebContentsViewPort* TestContentBrowserClient::OverrideCreateWebContentsView(
#endif
}
-net::URLRequestContextGetter* TestContentBrowserClient::CreateRequestContext(
- BrowserContext* browser_context,
- ProtocolHandlerMap* protocol_handlers) {
- return new net::TestURLRequestContextGetter(
- BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO));
-}
-
base::FilePath TestContentBrowserClient::GetDefaultDownloadDirectory() {
if (!download_dir_.IsValid()) {
bool result = download_dir_.CreateUniqueTempDir();
diff --git a/content/test/test_content_browser_client.h b/content/test/test_content_browser_client.h
index 0182ef1..f0d58bb 100644
--- a/content/test/test_content_browser_client.h
+++ b/content/test/test_content_browser_client.h
@@ -12,10 +12,6 @@
#include "base/files/scoped_temp_dir.h"
#include "content/public/browser/content_browser_client.h"
-namespace net {
-class URLRequestContextGetter;
-} // namespace net
-
namespace content {
// Base for unit tests that need a ContentBrowserClient.
@@ -27,9 +23,6 @@ class TestContentBrowserClient : public ContentBrowserClient {
virtual WebContentsViewPort* OverrideCreateWebContentsView(
WebContents* web_contents,
RenderViewHostDelegateView** render_view_host_delegate_view) OVERRIDE;
- virtual net::URLRequestContextGetter* CreateRequestContext(
- BrowserContext* browser_context,
- ProtocolHandlerMap* protocol_handlers) OVERRIDE;
virtual base::FilePath GetDefaultDownloadDirectory() OVERRIDE;
private: