Commit e2aed4aa authored by csharrison's avatar csharrison Committed by Commit bot

[subresource_filter] Add custom strings/behavior on Desktop Page Info

This CL adds the following to the OIB (Page Info):
 - The menu only has two items (no default), with custom strings
 - The selected text uses user managed strings instead of default string
   (e.g. "Block" instead of "Block (default)"

BUG=689487

Review-Url: https://codereview.chromium.org/2884813003
Cr-Commit-Position: refs/heads/master@{#473704}
parent fc395879
...@@ -288,6 +288,10 @@ base::string16 PageInfoUI::PermissionActionToUIString( ...@@ -288,6 +288,10 @@ base::string16 PageInfoUI::PermissionActionToUIString(
NOTREACHED(); NOTREACHED();
return base::string16(); return base::string16();
} }
// The subresource filter permission uses the user managed strings
// (i.e. Allow / Block).
if (type == CONTENT_SETTINGS_TYPE_SUBRESOURCE_FILTER)
button_text_ids = kPermissionButtonTextIDUserManaged;
int button_text_id = button_text_ids[effective_setting]; int button_text_id = button_text_ids[effective_setting];
DCHECK_NE(button_text_id, kInvalidResourceID); DCHECK_NE(button_text_id, kInvalidResourceID);
return l10n_util::GetStringUTF16(button_text_id); return l10n_util::GetStringUTF16(button_text_id);
......
...@@ -70,7 +70,9 @@ PermissionMenuModel::PermissionMenuModel(Profile* profile, ...@@ -70,7 +70,9 @@ PermissionMenuModel::PermissionMenuModel(Profile* profile,
effective_default_setting, permission_.source); effective_default_setting, permission_.source);
} }
AddCheckItem(CONTENT_SETTING_DEFAULT, label); // The subresource filter permission does not display the default menu item.
if (permission_.type != CONTENT_SETTINGS_TYPE_SUBRESOURCE_FILTER)
AddCheckItem(CONTENT_SETTING_DEFAULT, label);
// Retrieve the string to show for allowing the permission. // Retrieve the string to show for allowing the permission.
// Notifications does not support CONTENT_SETTING_ALLOW in incognito. // Notifications does not support CONTENT_SETTING_ALLOW in incognito.
...@@ -104,6 +106,10 @@ PermissionMenuModel::PermissionMenuModel(Profile* profile, ...@@ -104,6 +106,10 @@ PermissionMenuModel::PermissionMenuModel(Profile* profile,
// Retrieve the string to show for blocking the permission. // Retrieve the string to show for blocking the permission.
label = l10n_util::GetStringUTF16(IDS_PAGE_INFO_MENU_ITEM_BLOCK); label = l10n_util::GetStringUTF16(IDS_PAGE_INFO_MENU_ITEM_BLOCK);
if (permission_.type == CONTENT_SETTINGS_TYPE_SUBRESOURCE_FILTER) {
label = l10n_util::GetStringUTF16(
IDS_PAGE_INFO_MENU_ITEM_SUBRESOURCE_FILTER_BLOCK);
}
if (ui::MaterialDesignController::IsSecondaryUiMaterial()) { if (ui::MaterialDesignController::IsSecondaryUiMaterial()) {
label = PageInfoUI::PermissionActionToUIString( label = PageInfoUI::PermissionActionToUIString(
profile, info.type, CONTENT_SETTING_BLOCK, effective_default_setting, profile, info.type, CONTENT_SETTING_BLOCK, effective_default_setting,
......
...@@ -88,3 +88,20 @@ TEST_F(PermissionMenuModelTest, TestIncognitoNotifications) { ...@@ -88,3 +88,20 @@ TEST_F(PermissionMenuModelTest, TestIncognitoNotifications) {
permission, callback.callback()); permission, callback.callback());
EXPECT_EQ(2, incognito_model.GetItemCount()); EXPECT_EQ(2, incognito_model.GetItemCount());
} }
TEST_F(PermissionMenuModelTest, TestSubresourceFilter) {
TestCallback callback;
PageInfoUI::PermissionInfo permission;
permission.type = CONTENT_SETTINGS_TYPE_SUBRESOURCE_FILTER;
permission.setting = CONTENT_SETTING_BLOCK;
permission.default_setting = CONTENT_SETTING_BLOCK;
permission.is_incognito = false;
PermissionMenuModel model(profile(), GURL("http://www.google.com"),
permission, callback.callback());
EXPECT_EQ(2, model.GetItemCount());
permission.is_incognito = true;
PermissionMenuModel incognito_model(profile(), GURL("https://www.google.com"),
permission, callback.callback());
EXPECT_EQ(2, incognito_model.GetItemCount());
}
...@@ -260,6 +260,10 @@ ...@@ -260,6 +260,10 @@
<message name="IDS_PAGE_INFO_MENU_ITEM_DETECT_IMPORTANT_CONTENT" desc="The text of the menu item of a permissions menu on the Page Info UI that sets the setting to detect important content."> <message name="IDS_PAGE_INFO_MENU_ITEM_DETECT_IMPORTANT_CONTENT" desc="The text of the menu item of a permissions menu on the Page Info UI that sets the setting to detect important content.">
Always detect important content on this site Always detect important content on this site
</message> </message>
<!-- IDS_PAGE_INFO_MENU_ITEM_SUBRESOURCE_FILTER_BLOCK is currently the same as IDS_PAGE_INFO_MENU_ITEM_BLOCK, but we use a different string identifier in the code for the flexibility to change it in the future. -->
<message name="IDS_PAGE_INFO_MENU_ITEM_SUBRESOURCE_FILTER_BLOCK" desc="The text of the menu item of a permissions menu on the Page Info UI for the subresource filter permission in Block mode">
Always block on this site
</message>
<!-- UI for device access granted to the site using the device chooser (e.g. USB, Bluetooth) --> <!-- UI for device access granted to the site using the device chooser (e.g. USB, Bluetooth) -->
<message name="IDS_PAGE_INFO_USB_DEVICE_LABEL" desc="The label used to describe a USB device that the user has granted the site permission to access."> <message name="IDS_PAGE_INFO_USB_DEVICE_LABEL" desc="The label used to describe a USB device that the user has granted the site permission to access.">
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment