Commit e53c8ced authored by Reilly Grant's avatar Reilly Grant Committed by Commit Bot

Remove TestingProfile::GetCookieStore()

This method was only used by the BrowsingDataCookieHelper unit tests,
which this change converts to using the network::mojom::CookieManager
interface.

Bug: 721395
Change-Id: Ia4f5a54221d0ce902a42e8f910230ad0d732b7ee
Reviewed-on: https://chromium-review.googlesource.com/1236289Reviewed-by: default avatarJoshua Bell <jsbell@chromium.org>
Commit-Queue: Reilly Grant <reillyg@chromium.org>
Cr-Commit-Position: refs/heads/master@{#593231}
parent 53f3d30e
...@@ -8,10 +8,11 @@ ...@@ -8,10 +8,11 @@
#include "base/run_loop.h" #include "base/run_loop.h"
#include "base/time/time.h" #include "base/time/time.h"
#include "chrome/test/base/testing_profile.h" #include "chrome/test/base/testing_profile.h"
#include "content/public/browser/storage_partition.h"
#include "content/public/test/test_browser_thread_bundle.h" #include "content/public/test/test_browser_thread_bundle.h"
#include "net/cookies/canonical_cookie.h" #include "net/cookies/canonical_cookie.h"
#include "net/cookies/cookie_options.h" #include "net/cookies/cookie_options.h"
#include "net/url_request/url_request_context_getter.h" #include "services/network/public/mojom/cookie_manager.mojom.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
namespace { namespace {
...@@ -109,23 +110,39 @@ class BrowsingDataCookieHelperTest : public testing::Test { ...@@ -109,23 +110,39 @@ class BrowsingDataCookieHelperTest : public testing::Test {
} }
void CreateCookiesForTest() { void CreateCookiesForTest() {
net::CookieStore* cookie_store = testing_profile_->GetCookieStore(); auto cookie1 =
cookie_store->SetCookieWithOptionsAsync( net::CanonicalCookie::Create(GURL("http://www.google.com"), "A=1",
GURL("http://www.google.com"), "A=1", net::CookieOptions(), base::Time::Now(), net::CookieOptions());
net::CookieMonster::SetCookiesCallback()); auto cookie2 =
cookie_store->SetCookieWithOptionsAsync( net::CanonicalCookie::Create(GURL("http://www.gmail.google.com"), "B=1",
GURL("http://www.gmail.google.com"), "B=1", net::CookieOptions(), base::Time::Now(), net::CookieOptions());
net::CookieMonster::SetCookiesCallback());
network::mojom::CookieManager* cookie_manager =
storage_partition()->GetCookieManagerForBrowserProcess();
cookie_manager->SetCanonicalCookie(*cookie1, true /* secure_source */,
false /* modify_http_only */,
base::DoNothing());
cookie_manager->SetCanonicalCookie(*cookie2, true /* secure_source */,
false /* modify_http_only */,
base::DoNothing());
} }
void CreateCookiesForDomainCookieTest() { void CreateCookiesForDomainCookieTest() {
net::CookieStore* cookie_store = testing_profile_->GetCookieStore(); auto cookie1 =
cookie_store->SetCookieWithOptionsAsync( net::CanonicalCookie::Create(GURL("http://www.google.com"), "A=1",
GURL("http://www.google.com"), "A=1", net::CookieOptions(), base::Time::Now(), net::CookieOptions());
net::CookieMonster::SetCookiesCallback()); auto cookie2 = net::CanonicalCookie::Create(
cookie_store->SetCookieWithOptionsAsync(
GURL("http://www.google.com"), "A=2; Domain=.www.google.com ", GURL("http://www.google.com"), "A=2; Domain=.www.google.com ",
net::CookieOptions(), net::CookieMonster::SetCookiesCallback()); base::Time::Now(), net::CookieOptions());
network::mojom::CookieManager* cookie_manager =
storage_partition()->GetCookieManagerForBrowserProcess();
cookie_manager->SetCanonicalCookie(*cookie1, true /* secure_source */,
false /* modify_http_only */,
base::DoNothing());
cookie_manager->SetCanonicalCookie(*cookie2, true /* secure_source */,
false /* modify_http_only */,
base::DoNothing());
} }
void FetchCallback(const net::CookieList& cookies) { void FetchCallback(const net::CookieList& cookies) {
......
...@@ -769,12 +769,6 @@ TestingProfile::GetExtensionSpecialStoragePolicy() { ...@@ -769,12 +769,6 @@ TestingProfile::GetExtensionSpecialStoragePolicy() {
#endif #endif
} }
net::CookieStore* TestingProfile::GetCookieStore() {
if (!GetRequestContext())
return NULL;
return GetRequestContext()->GetURLRequestContext()->cookie_store();
}
void TestingProfile::CreateTestingPrefService() { void TestingProfile::CreateTestingPrefService() {
DCHECK(!prefs_.get()); DCHECK(!prefs_.get());
testing_prefs_ = new sync_preferences::TestingPrefServiceSyncable(); testing_prefs_ = new sync_preferences::TestingPrefServiceSyncable();
......
...@@ -38,7 +38,6 @@ class ZoomLevelDelegate; ...@@ -38,7 +38,6 @@ class ZoomLevelDelegate;
} }
namespace net { namespace net {
class CookieStore;
class URLRequestContextGetter; class URLRequestContextGetter;
} }
...@@ -309,10 +308,6 @@ class TestingProfile : public Profile { ...@@ -309,10 +308,6 @@ class TestingProfile : public Profile {
ExtensionSpecialStoragePolicy* extension_special_storage_policy); ExtensionSpecialStoragePolicy* extension_special_storage_policy);
#endif #endif
ExtensionSpecialStoragePolicy* GetExtensionSpecialStoragePolicy() override; ExtensionSpecialStoragePolicy* GetExtensionSpecialStoragePolicy() override;
// TODO(ajwong): Remove this API in favor of directly retrieving the
// CookieStore from the StoragePartition after ExtensionURLRequestContext
// has been removed.
net::CookieStore* GetCookieStore();
PrefService* GetPrefs() override; PrefService* GetPrefs() override;
const PrefService* GetPrefs() const override; const PrefService* GetPrefs() const override;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment