summaryrefslogtreecommitdiffstats
path: root/chrome/browser/extensions/api
diff options
context:
space:
mode:
authorbattre@chromium.org <battre@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-07-18 13:13:34 +0000
committerbattre@chromium.org <battre@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-07-18 13:13:34 +0000
commit5b9bc3505d5cd23898d0bdb350f33956070cc3a6 (patch)
tree2e28070459f0324ce2dd9288e803f8aa095781fd /chrome/browser/extensions/api
parent64c186bdf8949a84c1b1e53da12710f50e51336b (diff)
downloadchromium_src-5b9bc3505d5cd23898d0bdb350f33956070cc3a6.zip
chromium_src-5b9bc3505d5cd23898d0bdb350f33956070cc3a6.tar.gz
chromium_src-5b9bc3505d5cd23898d0bdb350f33956070cc3a6.tar.bz2
Move CanonicalCookie into separate files
BUG=137014,112155 TEST=no TBR=sky@chromium.org, erg@chromium.org, tony@chromium.org, eroman@chromium.org Review URL: https://chromiumcodereview.appspot.com/10785017 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@147222 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/extensions/api')
-rw-r--r--chrome/browser/extensions/api/cookies/cookies_api.cc1
-rw-r--r--chrome/browser/extensions/api/cookies/cookies_helpers.cc12
-rw-r--r--chrome/browser/extensions/api/cookies/cookies_helpers.h14
-rw-r--r--chrome/browser/extensions/api/cookies/cookies_unittest.cc27
4 files changed, 26 insertions, 28 deletions
diff --git a/chrome/browser/extensions/api/cookies/cookies_api.cc b/chrome/browser/extensions/api/cookies/cookies_api.cc
index 58f928e..7584c1a 100644
--- a/chrome/browser/extensions/api/cookies/cookies_api.cc
+++ b/chrome/browser/extensions/api/cookies/cookies_api.cc
@@ -20,6 +20,7 @@
#include "chrome/common/extensions/extension_error_utils.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/notification_service.h"
+#include "net/cookies/canonical_cookie.h"
#include "net/cookies/cookie_monster.h"
#include "net/url_request/url_request_context.h"
#include "net/url_request/url_request_context_getter.h"
diff --git a/chrome/browser/extensions/api/cookies/cookies_helpers.cc b/chrome/browser/extensions/api/cookies/cookies_helpers.cc
index 55917d5..5bab1aa 100644
--- a/chrome/browser/extensions/api/cookies/cookies_helpers.cc
+++ b/chrome/browser/extensions/api/cookies/cookies_helpers.cc
@@ -20,6 +20,7 @@
#include "chrome/common/url_constants.h"
#include "content/public/browser/web_contents.h"
#include "googleurl/src/gurl.h"
+#include "net/cookies/canonical_cookie.h"
#include "net/cookies/cookie_util.h"
namespace extensions {
@@ -51,9 +52,8 @@ const char* GetStoreIdFromProfile(Profile* profile) {
kOffTheRecordProfileStoreId : kOriginalProfileStoreId;
}
-DictionaryValue* CreateCookieValue(
- const net::CookieMonster::CanonicalCookie& cookie,
- const std::string& store_id) {
+DictionaryValue* CreateCookieValue(const net::CanonicalCookie& cookie,
+ const std::string& store_id) {
DictionaryValue* result = new DictionaryValue();
// A cookie is a raw byte sequence. By explicitly parsing it as UTF8, we
@@ -103,8 +103,7 @@ void GetCookieListFromStore(
}
}
-GURL GetURLFromCanonicalCookie(
- const net::CookieMonster::CanonicalCookie& cookie) {
+GURL GetURLFromCanonicalCookie(const net::CanonicalCookie& cookie) {
const std::string& domain_key = cookie.Domain();
const std::string scheme =
cookie.IsSecure() ? chrome::kHttpsScheme : chrome::kHttpScheme;
@@ -149,8 +148,7 @@ MatchFilter::MatchFilter(const DictionaryValue* details)
DCHECK(details_);
}
-bool MatchFilter::MatchesCookie(
- const net::CookieMonster::CanonicalCookie& cookie) {
+bool MatchFilter::MatchesCookie(const net::CanonicalCookie& cookie) {
return MatchesString(keys::kNameKey, cookie.Name()) &&
MatchesDomain(cookie.Domain()) &&
MatchesString(keys::kPathKey, cookie.Path()) &&
diff --git a/chrome/browser/extensions/api/cookies/cookies_helpers.h b/chrome/browser/extensions/api/cookies/cookies_helpers.h
index 77d1e5d..39e2087 100644
--- a/chrome/browser/extensions/api/cookies/cookies_helpers.h
+++ b/chrome/browser/extensions/api/cookies/cookies_helpers.h
@@ -22,6 +22,10 @@ class DictionaryValue;
class ListValue;
}
+namespace net {
+class CanonicalCookie;
+}
+
namespace extensions {
class Extension;
@@ -41,9 +45,8 @@ const char* GetStoreIdFromProfile(Profile* profile);
// Constructs a Cookie object as defined by the cookies API. This function
// allocates a new DictionaryValue object; the caller is responsible for
// freeing it.
-base::DictionaryValue* CreateCookieValue(
- const net::CookieMonster::CanonicalCookie& cookie,
- const std::string& store_id);
+base::DictionaryValue* CreateCookieValue(const net::CanonicalCookie& cookie,
+ const std::string& store_id);
// Constructs a CookieStore object as defined by the cookies API. This function
// allocates a new DictionaryValue object; the caller is responsible for
@@ -62,8 +65,7 @@ void GetCookieListFromStore(
// a cookie against the extension's host permissions. The Secure
// property of the cookie defines the URL scheme, and the cookie's
// domain becomes the URL host.
-GURL GetURLFromCanonicalCookie(
- const net::CookieMonster::CanonicalCookie& cookie);
+GURL GetURLFromCanonicalCookie(const net::CanonicalCookie& cookie);
// Looks through all cookies in the given cookie store, and appends to the
// match list all the cookies that both match the given URL and cookie details
@@ -94,7 +96,7 @@ class MatchFilter {
// Returns true if the given cookie matches the properties in the match
// filter.
- bool MatchesCookie(const net::CookieMonster::CanonicalCookie& cookie);
+ bool MatchesCookie(const net::CanonicalCookie& cookie);
private:
// Returns true if the details dictionary contains a string with the given
diff --git a/chrome/browser/extensions/api/cookies/cookies_unittest.cc b/chrome/browser/extensions/api/cookies/cookies_unittest.cc
index 91c80f7..960fc80 100644
--- a/chrome/browser/extensions/api/cookies/cookies_unittest.cc
+++ b/chrome/browser/extensions/api/cookies/cookies_unittest.cc
@@ -12,6 +12,7 @@
#include "chrome/browser/extensions/api/cookies/cookies_helpers.h"
#include "chrome/test/base/testing_profile.h"
#include "googleurl/src/gurl.h"
+#include "net/cookies/canonical_cookie.h"
namespace extensions {
@@ -109,7 +110,7 @@ TEST_F(ExtensionCookiesTest, ExtensionTypeCreation) {
double double_value;
Value* value;
- net::CookieMonster::CanonicalCookie cookie1(
+ net::CanonicalCookie cookie1(
GURL(), "ABC", "DEF", "www.foobar.com", "/",
std::string(), std::string(),
base::Time(), base::Time(), base::Time(),
@@ -138,7 +139,7 @@ TEST_F(ExtensionCookiesTest, ExtensionTypeCreation) {
EXPECT_TRUE(cookie_value1->GetString(keys::kStoreIdKey, &string_value));
EXPECT_EQ("some cookie store", string_value);
- net::CookieMonster::CanonicalCookie cookie2(
+ net::CanonicalCookie cookie2(
GURL(), "ABC", "DEF", ".foobar.com", "/", std::string(), std::string(),
base::Time(), base::Time::FromDoubleT(10000), base::Time(),
false, false);
@@ -164,7 +165,7 @@ TEST_F(ExtensionCookiesTest, ExtensionTypeCreation) {
}
TEST_F(ExtensionCookiesTest, GetURLFromCanonicalCookie) {
- net::CookieMonster::CanonicalCookie cookie1(
+ net::CanonicalCookie cookie1(
GURL(), "ABC", "DEF", "www.foobar.com", "/",
std::string(), std::string(),
base::Time(), base::Time(), base::Time(),
@@ -173,7 +174,7 @@ TEST_F(ExtensionCookiesTest, GetURLFromCanonicalCookie) {
cookies_helpers::GetURLFromCanonicalCookie(
cookie1).spec());
- net::CookieMonster::CanonicalCookie cookie2(
+ net::CanonicalCookie cookie2(
GURL(), "ABC", "DEF", ".helloworld.com", "/",
std::string(), std::string(),
base::Time(), base::Time(), base::Time(),
@@ -187,7 +188,7 @@ TEST_F(ExtensionCookiesTest, EmptyDictionary) {
scoped_ptr<DictionaryValue> details(new DictionaryValue());
cookies_helpers::MatchFilter filter(details.get());
std::string domain;
- net::CookieMonster::CanonicalCookie cookie;
+ net::CanonicalCookie cookie;
EXPECT_TRUE(filter.MatchesCookie(cookie));
}
@@ -207,21 +208,17 @@ TEST_F(ExtensionCookiesTest, DomainMatching) {
for (size_t i = 0; i < arraysize(tests); ++i) {
details->SetString(keys::kDomainKey, std::string(tests[i].filter));
cookies_helpers::MatchFilter filter(details.get());
- net::CookieMonster::CanonicalCookie cookie(GURL(), "", "", tests[i].domain,
- "", "", "", base::Time(),
- base::Time(), base::Time(),
- false, false);
+ net::CanonicalCookie cookie(GURL(), "", "", tests[i].domain, "", "", "",
+ base::Time(), base::Time(), base::Time(), false,
+ false);
EXPECT_EQ(tests[i].matches, filter.MatchesCookie(cookie));
}
}
TEST_F(ExtensionCookiesTest, DecodeUTF8WithErrorHandling) {
- net::CookieMonster::CanonicalCookie cookie(GURL(), "",
- "011Q255bNX_1!yd\203e+",
- "test.com",
- "/path\203", "", "", base::Time(),
- base::Time(), base::Time(),
- false, false);
+ net::CanonicalCookie cookie(GURL(), "", "011Q255bNX_1!yd\203e+", "test.com",
+ "/path\203", "", "", base::Time(), base::Time(),
+ base::Time(), false, false);
scoped_ptr<DictionaryValue> cookie_value(
cookies_helpers::CreateCookieValue(
cookie, "some cookie store"));