summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/browsing_data_appcache_helper.cc4
-rw-r--r--chrome/browser/browsing_data_appcache_helper.h3
-rw-r--r--chrome/browser/browsing_data_database_helper.cc4
-rw-r--r--chrome/browser/browsing_data_database_helper.h3
-rw-r--r--chrome/browser/browsing_data_local_storage_helper.cc4
-rw-r--r--chrome/browser/browsing_data_local_storage_helper.h3
-rw-r--r--chrome/browser/content_setting_bubble_model.cc8
-rw-r--r--chrome/browser/content_setting_bubble_model_unittest.cc20
-rw-r--r--chrome/browser/content_setting_image_model.cc10
-rw-r--r--chrome/browser/content_setting_image_model_unittest.cc6
-rw-r--r--chrome/browser/geolocation/geolocation_browsertest.cc4
-rw-r--r--chrome/browser/geolocation/geolocation_permission_context.cc8
-rw-r--r--chrome/browser/geolocation/geolocation_permission_context_unittest.cc4
-rw-r--r--chrome/browser/in_process_webkit/dom_storage_dispatcher_host.cc6
-rw-r--r--chrome/browser/renderer_host/render_view_host.cc13
-rw-r--r--chrome/browser/renderer_host/render_view_host.h5
-rw-r--r--chrome/browser/renderer_host/render_view_host_delegate.h25
-rw-r--r--chrome/browser/renderer_host/render_view_host_notification_task.h13
-rw-r--r--chrome/browser/renderer_host/resource_dispatcher_host.cc10
-rw-r--r--chrome/browser/renderer_host/resource_dispatcher_host.h4
-rw-r--r--chrome/browser/renderer_host/resource_message_filter.cc15
-rw-r--r--chrome/browser/tab_contents/tab_contents.cc60
-rw-r--r--chrome/browser/tab_contents/tab_contents.h51
-rw-r--r--chrome/browser/tab_contents/tab_specific_content_settings.cc128
-rw-r--r--chrome/browser/tab_contents/tab_specific_content_settings.h114
-rw-r--r--chrome/browser/tab_contents/tab_specific_content_settings_unittest.cc78
-rw-r--r--chrome/chrome_browser.gypi2
-rw-r--r--chrome/chrome_tests.gypi1
-rw-r--r--chrome/common/render_messages_internal.h9
-rw-r--r--chrome/renderer/render_view.cc8
-rw-r--r--chrome_frame/test/net/fake_external_tab.cc4
-rw-r--r--net/url_request/url_request.h14
-rw-r--r--net/url_request/url_request_http_job.cc16
-rw-r--r--net/url_request/url_request_unittest.cc17
-rw-r--r--net/url_request/url_request_unittest.h27
35 files changed, 557 insertions, 144 deletions
diff --git a/chrome/browser/browsing_data_appcache_helper.cc b/chrome/browser/browsing_data_appcache_helper.cc
index f684e13..54b08ac 100644
--- a/chrome/browser/browsing_data_appcache_helper.cc
+++ b/chrome/browser/browsing_data_appcache_helper.cc
@@ -116,6 +116,10 @@ void CannedBrowsingDataAppCacheHelper::AddAppCache(const GURL& manifest_url) {
base::Time()));
}
+void CannedBrowsingDataAppCacheHelper::Reset() {
+ info_collection_->infos_by_origin.clear();
+}
+
void CannedBrowsingDataAppCacheHelper::StartFetching(
Callback0::Type* completion_callback) {
completion_callback->Run();
diff --git a/chrome/browser/browsing_data_appcache_helper.h b/chrome/browser/browsing_data_appcache_helper.h
index 226567da..d7da4a6 100644
--- a/chrome/browser/browsing_data_appcache_helper.h
+++ b/chrome/browser/browsing_data_appcache_helper.h
@@ -61,6 +61,9 @@ class CannedBrowsingDataAppCacheHelper : public BrowsingDataAppCacheHelper {
// helper.
void AddAppCache(const GURL& manifest_url);
+ // Clears the list of canned caches.
+ void Reset();
+
// BrowsingDataAppCacheHelper methods.
virtual void StartFetching(Callback0::Type* completion_callback);
virtual void CancelNotification() {}
diff --git a/chrome/browser/browsing_data_database_helper.cc b/chrome/browser/browsing_data_database_helper.cc
index 7c97163..0530225 100644
--- a/chrome/browser/browsing_data_database_helper.cc
+++ b/chrome/browser/browsing_data_database_helper.cc
@@ -131,6 +131,10 @@ void CannedBrowsingDataDatabaseHelper::AddDatabase(
base::Time()));
}
+void CannedBrowsingDataDatabaseHelper::Reset() {
+ database_info_.clear();
+}
+
void CannedBrowsingDataDatabaseHelper::StartFetching(
Callback1<const std::vector<DatabaseInfo>& >::Type* callback) {
callback->Run(database_info_);
diff --git a/chrome/browser/browsing_data_database_helper.h b/chrome/browser/browsing_data_database_helper.h
index a0b39c6..4fd852be 100644
--- a/chrome/browser/browsing_data_database_helper.h
+++ b/chrome/browser/browsing_data_database_helper.h
@@ -121,6 +121,9 @@ class CannedBrowsingDataDatabaseHelper : public BrowsingDataDatabaseHelper {
const std::string& name,
const std::string& description);
+ // Clear the list of canned databases.
+ void Reset();
+
// BrowsingDataDatabaseHelper methods.
virtual void StartFetching(
Callback1<const std::vector<DatabaseInfo>& >::Type* callback);
diff --git a/chrome/browser/browsing_data_local_storage_helper.cc b/chrome/browser/browsing_data_local_storage_helper.cc
index 4a9d517..47a4b61 100644
--- a/chrome/browser/browsing_data_local_storage_helper.cc
+++ b/chrome/browser/browsing_data_local_storage_helper.cc
@@ -139,6 +139,10 @@ void CannedBrowsingDataLocalStorageHelper::AddLocalStorage(
base::Time()));
}
+void CannedBrowsingDataLocalStorageHelper::Reset() {
+ local_storage_info_.clear();
+}
+
void CannedBrowsingDataLocalStorageHelper::StartFetching(
Callback1<const std::vector<LocalStorageInfo>& >::Type* callback) {
callback->Run(local_storage_info_);
diff --git a/chrome/browser/browsing_data_local_storage_helper.h b/chrome/browser/browsing_data_local_storage_helper.h
index 682d737..5d71423 100644
--- a/chrome/browser/browsing_data_local_storage_helper.h
+++ b/chrome/browser/browsing_data_local_storage_helper.h
@@ -117,6 +117,9 @@ class CannedBrowsingDataLocalStorageHelper
// by this helper.
void AddLocalStorage(const GURL& origin);
+ // Clear the list of canned local storages.
+ void Reset();
+
// BrowsingDataLocalStorageHelper methods.
virtual void StartFetching(
Callback1<const std::vector<LocalStorageInfo>& >::Type* callback);
diff --git a/chrome/browser/content_setting_bubble_model.cc b/chrome/browser/content_setting_bubble_model.cc
index d918c35..f396cded 100644
--- a/chrome/browser/content_setting_bubble_model.cc
+++ b/chrome/browser/content_setting_bubble_model.cc
@@ -199,8 +199,10 @@ class ContentSettingDomainListBubbleModel
}
}
void SetDomainsAndClearLink() {
+ TabSpecificContentSettings* content_settings =
+ tab_contents()->GetTabSpecificContentSettings();
const GeolocationSettingsState& settings =
- tab_contents()->geolocation_settings_state();
+ content_settings->geolocation_settings_state();
GeolocationSettingsState::FormattedHostsPerState formatted_hosts_per_state;
unsigned int tab_state_flags = 0;
settings.GetDetailedInfo(&formatted_hosts_per_state, &tab_state_flags);
@@ -233,8 +235,10 @@ class ContentSettingDomainListBubbleModel
// Reset this embedder's entry to default for each of the requesting
// origins currently on the page.
const GURL& embedder_url = tab_contents()->GetURL();
+ TabSpecificContentSettings* content_settings =
+ tab_contents()->GetTabSpecificContentSettings();
const GeolocationSettingsState::StateMap& state_map =
- tab_contents()->geolocation_settings_state().state_map();
+ content_settings->geolocation_settings_state().state_map();
GeolocationContentSettingsMap* settings_map =
profile()->GetGeolocationContentSettingsMap();
for (GeolocationSettingsState::StateMap::const_iterator it =
diff --git a/chrome/browser/content_setting_bubble_model_unittest.cc b/chrome/browser/content_setting_bubble_model_unittest.cc
index 0e3e8e5..5615a94 100644
--- a/chrome/browser/content_setting_bubble_model_unittest.cc
+++ b/chrome/browser/content_setting_bubble_model_unittest.cc
@@ -43,9 +43,9 @@ class ContentSettingBubbleModelTest : public RenderViewHostTestHarness {
};
TEST_F(ContentSettingBubbleModelTest, ImageRadios) {
- RenderViewHostDelegate::ContentSettings* render_view_host_delegate =
- contents();
- render_view_host_delegate->OnContentBlocked(CONTENT_SETTINGS_TYPE_IMAGES);
+ TabSpecificContentSettings* content_settings =
+ contents()->GetTabSpecificContentSettings();
+ content_settings->OnContentBlocked(CONTENT_SETTINGS_TYPE_IMAGES);
scoped_ptr<ContentSettingBubbleModel> content_setting_bubble_model(
ContentSettingBubbleModel::CreateContentSettingBubbleModel(
@@ -59,9 +59,9 @@ TEST_F(ContentSettingBubbleModelTest, ImageRadios) {
}
TEST_F(ContentSettingBubbleModelTest, Cookies) {
- RenderViewHostDelegate::ContentSettings* render_view_host_delegate =
- contents();
- render_view_host_delegate->OnContentBlocked(CONTENT_SETTINGS_TYPE_COOKIES);
+ TabSpecificContentSettings* content_settings =
+ contents()->GetTabSpecificContentSettings();
+ content_settings->OnContentBlocked(CONTENT_SETTINGS_TYPE_COOKIES);
scoped_ptr<ContentSettingBubbleModel> content_setting_bubble_model(
ContentSettingBubbleModel::CreateContentSettingBubbleModel(
@@ -79,11 +79,11 @@ TEST_F(ContentSettingBubbleModelTest, Geolocation) {
const GURL frame2_url("http://host2.example:999/");
NavigateAndCommit(page_url);
- RenderViewHostDelegate::ContentSettings* render_view_host_delegate =
- contents();
+ TabSpecificContentSettings* content_settings =
+ contents()->GetTabSpecificContentSettings();
// One permitted frame, but not in the content map: requires reload.
- render_view_host_delegate->OnGeolocationPermissionSet(frame1_url, true);
+ content_settings->OnGeolocationPermissionSet(frame1_url, true);
CheckGeolocationBubble(1, false, true);
// Add it to the content map, should now have a clear link.
@@ -97,7 +97,7 @@ TEST_F(ContentSettingBubbleModelTest, Geolocation) {
CheckGeolocationBubble(1, false, false);
// Second frame denied, but not stored in the content map: requires reload.
- render_view_host_delegate->OnGeolocationPermissionSet(frame2_url, false);
+ content_settings->OnGeolocationPermissionSet(frame2_url, false);
CheckGeolocationBubble(2, false, true);
// Change the default to block: offer a clear link for the persisted frame 1.
diff --git a/chrome/browser/content_setting_image_model.cc b/chrome/browser/content_setting_image_model.cc
index b1a0a53..26e349ac 100644
--- a/chrome/browser/content_setting_image_model.cc
+++ b/chrome/browser/content_setting_image_model.cc
@@ -59,8 +59,10 @@ ContentSettingBlockedImageModel::ContentSettingBlockedImageModel(
void ContentSettingBlockedImageModel::UpdateFromTabContents(
const TabContents* tab_contents) {
- if (!tab_contents ||
- !tab_contents->IsContentBlocked(get_content_settings_type())) {
+ TabSpecificContentSettings* content_settings = tab_contents ?
+ tab_contents->GetTabSpecificContentSettings() : NULL;
+ if (!content_settings ||
+ !content_settings->IsContentBlocked(get_content_settings_type())) {
set_visible(false);
return;
}
@@ -80,8 +82,10 @@ void ContentSettingGeolocationImageModel::UpdateFromTabContents(
set_visible(false);
return;
}
+ TabSpecificContentSettings* content_settings =
+ tab_contents->GetTabSpecificContentSettings();
const GeolocationSettingsState& settings_state =
- tab_contents->geolocation_settings_state();
+ content_settings->geolocation_settings_state();
if (settings_state.state_map().empty()) {
set_visible(false);
return;
diff --git a/chrome/browser/content_setting_image_model_unittest.cc b/chrome/browser/content_setting_image_model_unittest.cc
index d4d1529..02a5af3 100644
--- a/chrome/browser/content_setting_image_model_unittest.cc
+++ b/chrome/browser/content_setting_image_model_unittest.cc
@@ -14,8 +14,8 @@ typedef RenderViewHostTestHarness ContentSettingImageModelTest;
TEST_F(ContentSettingImageModelTest, UpdateFromTabContents) {
TestTabContents tab_contents(profile_.get(), NULL);
- RenderViewHostDelegate::ContentSettings* render_view_host_delegate =
- &tab_contents;
+ TabSpecificContentSettings* content_settings =
+ tab_contents.GetTabSpecificContentSettings();
scoped_ptr<ContentSettingImageModel> content_setting_image_model(
ContentSettingImageModel::CreateContentSettingImageModel(
CONTENT_SETTINGS_TYPE_IMAGES));
@@ -23,7 +23,7 @@ TEST_F(ContentSettingImageModelTest, UpdateFromTabContents) {
EXPECT_EQ(0, content_setting_image_model->get_icon());
EXPECT_EQ("", content_setting_image_model->get_tooltip());
- render_view_host_delegate->OnContentBlocked(CONTENT_SETTINGS_TYPE_IMAGES);
+ content_settings->OnContentBlocked(CONTENT_SETTINGS_TYPE_IMAGES);
content_setting_image_model->UpdateFromTabContents(&tab_contents);
EXPECT_TRUE(content_setting_image_model->is_visible());
diff --git a/chrome/browser/geolocation/geolocation_browsertest.cc b/chrome/browser/geolocation/geolocation_browsertest.cc
index f193f98..72f37b5 100644
--- a/chrome/browser/geolocation/geolocation_browsertest.cc
+++ b/chrome/browser/geolocation/geolocation_browsertest.cc
@@ -278,8 +278,10 @@ class GeolocationBrowserTest : public InProcessBrowserTest {
void SetInfobarResponse(const GURL& requesting_url, bool allowed) {
TabContents* tab_contents = current_browser_->GetSelectedTabContents();
+ TabSpecificContentSettings* content_settings =
+ tab_contents->GetTabSpecificContentSettings();
const GeolocationSettingsState& settings_state =
- tab_contents->geolocation_settings_state();
+ content_settings->geolocation_settings_state();
size_t state_map_size = settings_state.state_map().size();
ASSERT_TRUE(infobar_);
LOG(WARNING) << "will set infobar response";
diff --git a/chrome/browser/geolocation/geolocation_permission_context.cc b/chrome/browser/geolocation/geolocation_permission_context.cc
index 4aec91f..9b6733f 100644
--- a/chrome/browser/geolocation/geolocation_permission_context.cc
+++ b/chrome/browser/geolocation/geolocation_permission_context.cc
@@ -427,12 +427,16 @@ void GeolocationPermissionContext::NotifyPermissionSet(
const GURL& requesting_frame, bool allowed) {
DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI));
- RenderViewHostDelegate::ContentSettings* content_settings =
+ TabContents* tab_contents =
tab_util::GetTabContentsByID(render_process_id, render_view_id);
+
// TabContents may have gone away (or not exists for extension).
- if (content_settings)
+ if (tab_contents) {
+ TabSpecificContentSettings* content_settings =
+ tab_contents->GetTabSpecificContentSettings();
content_settings->OnGeolocationPermissionSet(requesting_frame.GetOrigin(),
allowed);
+ }
CallRenderViewHost(
render_process_id, render_view_id,
diff --git a/chrome/browser/geolocation/geolocation_permission_context_unittest.cc b/chrome/browser/geolocation/geolocation_permission_context_unittest.cc
index a8e61b6..ba5ca61 100644
--- a/chrome/browser/geolocation/geolocation_permission_context_unittest.cc
+++ b/chrome/browser/geolocation/geolocation_permission_context_unittest.cc
@@ -130,8 +130,10 @@ class GeolocationPermissionContextTests : public RenderViewHostTestHarness {
void CheckTabContentsState(const GURL& requesting_frame,
ContentSetting expected_content_setting) {
+ TabSpecificContentSettings* content_settings =
+ contents()->GetTabSpecificContentSettings();
const GeolocationSettingsState::StateMap& state_map =
- contents()->geolocation_settings_state().state_map();
+ content_settings->geolocation_settings_state().state_map();
EXPECT_EQ(1U, state_map.count(requesting_frame.GetOrigin()));
EXPECT_EQ(0U, state_map.count(requesting_frame));
GeolocationSettingsState::StateMap::const_iterator settings =
diff --git a/chrome/browser/in_process_webkit/dom_storage_dispatcher_host.cc b/chrome/browser/in_process_webkit/dom_storage_dispatcher_host.cc
index 63d6d82..dd01f79 100644
--- a/chrome/browser/in_process_webkit/dom_storage_dispatcher_host.cc
+++ b/chrome/browser/in_process_webkit/dom_storage_dispatcher_host.cc
@@ -264,11 +264,11 @@ void DOMStorageDispatcherHost::OnSetItem(
// If content was blocked, tell the UI to display the blocked content icon.
if (reply_msg->routing_id() == MSG_ROUTING_CONTROL) {
DLOG(WARNING) << "setItem was not given a proper routing id";
- } else if (result == WebKit::WebStorageArea::ResultBlockedByPolicy) {
+ } else {
CallRenderViewHostContentSettingsDelegate(
process_id_, reply_msg->routing_id(),
- &RenderViewHostDelegate::ContentSettings::OnContentBlocked,
- CONTENT_SETTINGS_TYPE_COOKIES);
+ &RenderViewHostDelegate::ContentSettings::OnLocalStorageAccessed,
+ url, result == WebStorageArea::ResultBlockedByPolicy);
}
ViewHostMsg_DOMStorageSetItem::WriteReplyParams(reply_msg, result, old_value);
diff --git a/chrome/browser/renderer_host/render_view_host.cc b/chrome/browser/renderer_host/render_view_host.cc
index 8d069de..ba6cfac 100644
--- a/chrome/browser/renderer_host/render_view_host.cc
+++ b/chrome/browser/renderer_host/render_view_host.cc
@@ -835,6 +835,7 @@ void RenderViewHost::OnMessageReceived(const IPC::Message& msg) {
IPC_MESSAGE_HANDLER(ViewHostMsg_PageContents, OnPageContents)
IPC_MESSAGE_HANDLER(ViewHostMsg_PageTranslated, OnPageTranslated)
IPC_MESSAGE_HANDLER(ViewHostMsg_ContentBlocked, OnContentBlocked)
+ IPC_MESSAGE_HANDLER(ViewHostMsg_WebDatabaseAccessed, OnWebDatabaseAccessed)
IPC_MESSAGE_HANDLER(ViewHostMsg_AccessibilityTree, OnAccessibilityTree)
IPC_MESSAGE_HANDLER(ViewHostMsg_FocusedNodeChanged, OnMsgFocusedNodeChanged)
// Have the super handle all other messages.
@@ -1907,3 +1908,15 @@ void RenderViewHost::OnContentBlocked(ContentSettingsType type) {
if (content_settings_delegate)
content_settings_delegate->OnContentBlocked(type);
}
+
+void RenderViewHost::OnWebDatabaseAccessed(const GURL& url,
+ const string16& name,
+ const string16& display_name,
+ unsigned long estimated_size,
+ bool blocked_by_policy) {
+ RenderViewHostDelegate::ContentSettings* content_settings_delegate =
+ delegate_->GetContentSettingsDelegate();
+ if (content_settings_delegate)
+ content_settings_delegate->OnWebDatabaseAccessed(
+ url, name, display_name, estimated_size, blocked_by_policy);
+}
diff --git a/chrome/browser/renderer_host/render_view_host.h b/chrome/browser/renderer_host/render_view_host.h
index 1cea762..90f600d 100644
--- a/chrome/browser/renderer_host/render_view_host.h
+++ b/chrome/browser/renderer_host/render_view_host.h
@@ -641,6 +641,11 @@ class RenderViewHost : public RenderWidgetHost {
const std::string& translated_lang,
TranslateErrors::Type error_type);
void OnContentBlocked(ContentSettingsType type);
+ void OnWebDatabaseAccessed(const GURL& url,
+ const string16& name,
+ const string16& display_name,
+ unsigned long estimated_size,
+ bool blocked_by_policy);
private:
friend class TestRenderViewHost;
diff --git a/chrome/browser/renderer_host/render_view_host_delegate.h b/chrome/browser/renderer_host/render_view_host_delegate.h
index cf0c9d9..a0728a2 100644
--- a/chrome/browser/renderer_host/render_view_host_delegate.h
+++ b/chrome/browser/renderer_host/render_view_host_delegate.h
@@ -317,6 +317,31 @@ class RenderViewHostDelegate {
// content settings.
virtual void OnContentBlocked(ContentSettingsType type) = 0;
+ // Called when a specific cookie in the current page was accessed.
+ // |blocked_by_policy| should be true, if the cookie was blocked due to the
+ // user's content settings. In that case, this function should invoke
+ // OnContentBlocked.
+ virtual void OnCookieAccessed(const GURL& url,
+ const std::string& cookie_line,
+ bool blocked_by_policy) = 0;
+
+ // Called when a specific local storage area in the current page was
+ // accessed. If access was blocked due to the user's content settings,
+ // |blocked_by_policy| should be true, and this function should invoke
+ // OnContentBlocked.
+ virtual void OnLocalStorageAccessed(const GURL& url,
+ bool blocked_by_policy) = 0;
+
+ // Called when a specific Web database in the current page was accessed. If
+ // access was blocked due to the user's content settings,
+ // |blocked_by_policy| should eb true, and this function should invoke
+ // OnContentBlocked.
+ virtual void OnWebDatabaseAccessed(const GURL& url,
+ const string16& name,
+ const string16& display_name,
+ unsigned long estimated_size,
+ bool blocked_by_policy) = 0;
+
// Called when geolocation permission was set in a frame on the current
// page.
virtual void OnGeolocationPermissionSet(const GURL& requesting_frame,
diff --git a/chrome/browser/renderer_host/render_view_host_notification_task.h b/chrome/browser/renderer_host/render_view_host_notification_task.h
index f10fc7f..c1d732a 100644
--- a/chrome/browser/renderer_host/render_view_host_notification_task.h
+++ b/chrome/browser/renderer_host/render_view_host_notification_task.h
@@ -257,6 +257,19 @@ inline void CallRenderViewHostContentSettingsDelegate(int render_process_id,
MakeTuple(a, b));
}
+template <typename Method, typename A, typename B, typename C>
+inline void CallRenderViewHostContentSettingsDelegate(int render_process_id,
+ int render_view_id,
+ Method method,
+ const A& a,
+ const B& b,
+ const C& c) {
+ internal::CallRenderViewHostContentSettingsDelegateHelper(render_process_id,
+ render_view_id,
+ method,
+ MakeTuple(a, b, c));
+}
+
// ----------------------------------------------------------------------------
// Proxy calls to the specified RenderViewHost's RendererManagement delegate.
diff --git a/chrome/browser/renderer_host/resource_dispatcher_host.cc b/chrome/browser/renderer_host/resource_dispatcher_host.cc
index 998ad96d..fcb5c79 100644
--- a/chrome/browser/renderer_host/resource_dispatcher_host.cc
+++ b/chrome/browser/renderer_host/resource_dispatcher_host.cc
@@ -978,8 +978,10 @@ void ResourceDispatcherHost::OnSSLCertificateError(
SSLManager::OnSSLCertificateError(this, request, cert_error, cert);
}
-void ResourceDispatcherHost::OnSetCookieBlocked(URLRequest* request) {
- RESOURCE_LOG("OnSetCookieBlocked: " << request->url().spec());
+void ResourceDispatcherHost::OnSetCookie(URLRequest* request,
+ const std::string& cookie_line,
+ bool blocked_by_policy) {
+ RESOURCE_LOG("OnSetCookie: " << request->url().spec());
int render_process_id, render_view_id;
if (!RenderViewForRequest(request, &render_process_id, &render_view_id))
@@ -987,8 +989,8 @@ void ResourceDispatcherHost::OnSetCookieBlocked(URLRequest* request) {
CallRenderViewHostContentSettingsDelegate(
render_process_id, render_view_id,
- &RenderViewHostDelegate::ContentSettings::OnContentBlocked,
- CONTENT_SETTINGS_TYPE_COOKIES);
+ &RenderViewHostDelegate::ContentSettings::OnCookieAccessed,
+ request->url(), cookie_line, 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 e932642..5580da9 100644
--- a/chrome/browser/renderer_host/resource_dispatcher_host.h
+++ b/chrome/browser/renderer_host/resource_dispatcher_host.h
@@ -210,7 +210,9 @@ class ResourceDispatcherHost : public URLRequest::Delegate {
virtual void OnSSLCertificateError(URLRequest* request,
int cert_error,
net::X509Certificate* cert);
- virtual void OnSetCookieBlocked(URLRequest* request);
+ virtual void OnSetCookie(URLRequest* request,
+ const std::string& cookie_line,
+ bool blocked_by_policy);
virtual void OnResponseStarted(URLRequest* request);
virtual void OnReadCompleted(URLRequest* request, int bytes_read);
void OnResponseCompleted(URLRequest* request);
diff --git a/chrome/browser/renderer_host/resource_message_filter.cc b/chrome/browser/renderer_host/resource_message_filter.cc
index 6b56ab1..80e3de8 100644
--- a/chrome/browser/renderer_host/resource_message_filter.cc
+++ b/chrome/browser/renderer_host/resource_message_filter.cc
@@ -173,20 +173,21 @@ class SetCookieCompletion : public net::CompletionCallback {
virtual void RunWithParams(const Tuple1<int>& params) {
int result = params.a;
+ bool blocked_by_policy = true;
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_,
options);
- } else {
- if (!context_->IsExternal()) {
- CallRenderViewHostContentSettingsDelegate(
- render_process_id_, render_view_id_,
- &RenderViewHostDelegate::ContentSettings::OnContentBlocked,
- CONTENT_SETTINGS_TYPE_COOKIES);
- }
+ }
+ if (!context_->IsExternal()) {
+ CallRenderViewHostContentSettingsDelegate(
+ render_process_id_, render_view_id_,
+ &RenderViewHostDelegate::ContentSettings::OnCookieAccessed,
+ url_, cookie_line_, blocked_by_policy);
}
delete this;
}
diff --git a/chrome/browser/tab_contents/tab_contents.cc b/chrome/browser/tab_contents/tab_contents.cc
index 332e320..d524840 100644
--- a/chrome/browser/tab_contents/tab_contents.cc
+++ b/chrome/browser/tab_contents/tab_contents.cc
@@ -294,12 +294,13 @@ TabContents::TabContents(Profile* profile,
renderer_preferences_(),
opener_dom_ui_type_(DOMUIFactory::kNoDOMUI),
language_state_(&controller_),
- geolocation_settings_state_(profile),
closed_by_user_gesture_(false) {
- ClearBlockedContentSettings();
renderer_preferences_util::UpdateFromSystemSettings(
&renderer_preferences_, profile);
+ content_settings_delegate_.reset(
+ new TabSpecificContentSettings(this, profile));
+
#if defined(OS_CHROMEOS)
// Make sure the thumbnailer is started before starting the render manager.
// The thumbnailer will want to listen for RVH creations, one of which will
@@ -649,26 +650,6 @@ bool TabContents::ShouldDisplayFavIcon() {
return true;
}
-bool TabContents::IsContentBlocked(ContentSettingsType content_type) const {
- DCHECK(content_type != CONTENT_SETTINGS_TYPE_GEOLOCATION)
- << "Geolocation settings handled by ContentSettingGeolocationImageModel";
- DCHECK(content_type != CONTENT_SETTINGS_TYPE_NOTIFICATIONS)
- << "Notifications settings handled by "
- << "ContentSettingsNotificationsImageModel";
-
- if (content_type == CONTENT_SETTINGS_TYPE_POPUPS)
- return blocked_popups_ != NULL;
-
- if (content_type == CONTENT_SETTINGS_TYPE_IMAGES ||
- content_type == CONTENT_SETTINGS_TYPE_JAVASCRIPT ||
- content_type == CONTENT_SETTINGS_TYPE_PLUGINS ||
- content_type == CONTENT_SETTINGS_TYPE_COOKIES)
- return content_blocked_[content_type];
-
- NOTREACHED();
- return false;
-}
-
std::wstring TabContents::GetStatusText() const {
if (!is_loading() || load_state_ == net::LOAD_STATE_IDLE)
return std::wstring();
@@ -957,10 +938,9 @@ bool TabContents::ExecuteCode(int request_id, const std::string& extension_id,
void TabContents::PopupNotificationVisibilityChanged(bool visible) {
if (is_being_destroyed_)
return;
+ content_settings_delegate_->SetPopupsBlocked(visible);
if (!dont_notify_render_view_)
render_view_host()->AllowScriptToClose(!visible);
- if (delegate_)
- delegate_->OnContentSettingsChange(this);
}
gfx::NativeView TabContents::GetContentNativeView() const {
@@ -1394,12 +1374,6 @@ TabContents* TabContents::CloneAndMakePhantom() {
return new_contents;
}
-// Resets the |content_blocked_| array.
-void TabContents::ClearBlockedContentSettings() {
- for (size_t i = 0; i < arraysize(content_blocked_); ++i)
- content_blocked_[i] = false;
-}
-
// Notifies the RenderWidgetHost instance about the fact that the page is
// loading, or done loading and calls the base implementation.
void TabContents::SetIsLoading(bool is_loading,
@@ -1453,6 +1427,7 @@ void TabContents::AddPopup(TabContents* new_contents,
if (!blocked_popups_)
blocked_popups_ = new BlockedPopupContainer(this);
blocked_popups_->AddTabContents(new_contents, initial_pos);
+ content_settings_delegate_->OnContentBlocked(CONTENT_SETTINGS_TYPE_POPUPS);
}
}
@@ -1595,10 +1570,8 @@ void TabContents::DidNavigateMainFramePostCommit(
}
// Clear "blocked" flags.
- ClearBlockedContentSettings();
- geolocation_settings_state_.DidNavigate(details);
- if (delegate_)
- delegate_->OnContentSettingsChange(this);
+ content_settings_delegate_->ClearBlockedContentSettings();
+ content_settings_delegate_->GeolocationDidNavigate(details);
// Once the main frame is navigated, we're no longer considered to have
// displayed insecure content.
@@ -2138,18 +2111,7 @@ void TabContents::DocumentLoadedInFrame() {
controller_.DocumentLoadedInFrame();
}
-void TabContents::OnContentBlocked(ContentSettingsType type) {
- DCHECK(type != CONTENT_SETTINGS_TYPE_GEOLOCATION)
- << "Geolocation settings handled by OnGeolocationPermissionSet";
- content_blocked_[type] = true;
- if (delegate_)
- delegate_->OnContentSettingsChange(this);
-}
-
-void TabContents::OnGeolocationPermissionSet(const GURL& requesting_origin,
- bool allowed) {
- geolocation_settings_state_.OnGeolocationPermissionSet(requesting_origin,
- allowed);
+void TabContents::OnContentSettingsChange() {
if (delegate_)
delegate_->OnContentSettingsChange(this);
}
@@ -2174,7 +2136,7 @@ RenderViewHostDelegate::Resource* TabContents::GetResourceDelegate() {
RenderViewHostDelegate::ContentSettings*
TabContents::GetContentSettingsDelegate() {
- return this;
+ return content_settings_delegate_.get();
}
RenderViewHostDelegate::Save* TabContents::GetSaveDelegate() {
@@ -2213,6 +2175,10 @@ void TabContents::SetBookmarkDragDelegate(
bookmark_drag_ = bookmark_drag;
}
+TabSpecificContentSettings* TabContents::GetTabSpecificContentSettings() const {
+ return content_settings_delegate_.get();
+}
+
RendererPreferences TabContents::GetRendererPrefs(Profile* profile) const {
return renderer_preferences_;
}
diff --git a/chrome/browser/tab_contents/tab_contents.h b/chrome/browser/tab_contents/tab_contents.h
index ac114bc..d2263ec 100644
--- a/chrome/browser/tab_contents/tab_contents.h
+++ b/chrome/browser/tab_contents/tab_contents.h
@@ -24,7 +24,6 @@
#include "chrome/browser/fav_icon_helper.h"
#include "chrome/browser/find_bar_controller.h"
#include "chrome/browser/find_notification_details.h"
-#include "chrome/browser/geolocation/geolocation_settings_state.h"
#include "chrome/browser/jsmessage_box_client.h"
#include "chrome/browser/password_manager/password_manager.h"
#include "chrome/browser/printing/print_view_manager.h"
@@ -37,8 +36,7 @@
#include "chrome/browser/tab_contents/navigation_entry.h"
#include "chrome/browser/tab_contents/page_navigator.h"
#include "chrome/browser/tab_contents/render_view_host_manager.h"
-#include "chrome/common/content_settings.h"
-#include "chrome/common/content_settings_types.h"
+#include "chrome/browser/tab_contents/tab_specific_content_settings.h"
#include "chrome/common/extensions/url_pattern.h"
#include "chrome/common/navigation_types.h"
#include "chrome/common/net/url_request_context_getter.h"
@@ -71,23 +69,24 @@ namespace IPC {
class Message;
}
+class AutocompleteHistoryManager;
class AutoFillManager;
class BlockedPopupContainer;
class DOMUI;
class DownloadItem;
class Extension;
-class AutocompleteHistoryManager;
+class GeolocationSettingsState;
class LoadNotificationDetails;
class OmniboxSearchHint;
class PluginInstaller;
class Profile;
struct RendererPreferences;
class RenderViewHost;
-class TabContentsDelegate;
-class TabContentsFactory;
-class SkBitmap;
class SiteInstance;
+class SkBitmap;
class TabContents;
+class TabContentsDelegate;
+class TabContentsFactory;
class TabContentsView;
struct ThumbnailScore;
struct ViewHostMsg_DidPrintPage_Params;
@@ -101,12 +100,12 @@ class TabContents : public PageNavigator,
public RenderViewHostDelegate,
public RenderViewHostDelegate::BrowserIntegration,
public RenderViewHostDelegate::Resource,
- public RenderViewHostDelegate::ContentSettings,
public RenderViewHostManager::Delegate,
public SelectFileDialog::Listener,
public JavaScriptMessageBoxClient,
public ImageLoadingTracker::Observer,
- public PasswordManager::Delegate {
+ public PasswordManager::Delegate,
+ public TabSpecificContentSettings::Delegate {
public:
// Flags passed to the TabContentsDelegate.NavigationStateChanged to tell it
// what has changed. Combine them to update more than one thing.
@@ -259,16 +258,6 @@ class TabContents : public PageNavigator,
// space is provided for the favicon, and the favicon is never displayed.
virtual bool ShouldDisplayFavIcon();
- // Returns whether a particular kind of content has been blocked for this
- // page.
- bool IsContentBlocked(ContentSettingsType content_type) const;
-
- // Returns the GeolocationSettingsState that controls the
- // geolocation API usage on this page.
- const GeolocationSettingsState& geolocation_settings_state() const {
- return geolocation_settings_state_;
- }
-
// Returns a human-readable description the tab's loading state.
virtual std::wstring GetStatusText() const;
@@ -706,6 +695,10 @@ class TabContents : public PageNavigator,
virtual void SetBookmarkDragDelegate(
RenderViewHostDelegate::BookmarkDrag* bookmark_drag);
+ // The TabSpecificContentSettings object is used to query the blocked content
+ // state by various UI elements.
+ TabSpecificContentSettings* GetTabSpecificContentSettings() const;
+
// PasswordManager::Delegate implementation.
virtual void FillPasswordForm(
const webkit_glue::PasswordFormDomManager::FillData& form_data);
@@ -739,9 +732,6 @@ class TabContents : public PageNavigator,
// TODO(brettw) TestTabContents shouldn't exist!
friend class TestTabContents;
- // Resets the |content_blocked_| array.
- void ClearBlockedContentSettings();
-
// Changes the IsLoading state and notifies delegate as needed
// |details| is used to provide details on the load that just finished
// (but can be null if not applicable). Can be overridden.
@@ -832,6 +822,9 @@ class TabContents : public PageNavigator,
void GenerateKeywordIfNecessary(
const ViewHostMsg_FrameNavigate_Params& params);
+ // ContentBlockedDelegate::Delegate implementation.
+ virtual void OnContentSettingsChange();
+
// RenderViewHostDelegate ----------------------------------------------------
// RenderViewHostDelegate::BrowserIntegration implementation.
@@ -884,11 +877,6 @@ class TabContents : public PageNavigator,
bool showing_repost_interstitial);
virtual void DocumentLoadedInFrame();
- // RenderViewHostDelegate::ContentSettings implementation.
- virtual void OnContentBlocked(ContentSettingsType type);
- virtual void OnGeolocationPermissionSet(const GURL& requesting_origin,
- bool allowed);
-
// RenderViewHostDelegate implementation.
virtual RenderViewHostDelegate::View* GetViewDelegate();
virtual RenderViewHostDelegate::RendererManagement*
@@ -1098,6 +1086,9 @@ class TabContents : public PageNavigator,
// Cached web app icon.
SkBitmap app_icon_;
+ // RenderViewHost::ContentSettingsDelegate.
+ scoped_ptr<TabSpecificContentSettings> content_settings_delegate_;
+
// Data for loading state ----------------------------------------------------
// Indicates whether we're currently loading a resource.
@@ -1150,9 +1141,6 @@ class TabContents : public PageNavigator,
// TODO(pkasting): Hack to try and fix Linux browser tests.
bool dont_notify_render_view_;
- // Stores which content setting types actually have blocked content.
- bool content_blocked_[CONTENT_SETTINGS_NUM_TYPES];
-
// True if this is a secure page which displayed insecure content.
bool displayed_insecure_content_;
@@ -1274,9 +1262,6 @@ class TabContents : public PageNavigator,
// Information about the language the page is in and has been translated to.
LanguageState language_state_;
- // Manages information about Geolocation API usage in this page.
- GeolocationSettingsState geolocation_settings_state_;
-
// See description above setter.
bool closed_by_user_gesture_;
diff --git a/chrome/browser/tab_contents/tab_specific_content_settings.cc b/chrome/browser/tab_contents/tab_specific_content_settings.cc
new file mode 100644
index 0000000..891debd
--- /dev/null
+++ b/chrome/browser/tab_contents/tab_specific_content_settings.cc
@@ -0,0 +1,128 @@
+// Copyright (c) 2010 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 "chrome/browser/tab_contents/tab_specific_content_settings.h"
+
+#include "base/utf_string_conversions.h"
+
+bool TabSpecificContentSettings::IsContentBlocked(
+ ContentSettingsType content_type) const {
+ DCHECK(content_type != CONTENT_SETTINGS_TYPE_GEOLOCATION)
+ << "Geolocation settings handled by ContentSettingGeolocationImageModel";
+ DCHECK(content_type != CONTENT_SETTINGS_TYPE_NOTIFICATIONS)
+ << "Notifications settings handled by "
+ << "ContentSettingsNotificationsImageModel";
+
+ if (content_type == CONTENT_SETTINGS_TYPE_IMAGES ||
+ content_type == CONTENT_SETTINGS_TYPE_JAVASCRIPT ||
+ content_type == CONTENT_SETTINGS_TYPE_PLUGINS ||
+ content_type == CONTENT_SETTINGS_TYPE_COOKIES ||
+ content_type == CONTENT_SETTINGS_TYPE_POPUPS)
+ return content_blocked_[content_type];
+
+ NOTREACHED();
+ return false;
+}
+
+void TabSpecificContentSettings::OnContentBlocked(ContentSettingsType type) {
+ DCHECK(type != CONTENT_SETTINGS_TYPE_GEOLOCATION)
+ << "Geolocation settings handled by OnGeolocationPermissionSet";
+ content_blocked_[type] = true;
+ if (delegate_)
+ delegate_->OnContentSettingsChange();
+}
+
+void TabSpecificContentSettings::OnCookieAccessed(
+ const GURL& url, const std::string& cookie_line, bool blocked_by_policy) {
+ net::CookieOptions options;
+ options.set_include_httponly();
+ if (blocked_by_policy) {
+ blocked_local_shared_objects_.cookies()->SetCookieWithOptions(
+ url, cookie_line, options);
+ OnContentBlocked(CONTENT_SETTINGS_TYPE_COOKIES);
+ } else {
+ allowed_local_shared_objects_.cookies()->SetCookieWithOptions(
+ url, cookie_line, options);
+ }
+}
+
+void TabSpecificContentSettings::OnLocalStorageAccessed(
+ const GURL& url, bool blocked_by_policy) {
+ if (blocked_by_policy) {
+ blocked_local_shared_objects_.local_storages()->AddLocalStorage(url);
+ OnContentBlocked(CONTENT_SETTINGS_TYPE_COOKIES);
+ } else {
+ allowed_local_shared_objects_.local_storages()->AddLocalStorage(url);
+ }
+}
+
+void TabSpecificContentSettings::OnWebDatabaseAccessed(
+ const GURL& url,
+ const string16& name,
+ const string16& display_name,
+ unsigned long estimated_size,
+ bool blocked_by_policy) {
+ if (blocked_by_policy) {
+ blocked_local_shared_objects_.databases()->AddDatabase(
+ url, UTF16ToUTF8(name), UTF16ToUTF8(display_name));
+ OnContentBlocked(CONTENT_SETTINGS_TYPE_COOKIES);
+ } else {
+ allowed_local_shared_objects_.databases()->AddDatabase(
+ url, UTF16ToUTF8(name), UTF16ToUTF8(display_name));
+ }
+}
+
+void TabSpecificContentSettings::OnGeolocationPermissionSet(
+ const GURL& requesting_origin,
+ bool allowed) {
+ geolocation_settings_state_.OnGeolocationPermissionSet(requesting_origin,
+ allowed);
+ if (delegate_)
+ delegate_->OnContentSettingsChange();
+}
+
+TabSpecificContentSettings::TabSpecificContentSettings(
+ Delegate* delegate, Profile* profile)
+ : allowed_local_shared_objects_(profile),
+ blocked_local_shared_objects_(profile),
+ geolocation_settings_state_(profile),
+ delegate_(NULL) {
+ ClearBlockedContentSettings();
+ delegate_ = delegate;
+}
+
+void TabSpecificContentSettings::ClearBlockedContentSettings() {
+ for (size_t i = 0; i < arraysize(content_blocked_); ++i)
+ content_blocked_[i] = false;
+ blocked_local_shared_objects_.Reset();
+ allowed_local_shared_objects_.Reset();
+ if (delegate_)
+ delegate_->OnContentSettingsChange();
+}
+
+void TabSpecificContentSettings::SetPopupsBlocked(bool blocked) {
+ content_blocked_[CONTENT_SETTINGS_TYPE_POPUPS] = blocked;
+ if (delegate_)
+ delegate_->OnContentSettingsChange();
+}
+
+void TabSpecificContentSettings::GeolocationDidNavigate(
+ const NavigationController::LoadCommittedDetails& details) {
+ geolocation_settings_state_.DidNavigate(details);
+}
+
+TabSpecificContentSettings::LocalSharedObjectsContainer::
+ LocalSharedObjectsContainer(Profile* profile)
+ : cookies_(new net::CookieMonster(NULL, NULL)),
+ appcaches_(new CannedBrowsingDataAppCacheHelper(profile)),
+ databases_(new CannedBrowsingDataDatabaseHelper(profile)),
+ local_storages_(new CannedBrowsingDataLocalStorageHelper(profile)) {
+}
+
+void TabSpecificContentSettings::LocalSharedObjectsContainer::Reset() {
+ cookies_->DeleteAll(false);
+ appcaches_->Reset();
+ databases_->Reset();
+ local_storages_->Reset();
+}
diff --git a/chrome/browser/tab_contents/tab_specific_content_settings.h b/chrome/browser/tab_contents/tab_specific_content_settings.h
new file mode 100644
index 0000000..8613b1a
--- /dev/null
+++ b/chrome/browser/tab_contents/tab_specific_content_settings.h
@@ -0,0 +1,114 @@
+// Copyright (c) 2010 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 CHROME_BROWSER_TAB_CONTENTS_TAB_SPECIFIC_CONTENT_SETTINGS_H_
+#define CHROME_BROWSER_TAB_CONTENTS_TAB_SPECIFIC_CONTENT_SETTINGS_H_
+
+#include "base/basictypes.h"
+#include "chrome/browser/browsing_data_appcache_helper.h"
+#include "chrome/browser/browsing_data_database_helper.h"
+#include "chrome/browser/browsing_data_local_storage_helper.h"
+#include "chrome/browser/geolocation/geolocation_settings_state.h"
+#include "chrome/browser/renderer_host/render_view_host_delegate.h"
+#include "chrome/browser/tab_contents/navigation_controller.h"
+#include "chrome/common/content_settings.h"
+#include "chrome/common/content_settings_types.h"
+#include "net/base/cookie_monster.h"
+
+class Profile;
+
+class TabSpecificContentSettings
+ : public RenderViewHostDelegate::ContentSettings {
+ public:
+ class Delegate {
+ public:
+ // Invoked when content settings managed by the TabSpecificContentSettings
+ // object change.
+ virtual void OnContentSettingsChange() = 0;
+
+ virtual ~Delegate() {}
+ };
+
+ TabSpecificContentSettings(Delegate* delegate, Profile* profile);
+
+ virtual ~TabSpecificContentSettings() {}
+
+ // Resets the |content_blocked_| array and stored cookies.
+ void ClearBlockedContentSettings();
+
+ // Changes the |content_blocked_| entry for popups.
+ void SetPopupsBlocked(bool blocked);
+
+ // Updates Geolocation settings on navigation.
+ void GeolocationDidNavigate(
+ const NavigationController::LoadCommittedDetails& details);
+
+ // Returns whether a particular kind of content has been blocked for this
+ // page.
+ bool IsContentBlocked(ContentSettingsType content_type) const;
+
+ // Returns the GeolocationSettingsState that controls the
+ // geolocation API usage on this page.
+ const GeolocationSettingsState& geolocation_settings_state() const {
+ return geolocation_settings_state_;
+ }
+
+ // RenderViewHostDelegate::ContentSettings implementation.
+ virtual void OnContentBlocked(ContentSettingsType type);
+ virtual void OnCookieAccessed(const GURL& url,
+ const std::string& cookie_line,
+ bool blocked_by_policy);
+ virtual void OnLocalStorageAccessed(const GURL& url, bool blocked_by_policy);
+ virtual void OnWebDatabaseAccessed(const GURL& url,
+ const string16& name,
+ const string16& display_name,
+ unsigned long estimated_size,
+ bool blocked_by_policy);
+ virtual void OnGeolocationPermissionSet(const GURL& requesting_frame,
+ bool allowed);
+
+ private:
+ class LocalSharedObjectsContainer {
+ public:
+ explicit LocalSharedObjectsContainer(Profile* profile);
+
+ // Empties the container.
+ void Reset();
+
+ net::CookieMonster* cookies() const { return cookies_; }
+ CannedBrowsingDataAppCacheHelper* appcaches() const {
+ return appcaches_;
+ }
+ CannedBrowsingDataDatabaseHelper* databases() const {
+ return databases_;
+ }
+ CannedBrowsingDataLocalStorageHelper* local_storages() const {
+ return local_storages_;
+ }
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(LocalSharedObjectsContainer);
+
+ scoped_refptr<net::CookieMonster> cookies_;
+ scoped_refptr<CannedBrowsingDataAppCacheHelper> appcaches_;
+ scoped_refptr<CannedBrowsingDataDatabaseHelper> databases_;
+ scoped_refptr<CannedBrowsingDataLocalStorageHelper> local_storages_;
+ };
+
+ // Stores which content setting types actually have blocked content.
+ bool content_blocked_[CONTENT_SETTINGS_NUM_TYPES];
+
+ // Stores the blocked/allowed cookies.
+ LocalSharedObjectsContainer allowed_local_shared_objects_;
+ LocalSharedObjectsContainer blocked_local_shared_objects_;
+
+ // Manages information about Geolocation API usage in this page.
+ GeolocationSettingsState geolocation_settings_state_;
+
+ Delegate* delegate_;
+
+ DISALLOW_COPY_AND_ASSIGN(TabSpecificContentSettings);
+};
+
+#endif // CHROME_BROWSER_TAB_CONTENTS_TAB_SPECIFIC_CONTENT_SETTINGS_H_
diff --git a/chrome/browser/tab_contents/tab_specific_content_settings_unittest.cc b/chrome/browser/tab_contents/tab_specific_content_settings_unittest.cc
new file mode 100644
index 0000000..b89d772
--- /dev/null
+++ b/chrome/browser/tab_contents/tab_specific_content_settings_unittest.cc
@@ -0,0 +1,78 @@
+// Copyright (c) 2010 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 "chrome/browser/tab_contents/tab_specific_content_settings.h"
+
+#include "chrome/test/testing_profile.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace {
+class TestContentSettingsDelegate
+ : public TabSpecificContentSettings::Delegate {
+ public:
+ TestContentSettingsDelegate() : settings_changed_(false) {}
+ virtual ~TestContentSettingsDelegate() {}
+
+ void Reset() { settings_changed_ = false; }
+
+ bool SettingsChanged() { return settings_changed_; }
+
+ // TabSpecificContentSettings::Delegate implementation.
+ virtual void OnContentSettingsChange() { settings_changed_ = true; }
+
+ private:
+ bool settings_changed_;
+
+ DISALLOW_COPY_AND_ASSIGN(TestContentSettingsDelegate);
+};
+} // namespace
+
+TEST(TabSpecificContentSettingsTest, BlockedContent) {
+ TestContentSettingsDelegate test_delegate;
+ TestingProfile profile;
+ TabSpecificContentSettings content_settings(&test_delegate, &profile);
+
+ // Check that after initializing, nothing is blocked.
+ EXPECT_FALSE(content_settings.IsContentBlocked(CONTENT_SETTINGS_TYPE_IMAGES));
+ EXPECT_FALSE(
+ content_settings.IsContentBlocked(CONTENT_SETTINGS_TYPE_JAVASCRIPT));
+ EXPECT_FALSE(
+ content_settings.IsContentBlocked(CONTENT_SETTINGS_TYPE_PLUGINS));
+ EXPECT_FALSE(
+ content_settings.IsContentBlocked(CONTENT_SETTINGS_TYPE_COOKIES));
+ 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);
+ EXPECT_FALSE(test_delegate.SettingsChanged());
+ test_delegate.Reset();
+ content_settings.OnContentBlocked(CONTENT_SETTINGS_TYPE_IMAGES);
+ EXPECT_TRUE(test_delegate.SettingsChanged());
+ test_delegate.Reset();
+ content_settings.SetPopupsBlocked(true);
+ EXPECT_TRUE(test_delegate.SettingsChanged());
+ test_delegate.Reset();
+
+ // Check that only the respective content types are affected.
+ EXPECT_TRUE(content_settings.IsContentBlocked(CONTENT_SETTINGS_TYPE_IMAGES));
+ EXPECT_FALSE(
+ content_settings.IsContentBlocked(CONTENT_SETTINGS_TYPE_JAVASCRIPT));
+ EXPECT_FALSE(
+ content_settings.IsContentBlocked(CONTENT_SETTINGS_TYPE_PLUGINS));
+ EXPECT_FALSE(
+ content_settings.IsContentBlocked(CONTENT_SETTINGS_TYPE_COOKIES));
+ EXPECT_TRUE(content_settings.IsContentBlocked(CONTENT_SETTINGS_TYPE_POPUPS));
+
+ // Reset blocked content settings.
+ content_settings.ClearBlockedContentSettings();
+ EXPECT_TRUE(test_delegate.SettingsChanged());
+ EXPECT_FALSE(content_settings.IsContentBlocked(CONTENT_SETTINGS_TYPE_IMAGES));
+ EXPECT_FALSE(
+ content_settings.IsContentBlocked(CONTENT_SETTINGS_TYPE_JAVASCRIPT));
+ EXPECT_FALSE(
+ content_settings.IsContentBlocked(CONTENT_SETTINGS_TYPE_PLUGINS));
+ EXPECT_FALSE(
+ content_settings.IsContentBlocked(CONTENT_SETTINGS_TYPE_COOKIES));
+ EXPECT_FALSE(content_settings.IsContentBlocked(CONTENT_SETTINGS_TYPE_POPUPS));
+}
diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi
index 2679aa3..d4c04c5 100644
--- a/chrome/chrome_browser.gypi
+++ b/chrome/chrome_browser.gypi
@@ -2286,6 +2286,8 @@
'browser/tab_contents/tab_contents_view_gtk.h',
'browser/tab_contents/tab_contents_view_mac.h',
'browser/tab_contents/tab_contents_view_mac.mm',
+ 'browser/tab_contents/tab_specific_content_settings.h',
+ 'browser/tab_contents/tab_specific_content_settings.cc',
'browser/tab_contents/tab_util.cc',
'browser/tab_contents/tab_util.h',
'browser/tab_contents/thumbnail_generator.cc',
diff --git a/chrome/chrome_tests.gypi b/chrome/chrome_tests.gypi
index ea2e142..bb0eb26 100644
--- a/chrome/chrome_tests.gypi
+++ b/chrome/chrome_tests.gypi
@@ -982,6 +982,7 @@
'browser/tab_contents/navigation_controller_unittest.cc',
'browser/tab_contents/navigation_entry_unittest.cc',
'browser/tab_contents/render_view_host_manager_unittest.cc',
+ 'browser/tab_contents/tab_specific_content_settings_unittest.cc',
'browser/tab_contents/thumbnail_generator_unittest.cc',
'browser/tab_contents/web_contents_unittest.cc',
'browser/tab_menu_model_unittest.cc',
diff --git a/chrome/common/render_messages_internal.h b/chrome/common/render_messages_internal.h
index 0ba750a..421e4fb 100644
--- a/chrome/common/render_messages_internal.h
+++ b/chrome/common/render_messages_internal.h
@@ -1271,6 +1271,15 @@ IPC_BEGIN_MESSAGES(ViewHost)
IPC_MESSAGE_ROUTED1(ViewHostMsg_ContentBlocked,
ContentSettingsType /* type of blocked content */)
+ // Tells the browser that a specific Web database in the current page was
+ // accessed.
+ IPC_MESSAGE_ROUTED5(ViewHostMsg_WebDatabaseAccessed,
+ GURL /* origin url */,
+ string16 /* database name */,
+ string16 /* database display name */,
+ unsigned long /* estimated size */,
+ bool /* blocked by policy */)
+
// Initiates a download based on user actions like 'ALT+click'.
IPC_MESSAGE_ROUTED2(ViewHostMsg_DownloadUrl,
GURL /* url */,
diff --git a/chrome/renderer/render_view.cc b/chrome/renderer/render_view.cc
index 0aa716d..bb7d877 100644
--- a/chrome/renderer/render_view.cc
+++ b/chrome/renderer/render_view.cc
@@ -3110,8 +3110,12 @@ bool RenderView::allowDatabase(
if (!Send(new ViewHostMsg_AllowDatabase(routing_id_,
origin.toString().utf8(), name, display_name, estimated_size, &result)))
return false;
- if (!result)
- DidBlockContentType(CONTENT_SETTINGS_TYPE_COOKIES);
+ Send(new ViewHostMsg_WebDatabaseAccessed(routing_id_,
+ GURL(origin.toString().utf8()),
+ name,
+ display_name,
+ estimated_size,
+ !result));
return result;
}
void RenderView::didNotAllowScript(WebKit::WebFrame* frame) {
diff --git a/chrome_frame/test/net/fake_external_tab.cc b/chrome_frame/test/net/fake_external_tab.cc
index aab6e63..fbdc192 100644
--- a/chrome_frame/test/net/fake_external_tab.cc
+++ b/chrome_frame/test/net/fake_external_tab.cc
@@ -441,8 +441,8 @@ void FilterDisabledTests() {
"URLRequestTest.CookiePolicy_ForceSession",
"URLRequestTest.DoNotSendCookies",
"URLRequestTest.DoNotSendCookies_ViaPolicy_Async",
- "URLRequestTest.CancelTest_During_OnGetCookiesBlocked",
- "URLRequestTest.CancelTest_During_OnSetCookieBlocked",
+ "URLRequestTest.CancelTest_During_OnGetCookies",
+ "URLRequestTest.CancelTest_During_OnSetCookie",
// These tests are disabled as the rely on functionality provided by
// Chrome's HTTP stack like the ability to set the proxy for a URL, etc.
diff --git a/net/url_request/url_request.h b/net/url_request/url_request.h
index f770c89..23e2f6f 100644
--- a/net/url_request/url_request.h
+++ b/net/url_request/url_request.h
@@ -187,12 +187,18 @@ class URLRequest {
request->Cancel();
}
- // Called when unable to get cookies due to policy.
- virtual void OnGetCookiesBlocked(URLRequest* request) {
+ // Called when reading cookies. |blocked_by_policy| is true if access to
+ // cookies was denied due to content settings. This method will never be
+ // invoked when LOAD_DO_NOT_SEND_COOKIES is specified.
+ virtual void OnGetCookies(URLRequest* request, bool blocked_by_policy) {
}
- // Called when unable to set a cookie due to policy.
- virtual void OnSetCookieBlocked(URLRequest* request) {
+ // Called when a cookie is set. |blocked_by_policy| is true if the cookie
+ // was rejected due to content settings. This method will never be invoked
+ // when LOAD_DO_NOT_SAVE_COOKIES is specified.
+ virtual void OnSetCookie(URLRequest* request,
+ const std::string& cookie_line,
+ 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 4f44f2e3..9a03213 100644
--- a/net/url_request/url_request_http_job.cc
+++ b/net/url_request/url_request_http_job.cc
@@ -441,8 +441,9 @@ void URLRequestHttpJob::OnCanGetCookiesCompleted(int policy) {
// If the request was destroyed, then there is no more work to do.
if (request_ && request_->delegate()) {
if (policy == net::ERR_ACCESS_DENIED) {
- request_->delegate()->OnGetCookiesBlocked(request_);
+ request_->delegate()->OnGetCookies(request_, true);
} else if (policy == net::OK && request_->context()->cookie_store()) {
+ request_->delegate()->OnGetCookies(request_, false);
net::CookieOptions options;
options.set_include_httponly();
std::string cookies =
@@ -453,7 +454,7 @@ void URLRequestHttpJob::OnCanGetCookiesCompleted(int policy) {
net::HttpRequestHeaders::kCookie, cookies);
}
}
- // We may have been canceled within OnGetCookiesBlocked.
+ // We may have been canceled within OnGetCookies.
if (GetStatus().is_success()) {
StartTransaction();
} else {
@@ -467,7 +468,10 @@ void URLRequestHttpJob::OnCanSetCookieCompleted(int policy) {
// If the request was destroyed, then there is no more work to do.
if (request_ && request_->delegate()) {
if (policy == net::ERR_ACCESS_DENIED) {
- request_->delegate()->OnSetCookieBlocked(request_);
+ request_->delegate()->OnSetCookie(
+ request_,
+ response_cookies_[response_cookies_save_index_],
+ true);
} else if ((policy == net::OK || policy == net::OK_FOR_SESSION_ONLY) &&
request_->context()->cookie_store()) {
// OK to save the current response cookie now.
@@ -478,9 +482,13 @@ void URLRequestHttpJob::OnCanSetCookieCompleted(int policy) {
request_->context()->cookie_store()->SetCookieWithOptions(
request_->url(), response_cookies_[response_cookies_save_index_],
options);
+ request_->delegate()->OnSetCookie(
+ request_,
+ response_cookies_[response_cookies_save_index_],
+ false);
}
response_cookies_save_index_++;
- // We may have been canceled within OnSetCookieBlocked.
+ // We may have been canceled within OnSetCookie.
if (GetStatus().is_success()) {
SaveNextCookie();
} else {
diff --git a/net/url_request/url_request_unittest.cc b/net/url_request/url_request_unittest.cc
index a15d82f..026038f 100644
--- a/net/url_request/url_request_unittest.cc
+++ b/net/url_request/url_request_unittest.cc
@@ -1265,7 +1265,7 @@ TEST_F(URLRequestTest, DoNotSendCookies) {
EXPECT_TRUE(d.data_received().find("Cookie: CookieToNotSend=1")
== std::string::npos);
- // LOAD_DO_NOT_SEND_COOKIES does not trigger OnGetCookiesBlocked.
+ // LOAD_DO_NOT_SEND_COOKIES does not trigger OnGetCookies.
EXPECT_EQ(0, d.blocked_get_cookies_count());
EXPECT_EQ(0, d.blocked_set_cookie_count());
}
@@ -1288,6 +1288,7 @@ TEST_F(URLRequestTest, DoNotSaveCookies) {
EXPECT_EQ(0, d.blocked_get_cookies_count());
EXPECT_EQ(0, d.blocked_set_cookie_count());
+ EXPECT_EQ(1, d.set_cookie_count());
}
// Try to set-up another cookie and update the previous cookie.
@@ -1301,9 +1302,10 @@ TEST_F(URLRequestTest, DoNotSaveCookies) {
MessageLoop::current()->Run();
- // LOAD_DO_NOT_SAVE_COOKIES does not trigger OnSetCookieBlocked.
+ // LOAD_DO_NOT_SAVE_COOKIES does not trigger OnSetCookie.
EXPECT_EQ(0, d.blocked_get_cookies_count());
EXPECT_EQ(0, d.blocked_set_cookie_count());
+ EXPECT_EQ(0, d.set_cookie_count());
}
// Verify the cookies weren't saved or updated.
@@ -1321,6 +1323,7 @@ TEST_F(URLRequestTest, DoNotSaveCookies) {
EXPECT_EQ(0, d.blocked_get_cookies_count());
EXPECT_EQ(0, d.blocked_set_cookie_count());
+ EXPECT_EQ(0, d.set_cookie_count());
}
}
@@ -1578,7 +1581,7 @@ TEST_F(URLRequestTest, CancelTest_During_CookiePolicy) {
MessageLoop::current()->RunAllPending();
}
-TEST_F(URLRequestTest, CancelTest_During_OnGetCookiesBlocked) {
+TEST_F(URLRequestTest, CancelTest_During_OnGetCookies) {
scoped_refptr<HTTPTestServer> server =
HTTPTestServer::CreateServer(L"", NULL);
ASSERT_TRUE(NULL != server.get());
@@ -1607,7 +1610,7 @@ TEST_F(URLRequestTest, CancelTest_During_OnGetCookiesBlocked) {
context->set_cookie_policy(NULL);
}
-TEST_F(URLRequestTest, CancelTest_During_OnSetCookieBlocked) {
+TEST_F(URLRequestTest, CancelTest_During_OnSetCookie) {
scoped_refptr<HTTPTestServer> server =
HTTPTestServer::CreateServer(L"", NULL);
ASSERT_TRUE(NULL != server.get());
@@ -1630,9 +1633,9 @@ TEST_F(URLRequestTest, CancelTest_During_OnSetCookieBlocked) {
EXPECT_EQ(URLRequestStatus::CANCELED, req.status().status());
// Even though the response will contain 3 set-cookie headers, we expect
- // only one to be blocked as that first one will cause OnSetCookieBlocked
- // to be called, which will cancel the request. Once canceled, it should
- // not attempt to set further cookies.
+ // only one to be blocked as that first one will cause OnSetCookie to be
+ // called, which will cancel the request. Once canceled, it should not
+ // attempt to set further cookies.
EXPECT_EQ(0, d.blocked_get_cookies_count());
EXPECT_EQ(1, d.blocked_set_cookie_count());
diff --git a/net/url_request/url_request_unittest.h b/net/url_request/url_request_unittest.h
index 411e32a..0dfa766 100644
--- a/net/url_request/url_request_unittest.h
+++ b/net/url_request/url_request_unittest.h
@@ -204,6 +204,7 @@ class TestDelegate : public URLRequest::Delegate {
received_redirect_count_(0),
blocked_get_cookies_count_(0),
blocked_set_cookie_count_(0),
+ set_cookie_count_(0),
received_data_before_response_(false),
request_failed_(false),
have_certificate_errors_(false),
@@ -306,16 +307,24 @@ class TestDelegate : public URLRequest::Delegate {
request->Cancel();
}
- virtual void OnGetCookiesBlocked(URLRequest* request) {
- blocked_get_cookies_count_++;
- if (cancel_in_getcookiesblocked_)
- request->Cancel();
+ virtual void OnGetCookies(URLRequest* request, bool blocked_by_policy) {
+ if (blocked_by_policy) {
+ blocked_get_cookies_count_++;
+ if (cancel_in_getcookiesblocked_)
+ request->Cancel();
+ }
}
- virtual void OnSetCookieBlocked(URLRequest* request) {
- blocked_set_cookie_count_++;
- if (cancel_in_setcookieblocked_)
- request->Cancel();
+ virtual void OnSetCookie(URLRequest* request,
+ const std::string& cookie_line,
+ bool blocked_by_policy) {
+ if (blocked_by_policy) {
+ blocked_set_cookie_count_++;
+ if (cancel_in_setcookieblocked_)
+ request->Cancel();
+ } else {
+ set_cookie_count_++;
+ }
}
void set_cancel_in_received_redirect(bool val) { cancel_in_rr_ = val; }
@@ -345,6 +354,7 @@ class TestDelegate : public URLRequest::Delegate {
int received_redirect_count() const { return received_redirect_count_; }
int blocked_get_cookies_count() const { return blocked_get_cookies_count_; }
int blocked_set_cookie_count() const { return blocked_set_cookie_count_; }
+ int set_cookie_count() const { return set_cookie_count_; }
bool received_data_before_response() const {
return received_data_before_response_;
}
@@ -373,6 +383,7 @@ class TestDelegate : public URLRequest::Delegate {
int received_redirect_count_;
int blocked_get_cookies_count_;
int blocked_set_cookie_count_;
+ int set_cookie_count_;
bool received_data_before_response_;
bool request_failed_;
bool have_certificate_errors_;