summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjochen@chromium.org <jochen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-11-25 08:28:49 +0000
committerjochen@chromium.org <jochen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-11-25 08:28:49 +0000
commit827d9876324c94e889fe7caffda7d32cb4b62f1f (patch)
treef11493cb792ad0884fe2b549b7579fff6f0b5281
parentf73ecb005462a2d7de56979ef9168452559ea71c (diff)
downloadchromium_src-827d9876324c94e889fe7caffda7d32cb4b62f1f.zip
chromium_src-827d9876324c94e889fe7caffda7d32cb4b62f1f.tar.gz
chromium_src-827d9876324c94e889fe7caffda7d32cb4b62f1f.tar.bz2
Pass cookie options to content settings delegate.
BUG=63650 TEST=unit tests Review URL: http://codereview.chromium.org/5261004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@67394 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/content_setting_image_model_unittest.cc5
-rw-r--r--chrome/browser/renderer_host/render_view_host_delegate.h5
-rw-r--r--chrome/browser/renderer_host/resource_dispatcher_host.cc3
-rw-r--r--chrome/browser/renderer_host/resource_dispatcher_host.h1
-rw-r--r--chrome/browser/renderer_host/resource_message_filter.cc4
-rw-r--r--chrome/browser/tab_contents/tab_specific_content_settings.cc7
-rw-r--r--chrome/browser/tab_contents/tab_specific_content_settings.h1
-rw-r--r--chrome/browser/tab_contents/tab_specific_content_settings_unittest.cc18
-rw-r--r--net/url_request/url_request.cc1
-rw-r--r--net/url_request/url_request.h2
-rw-r--r--net/url_request/url_request_http_job.cc2
-rw-r--r--net/url_request/url_request_unittest.h1
12 files changed, 38 insertions, 12 deletions
diff --git a/chrome/browser/content_setting_image_model_unittest.cc b/chrome/browser/content_setting_image_model_unittest.cc
index 16753c4..f84f22d 100644
--- a/chrome/browser/content_setting_image_model_unittest.cc
+++ b/chrome/browser/content_setting_image_model_unittest.cc
@@ -10,6 +10,7 @@
#include "chrome/browser/renderer_host/test/test_render_view_host.h"
#include "chrome/browser/tab_contents/test_tab_contents.h"
#include "chrome/test/testing_profile.h"
+#include "net/base/cookie_options.h"
#include "testing/gtest/include/gtest/gtest.h"
class ContentSettingImageModelTest : public RenderViewHostTestHarness {
@@ -57,7 +58,9 @@ TEST_F(ContentSettingImageModelTest, CookieAccessed) {
EXPECT_EQ(0, content_setting_image_model->get_icon());
EXPECT_EQ(std::string(), content_setting_image_model->get_tooltip());
- content_settings->OnCookieAccessed(GURL("http://google.com"), "A=B", false);
+ net::CookieOptions options;
+ content_settings->OnCookieAccessed(
+ GURL("http://google.com"), "A=B", options, false);
content_setting_image_model->UpdateFromTabContents(&tab_contents);
EXPECT_TRUE(content_setting_image_model->is_visible());
EXPECT_NE(0, content_setting_image_model->get_icon());
diff --git a/chrome/browser/renderer_host/render_view_host_delegate.h b/chrome/browser/renderer_host/render_view_host_delegate.h
index 2a6f745..9bde9cd 100644
--- a/chrome/browser/renderer_host/render_view_host_delegate.h
+++ b/chrome/browser/renderer_host/render_view_host_delegate.h
@@ -70,6 +70,10 @@ namespace IPC {
class Message;
}
+namespace net {
+class CookieOptions;
+}
+
namespace webkit_glue {
struct FormData;
class FormField;
@@ -392,6 +396,7 @@ class RenderViewHostDelegate {
// OnContentBlocked.
virtual void OnCookieAccessed(const GURL& url,
const std::string& cookie_line,
+ const net::CookieOptions& options,
bool blocked_by_policy) = 0;
// Called when a specific indexed db factory in the current page was
diff --git a/chrome/browser/renderer_host/resource_dispatcher_host.cc b/chrome/browser/renderer_host/resource_dispatcher_host.cc
index b2610d5..a187d99 100644
--- a/chrome/browser/renderer_host/resource_dispatcher_host.cc
+++ b/chrome/browser/renderer_host/resource_dispatcher_host.cc
@@ -1080,6 +1080,7 @@ void ResourceDispatcherHost::OnSSLCertificateError(
void ResourceDispatcherHost::OnSetCookie(URLRequest* request,
const std::string& cookie_line,
+ const net::CookieOptions& options,
bool blocked_by_policy) {
VLOG(1) << "OnSetCookie: " << request->url().spec();
@@ -1090,7 +1091,7 @@ void ResourceDispatcherHost::OnSetCookie(URLRequest* request,
CallRenderViewHostContentSettingsDelegate(
render_process_id, render_view_id,
&RenderViewHostDelegate::ContentSettings::OnCookieAccessed,
- request->url(), cookie_line, blocked_by_policy);
+ request->url(), cookie_line, options, blocked_by_policy);
}
void ResourceDispatcherHost::OnResponseStarted(URLRequest* request) {
diff --git a/chrome/browser/renderer_host/resource_dispatcher_host.h b/chrome/browser/renderer_host/resource_dispatcher_host.h
index 95909d3be..7fc27b8 100644
--- a/chrome/browser/renderer_host/resource_dispatcher_host.h
+++ b/chrome/browser/renderer_host/resource_dispatcher_host.h
@@ -216,6 +216,7 @@ class ResourceDispatcherHost : public URLRequest::Delegate {
net::X509Certificate* cert);
virtual void OnSetCookie(URLRequest* request,
const std::string& cookie_line,
+ const net::CookieOptions& options,
bool blocked_by_policy);
virtual void OnResponseStarted(URLRequest* request);
virtual void OnReadCompleted(URLRequest* request, int bytes_read);
diff --git a/chrome/browser/renderer_host/resource_message_filter.cc b/chrome/browser/renderer_host/resource_message_filter.cc
index 3ebeb17..a1ae820 100644
--- a/chrome/browser/renderer_host/resource_message_filter.cc
+++ b/chrome/browser/renderer_host/resource_message_filter.cc
@@ -1750,10 +1750,10 @@ SetCookieCompletion::~SetCookieCompletion() {}
void SetCookieCompletion::RunWithParams(const Tuple1<int>& params) {
int result = params.a;
bool blocked_by_policy = true;
+ net::CookieOptions options;
if (result == net::OK ||
result == net::OK_FOR_SESSION_ONLY) {
blocked_by_policy = false;
- net::CookieOptions options;
if (result == net::OK_FOR_SESSION_ONLY)
options.set_force_session();
context_->cookie_store()->SetCookieWithOptions(url_, cookie_line_,
@@ -1763,7 +1763,7 @@ void SetCookieCompletion::RunWithParams(const Tuple1<int>& params) {
CallRenderViewHostContentSettingsDelegate(
render_process_id_, render_view_id_,
&RenderViewHostDelegate::ContentSettings::OnCookieAccessed,
- url_, cookie_line_, blocked_by_policy);
+ url_, cookie_line_, options, blocked_by_policy);
}
delete this;
}
diff --git a/chrome/browser/tab_contents/tab_specific_content_settings.cc b/chrome/browser/tab_contents/tab_specific_content_settings.cc
index edafe6cd..62f3646 100644
--- a/chrome/browser/tab_contents/tab_specific_content_settings.cc
+++ b/chrome/browser/tab_contents/tab_specific_content_settings.cc
@@ -94,9 +94,10 @@ void TabSpecificContentSettings::OnContentAccessed(ContentSettingsType type) {
}
void TabSpecificContentSettings::OnCookieAccessed(
- const GURL& url, const std::string& cookie_line, bool blocked_by_policy) {
- net::CookieOptions options;
- options.set_include_httponly();
+ const GURL& url,
+ const std::string& cookie_line,
+ const net::CookieOptions& options,
+ bool blocked_by_policy) {
if (blocked_by_policy) {
blocked_local_shared_objects_.cookies()->SetCookieWithOptions(
url, cookie_line, options);
diff --git a/chrome/browser/tab_contents/tab_specific_content_settings.h b/chrome/browser/tab_contents/tab_specific_content_settings.h
index 5cc9213..a5030ed 100644
--- a/chrome/browser/tab_contents/tab_specific_content_settings.h
+++ b/chrome/browser/tab_contents/tab_specific_content_settings.h
@@ -93,6 +93,7 @@ class TabSpecificContentSettings
const std::string& resource_identifier);
virtual void OnCookieAccessed(const GURL& url,
const std::string& cookie_line,
+ const net::CookieOptions& options,
bool blocked_by_policy);
virtual void OnIndexedDBAccessed(const GURL& url,
const string16& description,
diff --git a/chrome/browser/tab_contents/tab_specific_content_settings_unittest.cc b/chrome/browser/tab_contents/tab_specific_content_settings_unittest.cc
index 64c84e4..5be081c 100644
--- a/chrome/browser/tab_contents/tab_specific_content_settings_unittest.cc
+++ b/chrome/browser/tab_contents/tab_specific_content_settings_unittest.cc
@@ -5,6 +5,7 @@
#include "chrome/browser/tab_contents/tab_specific_content_settings.h"
#include "chrome/test/testing_profile.h"
+#include "net/base/cookie_options.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace {
@@ -39,6 +40,7 @@ TEST(TabSpecificContentSettingsTest, BlockedContent) {
TestContentSettingsDelegate test_delegate;
TestingProfile profile;
TabSpecificContentSettings content_settings(&test_delegate, &profile);
+ net::CookieOptions options;
// Check that after initializing, nothing is blocked.
EXPECT_FALSE(content_settings.IsContentBlocked(CONTENT_SETTINGS_TYPE_IMAGES));
@@ -51,7 +53,8 @@ TEST(TabSpecificContentSettingsTest, BlockedContent) {
EXPECT_FALSE(content_settings.IsContentBlocked(CONTENT_SETTINGS_TYPE_POPUPS));
// Set a cookie, block access to images, block a popup.
- content_settings.OnCookieAccessed(GURL("http://google.com"), "A=B", false);
+ content_settings.OnCookieAccessed(
+ GURL("http://google.com"), "A=B", options, false);
EXPECT_TRUE(test_delegate.SettingsChanged());
EXPECT_FALSE(test_delegate.ContentBlocked());
test_delegate.Reset();
@@ -74,10 +77,12 @@ TEST(TabSpecificContentSettingsTest, BlockedContent) {
EXPECT_FALSE(
content_settings.IsContentBlocked(CONTENT_SETTINGS_TYPE_COOKIES));
EXPECT_TRUE(content_settings.IsContentBlocked(CONTENT_SETTINGS_TYPE_POPUPS));
- content_settings.OnCookieAccessed(GURL("http://google.com"), "A=B", false);
+ content_settings.OnCookieAccessed(
+ GURL("http://google.com"), "A=B", options, false);
// Block a cookie.
- content_settings.OnCookieAccessed(GURL("http://google.com"), "C=D", true);
+ content_settings.OnCookieAccessed(
+ GURL("http://google.com"), "C=D", options, true);
EXPECT_TRUE(
content_settings.IsContentBlocked(CONTENT_SETTINGS_TYPE_COOKIES));
@@ -111,6 +116,7 @@ TEST(TabSpecificContentSettingsTest, AllowedContent) {
TestContentSettingsDelegate test_delegate;
TestingProfile profile;
TabSpecificContentSettings content_settings(&test_delegate, &profile);
+ net::CookieOptions options;
ASSERT_FALSE(
content_settings.IsContentAccessed(CONTENT_SETTINGS_TYPE_IMAGES));
@@ -118,12 +124,14 @@ TEST(TabSpecificContentSettingsTest, AllowedContent) {
content_settings.IsContentAccessed(CONTENT_SETTINGS_TYPE_COOKIES));
ASSERT_FALSE(
content_settings.IsContentBlocked(CONTENT_SETTINGS_TYPE_COOKIES));
- content_settings.OnCookieAccessed(GURL("http://google.com"), "A=B", false);
+ content_settings.OnCookieAccessed(
+ GURL("http://google.com"), "A=B", options, false);
ASSERT_TRUE(
content_settings.IsContentAccessed(CONTENT_SETTINGS_TYPE_COOKIES));
ASSERT_FALSE(
content_settings.IsContentBlocked(CONTENT_SETTINGS_TYPE_COOKIES));
- content_settings.OnCookieAccessed(GURL("http://google.com"), "C=D", true);
+ content_settings.OnCookieAccessed(
+ GURL("http://google.com"), "C=D", options, true);
ASSERT_TRUE(
content_settings.IsContentAccessed(CONTENT_SETTINGS_TYPE_COOKIES));
ASSERT_TRUE(
diff --git a/net/url_request/url_request.cc b/net/url_request/url_request.cc
index 7898848..ac54a1f 100644
--- a/net/url_request/url_request.cc
+++ b/net/url_request/url_request.cc
@@ -89,6 +89,7 @@ void URLRequest::Delegate::OnGetCookies(URLRequest* request,
void URLRequest::Delegate::OnSetCookie(URLRequest* request,
const std::string& cookie_line,
+ const net::CookieOptions& options,
bool blocked_by_policy) {
}
diff --git a/net/url_request/url_request.h b/net/url_request/url_request.h
index 66c0aa9..01df25b 100644
--- a/net/url_request/url_request.h
+++ b/net/url_request/url_request.h
@@ -29,6 +29,7 @@ class Time;
} // namespace base
namespace net {
+class CookieOptions;
class IOBuffer;
class SSLCertRequestInfo;
class UploadData;
@@ -187,6 +188,7 @@ class URLRequest : public NonThreadSafe {
// when LOAD_DO_NOT_SAVE_COOKIES is specified.
virtual void OnSetCookie(URLRequest* request,
const std::string& cookie_line,
+ const net::CookieOptions& options,
bool blocked_by_policy);
// After calling Start(), the delegate will receive an OnResponseStarted
diff --git a/net/url_request/url_request_http_job.cc b/net/url_request/url_request_http_job.cc
index 826f635..bbb229b 100644
--- a/net/url_request/url_request_http_job.cc
+++ b/net/url_request/url_request_http_job.cc
@@ -475,6 +475,7 @@ void URLRequestHttpJob::OnCanSetCookieCompleted(int policy) {
request_->delegate()->OnSetCookie(
request_,
response_cookies_[response_cookies_save_index_],
+ net::CookieOptions(),
true);
} else if ((policy == net::OK || policy == net::OK_FOR_SESSION_ONLY) &&
request_->context()->cookie_store()) {
@@ -489,6 +490,7 @@ void URLRequestHttpJob::OnCanSetCookieCompleted(int policy) {
request_->delegate()->OnSetCookie(
request_,
response_cookies_[response_cookies_save_index_],
+ options,
false);
}
response_cookies_save_index_++;
diff --git a/net/url_request/url_request_unittest.h b/net/url_request/url_request_unittest.h
index 378b133..af8f49e 100644
--- a/net/url_request/url_request_unittest.h
+++ b/net/url_request/url_request_unittest.h
@@ -319,6 +319,7 @@ class TestDelegate : public URLRequest::Delegate {
virtual void OnSetCookie(URLRequest* request,
const std::string& cookie_line,
+ const net::CookieOptions& options,
bool blocked_by_policy) {
if (blocked_by_policy) {
blocked_set_cookie_count_++;