From a00ae1e67a8dc35d1ae4d1d36449447ec0f26cd7 Mon Sep 17 00:00:00 2001 From: "groby@chromium.org" Date: Thu, 18 Aug 2011 21:16:33 +0000 Subject: Enable WebIntents blacklist UI (redo of #7645034) BUG=ContentSettingBubbleControllerTest.Init TEST=Run Chromium with -enable-web-intents, go to content settings/manage exceptions, see UI Review URL: http://codereview.chromium.org/7670052 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@97357 0039d316-1c4b-4281-b951-d872f2087c98 --- chrome/app/generated_resources.grd | 15 +++++++++++++ .../content_settings_pref_provider.cc | 3 +++ .../content_settings/host_content_settings_map.cc | 7 ++++++ .../host_content_settings_map_unittest.cc | 6 +++++ .../resources/options/content_settings.html | 26 ++++++++++++++++++++++ .../browser/resources/options/content_settings.js | 5 ++++- .../options/content_settings_exceptions_area.html | 3 +++ .../content_setting_bubble_cocoa_unittest.mm | 5 +++-- .../ui/webui/options/content_settings_handler.cc | 10 +++++++++ chrome/common/content_settings_types.h | 1 + 10 files changed, 78 insertions(+), 3 deletions(-) (limited to 'chrome') diff --git a/chrome/app/generated_resources.grd b/chrome/app/generated_resources.grd index 2e26ef0..155801e 100644 --- a/chrome/app/generated_resources.grd +++ b/chrome/app/generated_resources.grd @@ -5636,6 +5636,21 @@ Keep your key file in a safe place. You will need it to create new versions of y Ask me when a site wants to show desktop notifications (recommended) + + Web Intents + + + Web Intents Exceptions + + + Allow all sites to register intents + + + Do not allow any site to register intents + + + Ask me when a site wants to register intents (recommended) + Site diff --git a/chrome/browser/content_settings/content_settings_pref_provider.cc b/chrome/browser/content_settings/content_settings_pref_provider.cc index a7f62fa..4a896b3 100644 --- a/chrome/browser/content_settings/content_settings_pref_provider.cc +++ b/chrome/browser/content_settings/content_settings_pref_provider.cc @@ -44,6 +44,7 @@ const char* kResourceTypeNames[] = { NULL, NULL, NULL, // Not used for Notifications + NULL, // Not used for Intents. }; COMPILE_ASSERT(arraysize(kResourceTypeNames) == CONTENT_SETTINGS_NUM_TYPES, resource_type_names_incorrect_size); @@ -57,6 +58,7 @@ const ContentSetting kDefaultSettings[] = { CONTENT_SETTING_BLOCK, // CONTENT_SETTINGS_TYPE_POPUPS CONTENT_SETTING_ASK, // CONTENT_SETTINGS_TYPE_GEOLOCATION CONTENT_SETTING_ASK, // CONTENT_SETTINGS_TYPE_NOTIFICATIONS + CONTENT_SETTING_ASK, // CONTENT_SETTINGS_TYPE_INTENTS }; COMPILE_ASSERT(arraysize(kDefaultSettings) == CONTENT_SETTINGS_NUM_TYPES, default_settings_incorrect_size); @@ -72,6 +74,7 @@ const char* kTypeNames[] = { // TODO(markusheintz): Refactoring in progress. Content settings exceptions // for notifications added next. "notifications", // Only used for default Notifications settings. + "intents", }; COMPILE_ASSERT(arraysize(kTypeNames) == CONTENT_SETTINGS_NUM_TYPES, type_names_incorrect_size); diff --git a/chrome/browser/content_settings/host_content_settings_map.cc b/chrome/browser/content_settings/host_content_settings_map.cc index 4bdb243..3d15073 100644 --- a/chrome/browser/content_settings/host_content_settings_map.cc +++ b/chrome/browser/content_settings/host_content_settings_map.cc @@ -407,6 +407,12 @@ void HostContentSettingsMap::ClearSettingsForOneType( // static bool HostContentSettingsMap::IsSettingAllowedForType( ContentSetting setting, ContentSettingsType content_type) { + // Intents content settings are hidden behind a switch for now. + if (content_type == CONTENT_SETTINGS_TYPE_INTENTS && + !CommandLine::ForCurrentProcess()->HasSwitch( + switches::kEnableWebIntents)) + return false; + // DEFAULT, ALLOW and BLOCK are always allowed. if (setting == CONTENT_SETTING_DEFAULT || setting == CONTENT_SETTING_ALLOW || @@ -422,6 +428,7 @@ bool HostContentSettingsMap::IsSettingAllowedForType( switches::kEnableClickToPlay)); case CONTENT_SETTINGS_TYPE_GEOLOCATION: case CONTENT_SETTINGS_TYPE_NOTIFICATIONS: + case CONTENT_SETTINGS_TYPE_INTENTS: return (setting == CONTENT_SETTING_ASK); default: return false; diff --git a/chrome/browser/content_settings/host_content_settings_map_unittest.cc b/chrome/browser/content_settings/host_content_settings_map_unittest.cc index e78baa4..b2623fc 100644 --- a/chrome/browser/content_settings/host_content_settings_map_unittest.cc +++ b/chrome/browser/content_settings/host_content_settings_map_unittest.cc @@ -150,6 +150,8 @@ TEST_F(HostContentSettingsMapTest, IndividualSettings) { CONTENT_SETTING_ASK; desired_settings.settings[CONTENT_SETTINGS_TYPE_NOTIFICATIONS] = CONTENT_SETTING_ASK; + desired_settings.settings[CONTENT_SETTINGS_TYPE_INTENTS] = + CONTENT_SETTING_ASK; ContentSettings settings = host_content_settings_map->GetContentSettings(host, host); EXPECT_TRUE(SettingsEqual(desired_settings, settings)); @@ -596,6 +598,8 @@ TEST_F(HostContentSettingsMapTest, NestedSettings) { CONTENT_SETTING_ASK; desired_settings.settings[CONTENT_SETTINGS_TYPE_NOTIFICATIONS] = CONTENT_SETTING_ASK; + desired_settings.settings[CONTENT_SETTINGS_TYPE_INTENTS] = + CONTENT_SETTING_ASK; ContentSettings settings = host_content_settings_map->GetContentSettings(host, host); EXPECT_TRUE(SettingsEqual(desired_settings, settings)); @@ -611,6 +615,8 @@ TEST_F(HostContentSettingsMapTest, NestedSettings) { settings.settings[CONTENT_SETTINGS_TYPE_GEOLOCATION]); EXPECT_EQ(desired_settings.settings[CONTENT_SETTINGS_TYPE_COOKIES], settings.settings[CONTENT_SETTINGS_TYPE_COOKIES]); + EXPECT_EQ(desired_settings.settings[CONTENT_SETTINGS_TYPE_INTENTS], + settings.settings[CONTENT_SETTINGS_TYPE_INTENTS]); } TEST_F(HostContentSettingsMapTest, OffTheRecord) { diff --git a/chrome/browser/resources/options/content_settings.html b/chrome/browser/resources/options/content_settings.html index 12af626..ea1fb11 100644 --- a/chrome/browser/resources/options/content_settings.html +++ b/chrome/browser/resources/options/content_settings.html @@ -211,5 +211,31 @@ i18n-content="manage_exceptions"> + +
+

+
+
+ +
+
+ +
+
+ +
+ +
+
diff --git a/chrome/browser/resources/options/content_settings.js b/chrome/browser/resources/options/content_settings.js index bc917cd..08c6015 100644 --- a/chrome/browser/resources/options/content_settings.js +++ b/chrome/browser/resources/options/content_settings.js @@ -60,7 +60,10 @@ cr.define('options', function() { }; if (!templateData.enable_click_to_play) - $('click_to_play').style.display = 'none'; + $('click_to_play').hidden = true; + + if (!templateData.enable_web_intents) + $('intent-filter').hidden = true; }, }; diff --git a/chrome/browser/resources/options/content_settings_exceptions_area.html b/chrome/browser/resources/options/content_settings_exceptions_area.html index 043c4e9..285645f 100644 --- a/chrome/browser/resources/options/content_settings_exceptions_area.html +++ b/chrome/browser/resources/options/content_settings_exceptions_area.html @@ -56,4 +56,7 @@
+
+ +
diff --git a/chrome/browser/ui/cocoa/content_settings/content_setting_bubble_cocoa_unittest.mm b/chrome/browser/ui/cocoa/content_settings/content_setting_bubble_cocoa_unittest.mm index 8cfd2d3..f69ece5 100644 --- a/chrome/browser/ui/cocoa/content_settings/content_setting_bubble_cocoa_unittest.mm +++ b/chrome/browser/ui/cocoa/content_settings/content_setting_bubble_cocoa_unittest.mm @@ -55,8 +55,9 @@ ContentSettingBubbleControllerTest::~ContentSettingBubbleControllerTest() { // Check that the bubble doesn't crash or leak for any settings type TEST_F(ContentSettingBubbleControllerTest, Init) { for (int i = 0; i < CONTENT_SETTINGS_NUM_TYPES; ++i) { - if (i == CONTENT_SETTINGS_TYPE_NOTIFICATIONS) - continue; // Notifications have no bubble. + if (i == CONTENT_SETTINGS_TYPE_NOTIFICATIONS || + i == CONTENT_SETTINGS_TYPE_INTENTS) + continue; // Notifications and web intents have no bubble. ContentSettingsType settingsType = static_cast(i); diff --git a/chrome/browser/ui/webui/options/content_settings_handler.cc b/chrome/browser/ui/webui/options/content_settings_handler.cc index 0992400..6ef0239 100644 --- a/chrome/browser/ui/webui/options/content_settings_handler.cc +++ b/chrome/browser/ui/webui/options/content_settings_handler.cc @@ -60,6 +60,7 @@ const ContentSettingsTypeNameEntry kContentSettingsTypeGroupNames[] = { {CONTENT_SETTINGS_TYPE_POPUPS, "popups"}, {CONTENT_SETTINGS_TYPE_GEOLOCATION, "location"}, {CONTENT_SETTINGS_TYPE_NOTIFICATIONS, "notifications"}, + {CONTENT_SETTINGS_TYPE_INTENTS, "intents"}, }; ContentSettingsType ContentSettingsTypeFromGroupName(const std::string& name) { @@ -247,6 +248,12 @@ void ContentSettingsHandler::GetLocalizedValues( { "notifications_allow", IDS_NOTIFICATIONS_ALLOW_RADIO }, { "notifications_ask", IDS_NOTIFICATIONS_ASK_RADIO }, { "notifications_block", IDS_NOTIFICATIONS_BLOCK_RADIO }, + // Intents filter. + { "intentsTabLabel", IDS_INTENTS_TAB_LABEL }, + { "intentsAllow", IDS_INTENTS_ALLOW_RADIO }, + { "intentsAsk", IDS_INTENTS_ASK_RADIO }, + { "intentsBlock", IDS_INTENTS_BLOCK_RADIO }, + { "intents_header", IDS_INTENTS_HEADER }, }; RegisterStrings(localized_strings, resources, arraysize(resources)); @@ -255,6 +262,9 @@ void ContentSettingsHandler::GetLocalizedValues( localized_strings->SetBoolean("enable_click_to_play", CommandLine::ForCurrentProcess()->HasSwitch( switches::kEnableClickToPlay)); + localized_strings->SetBoolean("enable_web_intents", + CommandLine::ForCurrentProcess()->HasSwitch( + switches::kEnableWebIntents)); } void ContentSettingsHandler::Initialize() { diff --git a/chrome/common/content_settings_types.h b/chrome/common/content_settings_types.h index f9ac455..4c450ea 100644 --- a/chrome/common/content_settings_types.h +++ b/chrome/common/content_settings_types.h @@ -19,6 +19,7 @@ enum ContentSettingsType { CONTENT_SETTINGS_TYPE_POPUPS, CONTENT_SETTINGS_TYPE_GEOLOCATION, CONTENT_SETTINGS_TYPE_NOTIFICATIONS, + CONTENT_SETTINGS_TYPE_INTENTS, CONTENT_SETTINGS_NUM_TYPES }; -- cgit v1.1