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

Side by Side Diff: chrome/browser/ui/content_settings/content_setting_bubble_model.cc

Issue 2169453003: Hide protocol handler icon in location bar after user is done (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: also remove header include Created 4 years, 5 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/ui/content_settings/content_setting_bubble_model.h" 5 #include "chrome/browser/ui/content_settings/content_setting_bubble_model.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/macros.h" 10 #include "base/macros.h"
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 219
220 ContentSetting block_setting_; 220 ContentSetting block_setting_;
221 int selected_item_; 221 int selected_item_;
222 }; 222 };
223 223
224 ContentSettingSingleRadioGroup::ContentSettingSingleRadioGroup( 224 ContentSettingSingleRadioGroup::ContentSettingSingleRadioGroup(
225 Delegate* delegate, 225 Delegate* delegate,
226 WebContents* web_contents, 226 WebContents* web_contents,
227 Profile* profile, 227 Profile* profile,
228 ContentSettingsType content_type) 228 ContentSettingsType content_type)
229 : ContentSettingSimpleBubbleModel(delegate, web_contents, profile, 229 : ContentSettingSimpleBubbleModel(delegate,
230 web_contents,
231 profile,
230 content_type), 232 content_type),
231 block_setting_(CONTENT_SETTING_BLOCK), 233 block_setting_(CONTENT_SETTING_BLOCK),
232 selected_item_(0) { 234 selected_item_(0) {
233 SetRadioGroup(); 235 SetRadioGroup();
234 } 236 }
235 237
236 ContentSettingSingleRadioGroup::~ContentSettingSingleRadioGroup() { 238 ContentSettingSingleRadioGroup::~ContentSettingSingleRadioGroup() {
237 if (settings_changed()) { 239 if (settings_changed()) {
238 ContentSetting setting = 240 ContentSetting setting =
239 selected_item_ == kAllowButtonIndex ? 241 selected_item_ == kAllowButtonIndex ?
(...skipping 760 matching lines...) Expand 10 before | Expand all | Expand 10 after
1000 ContentSettingRPHBubbleModel::ContentSettingRPHBubbleModel( 1002 ContentSettingRPHBubbleModel::ContentSettingRPHBubbleModel(
1001 Delegate* delegate, 1003 Delegate* delegate,
1002 WebContents* web_contents, 1004 WebContents* web_contents,
1003 Profile* profile, 1005 Profile* profile,
1004 ProtocolHandlerRegistry* registry) 1006 ProtocolHandlerRegistry* registry)
1005 : ContentSettingSimpleBubbleModel(delegate, 1007 : ContentSettingSimpleBubbleModel(delegate,
1006 web_contents, 1008 web_contents,
1007 profile, 1009 profile,
1008 CONTENT_SETTINGS_TYPE_PROTOCOL_HANDLERS), 1010 CONTENT_SETTINGS_TYPE_PROTOCOL_HANDLERS),
1009 selected_item_(0), 1011 selected_item_(0),
1012 interacted_(false),
1010 registry_(registry), 1013 registry_(registry),
1011 pending_handler_(ProtocolHandler::EmptyProtocolHandler()), 1014 pending_handler_(ProtocolHandler::EmptyProtocolHandler()),
1012 previous_handler_(ProtocolHandler::EmptyProtocolHandler()) { 1015 previous_handler_(ProtocolHandler::EmptyProtocolHandler()) {
1013 TabSpecificContentSettings* content_settings = 1016 TabSpecificContentSettings* content_settings =
1014 TabSpecificContentSettings::FromWebContents(web_contents); 1017 TabSpecificContentSettings::FromWebContents(web_contents);
1015 pending_handler_ = content_settings->pending_protocol_handler(); 1018 pending_handler_ = content_settings->pending_protocol_handler();
1016 previous_handler_ = content_settings->previous_protocol_handler(); 1019 previous_handler_ = content_settings->previous_protocol_handler();
1017 1020
1018 base::string16 protocol; 1021 base::string16 protocol;
1019 if (pending_handler_.protocol() == "mailto") { 1022 if (pending_handler_.protocol() == "mailto") {
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
1061 else if (setting == CONTENT_SETTING_BLOCK) 1064 else if (setting == CONTENT_SETTING_BLOCK)
1062 radio_group.default_item = RPH_BLOCK; 1065 radio_group.default_item = RPH_BLOCK;
1063 else 1066 else
1064 radio_group.default_item = RPH_IGNORE; 1067 radio_group.default_item = RPH_IGNORE;
1065 1068
1066 selected_item_ = radio_group.default_item; 1069 selected_item_ = radio_group.default_item;
1067 set_radio_group_enabled(true); 1070 set_radio_group_enabled(true);
1068 set_radio_group(radio_group); 1071 set_radio_group(radio_group);
1069 } 1072 }
1070 1073
1074 ContentSettingRPHBubbleModel::~ContentSettingRPHBubbleModel() {
1075 if (!web_contents() || !interacted_)
1076 return;
1077
1078 // The user has one chance to deal with the RPH content setting UI,
1079 // then we remove it.
1080 TabSpecificContentSettings::FromWebContents(web_contents())->
1081 ClearPendingProtocolHandler();
1082 content::NotificationService::current()->Notify(
1083 chrome::NOTIFICATION_WEB_CONTENT_SETTINGS_CHANGED,
1084 content::Source<WebContents>(web_contents()),
1085 content::NotificationService::NoDetails());
1086 }
1087
1071 void ContentSettingRPHBubbleModel::OnRadioClicked(int radio_index) { 1088 void ContentSettingRPHBubbleModel::OnRadioClicked(int radio_index) {
1072 if (selected_item_ == radio_index) 1089 if (selected_item_ == radio_index)
1073 return; 1090 return;
1074 1091
1092 interacted_ = true;
1075 selected_item_ = radio_index; 1093 selected_item_ = radio_index;
1076 1094
1077 if (radio_index == RPH_ALLOW) 1095 if (radio_index == RPH_ALLOW)
1078 RegisterProtocolHandler(); 1096 RegisterProtocolHandler();
1079 else if (radio_index == RPH_BLOCK) 1097 else if (radio_index == RPH_BLOCK)
1080 UnregisterProtocolHandler(); 1098 UnregisterProtocolHandler();
1081 else if (radio_index == RPH_IGNORE) 1099 else if (radio_index == RPH_IGNORE)
1082 IgnoreProtocolHandler(); 1100 IgnoreProtocolHandler();
1083 else 1101 else
1084 NOTREACHED(); 1102 NOTREACHED();
1085 } 1103 }
1086 1104
1087 void ContentSettingRPHBubbleModel::OnDoneClicked() { 1105 void ContentSettingRPHBubbleModel::OnDoneClicked() {
1088 if (!web_contents()) 1106 interacted_ = true;
1089 return;
1090
1091 // The user has one chance to deal with the RPH content setting UI,
1092 // then we remove it.
1093 TabSpecificContentSettings::FromWebContents(web_contents())->
1094 ClearPendingProtocolHandler();
1095 content::NotificationService::current()->Notify(
1096 chrome::NOTIFICATION_WEB_CONTENT_SETTINGS_CHANGED,
1097 content::Source<WebContents>(web_contents()),
1098 content::NotificationService::NoDetails());
1099 } 1107 }
1100 1108
1101 void ContentSettingRPHBubbleModel::RegisterProtocolHandler() { 1109 void ContentSettingRPHBubbleModel::RegisterProtocolHandler() {
1102 if (!web_contents()) 1110 if (!web_contents())
1103 return; 1111 return;
1104 1112
1105 // A no-op if the handler hasn't been ignored, but needed in case the user 1113 // A no-op if the handler hasn't been ignored, but needed in case the user
1106 // selects sequences like register/ignore/register. 1114 // selects sequences like register/ignore/register.
1107 registry_->RemoveIgnoredHandler(pending_handler_); 1115 registry_->RemoveIgnoredHandler(pending_handler_);
1108 1116
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
1331 ContentSettingBubbleModel::AsSimpleBubbleModel() { 1339 ContentSettingBubbleModel::AsSimpleBubbleModel() {
1332 // In general, bubble models might not inherit from the simple bubble model. 1340 // In general, bubble models might not inherit from the simple bubble model.
1333 return nullptr; 1341 return nullptr;
1334 } 1342 }
1335 1343
1336 ContentSettingMediaStreamBubbleModel* 1344 ContentSettingMediaStreamBubbleModel*
1337 ContentSettingBubbleModel::AsMediaStreamBubbleModel() { 1345 ContentSettingBubbleModel::AsMediaStreamBubbleModel() {
1338 // In general, bubble models might not inherit from the media bubble model. 1346 // In general, bubble models might not inherit from the media bubble model.
1339 return nullptr; 1347 return nullptr;
1340 } 1348 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698