Chromium Code Reviews| 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 f7006a56ae0d1c154aff9ab6edb4e2530cebcda5..07efc6e5bb65377db5b473372bada7c0dbdf77ce 100644 |
| --- a/chrome/browser/ui/content_settings/content_setting_bubble_model.cc |
| +++ b/chrome/browser/ui/content_settings/content_setting_bubble_model.cc |
| @@ -8,6 +8,7 @@ |
| #include "chrome/browser/content_settings/content_settings_utils.h" |
| #include "chrome/browser/content_settings/cookie_settings.h" |
| #include "chrome/browser/content_settings/tab_specific_content_settings.h" |
| +#include "chrome/browser/custom_handlers/protocol_handler_registry.h" |
| #include "chrome/browser/favicon/favicon_tab_helper.h" |
| #include "chrome/browser/infobars/infobar_tab_helper.h" |
| #include "chrome/browser/prefs/pref_service.h" |
| @@ -125,6 +126,8 @@ class ContentSettingTitleAndLinkModel : public ContentSettingBubbleModel { |
| {CONTENT_SETTINGS_TYPE_PLUGINS, IDS_BLOCKED_PLUGINS_LINK}, |
| {CONTENT_SETTINGS_TYPE_POPUPS, IDS_BLOCKED_POPUPS_LINK}, |
| {CONTENT_SETTINGS_TYPE_GEOLOCATION, IDS_GEOLOCATION_BUBBLE_MANAGE_LINK}, |
| + {CONTENT_SETTINGS_TYPE_REGISTER_PROTOCOL_HANDLER, |
| + IDS_HANDLERS_BUBBLE_MANAGE_LINK} |
| }; |
| set_manage_link(l10n_util::GetStringUTF8( |
| GetIdForContentType(kLinkIDs, arraysize(kLinkIDs), content_type()))); |
| @@ -510,6 +513,96 @@ class ContentSettingDomainListBubbleModel |
| } |
| }; |
| +class ContentSettingRPHBubbleModel : public ContentSettingTitleAndLinkModel { |
| + public: |
| + ContentSettingRPHBubbleModel(Delegate* delegate, |
| + TabContents* tab_contents, |
| + Profile* profile, |
| + ContentSettingsType content_type) |
| + : ContentSettingTitleAndLinkModel( |
| + delegate, tab_contents, profile, content_type) { |
| + DCHECK_EQ(CONTENT_SETTINGS_TYPE_REGISTER_PROTOCOL_HANDLER, content_type); |
| + |
| + TabSpecificContentSettings* content_settings = |
| + tab_contents->content_settings(); |
| + const ProtocolHandler& handler = |
| + content_settings->UngesturedProtocolHandler(); |
| + |
| + string16 protocol = UTF8ToUTF16(handler.protocol()); |
| + if (handler.protocol() == "mailto") { |
| + protocol = l10n_util::GetStringUTF16( |
| + IDS_REGISTER_PROTOCOL_HANDLER_MAILTO_NAME); |
| + } |
| + if (handler.protocol() == "webcal") { |
| + protocol = l10n_util::GetStringUTF16( |
| + IDS_REGISTER_PROTOCOL_HANDLER_WEBCAL_NAME); |
| + } |
| + if (content_settings->OldRegisterProtocolHandlerTitle().empty()) { |
| + set_title(l10n_util::GetStringFUTF8( |
| + IDS_REGISTER_PROTOCOL_HANDLER_CONFIRM, |
| + handler.title(), UTF8ToUTF16(handler.url().host()), |
| + protocol)); |
| + } else { |
| + set_title(l10n_util::GetStringFUTF8( |
| + IDS_REGISTER_PROTOCOL_HANDLER_CONFIRM_REPLACE, |
| + handler.title(), UTF8ToUTF16(handler.url().host()), |
| + protocol, content_settings->OldRegisterProtocolHandlerTitle())); |
| + } |
| + |
| + std::string radio_allow_label = |
| + l10n_util::GetStringFUTF8(IDS_REGISTER_PROTOCOL_HANDLER_ACCEPT, |
| + handler.title()); |
| + std::string radio_block_label = |
|
koz (OOO until 15th September)
2012/06/21 01:50:53
radio_block_label -> radio_deny_label
Greg Billock
2012/06/21 19:59:11
Done.
|
| + l10n_util::GetStringUTF8(IDS_REGISTER_PROTOCOL_HANDLER_DENY); |
| + |
| + /* |
| + GURL url = tab_contents->web_contents()->GetURL(); |
| + RadioGroup radio_group; |
| + radio_group.url = url; |
| + |
| + radio_group.radio_items.push_back(radio_allow_label); |
| + radio_group.radio_items.push_back(radio_block_label); |
| + radio_group.default_item = 1; |
| + selected_item_ = radio_group.default_item; |
| + set_radio_group_enabled(true); |
| + set_radio_group(radio_group); |
| + */ |
| + |
| + set_custom_link(radio_allow_label); |
| + set_custom_link_enabled(true); |
| + } |
| + |
| + virtual void OnCustomLinkClicked() { |
| + RegisterProtocolHandler(); |
| + } |
| + |
| + virtual void OnRadioClicked(int radio_index) { |
| + if (selected_item_ != radio_index) { |
| + selected_item_ = radio_index; |
| + if (radio_index == 0) { |
| + RegisterProtocolHandler(); |
| + } else { |
| + UnregisterProtocolHandler(); |
|
koz (OOO until 15th September)
2012/06/21 01:50:53
Is the idea here that there are two radio boxes th
Greg Billock
2012/06/21 19:59:11
Ah, that's a good point. I'll just save the whole
|
| + } |
| + } |
| + } |
| + |
| + void RegisterProtocolHandler() { |
| + profile()->GetProtocolHandlerRegistry()->OnAcceptRegisterProtocolHandler( |
| + tab_contents()->content_settings()->UngesturedProtocolHandler()); |
| + } |
| + |
| + void UnregisterProtocolHandler() { |
| + profile()->GetProtocolHandlerRegistry()->OnDenyRegisterProtocolHandler( |
| + tab_contents()->content_settings()->UngesturedProtocolHandler()); |
| + } |
| + |
| + private: |
| + int selected_item_; |
| + bool registered_; |
| +}; |
| + |
| + |
| // static |
| ContentSettingBubbleModel* |
| ContentSettingBubbleModel::CreateContentSettingBubbleModel( |
| @@ -533,6 +626,10 @@ ContentSettingBubbleModel* |
| return new ContentSettingPluginBubbleModel(delegate, tab_contents, profile, |
| content_type); |
| } |
| + if (content_type == CONTENT_SETTINGS_TYPE_REGISTER_PROTOCOL_HANDLER) { |
| + return new ContentSettingRPHBubbleModel(delegate, tab_contents, profile, |
| + content_type); |
| + } |
| return new ContentSettingSingleRadioGroup(delegate, tab_contents, profile, |
| content_type); |
| } |