summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoridanan@chromium.org <idanan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-15 15:24:46 +0000
committeridanan@chromium.org <idanan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-15 15:24:46 +0000
commit0820ac156d55a3532af12014177dd619cafe216f (patch)
tree7701a3a801e3fc0c50bfe97b9801a7d3af769a9c
parent32b8072a2ac29592417255fb6efafee33e46d70e (diff)
downloadchromium_src-0820ac156d55a3532af12014177dd619cafe216f.zip
chromium_src-0820ac156d55a3532af12014177dd619cafe216f.tar.gz
chromium_src-0820ac156d55a3532af12014177dd619cafe216f.tar.bz2
Privacy option added for all cookies to become session cookies.
BUG=10502 Review URL: http://codereview.chromium.org/87047 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@16158 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/app/generated_resources.grd3
-rw-r--r--chrome/browser/net/chrome_url_request_context.cc9
-rw-r--r--chrome/browser/views/options/advanced_contents_view.cc6
-rw-r--r--net/base/cookie_monster.cc4
-rw-r--r--net/base/cookie_monster.h3
-rw-r--r--net/base/cookie_policy.cc4
-rw-r--r--net/base/cookie_policy.h8
7 files changed, 32 insertions, 5 deletions
diff --git a/chrome/app/generated_resources.grd b/chrome/app/generated_resources.grd
index 33bbbf3..f711187 100644
--- a/chrome/app/generated_resources.grd
+++ b/chrome/app/generated_resources.grd
@@ -3132,6 +3132,9 @@ each locale. -->
<message name="IDS_OPTIONS_COOKIES_BLOCK_ALL_COOKIES" desc="The label of the 'Block all cookies' dropdown list item">
Block all cookies
</message>
+ <message name="IDS_OPTIONS_COOKIES_SESSION_COOKIES" desc="The label of the 'Session cookies' dropdown list item">
+ Session Cookies
+ </message>
<message name="IDS_OPTIONS_COOKIES_SHOWCOOKIES" desc="The label of the 'Show Cookies' button">
Show cookies
</message>
diff --git a/chrome/browser/net/chrome_url_request_context.cc b/chrome/browser/net/chrome_url_request_context.cc
index 1c18ed4..eb3a0d0 100644
--- a/chrome/browser/net/chrome_url_request_context.cc
+++ b/chrome/browser/net/chrome_url_request_context.cc
@@ -142,7 +142,9 @@ ChromeURLRequestContext* ChromeURLRequestContext::CreateOriginal(
context->cookie_db_.reset(new SQLitePersistentCookieStore(
cookie_store_path.ToWStringHack(),
g_browser_process->db_thread()->message_loop()));
- context->cookie_store_ = new net::CookieMonster(context->cookie_db_.get());
+ context->cookie_store_ = new net::CookieMonster(
+ context->cookie_policy_.GetType() ==
+ net::CookiePolicy::SESSION_COOKIES ? NULL : context->cookie_db_.get());
}
return context;
@@ -390,6 +392,11 @@ void ChromeURLRequestContext::OnCookiePolicyChange(
DCHECK(MessageLoop::current() ==
ChromeThread::GetMessageLoop(ChromeThread::IO));
cookie_policy_.SetType(type);
+
+ if (is_off_the_record_ || type == net::CookiePolicy::SESSION_COOKIES)
+ cookie_store_->SetStore(NULL);
+ else
+ cookie_store_->SetStore(cookie_db_.get());
}
void ChromeURLRequestContext::OnNewExtensions(ExtensionPaths* new_paths) {
diff --git a/chrome/browser/views/options/advanced_contents_view.cc b/chrome/browser/views/options/advanced_contents_view.cc
index a1ed601..1d56393 100644
--- a/chrome/browser/views/options/advanced_contents_view.cc
+++ b/chrome/browser/views/options/advanced_contents_view.cc
@@ -286,14 +286,15 @@ class CookieBehaviorComboModel : public views::ComboBox::Model {
// Return the number of items in the combo box.
virtual int GetItemCount(views::ComboBox* source) {
- return 3;
+ return 4;
}
virtual std::wstring GetItemAt(views::ComboBox* source, int index) {
const int kStringIDs[] = {
IDS_OPTIONS_COOKIES_ACCEPT_ALL_COOKIES,
IDS_OPTIONS_COOKIES_RESTRICT_THIRD_PARTY_COOKIES,
- IDS_OPTIONS_COOKIES_BLOCK_ALL_COOKIES
+ IDS_OPTIONS_COOKIES_BLOCK_ALL_COOKIES,
+ IDS_OPTIONS_COOKIES_SESSION_COOKIES
};
if (index >= 0 && index < arraysize(kStringIDs))
return l10n_util::GetString(kStringIDs[index]);
@@ -472,6 +473,7 @@ void PrivacySection::ItemChanged(views::ComboBox* sender,
const wchar_t* kUserMetrics[] = {
L"Options_AllowAllCookies",
L"Options_BlockThirdPartyCookies",
+ L"Options_SessionCookies",
L"Options_BlockAllCookies"
};
DCHECK(cookie_policy >= 0 && cookie_policy < arraysize(kUserMetrics));
diff --git a/net/base/cookie_monster.cc b/net/base/cookie_monster.cc
index 470bfc2..7eb487e 100644
--- a/net/base/cookie_monster.cc
+++ b/net/base/cookie_monster.cc
@@ -711,6 +711,10 @@ bool CookieMonster::DeleteCookie(const std::string& domain,
return false;
}
+void CookieMonster::SetStore(PersistentCookieStore* store) {
+ store_ = store;
+}
+
// Mozilla sorts on the path length (longest first), and then it
// sorts by creation time (oldest first).
// The RFC says the sort order for the domain attribute is undefined.
diff --git a/net/base/cookie_monster.h b/net/base/cookie_monster.h
index 24db893..69750e5 100644
--- a/net/base/cookie_monster.h
+++ b/net/base/cookie_monster.h
@@ -134,6 +134,9 @@ class CookieMonster {
const CanonicalCookie& cookie,
bool sync_to_store);
+ // Sets the store, possibly to null for session only cookies.
+ void SetStore(PersistentCookieStore* store);
+
// Override the default list of schemes that are allowed to be set in
// this cookie store. Calling his overrides the value of
// "enable_file_scheme_".
diff --git a/net/base/cookie_policy.cc b/net/base/cookie_policy.cc
index d18db63..8eb1179 100644
--- a/net/base/cookie_policy.cc
+++ b/net/base/cookie_policy.cc
@@ -16,6 +16,8 @@ bool CookiePolicy::CanGetCookies(const GURL& url, const GURL& policy_url) {
return true;
case CookiePolicy::BLOCK_THIRD_PARTY_COOKIES:
return true;
+ case CookiePolicy::SESSION_COOKIES:
+ return true;
case CookiePolicy::BLOCK_ALL_COOKIES:
return false;
default:
@@ -33,6 +35,8 @@ bool CookiePolicy::CanSetCookie(const GURL& url, const GURL& policy_url) {
return true; // Empty policy URL should indicate a first-party request
return net::RegistryControlledDomainService::SameDomainOrHost(url,
policy_url);
+ case CookiePolicy::SESSION_COOKIES:
+ return true;
case CookiePolicy::BLOCK_ALL_COOKIES:
return false;
default:
diff --git a/net/base/cookie_policy.h b/net/base/cookie_policy.h
index 89d490b..6fa6002 100644
--- a/net/base/cookie_policy.h
+++ b/net/base/cookie_policy.h
@@ -25,11 +25,12 @@ class CookiePolicy {
enum Type {
ALLOW_ALL_COOKIES = 0, // do not perform any cookie blocking
BLOCK_THIRD_PARTY_COOKIES, // prevent third-party cookies from being sent
- BLOCK_ALL_COOKIES // disable cookies
+ BLOCK_ALL_COOKIES, // disable cookies
+ SESSION_COOKIES // expire all cookies at end of session
};
static bool ValidType(int32 type) {
- return type >= ALLOW_ALL_COOKIES && type <= BLOCK_ALL_COOKIES;
+ return type >= ALLOW_ALL_COOKIES && type <= SESSION_COOKIES;
}
static Type FromInt(int32 type) {
@@ -40,6 +41,9 @@ class CookiePolicy {
// preferences change.
void SetType(Type type) { type_ = type; }
+ // Get the current policy.
+ Type GetType() const { return type_; }
+
CookiePolicy();
private: