summaryrefslogtreecommitdiffstats
path: root/chrome/browser
diff options
context:
space:
mode:
authorjochen@chromium.org <jochen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-08-10 08:27:52 +0000
committerjochen@chromium.org <jochen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-08-10 08:27:52 +0000
commit64ec3d13abf89f523f5d834a3dddb76e115bdf88 (patch)
tree80ca491a9e61ff35ad2edbda8bace09dd98c5681 /chrome/browser
parent5699b94105b6a97b528837f5ae5278deeb461b84 (diff)
downloadchromium_src-64ec3d13abf89f523f5d834a3dddb76e115bdf88.zip
chromium_src-64ec3d13abf89f523f5d834a3dddb76e115bdf88.tar.gz
chromium_src-64ec3d13abf89f523f5d834a3dddb76e115bdf88.tar.bz2
Revert 55536 - Reland r55382. When blocking cookies, also show an icon in the location bar when cookies are accessed.
If the user choses to block cookies per default, this will grant access to the collected cookies dialog as soon as the page accesses cookies. Right now, the icon is only shown if cookies were actually blocked. BUG=45230 TEST=Canned*.*:ContentSettingImage*.*:TabSpecific*.* Review URL: http://codereview.chromium.org/3014056 Review URL: http://codereview.chromium.org/3146003 TBR=jochen@chromium.org Review URL: http://codereview.chromium.org/3127002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@55540 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-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_appcache_helper_unittest.cc15
-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_database_helper_unittest.cc16
-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/browsing_data_local_storage_helper_unittest.cc15
-rw-r--r--chrome/browser/content_setting_bubble_model.cc29
-rw-r--r--chrome/browser/content_setting_image_model.cc62
-rw-r--r--chrome/browser/content_setting_image_model_unittest.cc38
-rw-r--r--chrome/browser/tab_contents/tab_contents.cc2
-rw-r--r--chrome/browser/tab_contents/tab_contents.h4
-rw-r--r--chrome/browser/tab_contents/tab_specific_content_settings.cc49
-rw-r--r--chrome/browser/tab_contents/tab_specific_content_settings.h20
-rw-r--r--chrome/browser/tab_contents/tab_specific_content_settings_unittest.cc42
17 files changed, 35 insertions, 278 deletions
diff --git a/chrome/browser/browsing_data_appcache_helper.cc b/chrome/browser/browsing_data_appcache_helper.cc
index de330fe..2e58c6b 100644
--- a/chrome/browser/browsing_data_appcache_helper.cc
+++ b/chrome/browser/browsing_data_appcache_helper.cc
@@ -127,10 +127,6 @@ void CannedBrowsingDataAppCacheHelper::Reset() {
info_collection_->infos_by_origin.clear();
}
-bool CannedBrowsingDataAppCacheHelper::empty() const {
- return info_collection_->infos_by_origin.empty();
-}
-
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 2e57fd8..b89f7a2 100644
--- a/chrome/browser/browsing_data_appcache_helper.h
+++ b/chrome/browser/browsing_data_appcache_helper.h
@@ -65,9 +65,6 @@ class CannedBrowsingDataAppCacheHelper : public BrowsingDataAppCacheHelper {
// Clears the list of canned caches.
void Reset();
- // True if no appcaches are currently stored.
- bool empty() const;
-
// BrowsingDataAppCacheHelper methods.
virtual void StartFetching(Callback0::Type* completion_callback);
virtual void CancelNotification() {}
diff --git a/chrome/browser/browsing_data_appcache_helper_unittest.cc b/chrome/browser/browsing_data_appcache_helper_unittest.cc
index 32d928c..e5631b1 100644
--- a/chrome/browser/browsing_data_appcache_helper_unittest.cc
+++ b/chrome/browser/browsing_data_appcache_helper_unittest.cc
@@ -82,18 +82,3 @@ TEST(CannedBrowsingDataAppCacheHelperTest, Unique) {
ASSERT_EQ(1u, collection[manifest.GetOrigin()].size());
EXPECT_EQ(manifest, collection[manifest.GetOrigin()].at(0).manifest_url);
}
-
-TEST(CannedBrowsingDataAppCacheHelperTest, Empty) {
- TestingProfile profile;
-
- GURL manifest("http://example.com/manifest.xml");
-
- scoped_refptr<CannedBrowsingDataAppCacheHelper> helper =
- new CannedBrowsingDataAppCacheHelper(&profile);
-
- ASSERT_TRUE(helper->empty());
- helper->AddAppCache(manifest);
- ASSERT_FALSE(helper->empty());
- helper->Reset();
- ASSERT_TRUE(helper->empty());
-}
diff --git a/chrome/browser/browsing_data_database_helper.cc b/chrome/browser/browsing_data_database_helper.cc
index 5c00df1..11e5e6b 100644
--- a/chrome/browser/browsing_data_database_helper.cc
+++ b/chrome/browser/browsing_data_database_helper.cc
@@ -147,10 +147,6 @@ void CannedBrowsingDataDatabaseHelper::Reset() {
database_info_.clear();
}
-bool CannedBrowsingDataDatabaseHelper::empty() const {
- return database_info_.empty();
-}
-
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 26210a7..fb73784 100644
--- a/chrome/browser/browsing_data_database_helper.h
+++ b/chrome/browser/browsing_data_database_helper.h
@@ -128,9 +128,6 @@ class CannedBrowsingDataDatabaseHelper : public BrowsingDataDatabaseHelper {
// Clear the list of canned databases.
void Reset();
- // True if no databases are currently stored.
- bool empty() const;
-
// BrowsingDataDatabaseHelper methods.
virtual void StartFetching(
Callback1<const std::vector<DatabaseInfo>& >::Type* callback);
diff --git a/chrome/browser/browsing_data_database_helper_unittest.cc b/chrome/browser/browsing_data_database_helper_unittest.cc
index 9d313db..b5368c4 100644
--- a/chrome/browser/browsing_data_database_helper_unittest.cc
+++ b/chrome/browser/browsing_data_database_helper_unittest.cc
@@ -93,19 +93,3 @@ TEST(CannedBrowsingDataDatabaseTest, Unique) {
EXPECT_STREQ(origin_str, result[0].origin_identifier.c_str());
EXPECT_STREQ(db, result[0].database_name.c_str());
}
-
-TEST(CannedBrowsingDataDatabaseTest, Empty) {
- TestingProfile profile;
-
- const GURL origin("http://host1:1/");
- const char db[] = "db1";
-
- scoped_refptr<CannedBrowsingDataDatabaseHelper> helper =
- new CannedBrowsingDataDatabaseHelper(&profile);
-
- ASSERT_TRUE(helper->empty());
- helper->AddDatabase(origin, db, "");
- ASSERT_FALSE(helper->empty());
- helper->Reset();
- ASSERT_TRUE(helper->empty());
-}
diff --git a/chrome/browser/browsing_data_local_storage_helper.cc b/chrome/browser/browsing_data_local_storage_helper.cc
index 8aedc24..2193305 100644
--- a/chrome/browser/browsing_data_local_storage_helper.cc
+++ b/chrome/browser/browsing_data_local_storage_helper.cc
@@ -152,10 +152,6 @@ void CannedBrowsingDataLocalStorageHelper::Reset() {
local_storage_info_.clear();
}
-bool CannedBrowsingDataLocalStorageHelper::empty() const {
- return local_storage_info_.empty();
-}
-
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 1f61070..bf09d08 100644
--- a/chrome/browser/browsing_data_local_storage_helper.h
+++ b/chrome/browser/browsing_data_local_storage_helper.h
@@ -122,9 +122,6 @@ class CannedBrowsingDataLocalStorageHelper
// Clear the list of canned local storages.
void Reset();
- // True if no local storages are currently stored.
- bool empty() const;
-
// BrowsingDataLocalStorageHelper methods.
virtual void StartFetching(
Callback1<const std::vector<LocalStorageInfo>& >::Type* callback);
diff --git a/chrome/browser/browsing_data_local_storage_helper_unittest.cc b/chrome/browser/browsing_data_local_storage_helper_unittest.cc
index 918dc92..37c3555 100644
--- a/chrome/browser/browsing_data_local_storage_helper_unittest.cc
+++ b/chrome/browser/browsing_data_local_storage_helper_unittest.cc
@@ -87,18 +87,3 @@ TEST(CannedBrowsingDataLocalStorageTest, Unique) {
ASSERT_EQ(1u, result.size());
EXPECT_EQ(FilePath(file).value(), result[0].file_path.BaseName().value());
}
-
-TEST(CannedBrowsingDataLocalStorageTest, Empty) {
- TestingProfile profile;
-
- const GURL origin("http://host1:1/");
-
- scoped_refptr<CannedBrowsingDataLocalStorageHelper> helper =
- new CannedBrowsingDataLocalStorageHelper(&profile);
-
- ASSERT_TRUE(helper->empty());
- helper->AddLocalStorage(origin);
- ASSERT_FALSE(helper->empty());
- helper->Reset();
- ASSERT_TRUE(helper->empty());
-}
diff --git a/chrome/browser/content_setting_bubble_model.cc b/chrome/browser/content_setting_bubble_model.cc
index 8f83f02..6c1c13b 100644
--- a/chrome/browser/content_setting_bubble_model.cc
+++ b/chrome/browser/content_setting_bubble_model.cc
@@ -14,7 +14,6 @@
#include "chrome/browser/renderer_host/render_view_host.h"
#include "chrome/browser/tab_contents/tab_contents.h"
#include "chrome/browser/tab_contents/tab_contents_delegate.h"
-#include "chrome/browser/tab_contents/tab_specific_content_settings.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/notification_service.h"
#include "chrome/common/pref_names.h"
@@ -34,7 +33,7 @@ class ContentSettingTitleAndLinkModel : public ContentSettingBubbleModel {
private:
void SetTitle() {
- static const int kBlockedTitleIDs[] = {
+ static const int kTitleIDs[] = {
IDS_BLOCKED_COOKIES_TITLE,
IDS_BLOCKED_IMAGES_TITLE,
IDS_BLOCKED_JAVASCRIPT_TITLE,
@@ -43,30 +42,10 @@ class ContentSettingTitleAndLinkModel : public ContentSettingBubbleModel {
0, // Geolocation does not have an overall title.
0, // Notifications do not have a bubble.
};
- static const int kAccessedTitleIDs[] = {
- IDS_ACCESSED_COOKIES_TITLE,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- };
- COMPILE_ASSERT(arraysize(kAccessedTitleIDs) == CONTENT_SETTINGS_NUM_TYPES,
- Need_a_setting_for_every_content_settings_type);
- COMPILE_ASSERT(arraysize(kBlockedTitleIDs) == CONTENT_SETTINGS_NUM_TYPES,
+ COMPILE_ASSERT(arraysize(kTitleIDs) == CONTENT_SETTINGS_NUM_TYPES,
Need_a_setting_for_every_content_settings_type);
- const int *title_ids = kBlockedTitleIDs;
- if (tab_contents() &&
- tab_contents()->GetTabSpecificContentSettings()->IsContentAccessed(
- content_type()) &&
- !tab_contents()->GetTabSpecificContentSettings()->IsContentBlocked(
- content_type()) &&
- !CommandLine::ForCurrentProcess()->HasSwitch(
- switches::kEnableCookiePrompt))
- title_ids = kAccessedTitleIDs;
- if (title_ids[content_type()])
- set_title(l10n_util::GetStringUTF8(title_ids[content_type()]));
+ if (kTitleIDs[content_type()])
+ set_title(l10n_util::GetStringUTF8(kTitleIDs[content_type()]));
}
void SetManageLink() {
diff --git a/chrome/browser/content_setting_image_model.cc b/chrome/browser/content_setting_image_model.cc
index e45aead..26e349ac 100644
--- a/chrome/browser/content_setting_image_model.cc
+++ b/chrome/browser/content_setting_image_model.cc
@@ -5,11 +5,7 @@
#include "chrome/browser/content_setting_image_model.h"
#include "app/l10n_util.h"
-#include "base/command_line.h"
-#include "chrome/browser/host_content_settings_map.h"
-#include "chrome/browser/profile.h"
#include "chrome/browser/tab_contents/tab_contents.h"
-#include "chrome/common/chrome_switches.h"
#include "grit/generated_resources.h"
#include "grit/theme_resources.h"
@@ -21,10 +17,8 @@ class ContentSettingBlockedImageModel : public ContentSettingImageModel {
virtual void UpdateFromTabContents(const TabContents* tab_contents);
private:
- static const int kAccessedIconIDs[];
static const int kBlockedIconIDs[];
- static const int kAccessedTooltipIDs[];
- static const int kBlockedTooltipIDs[];
+ static const int kTooltipIDs[];
};
class ContentSettingGeolocationImageModel : public ContentSettingImageModel {
@@ -49,29 +43,14 @@ const int ContentSettingBlockedImageModel::kBlockedIconIDs[] = {
IDR_BLOCKED_POPUPS,
};
-const int ContentSettingBlockedImageModel::kAccessedIconIDs[] = {
- IDR_ACCESSED_COOKIES,
- 0,
- 0,
- 0,
- 0,
+const int ContentSettingBlockedImageModel::kTooltipIDs[] = {
+ IDS_BLOCKED_COOKIES_TITLE,
+ IDS_BLOCKED_IMAGES_TITLE,
+ IDS_BLOCKED_JAVASCRIPT_TITLE,
+ IDS_BLOCKED_PLUGINS_TITLE,
+ IDS_BLOCKED_POPUPS_TOOLTIP,
};
-const int ContentSettingBlockedImageModel::kBlockedTooltipIDs[] = {
- IDS_BLOCKED_COOKIES_TITLE,
- IDS_BLOCKED_IMAGES_TITLE,
- IDS_BLOCKED_JAVASCRIPT_TITLE,
- IDS_BLOCKED_PLUGINS_TITLE,
- IDS_BLOCKED_POPUPS_TOOLTIP,
-};
-
-const int ContentSettingBlockedImageModel::kAccessedTooltipIDs[] = {
- IDS_ACCESSED_COOKIES_TITLE,
- 0,
- 0,
- 0,
- 0,
-};
ContentSettingBlockedImageModel::ContentSettingBlockedImageModel(
ContentSettingsType content_settings_type)
@@ -82,33 +61,14 @@ void ContentSettingBlockedImageModel::UpdateFromTabContents(
const TabContents* tab_contents) {
TabSpecificContentSettings* content_settings = tab_contents ?
tab_contents->GetTabSpecificContentSettings() : NULL;
- const int* icon_ids;
- const int* tooltip_ids;
-
- if (!content_settings) {
- set_visible(false);
- return;
- }
- if (content_settings->IsContentBlocked(get_content_settings_type())) {
- icon_ids = kBlockedIconIDs;
- tooltip_ids = kBlockedTooltipIDs;
- } else if (!CommandLine::ForCurrentProcess()->HasSwitch(
- switches::kEnableCookiePrompt) &&
- tab_contents->profile()->GetHostContentSettingsMap()->
- GetDefaultContentSetting(get_content_settings_type()) ==
- CONTENT_SETTING_BLOCK &&
- content_settings->IsContentAccessed(get_content_settings_type())) {
- // If a content type is blocked by default and was accessed, display the
- // accessed icon.
- icon_ids = kAccessedIconIDs;
- tooltip_ids = kAccessedTooltipIDs;
- } else {
+ if (!content_settings ||
+ !content_settings->IsContentBlocked(get_content_settings_type())) {
set_visible(false);
return;
}
- set_icon(icon_ids[get_content_settings_type()]);
+ set_icon(kBlockedIconIDs[get_content_settings_type()]);
set_tooltip(
- l10n_util::GetStringUTF8(tooltip_ids[get_content_settings_type()]));
+ l10n_util::GetStringUTF8(kTooltipIDs[get_content_settings_type()]));
set_visible(true);
}
diff --git a/chrome/browser/content_setting_image_model_unittest.cc b/chrome/browser/content_setting_image_model_unittest.cc
index 32aed3e..02a5af3 100644
--- a/chrome/browser/content_setting_image_model_unittest.cc
+++ b/chrome/browser/content_setting_image_model_unittest.cc
@@ -4,25 +4,13 @@
#include "chrome/browser/content_setting_image_model.h"
-#include "chrome/browser/chrome_thread.h"
-#include "chrome/browser/host_content_settings_map.h"
#include "chrome/browser/profile.h"
#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 "testing/gtest/include/gtest/gtest.h"
-class ContentSettingImageModelTest : public RenderViewHostTestHarness {
- public:
- ContentSettingImageModelTest()
- : RenderViewHostTestHarness(),
- ui_thread_(ChromeThread::UI, &message_loop_) {}
-
- private:
- ChromeThread ui_thread_;
-
- DISALLOW_COPY_AND_ASSIGN(ContentSettingImageModelTest);
-};
+typedef RenderViewHostTestHarness ContentSettingImageModelTest;
TEST_F(ContentSettingImageModelTest, UpdateFromTabContents) {
TestTabContents tab_contents(profile_.get(), NULL);
@@ -33,32 +21,12 @@ TEST_F(ContentSettingImageModelTest, UpdateFromTabContents) {
CONTENT_SETTINGS_TYPE_IMAGES));
EXPECT_FALSE(content_setting_image_model->is_visible());
EXPECT_EQ(0, content_setting_image_model->get_icon());
- EXPECT_EQ(std::string(), content_setting_image_model->get_tooltip());
+ EXPECT_EQ("", content_setting_image_model->get_tooltip());
content_settings->OnContentBlocked(CONTENT_SETTINGS_TYPE_IMAGES);
content_setting_image_model->UpdateFromTabContents(&tab_contents);
EXPECT_TRUE(content_setting_image_model->is_visible());
EXPECT_NE(0, content_setting_image_model->get_icon());
- EXPECT_NE(std::string(), content_setting_image_model->get_tooltip());
-}
-
-TEST_F(ContentSettingImageModelTest, CookieAccessed) {
- TestTabContents tab_contents(profile_.get(), NULL);
- TabSpecificContentSettings* content_settings =
- tab_contents.GetTabSpecificContentSettings();
- profile_->GetHostContentSettingsMap()->SetDefaultContentSetting(
- CONTENT_SETTINGS_TYPE_COOKIES, CONTENT_SETTING_BLOCK);
- scoped_ptr<ContentSettingImageModel> content_setting_image_model(
- ContentSettingImageModel::CreateContentSettingImageModel(
- CONTENT_SETTINGS_TYPE_COOKIES));
- EXPECT_FALSE(content_setting_image_model->is_visible());
- 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);
- content_setting_image_model->UpdateFromTabContents(&tab_contents);
- EXPECT_TRUE(content_setting_image_model->is_visible());
- EXPECT_NE(0, content_setting_image_model->get_icon());
- EXPECT_NE(std::string(), content_setting_image_model->get_tooltip());
+ EXPECT_NE("", content_setting_image_model->get_tooltip());
}
diff --git a/chrome/browser/tab_contents/tab_contents.cc b/chrome/browser/tab_contents/tab_contents.cc
index 0127f35..96c2411 100644
--- a/chrome/browser/tab_contents/tab_contents.cc
+++ b/chrome/browser/tab_contents/tab_contents.cc
@@ -2200,7 +2200,7 @@ void TabContents::DocumentLoadedInFrame() {
controller_.DocumentLoadedInFrame();
}
-void TabContents::OnContentSettingsAccessed(bool content_was_blocked) {
+void TabContents::OnContentSettingsChange() {
if (delegate_)
delegate_->OnContentSettingsChange(this);
}
diff --git a/chrome/browser/tab_contents/tab_contents.h b/chrome/browser/tab_contents/tab_contents.h
index 8df35c9..ab4cf56 100644
--- a/chrome/browser/tab_contents/tab_contents.h
+++ b/chrome/browser/tab_contents/tab_contents.h
@@ -815,8 +815,8 @@ class TabContents : public PageNavigator,
void GenerateKeywordIfNecessary(
const ViewHostMsg_FrameNavigate_Params& params);
- // TabSpecificContentSettings::Delegate implementation.
- virtual void OnContentSettingsAccessed(bool content_was_blocked);
+ // ContentBlockedDelegate::Delegate implementation.
+ virtual void OnContentSettingsChange();
// RenderViewHostDelegate ----------------------------------------------------
diff --git a/chrome/browser/tab_contents/tab_specific_content_settings.cc b/chrome/browser/tab_contents/tab_specific_content_settings.cc
index c8f976f..b09992c 100644
--- a/chrome/browser/tab_contents/tab_specific_content_settings.cc
+++ b/chrome/browser/tab_contents/tab_specific_content_settings.cc
@@ -11,13 +11,6 @@
#include "chrome/browser/cookies_tree_model.h"
#include "net/base/cookie_monster.h"
-bool TabSpecificContentSettings::LocalSharedObjectsContainer::empty() const {
- return cookies_->GetAllCookies().empty() &&
- appcaches_->empty() &&
- databases_->empty() &&
- local_storages_->empty();
-}
-
bool TabSpecificContentSettings::IsContentBlocked(
ContentSettingsType content_type) const {
DCHECK(content_type != CONTENT_SETTINGS_TYPE_GEOLOCATION)
@@ -37,34 +30,12 @@ bool TabSpecificContentSettings::IsContentBlocked(
return false;
}
-bool TabSpecificContentSettings::IsContentAccessed(
- ContentSettingsType content_type) const {
- // This method currently only returns meaningful values for cookies.
- if (content_type != CONTENT_SETTINGS_TYPE_COOKIES)
- return false;
-
- return content_accessed_[content_type];
-}
-
void TabSpecificContentSettings::OnContentBlocked(ContentSettingsType type) {
DCHECK(type != CONTENT_SETTINGS_TYPE_GEOLOCATION)
<< "Geolocation settings handled by OnGeolocationPermissionSet";
- content_accessed_[type] = true;
- if (!content_blocked_[type]) {
- content_blocked_[type] = true;
- if (delegate_)
- delegate_->OnContentSettingsAccessed(true);
- }
-}
-
-void TabSpecificContentSettings::OnContentAccessed(ContentSettingsType type) {
- DCHECK(type != CONTENT_SETTINGS_TYPE_GEOLOCATION)
- << "Geolocation settings handled by OnGeolocationPermissionSet";
- if (!content_accessed_[type]) {
- content_accessed_[type] = true;
- if (delegate_)
- delegate_->OnContentSettingsAccessed(false);
- }
+ content_blocked_[type] = true;
+ if (delegate_)
+ delegate_->OnContentSettingsChange();
}
void TabSpecificContentSettings::OnCookieAccessed(
@@ -78,7 +49,6 @@ void TabSpecificContentSettings::OnCookieAccessed(
} else {
allowed_local_shared_objects_.cookies()->SetCookieWithOptions(
url, cookie_line, options);
- OnContentAccessed(CONTENT_SETTINGS_TYPE_COOKIES);
}
}
@@ -89,7 +59,6 @@ void TabSpecificContentSettings::OnLocalStorageAccessed(
OnContentBlocked(CONTENT_SETTINGS_TYPE_COOKIES);
} else {
allowed_local_shared_objects_.local_storages()->AddLocalStorage(url);
- OnContentAccessed(CONTENT_SETTINGS_TYPE_COOKIES);
}
}
@@ -106,7 +75,6 @@ void TabSpecificContentSettings::OnWebDatabaseAccessed(
} else {
allowed_local_shared_objects_.databases()->AddDatabase(
url, UTF16ToUTF8(name), UTF16ToUTF8(display_name));
- OnContentAccessed(CONTENT_SETTINGS_TYPE_COOKIES);
}
}
@@ -117,7 +85,6 @@ void TabSpecificContentSettings::OnAppCacheAccessed(
OnContentBlocked(CONTENT_SETTINGS_TYPE_COOKIES);
} else {
allowed_local_shared_objects_.appcaches()->AddAppCache(manifest_url);
- OnContentAccessed(CONTENT_SETTINGS_TYPE_COOKIES);
}
}
@@ -127,7 +94,7 @@ void TabSpecificContentSettings::OnGeolocationPermissionSet(
geolocation_settings_state_.OnGeolocationPermissionSet(requesting_origin,
allowed);
if (delegate_)
- delegate_->OnContentSettingsAccessed(!allowed);
+ delegate_->OnContentSettingsChange();
}
TabSpecificContentSettings::TabSpecificContentSettings(
@@ -142,21 +109,19 @@ TabSpecificContentSettings::TabSpecificContentSettings(
}
void TabSpecificContentSettings::ClearBlockedContentSettings() {
- for (size_t i = 0; i < arraysize(content_blocked_); ++i) {
+ for (size_t i = 0; i < arraysize(content_blocked_); ++i)
content_blocked_[i] = false;
- content_accessed_[i] = false;
- }
load_plugins_link_enabled_ = true;
blocked_local_shared_objects_.Reset();
allowed_local_shared_objects_.Reset();
if (delegate_)
- delegate_->OnContentSettingsAccessed(false);
+ delegate_->OnContentSettingsChange();
}
void TabSpecificContentSettings::SetPopupsBlocked(bool blocked) {
content_blocked_[CONTENT_SETTINGS_TYPE_POPUPS] = blocked;
if (delegate_)
- delegate_->OnContentSettingsAccessed(blocked);
+ delegate_->OnContentSettingsChange();
}
void TabSpecificContentSettings::GeolocationDidNavigate(
diff --git a/chrome/browser/tab_contents/tab_specific_content_settings.h b/chrome/browser/tab_contents/tab_specific_content_settings.h
index 8a6d181..157976b 100644
--- a/chrome/browser/tab_contents/tab_specific_content_settings.h
+++ b/chrome/browser/tab_contents/tab_specific_content_settings.h
@@ -28,12 +28,9 @@ class TabSpecificContentSettings
public:
class Delegate {
public:
- // Invoked when content settings for resources in the tab contents
- // associated with this TabSpecificContentSettings object were accessed.
- // |content_was_blocked| is true, if a content settings type was blocked
- // (as opposed to just accessed). Currently, this parameter is checked in
- // unit tests only.
- virtual void OnContentSettingsAccessed(bool content_was_blocked) = 0;
+ // Invoked when content settings managed by the TabSpecificContentSettings
+ // object change.
+ virtual void OnContentSettingsChange() = 0;
virtual ~Delegate() {}
};
@@ -56,10 +53,6 @@ class TabSpecificContentSettings
// page.
bool IsContentBlocked(ContentSettingsType content_type) const;
- // Returns whether a particular kind of content has been accessed. Currently
- // only tracks cookies.
- bool IsContentAccessed(ContentSettingsType content_type) const;
-
// Returns the GeolocationSettingsState that controls the
// geolocation API usage on this page.
const GeolocationSettingsState& geolocation_settings_state() const {
@@ -115,8 +108,6 @@ class TabSpecificContentSettings
CookiesTreeModel* GetCookiesTreeModel();
- bool empty() const;
-
private:
DISALLOW_COPY_AND_ASSIGN(LocalSharedObjectsContainer);
@@ -126,14 +117,9 @@ class TabSpecificContentSettings
scoped_refptr<CannedBrowsingDataLocalStorageHelper> local_storages_;
};
- void OnContentAccessed(ContentSettingsType type);
-
// Stores which content setting types actually have blocked content.
bool content_blocked_[CONTENT_SETTINGS_NUM_TYPES];
- // Stores which content setting types actually were accessed.
- bool content_accessed_[CONTENT_SETTINGS_NUM_TYPES];
-
// Stores the blocked/allowed cookies.
LocalSharedObjectsContainer allowed_local_shared_objects_;
LocalSharedObjectsContainer blocked_local_shared_objects_;
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 6129f7d..b89d772 100644
--- a/chrome/browser/tab_contents/tab_specific_content_settings_unittest.cc
+++ b/chrome/browser/tab_contents/tab_specific_content_settings_unittest.cc
@@ -11,25 +11,18 @@ namespace {
class TestContentSettingsDelegate
: public TabSpecificContentSettings::Delegate {
public:
- TestContentSettingsDelegate()
- : settings_changed_(false), content_blocked_(false) {}
+ TestContentSettingsDelegate() : settings_changed_(false) {}
virtual ~TestContentSettingsDelegate() {}
- void Reset() { settings_changed_ = content_blocked_ = false; }
+ void Reset() { settings_changed_ = false; }
bool SettingsChanged() { return settings_changed_; }
- bool ContentBlocked() { return content_blocked_; }
-
// TabSpecificContentSettings::Delegate implementation.
- virtual void OnContentSettingsAccessed(bool content_was_blocked) {
- settings_changed_ = true;
- content_blocked_ = content_was_blocked;
- }
+ virtual void OnContentSettingsChange() { settings_changed_ = true; }
private:
bool settings_changed_;
- bool content_blocked_;
DISALLOW_COPY_AND_ASSIGN(TestContentSettingsDelegate);
};
@@ -52,16 +45,13 @@ TEST(TabSpecificContentSettingsTest, BlockedContent) {
// Set a cookie, block access to images, block a popup.
content_settings.OnCookieAccessed(GURL("http://google.com"), "A=B", false);
- EXPECT_TRUE(test_delegate.SettingsChanged());
- EXPECT_FALSE(test_delegate.ContentBlocked());
+ EXPECT_FALSE(test_delegate.SettingsChanged());
test_delegate.Reset();
content_settings.OnContentBlocked(CONTENT_SETTINGS_TYPE_IMAGES);
EXPECT_TRUE(test_delegate.SettingsChanged());
- EXPECT_TRUE(test_delegate.ContentBlocked());
test_delegate.Reset();
content_settings.SetPopupsBlocked(true);
EXPECT_TRUE(test_delegate.SettingsChanged());
- EXPECT_TRUE(test_delegate.ContentBlocked());
test_delegate.Reset();
// Check that only the respective content types are affected.
@@ -77,7 +67,6 @@ TEST(TabSpecificContentSettingsTest, BlockedContent) {
// Reset blocked content settings.
content_settings.ClearBlockedContentSettings();
EXPECT_TRUE(test_delegate.SettingsChanged());
- EXPECT_FALSE(test_delegate.ContentBlocked());
EXPECT_FALSE(content_settings.IsContentBlocked(CONTENT_SETTINGS_TYPE_IMAGES));
EXPECT_FALSE(
content_settings.IsContentBlocked(CONTENT_SETTINGS_TYPE_JAVASCRIPT));
@@ -87,26 +76,3 @@ TEST(TabSpecificContentSettingsTest, BlockedContent) {
content_settings.IsContentBlocked(CONTENT_SETTINGS_TYPE_COOKIES));
EXPECT_FALSE(content_settings.IsContentBlocked(CONTENT_SETTINGS_TYPE_POPUPS));
}
-
-TEST(TabSpecificContentSettingsTest, AllowedContent) {
- TestContentSettingsDelegate test_delegate;
- TestingProfile profile;
- TabSpecificContentSettings content_settings(&test_delegate, &profile);
-
- ASSERT_FALSE(
- content_settings.IsContentAccessed(CONTENT_SETTINGS_TYPE_IMAGES));
- ASSERT_FALSE(
- 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);
- 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);
- ASSERT_TRUE(
- content_settings.IsContentAccessed(CONTENT_SETTINGS_TYPE_COOKIES));
- ASSERT_TRUE(
- content_settings.IsContentBlocked(CONTENT_SETTINGS_TYPE_COOKIES));
-}