diff options
author | markusheintz@chromium.org <markusheintz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-01-27 23:51:36 +0000 |
---|---|---|
committer | markusheintz@chromium.org <markusheintz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-01-27 23:51:36 +0000 |
commit | d017a7046c34bb37a980e0a1a4fd20ec44ba7c78 (patch) | |
tree | 3f7bd4f29c100fd7f3cba34699254e1ac578c4ac /chrome/browser/content_settings | |
parent | 7b2139fd769a7b01636f0f35ada632da5c81a5c8 (diff) | |
download | chromium_src-d017a7046c34bb37a980e0a1a4fd20ec44ba7c78.zip chromium_src-d017a7046c34bb37a980e0a1a4fd20ec44ba7c78.tar.gz chromium_src-d017a7046c34bb37a980e0a1a4fd20ec44ba7c78.tar.bz2 |
Display a content settings icon in the location bar that indicates whether the current website accesses the mediastream (camera/micorphone) or whether mediastream access was blocked. By clicking on the icon users can open a bubble that allows them change the media setting for the current website.
BUG=167263
TEST=TabSpecificContentSettings*
TBR=pastarmovj@chromium.org
Review URL: https://chromiumcodereview.appspot.com/11896028
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@179093 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/content_settings')
3 files changed, 47 insertions, 5 deletions
diff --git a/chrome/browser/content_settings/tab_specific_content_settings.cc b/chrome/browser/content_settings/tab_specific_content_settings.cc index caf6c12..39b6e86 100644 --- a/chrome/browser/content_settings/tab_specific_content_settings.cc +++ b/chrome/browser/content_settings/tab_specific_content_settings.cc @@ -206,7 +206,8 @@ bool TabSpecificContentSettings::IsContentBlocked( content_type == CONTENT_SETTINGS_TYPE_PLUGINS || content_type == CONTENT_SETTINGS_TYPE_COOKIES || content_type == CONTENT_SETTINGS_TYPE_POPUPS || - content_type == CONTENT_SETTINGS_TYPE_MIXEDSCRIPT) + content_type == CONTENT_SETTINGS_TYPE_MIXEDSCRIPT || + content_type == CONTENT_SETTINGS_TYPE_MEDIASTREAM) return content_blocked_[content_type]; return false; @@ -224,8 +225,10 @@ void TabSpecificContentSettings::SetBlockageHasBeenIndicated( bool TabSpecificContentSettings::IsContentAccessed( ContentSettingsType content_type) const { - // This method currently only returns meaningful values for cookies. - if (content_type != CONTENT_SETTINGS_TYPE_COOKIES) + // This method currently only returns meaningful values for the content type + // cookies and mediastream. + if (content_type != CONTENT_SETTINGS_TYPE_COOKIES && + content_type != CONTENT_SETTINGS_TYPE_MEDIASTREAM) return false; return content_accessed_[content_type]; @@ -422,6 +425,10 @@ void TabSpecificContentSettings::OnGeolocationPermissionSet( content::NotificationService::NoDetails()); } +void TabSpecificContentSettings::OnMediaStreamAccessed() { + OnContentAccessed(CONTENT_SETTINGS_TYPE_MEDIASTREAM); +} + void TabSpecificContentSettings::ClearBlockedContentSettingsExceptForCookies() { for (size_t i = 0; i < arraysize(content_blocked_); ++i) { if (i == CONTENT_SETTINGS_TYPE_COOKIES) diff --git a/chrome/browser/content_settings/tab_specific_content_settings.h b/chrome/browser/content_settings/tab_specific_content_settings.h index 3ba7f4f..fee681f 100644 --- a/chrome/browser/content_settings/tab_specific_content_settings.h +++ b/chrome/browser/content_settings/tab_specific_content_settings.h @@ -191,7 +191,6 @@ class TabSpecificContentSettings pending_protocol_handler_ = ProtocolHandler::EmptyProtocolHandler(); } - // Sets the previous protocol handler which will be replaced by the // pending protocol handler. void set_previous_protocol_handler(const ProtocolHandler& handler) { @@ -278,6 +277,9 @@ class TabSpecificContentSettings void OnGeolocationPermissionSet(const GURL& requesting_frame, bool allowed); + // This method is called when a media stream is accessed. + void OnMediaStreamAccessed(); + // Adds the given |SiteDataObserver|. The |observer| is notified when a // locale shared object, like for example a cookie, is accessed. void AddSiteDataObserver(SiteDataObserver* observer); 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 e0bbb45..9b28d9b 100644 --- a/chrome/browser/content_settings/tab_specific_content_settings_unittest.cc +++ b/chrome/browser/content_settings/tab_specific_content_settings_unittest.cc @@ -68,8 +68,11 @@ TEST_F(TabSpecificContentSettingsTest, BlockedContent) { content_settings->IsContentBlocked(CONTENT_SETTINGS_TYPE_COOKIES)); EXPECT_FALSE( content_settings->IsContentBlocked(CONTENT_SETTINGS_TYPE_POPUPS)); + EXPECT_FALSE( + content_settings->IsContentBlocked(CONTENT_SETTINGS_TYPE_MEDIASTREAM)); - // Set a cookie, block access to images, block a popup. + // Set a cookie, block access to images, block mediastream access and block a + // popup. content_settings->OnCookieChanged(GURL("http://google.com"), GURL("http://google.com"), "A=B", @@ -78,6 +81,8 @@ TEST_F(TabSpecificContentSettingsTest, BlockedContent) { content_settings->OnContentBlocked(CONTENT_SETTINGS_TYPE_IMAGES, std::string()); content_settings->SetPopupsBlocked(true); + content_settings->OnContentBlocked(CONTENT_SETTINGS_TYPE_MEDIASTREAM, + std::string()); // Check that only the respective content types are affected. EXPECT_TRUE(content_settings->IsContentBlocked(CONTENT_SETTINGS_TYPE_IMAGES)); @@ -88,6 +93,8 @@ TEST_F(TabSpecificContentSettingsTest, BlockedContent) { EXPECT_FALSE( content_settings->IsContentBlocked(CONTENT_SETTINGS_TYPE_COOKIES)); EXPECT_TRUE(content_settings->IsContentBlocked(CONTENT_SETTINGS_TYPE_POPUPS)); + EXPECT_TRUE( + content_settings->IsContentBlocked(CONTENT_SETTINGS_TYPE_MEDIASTREAM)); content_settings->OnCookieChanged(GURL("http://google.com"), GURL("http://google.com"), "A=B", @@ -115,6 +122,8 @@ TEST_F(TabSpecificContentSettingsTest, BlockedContent) { content_settings->IsContentBlocked(CONTENT_SETTINGS_TYPE_COOKIES)); EXPECT_FALSE( content_settings->IsContentBlocked(CONTENT_SETTINGS_TYPE_POPUPS)); + EXPECT_FALSE( + content_settings->IsContentBlocked(CONTENT_SETTINGS_TYPE_MEDIASTREAM)); content_settings->ClearCookieSpecificContentSettings(); EXPECT_FALSE( @@ -127,6 +136,8 @@ TEST_F(TabSpecificContentSettingsTest, BlockedContent) { content_settings->IsContentBlocked(CONTENT_SETTINGS_TYPE_COOKIES)); EXPECT_FALSE( content_settings->IsContentBlocked(CONTENT_SETTINGS_TYPE_POPUPS)); + EXPECT_FALSE( + content_settings->IsContentBlocked(CONTENT_SETTINGS_TYPE_MEDIASTREAM)); } TEST_F(TabSpecificContentSettingsTest, BlockedFileSystems) { @@ -149,12 +160,17 @@ TEST_F(TabSpecificContentSettingsTest, AllowedContent) { TabSpecificContentSettings::FromWebContents(web_contents()); net::CookieOptions options; + // Test default settings. 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)); + ASSERT_FALSE( + content_settings->IsContentAccessed(CONTENT_SETTINGS_TYPE_MEDIASTREAM)); + + // Record a cookie. content_settings->OnCookieChanged(GURL("http://google.com"), GURL("http://google.com"), "A=B", @@ -164,6 +180,8 @@ TEST_F(TabSpecificContentSettingsTest, AllowedContent) { content_settings->IsContentAccessed(CONTENT_SETTINGS_TYPE_COOKIES)); ASSERT_FALSE( content_settings->IsContentBlocked(CONTENT_SETTINGS_TYPE_COOKIES)); + + // Record a blocked cookie. content_settings->OnCookieChanged(GURL("http://google.com"), GURL("http://google.com"), "C=D", @@ -173,6 +191,21 @@ TEST_F(TabSpecificContentSettingsTest, AllowedContent) { content_settings->IsContentAccessed(CONTENT_SETTINGS_TYPE_COOKIES)); ASSERT_TRUE( content_settings->IsContentBlocked(CONTENT_SETTINGS_TYPE_COOKIES)); + + // Record mediastream access. + content_settings->OnMediaStreamAccessed(); + ASSERT_TRUE( + content_settings->IsContentAccessed(CONTENT_SETTINGS_TYPE_MEDIASTREAM)); + ASSERT_FALSE( + content_settings->IsContentBlocked(CONTENT_SETTINGS_TYPE_MEDIASTREAM)); + + // Record a blocked mediastream access request. + content_settings->OnContentBlocked(CONTENT_SETTINGS_TYPE_MEDIASTREAM, + std::string()); + ASSERT_TRUE( + content_settings->IsContentAccessed(CONTENT_SETTINGS_TYPE_MEDIASTREAM)); + ASSERT_TRUE( + content_settings->IsContentBlocked(CONTENT_SETTINGS_TYPE_MEDIASTREAM)); } TEST_F(TabSpecificContentSettingsTest, EmptyCookieList) { |