summaryrefslogtreecommitdiffstats
path: root/chrome/browser/content_settings
diff options
context:
space:
mode:
authorxians@chromium.org <xians@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-02-21 14:20:51 +0000
committerxians@chromium.org <xians@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-02-21 14:20:51 +0000
commiteb5c1f45fa7b5c03c63daec3e090db5e91ddb26e (patch)
treeaa2deb8bd58b6bafbc4f4dc11ef012d6a4026701 /chrome/browser/content_settings
parente772bf918c384da7e3a3d113f111147a9a524a83 (diff)
downloadchromium_src-eb5c1f45fa7b5c03c63daec3e090db5e91ddb26e.zip
chromium_src-eb5c1f45fa7b5c03c63daec3e090db5e91ddb26e.tar.gz
chromium_src-eb5c1f45fa7b5c03c63daec3e090db5e91ddb26e.tar.bz2
Fixed the problem that the omnibox icon does not reflect the latest usermedia constraints.
When an access is first denied then allowed, without reloading the page, the omnibox never reveals the latest permission change because the deny access is still there and has a higher priority than the allow access. BUG=175993 TEST= Browse to the WebRTC peerconnection.html page: http://src.chromium.org/viewvc/chrome/trunk/src/chrome/test/data/webrtc/manual/peerconnection.html 2. Click request GetUserMedia 3. Click Deny in the infobar 4. In the omnibar click the privacy/camera icon and select the "Ask if" option 5. Click request GetUserMedia 6. Click Allow Review URL: https://codereview.chromium.org/12288049 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@183807 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/content_settings')
-rw-r--r--chrome/browser/content_settings/tab_specific_content_settings.cc12
-rw-r--r--chrome/browser/content_settings/tab_specific_content_settings_unittest.cc28
2 files changed, 37 insertions, 3 deletions
diff --git a/chrome/browser/content_settings/tab_specific_content_settings.cc b/chrome/browser/content_settings/tab_specific_content_settings.cc
index fb98667..7ac9c0b 100644
--- a/chrome/browser/content_settings/tab_specific_content_settings.cc
+++ b/chrome/browser/content_settings/tab_specific_content_settings.cc
@@ -263,7 +263,7 @@ void TabSpecificContentSettings::OnContentBlocked(
<< "Geolocation settings handled by OnGeolocationPermissionSet";
if (type < 0 || type >= CONTENT_SETTINGS_NUM_TYPES)
return;
- content_accessed_[type] = true;
+ content_accessed_[type] = false;
// Unless UI for resource content settings is enabled, ignore the resource
// identifier.
// TODO(bauerb): The UI to unblock content should be disabled if the content
@@ -300,8 +300,18 @@ void TabSpecificContentSettings::OnContentBlocked(
void TabSpecificContentSettings::OnContentAccessed(ContentSettingsType type) {
DCHECK(type != CONTENT_SETTINGS_TYPE_GEOLOCATION)
<< "Geolocation settings handled by OnGeolocationPermissionSet";
+ bool access_changed = false;
+ if (content_blocked_[type]) {
+ content_blocked_[type] = false;
+ access_changed = true;
+ }
+
if (!content_accessed_[type]) {
content_accessed_[type] = true;
+ access_changed = true;
+ }
+
+ if (access_changed) {
content::NotificationService::current()->Notify(
chrome::NOTIFICATION_WEB_CONTENT_SETTINGS_CHANGED,
content::Source<WebContents>(web_contents()),
diff --git a/chrome/browser/content_settings/tab_specific_content_settings_unittest.cc b/chrome/browser/content_settings/tab_specific_content_settings_unittest.cc
index 9b28d9b..da2d3ed 100644
--- a/chrome/browser/content_settings/tab_specific_content_settings_unittest.cc
+++ b/chrome/browser/content_settings/tab_specific_content_settings_unittest.cc
@@ -187,7 +187,7 @@ TEST_F(TabSpecificContentSettingsTest, AllowedContent) {
"C=D",
options,
true);
- ASSERT_TRUE(
+ ASSERT_FALSE(
content_settings->IsContentAccessed(CONTENT_SETTINGS_TYPE_COOKIES));
ASSERT_TRUE(
content_settings->IsContentBlocked(CONTENT_SETTINGS_TYPE_COOKIES));
@@ -202,7 +202,7 @@ TEST_F(TabSpecificContentSettingsTest, AllowedContent) {
// Record a blocked mediastream access request.
content_settings->OnContentBlocked(CONTENT_SETTINGS_TYPE_MEDIASTREAM,
std::string());
- ASSERT_TRUE(
+ ASSERT_FALSE(
content_settings->IsContentAccessed(CONTENT_SETTINGS_TYPE_MEDIASTREAM));
ASSERT_TRUE(
content_settings->IsContentBlocked(CONTENT_SETTINGS_TYPE_MEDIASTREAM));
@@ -262,3 +262,27 @@ TEST_F(TabSpecificContentSettingsTest, SiteDataObserver) {
UTF8ToUTF16("display_name"),
blocked_by_policy);
}
+
+TEST_F(TabSpecificContentSettingsTest, BlockThenAllowMediaAccess) {
+ TabSpecificContentSettings* content_settings =
+ TabSpecificContentSettings::FromWebContents(web_contents());
+ ContentSettingsType type = CONTENT_SETTINGS_TYPE_MEDIASTREAM;
+ content_settings->OnContentBlocked(type, std::string());
+ EXPECT_TRUE(content_settings->IsContentBlocked(type));
+ EXPECT_FALSE(content_settings->IsContentAccessed(type));
+ content_settings->OnContentAccessed(type);
+ EXPECT_TRUE(content_settings->IsContentAccessed(type));
+ EXPECT_FALSE(content_settings->IsContentBlocked(type));
+}
+
+TEST_F(TabSpecificContentSettingsTest, AllowThenBlockMediaAccess) {
+ TabSpecificContentSettings* content_settings =
+ TabSpecificContentSettings::FromWebContents(web_contents());
+ ContentSettingsType type = CONTENT_SETTINGS_TYPE_MEDIASTREAM;
+ content_settings->OnContentAccessed(type);
+ EXPECT_TRUE(content_settings->IsContentAccessed(type));
+ EXPECT_FALSE(content_settings->IsContentBlocked(type));
+ content_settings->OnContentBlocked(type, std::string());
+ EXPECT_TRUE(content_settings->IsContentBlocked(type));
+ EXPECT_FALSE(content_settings->IsContentAccessed(type));
+}