summaryrefslogtreecommitdiffstats
path: root/chrome/browser/tab_contents
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/browser/tab_contents')
-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
5 files changed, 17 insertions, 100 deletions
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));
-}