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

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

Issue 2103733002: Handle WebContents going away in content settings bubbles. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 958 matching lines...) Expand 10 before | Expand all | Expand 10 after
969 delegate, 969 delegate,
970 web_contents, 970 web_contents,
971 profile, 971 profile,
972 CONTENT_SETTINGS_TYPE_MIXEDSCRIPT) { 972 CONTENT_SETTINGS_TYPE_MIXEDSCRIPT) {
973 content_settings::RecordMixedScriptAction( 973 content_settings::RecordMixedScriptAction(
974 content_settings::MIXED_SCRIPT_ACTION_DISPLAYED_BUBBLE); 974 content_settings::MIXED_SCRIPT_ACTION_DISPLAYED_BUBBLE);
975 set_custom_link_enabled(true); 975 set_custom_link_enabled(true);
976 } 976 }
977 977
978 void ContentSettingMixedScriptBubbleModel::OnCustomLinkClicked() { 978 void ContentSettingMixedScriptBubbleModel::OnCustomLinkClicked() {
979 DCHECK(web_contents()); 979 if (!web_contents())
980 return;
981
980 web_contents()->SendToAllFrames( 982 web_contents()->SendToAllFrames(
981 new ChromeViewMsg_SetAllowRunningInsecureContent(MSG_ROUTING_NONE, true)); 983 new ChromeViewMsg_SetAllowRunningInsecureContent(MSG_ROUTING_NONE, true));
982 web_contents()->GetMainFrame()->Send(new ChromeViewMsg_ReloadFrame( 984 web_contents()->GetMainFrame()->Send(new ChromeViewMsg_ReloadFrame(
983 web_contents()->GetMainFrame()->GetRoutingID())); 985 web_contents()->GetMainFrame()->GetRoutingID()));
984 986
985 content_settings::RecordMixedScriptAction( 987 content_settings::RecordMixedScriptAction(
986 content_settings::MIXED_SCRIPT_ACTION_CLICKED_ALLOW); 988 content_settings::MIXED_SCRIPT_ACTION_CLICKED_ALLOW);
987 content_settings::RecordMixedScriptActionWithRAPPOR( 989 content_settings::RecordMixedScriptActionWithRAPPOR(
988 content_settings::MIXED_SCRIPT_ACTION_CLICKED_ALLOW, 990 content_settings::MIXED_SCRIPT_ACTION_CLICKED_ALLOW,
989 web_contents()->GetLastCommittedURL()); 991 web_contents()->GetLastCommittedURL());
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
1072 RegisterProtocolHandler(); 1074 RegisterProtocolHandler();
1073 else if (radio_index == RPH_BLOCK) 1075 else if (radio_index == RPH_BLOCK)
1074 UnregisterProtocolHandler(); 1076 UnregisterProtocolHandler();
1075 else if (radio_index == RPH_IGNORE) 1077 else if (radio_index == RPH_IGNORE)
1076 IgnoreProtocolHandler(); 1078 IgnoreProtocolHandler();
1077 else 1079 else
1078 NOTREACHED(); 1080 NOTREACHED();
1079 } 1081 }
1080 1082
1081 void ContentSettingRPHBubbleModel::OnDoneClicked() { 1083 void ContentSettingRPHBubbleModel::OnDoneClicked() {
1084 if (!web_contents())
1085 return;
1086
1082 // The user has one chance to deal with the RPH content setting UI, 1087 // The user has one chance to deal with the RPH content setting UI,
1083 // then we remove it. 1088 // then we remove it.
1084 TabSpecificContentSettings::FromWebContents(web_contents())-> 1089 TabSpecificContentSettings::FromWebContents(web_contents())->
1085 ClearPendingProtocolHandler(); 1090 ClearPendingProtocolHandler();
1086 content::NotificationService::current()->Notify( 1091 content::NotificationService::current()->Notify(
1087 chrome::NOTIFICATION_WEB_CONTENT_SETTINGS_CHANGED, 1092 chrome::NOTIFICATION_WEB_CONTENT_SETTINGS_CHANGED,
1088 content::Source<WebContents>(web_contents()), 1093 content::Source<WebContents>(web_contents()),
1089 content::NotificationService::NoDetails()); 1094 content::NotificationService::NoDetails());
1090 } 1095 }
1091 1096
1092 void ContentSettingRPHBubbleModel::RegisterProtocolHandler() { 1097 void ContentSettingRPHBubbleModel::RegisterProtocolHandler() {
1098 if (!web_contents())
1099 return;
1100
1093 // A no-op if the handler hasn't been ignored, but needed in case the user 1101 // A no-op if the handler hasn't been ignored, but needed in case the user
1094 // selects sequences like register/ignore/register. 1102 // selects sequences like register/ignore/register.
1095 registry_->RemoveIgnoredHandler(pending_handler_); 1103 registry_->RemoveIgnoredHandler(pending_handler_);
1096 1104
1097 registry_->OnAcceptRegisterProtocolHandler(pending_handler_); 1105 registry_->OnAcceptRegisterProtocolHandler(pending_handler_);
1098 TabSpecificContentSettings::FromWebContents(web_contents())-> 1106 TabSpecificContentSettings::FromWebContents(web_contents())->
1099 set_pending_protocol_handler_setting(CONTENT_SETTING_ALLOW); 1107 set_pending_protocol_handler_setting(CONTENT_SETTING_ALLOW);
1100 } 1108 }
1101 1109
1102 void ContentSettingRPHBubbleModel::UnregisterProtocolHandler() { 1110 void ContentSettingRPHBubbleModel::UnregisterProtocolHandler() {
1111 if (!web_contents())
1112 return;
1113
1103 registry_->OnDenyRegisterProtocolHandler(pending_handler_); 1114 registry_->OnDenyRegisterProtocolHandler(pending_handler_);
1104 TabSpecificContentSettings::FromWebContents(web_contents())-> 1115 TabSpecificContentSettings::FromWebContents(web_contents())->
1105 set_pending_protocol_handler_setting(CONTENT_SETTING_BLOCK); 1116 set_pending_protocol_handler_setting(CONTENT_SETTING_BLOCK);
1106 ClearOrSetPreviousHandler(); 1117 ClearOrSetPreviousHandler();
1107 } 1118 }
1108 1119
1109 void ContentSettingRPHBubbleModel::IgnoreProtocolHandler() { 1120 void ContentSettingRPHBubbleModel::IgnoreProtocolHandler() {
1121 if (!web_contents())
1122 return;
1123
1110 registry_->OnIgnoreRegisterProtocolHandler(pending_handler_); 1124 registry_->OnIgnoreRegisterProtocolHandler(pending_handler_);
1111 TabSpecificContentSettings::FromWebContents(web_contents())-> 1125 TabSpecificContentSettings::FromWebContents(web_contents())->
1112 set_pending_protocol_handler_setting(CONTENT_SETTING_DEFAULT); 1126 set_pending_protocol_handler_setting(CONTENT_SETTING_DEFAULT);
1113 ClearOrSetPreviousHandler(); 1127 ClearOrSetPreviousHandler();
1114 } 1128 }
1115 1129
1116 void ContentSettingRPHBubbleModel::ClearOrSetPreviousHandler() { 1130 void ContentSettingRPHBubbleModel::ClearOrSetPreviousHandler() {
1117 if (previous_handler_.IsEmpty()) { 1131 if (previous_handler_.IsEmpty()) {
1118 registry_->ClearDefault(pending_handler_.protocol()); 1132 registry_->ClearDefault(pending_handler_.protocol());
1119 } else { 1133 } else {
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
1313 ContentSettingBubbleModel::AsSimpleBubbleModel() { 1327 ContentSettingBubbleModel::AsSimpleBubbleModel() {
1314 // In general, bubble models might not inherit from the simple bubble model. 1328 // In general, bubble models might not inherit from the simple bubble model.
1315 return nullptr; 1329 return nullptr;
1316 } 1330 }
1317 1331
1318 ContentSettingMediaStreamBubbleModel* 1332 ContentSettingMediaStreamBubbleModel*
1319 ContentSettingBubbleModel::AsMediaStreamBubbleModel() { 1333 ContentSettingBubbleModel::AsMediaStreamBubbleModel() {
1320 // In general, bubble models might not inherit from the media bubble model. 1334 // In general, bubble models might not inherit from the media bubble model.
1321 return nullptr; 1335 return nullptr;
1322 } 1336 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698