Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(746)

Unified Diff: chrome/browser/ui/content_settings/content_setting_bubble_model.cc

Issue 319553008: Updated Plugin bubble model to add "learn more" link and to appear with a sliding yellow thing (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed indentation and style issues Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/content_settings/content_setting_bubble_model.cc
diff --git a/chrome/browser/ui/content_settings/content_setting_bubble_model.cc b/chrome/browser/ui/content_settings/content_setting_bubble_model.cc
index 2acc49698b1cf1f11cbe5ec009093b2ccdbdab24..e7fd0373e44f0ff9db284767fdc1b20f02226664 100644
--- a/chrome/browser/ui/content_settings/content_setting_bubble_model.cc
+++ b/chrome/browser/ui/content_settings/content_setting_bubble_model.cc
@@ -50,6 +50,7 @@ using content_settings::SETTING_SOURCE_NONE;
namespace {
const int kAllowButtonIndex = 0;
+const int kAllowOnceButtonIndex = 1;
struct ContentSettingsTypeIdEntry {
ContentSettingsType type;
@@ -95,6 +96,7 @@ ContentSettingTitleAndLinkModel::ContentSettingTitleAndLinkModel(
DCHECK_NE(content_type, CONTENT_SETTINGS_TYPE_NOTIFICATIONS);
SetTitle();
SetManageLink();
+ SetLearnMoreLink();
}
void ContentSettingTitleAndLinkModel::SetTitle() {
@@ -156,6 +158,22 @@ void ContentSettingTitleAndLinkModel::OnManageLinkClicked() {
delegate_->ShowContentSettingsPage(content_type());
}
+void ContentSettingTitleAndLinkModel::SetLearnMoreLink() {
+ static const ContentSettingsTypeIdEntry kLearnMoreLinkIDs[] = {
+ {CONTENT_SETTINGS_TYPE_PLUGINS, IDS_LEARN_MORE},
+ };
+ int learn_more_link_id =
+ GetIdForContentType(kLearnMoreLinkIDs, arraysize(kLearnMoreLinkIDs),
+ content_type());
+ if (learn_more_link_id)
+ set_learn_more_link(l10n_util::GetStringUTF8(learn_more_link_id));
+}
+
+void ContentSettingTitleAndLinkModel::OnLearnMoreLinkClicked() {
+ if (delegate_)
+ delegate_->ShowLearnMorePage(content_type());
+}
+
class ContentSettingTitleLinkAndCustomModel
: public ContentSettingTitleAndLinkModel {
public:
@@ -183,7 +201,6 @@ ContentSettingTitleLinkAndCustomModel::ContentSettingTitleLinkAndCustomModel(
void ContentSettingTitleLinkAndCustomModel::SetCustomLink() {
static const ContentSettingsTypeIdEntry kCustomIDs[] = {
{CONTENT_SETTINGS_TYPE_COOKIES, IDS_BLOCKED_COOKIES_INFO},
- {CONTENT_SETTINGS_TYPE_PLUGINS, IDS_BLOCKED_PLUGINS_LOAD_ALL},
{CONTENT_SETTINGS_TYPE_MIXEDSCRIPT, IDS_ALLOW_INSECURE_CONTENT_BUTTON},
};
int custom_link_id =
@@ -228,16 +245,26 @@ ContentSettingSingleRadioGroup::ContentSettingSingleRadioGroup(
ContentSettingSingleRadioGroup::~ContentSettingSingleRadioGroup() {
if (settings_changed()) {
- ContentSetting setting =
- selected_item_ == kAllowButtonIndex ?
- CONTENT_SETTING_ALLOW :
- block_setting_;
+ ContentSetting setting;
+ if (content_type() == CONTENT_SETTINGS_TYPE_PLUGINS) {
+ if (selected_item_ == kAllowButtonIndex)
+ setting = CONTENT_SETTING_ALLOW;
+ else if (selected_item_ == kAllowOnceButtonIndex)
+ setting = CONTENT_SETTING_DEFAULT;
+ else
+ setting = block_setting_;
+ TabSpecificContentSettings::FromWebContents(web_contents())->
+ set_plugin_bubble_setting(setting);
+ } else {
+ setting = selected_item_ == kAllowButtonIndex ?
+ CONTENT_SETTING_ALLOW : block_setting_;
+ }
AddException(setting);
}
}
bool ContentSettingSingleRadioGroup::settings_changed() const {
- return selected_item_ != bubble_content().radio_group.default_item;
+ return selected_item_ != bubble_content().radio_group.default_item;
}
// Initialize the radio group by setting the appropriate labels for the
@@ -325,7 +352,18 @@ void ContentSettingSingleRadioGroup::SetRadioGroup() {
content_type()));
}
+ static const ContentSettingsTypeIdEntry kBlockedAllowOnceIDs[] = {
+ {CONTENT_SETTINGS_TYPE_PLUGINS, IDS_BLOCKED_PLUGINS_LOAD_ALL},
+ };
+
+ std::string radio_allow_once_label;
+ radio_allow_once_label = l10n_util::GetStringUTF8(
+ GetIdForContentType(kBlockedAllowOnceIDs, arraysize(kBlockedAllowOnceIDs),
+ content_type()));
+
radio_group.radio_items.push_back(radio_allow_label);
+ if (content_type() == CONTENT_SETTINGS_TYPE_PLUGINS)
+ radio_group.radio_items.push_back(radio_allow_once_label);
radio_group.radio_items.push_back(radio_block_label);
ContentSetting setting;
SettingSource setting_source = SETTING_SOURCE_NONE;
@@ -341,7 +379,10 @@ void ContentSettingSingleRadioGroup::SetRadioGroup() {
HostContentSettingsMap* map = profile()->GetHostContentSettingsMap();
scoped_ptr<base::Value> value(map->GetWebsiteSetting(
url, url, content_type(), std::string(), &info));
- setting = content_settings::ValueToContentSetting(value.get());
+ if (content_type() == CONTENT_SETTINGS_TYPE_PLUGINS)
+ setting = content_settings->plugin_bubble_setting();
+ else
+ setting = content_settings::ValueToContentSetting(value.get());
setting_source = info.source;
setting_is_wildcard =
info.primary_pattern == ContentSettingsPattern::Wildcard() &&
@@ -354,12 +395,17 @@ void ContentSettingSingleRadioGroup::SetRadioGroup() {
// In the corner case of unrecognized plugins (which are now blocked by
// default) we indicate the blocked state in the UI and allow the user to
// whitelist.
- radio_group.default_item = 1;
+ radio_group.default_item = 2;
+ } else if (content_type() == CONTENT_SETTINGS_TYPE_PLUGINS &&
+ setting == CONTENT_SETTING_DEFAULT) {
+ radio_group.default_item = kAllowOnceButtonIndex;
} else if (setting == CONTENT_SETTING_ALLOW) {
radio_group.default_item = kAllowButtonIndex;
// |block_setting_| is already set to |CONTENT_SETTING_BLOCK|.
} else {
- radio_group.default_item = 1;
+ content_type() == CONTENT_SETTINGS_TYPE_PLUGINS ?
+ radio_group.default_item = 2 :
+ radio_group.default_item = 1;
block_setting_ = setting;
}
@@ -455,6 +501,7 @@ ContentSettingPluginBubbleModel::ContentSettingPluginBubbleModel(
// Disable the "Run all plugins this time" link if the setting is managed and
// can't be controlled by the user or if the user already clicked on the link
// and ran all plugins.
+ // TODO(radhikabhar) this might not be needed if we switch to the new UI
set_custom_link_enabled(!setting_is_managed() &&
web_contents &&
TabSpecificContentSettings::FromWebContents(
@@ -464,8 +511,9 @@ ContentSettingPluginBubbleModel::ContentSettingPluginBubbleModel(
ContentSettingPluginBubbleModel::~ContentSettingPluginBubbleModel() {
if (settings_changed()) {
// If the user elected to allow all plugins then run plugins at this time.
- if (selected_item() == kAllowButtonIndex)
- OnCustomLinkClicked();
+ if (selected_item() == kAllowButtonIndex
+ || selected_item() == kAllowOnceButtonIndex)
+ OnCustomLinkClicked();
}
}

Powered by Google App Engine
This is Rietveld 408576698