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 bfd711a8d0e036d125082fc931d49a5f7ec52133..e9e58cd5ef5016120525d24a64e04cc4c5f196a7 100644 |
| --- a/chrome/browser/ui/content_settings/content_setting_bubble_model.cc |
| +++ b/chrome/browser/ui/content_settings/content_setting_bubble_model.cc |
| @@ -226,7 +226,9 @@ ContentSettingSingleRadioGroup::ContentSettingSingleRadioGroup( |
| WebContents* web_contents, |
| Profile* profile, |
| ContentSettingsType content_type) |
| - : ContentSettingSimpleBubbleModel(delegate, web_contents, profile, |
| + : ContentSettingSimpleBubbleModel(delegate, |
| + web_contents, |
| + profile, |
| content_type), |
| block_setting_(CONTENT_SETTING_BLOCK), |
| selected_item_(0) { |
| @@ -1007,6 +1009,7 @@ ContentSettingRPHBubbleModel::ContentSettingRPHBubbleModel( |
| profile, |
| CONTENT_SETTINGS_TYPE_PROTOCOL_HANDLERS), |
| selected_item_(0), |
| + interacted_(false), |
| registry_(registry), |
| pending_handler_(ProtocolHandler::EmptyProtocolHandler()), |
| previous_handler_(ProtocolHandler::EmptyProtocolHandler()) { |
| @@ -1068,10 +1071,25 @@ ContentSettingRPHBubbleModel::ContentSettingRPHBubbleModel( |
| set_radio_group(radio_group); |
| } |
| +ContentSettingRPHBubbleModel::~ContentSettingRPHBubbleModel() { |
| + if (!web_contents() || !interacted_) |
| + return; |
|
msw
2016/07/20 20:50:16
Early return in a dtor is a bit odd... can you ins
Evan Stade
2016/07/20 20:56:46
Is there a reason not to early return in a dtor? M
msw
2016/07/20 21:15:47
Just thinking of someone thoughtlessly adding code
Evan Stade
2016/07/20 22:11:05
That could happen, but isn't that possible for any
|
| + |
| + // The user has one chance to deal with the RPH content setting UI, |
| + // then we remove it. |
| + TabSpecificContentSettings::FromWebContents(web_contents())-> |
| + ClearPendingProtocolHandler(); |
| + content::NotificationService::current()->Notify( |
| + chrome::NOTIFICATION_WEB_CONTENT_SETTINGS_CHANGED, |
| + content::Source<WebContents>(web_contents()), |
| + content::NotificationService::NoDetails()); |
| +} |
| + |
| void ContentSettingRPHBubbleModel::OnRadioClicked(int radio_index) { |
| if (selected_item_ == radio_index) |
| return; |
| + interacted_ = true; |
| selected_item_ = radio_index; |
| if (radio_index == RPH_ALLOW) |
| @@ -1085,17 +1103,7 @@ void ContentSettingRPHBubbleModel::OnRadioClicked(int radio_index) { |
| } |
| void ContentSettingRPHBubbleModel::OnDoneClicked() { |
| - if (!web_contents()) |
| - return; |
| - |
| - // The user has one chance to deal with the RPH content setting UI, |
| - // then we remove it. |
| - TabSpecificContentSettings::FromWebContents(web_contents())-> |
| - ClearPendingProtocolHandler(); |
| - content::NotificationService::current()->Notify( |
| - chrome::NOTIFICATION_WEB_CONTENT_SETTINGS_CHANGED, |
| - content::Source<WebContents>(web_contents()), |
| - content::NotificationService::NoDetails()); |
| + interacted_ = true; |
| } |
| void ContentSettingRPHBubbleModel::RegisterProtocolHandler() { |