OLD | NEW |
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 "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/macros.h" | 8 #include "base/macros.h" |
9 #include "base/prefs/pref_service.h" | 9 #include "base/prefs/pref_service.h" |
10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 TabSpecificContentSettings* content_settings = NULL; | 114 TabSpecificContentSettings* content_settings = NULL; |
115 if (web_contents()) { | 115 if (web_contents()) { |
116 content_settings = | 116 content_settings = |
117 TabSpecificContentSettings::FromWebContents(web_contents()); | 117 TabSpecificContentSettings::FromWebContents(web_contents()); |
118 } | 118 } |
119 | 119 |
120 static const ContentSettingsTypeIdEntry kBlockedTitleIDs[] = { | 120 static const ContentSettingsTypeIdEntry kBlockedTitleIDs[] = { |
121 {CONTENT_SETTINGS_TYPE_COOKIES, IDS_BLOCKED_COOKIES_TITLE}, | 121 {CONTENT_SETTINGS_TYPE_COOKIES, IDS_BLOCKED_COOKIES_TITLE}, |
122 {CONTENT_SETTINGS_TYPE_IMAGES, IDS_BLOCKED_IMAGES_TITLE}, | 122 {CONTENT_SETTINGS_TYPE_IMAGES, IDS_BLOCKED_IMAGES_TITLE}, |
123 {CONTENT_SETTINGS_TYPE_JAVASCRIPT, IDS_BLOCKED_JAVASCRIPT_TITLE}, | 123 {CONTENT_SETTINGS_TYPE_JAVASCRIPT, IDS_BLOCKED_JAVASCRIPT_TITLE}, |
| 124 {CONTENT_SETTINGS_TYPE_KEYGEN, IDS_BLOCKED_KEYGEN_TITLE}, |
124 {CONTENT_SETTINGS_TYPE_PLUGINS, IDS_BLOCKED_PLUGINS_TITLE}, | 125 {CONTENT_SETTINGS_TYPE_PLUGINS, IDS_BLOCKED_PLUGINS_TITLE}, |
125 {CONTENT_SETTINGS_TYPE_POPUPS, IDS_BLOCKED_POPUPS_TITLE}, | 126 {CONTENT_SETTINGS_TYPE_POPUPS, IDS_BLOCKED_POPUPS_TITLE}, |
126 {CONTENT_SETTINGS_TYPE_MIXEDSCRIPT, | 127 {CONTENT_SETTINGS_TYPE_MIXEDSCRIPT, |
127 IDS_BLOCKED_DISPLAYING_INSECURE_CONTENT}, | 128 IDS_BLOCKED_DISPLAYING_INSECURE_CONTENT}, |
128 {CONTENT_SETTINGS_TYPE_PPAPI_BROKER, | 129 {CONTENT_SETTINGS_TYPE_PPAPI_BROKER, IDS_BLOCKED_PPAPI_BROKER_TITLE}, |
129 IDS_BLOCKED_PPAPI_BROKER_TITLE}, | |
130 {CONTENT_SETTINGS_TYPE_AUTOMATIC_DOWNLOADS, IDS_BLOCKED_DOWNLOAD_TITLE}, | 130 {CONTENT_SETTINGS_TYPE_AUTOMATIC_DOWNLOADS, IDS_BLOCKED_DOWNLOAD_TITLE}, |
| 131 {CONTENT_SETTINGS_TYPE_KEYGEN, IDS_BLOCKED_KEYGEN_TITLE}, |
131 }; | 132 }; |
132 // Fields as for kBlockedTitleIDs, above. | 133 // Fields as for kBlockedTitleIDs, above. |
133 static const ContentSettingsTypeIdEntry kAccessedTitleIDs[] = { | 134 static const ContentSettingsTypeIdEntry kAccessedTitleIDs[] = { |
134 {CONTENT_SETTINGS_TYPE_COOKIES, IDS_ACCESSED_COOKIES_TITLE}, | 135 {CONTENT_SETTINGS_TYPE_COOKIES, IDS_ACCESSED_COOKIES_TITLE}, |
135 {CONTENT_SETTINGS_TYPE_PPAPI_BROKER, IDS_ALLOWED_PPAPI_BROKER_TITLE}, | 136 {CONTENT_SETTINGS_TYPE_PPAPI_BROKER, IDS_ALLOWED_PPAPI_BROKER_TITLE}, |
136 {CONTENT_SETTINGS_TYPE_AUTOMATIC_DOWNLOADS, IDS_ALLOWED_DOWNLOAD_TITLE}, | 137 {CONTENT_SETTINGS_TYPE_AUTOMATIC_DOWNLOADS, IDS_ALLOWED_DOWNLOAD_TITLE}, |
137 }; | 138 }; |
138 const ContentSettingsTypeIdEntry *title_ids = kBlockedTitleIDs; | 139 const ContentSettingsTypeIdEntry *title_ids = kBlockedTitleIDs; |
139 size_t num_title_ids = arraysize(kBlockedTitleIDs); | 140 size_t num_title_ids = arraysize(kBlockedTitleIDs); |
140 if (content_settings && content_settings->IsContentAllowed(content_type()) && | 141 if (content_settings && content_settings->IsContentAllowed(content_type()) && |
141 !content_settings->IsContentBlocked(content_type())) { | 142 !content_settings->IsContentBlocked(content_type())) { |
142 title_ids = kAccessedTitleIDs; | 143 title_ids = kAccessedTitleIDs; |
143 num_title_ids = arraysize(kAccessedTitleIDs); | 144 num_title_ids = arraysize(kAccessedTitleIDs); |
144 } | 145 } |
145 int title_id = | 146 int title_id = |
146 GetIdForContentType(title_ids, num_title_ids, content_type()); | 147 GetIdForContentType(title_ids, num_title_ids, content_type()); |
147 if (title_id) | 148 if (title_id) |
148 set_title(l10n_util::GetStringUTF8(title_id)); | 149 set_title(l10n_util::GetStringUTF8(title_id)); |
149 } | 150 } |
150 | 151 |
151 void ContentSettingTitleAndLinkModel::SetManageLink() { | 152 void ContentSettingTitleAndLinkModel::SetManageLink() { |
152 static const ContentSettingsTypeIdEntry kLinkIDs[] = { | 153 static const ContentSettingsTypeIdEntry kLinkIDs[] = { |
153 {CONTENT_SETTINGS_TYPE_COOKIES, IDS_BLOCKED_COOKIES_LINK}, | 154 {CONTENT_SETTINGS_TYPE_COOKIES, IDS_BLOCKED_COOKIES_LINK}, |
154 {CONTENT_SETTINGS_TYPE_IMAGES, IDS_BLOCKED_IMAGES_LINK}, | 155 {CONTENT_SETTINGS_TYPE_IMAGES, IDS_BLOCKED_IMAGES_LINK}, |
155 {CONTENT_SETTINGS_TYPE_JAVASCRIPT, IDS_BLOCKED_JAVASCRIPT_LINK}, | 156 {CONTENT_SETTINGS_TYPE_JAVASCRIPT, IDS_BLOCKED_JAVASCRIPT_LINK}, |
| 157 {CONTENT_SETTINGS_TYPE_KEYGEN, IDS_BLOCKED_KEYGEN_LINK}, |
156 {CONTENT_SETTINGS_TYPE_PLUGINS, IDS_BLOCKED_PLUGINS_LINK}, | 158 {CONTENT_SETTINGS_TYPE_PLUGINS, IDS_BLOCKED_PLUGINS_LINK}, |
157 {CONTENT_SETTINGS_TYPE_POPUPS, IDS_BLOCKED_POPUPS_LINK}, | 159 {CONTENT_SETTINGS_TYPE_POPUPS, IDS_BLOCKED_POPUPS_LINK}, |
158 {CONTENT_SETTINGS_TYPE_GEOLOCATION, IDS_GEOLOCATION_BUBBLE_MANAGE_LINK}, | 160 {CONTENT_SETTINGS_TYPE_GEOLOCATION, IDS_GEOLOCATION_BUBBLE_MANAGE_LINK}, |
159 {CONTENT_SETTINGS_TYPE_MIXEDSCRIPT, IDS_LEARN_MORE}, | 161 {CONTENT_SETTINGS_TYPE_MIXEDSCRIPT, IDS_LEARN_MORE}, |
160 {CONTENT_SETTINGS_TYPE_PROTOCOL_HANDLERS, IDS_HANDLERS_BUBBLE_MANAGE_LINK}, | 162 {CONTENT_SETTINGS_TYPE_PROTOCOL_HANDLERS, IDS_HANDLERS_BUBBLE_MANAGE_LINK}, |
161 {CONTENT_SETTINGS_TYPE_MEDIASTREAM, IDS_MEDIASTREAM_BUBBLE_MANAGE_LINK}, | 163 {CONTENT_SETTINGS_TYPE_MEDIASTREAM, IDS_MEDIASTREAM_BUBBLE_MANAGE_LINK}, |
162 {CONTENT_SETTINGS_TYPE_PPAPI_BROKER, IDS_PPAPI_BROKER_BUBBLE_MANAGE_LINK}, | 164 {CONTENT_SETTINGS_TYPE_PPAPI_BROKER, IDS_PPAPI_BROKER_BUBBLE_MANAGE_LINK}, |
163 {CONTENT_SETTINGS_TYPE_AUTOMATIC_DOWNLOADS, IDS_BLOCKED_DOWNLOADS_LINK}, | 165 {CONTENT_SETTINGS_TYPE_AUTOMATIC_DOWNLOADS, IDS_BLOCKED_DOWNLOADS_LINK}, |
164 {CONTENT_SETTINGS_TYPE_MIDI_SYSEX, IDS_MIDI_SYSEX_BUBBLE_MANAGE_LINK}, | 166 {CONTENT_SETTINGS_TYPE_MIDI_SYSEX, IDS_MIDI_SYSEX_BUBBLE_MANAGE_LINK}, |
| 167 {CONTENT_SETTINGS_TYPE_KEYGEN, IDS_BLOCKED_KEYGEN_LINK}, |
165 }; | 168 }; |
166 set_manage_link(l10n_util::GetStringUTF8( | 169 set_manage_link(l10n_util::GetStringUTF8( |
167 GetIdForContentType(kLinkIDs, arraysize(kLinkIDs), content_type()))); | 170 GetIdForContentType(kLinkIDs, arraysize(kLinkIDs), content_type()))); |
168 } | 171 } |
169 | 172 |
170 void ContentSettingTitleAndLinkModel::OnManageLinkClicked() { | 173 void ContentSettingTitleAndLinkModel::OnManageLinkClicked() { |
171 if (delegate_) | 174 if (delegate_) |
172 delegate_->ShowContentSettingsPage(content_type()); | 175 delegate_->ShowContentSettingsPage(content_type()); |
173 } | 176 } |
174 | 177 |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
288 DCHECK(!allowed || | 291 DCHECK(!allowed || |
289 content_settings->IsContentAllowed(content_type())); | 292 content_settings->IsContentAllowed(content_type())); |
290 | 293 |
291 RadioGroup radio_group; | 294 RadioGroup radio_group; |
292 radio_group.url = url; | 295 radio_group.url = url; |
293 | 296 |
294 static const ContentSettingsTypeIdEntry kBlockedAllowIDs[] = { | 297 static const ContentSettingsTypeIdEntry kBlockedAllowIDs[] = { |
295 {CONTENT_SETTINGS_TYPE_COOKIES, IDS_BLOCKED_COOKIES_UNBLOCK}, | 298 {CONTENT_SETTINGS_TYPE_COOKIES, IDS_BLOCKED_COOKIES_UNBLOCK}, |
296 {CONTENT_SETTINGS_TYPE_IMAGES, IDS_BLOCKED_IMAGES_UNBLOCK}, | 299 {CONTENT_SETTINGS_TYPE_IMAGES, IDS_BLOCKED_IMAGES_UNBLOCK}, |
297 {CONTENT_SETTINGS_TYPE_JAVASCRIPT, IDS_BLOCKED_JAVASCRIPT_UNBLOCK}, | 300 {CONTENT_SETTINGS_TYPE_JAVASCRIPT, IDS_BLOCKED_JAVASCRIPT_UNBLOCK}, |
| 301 {CONTENT_SETTINGS_TYPE_KEYGEN, IDS_BLOCKED_KEYGEN_UNBLOCK}, |
298 {CONTENT_SETTINGS_TYPE_PLUGINS, IDS_BLOCKED_PLUGINS_UNBLOCK_ALL}, | 302 {CONTENT_SETTINGS_TYPE_PLUGINS, IDS_BLOCKED_PLUGINS_UNBLOCK_ALL}, |
299 {CONTENT_SETTINGS_TYPE_POPUPS, IDS_BLOCKED_POPUPS_UNBLOCK}, | 303 {CONTENT_SETTINGS_TYPE_POPUPS, IDS_BLOCKED_POPUPS_UNBLOCK}, |
300 {CONTENT_SETTINGS_TYPE_PPAPI_BROKER, IDS_BLOCKED_PPAPI_BROKER_UNBLOCK}, | 304 {CONTENT_SETTINGS_TYPE_PPAPI_BROKER, IDS_BLOCKED_PPAPI_BROKER_UNBLOCK}, |
301 {CONTENT_SETTINGS_TYPE_AUTOMATIC_DOWNLOADS, IDS_BLOCKED_DOWNLOAD_UNBLOCK}, | 305 {CONTENT_SETTINGS_TYPE_AUTOMATIC_DOWNLOADS, IDS_BLOCKED_DOWNLOAD_UNBLOCK}, |
| 306 {CONTENT_SETTINGS_TYPE_KEYGEN, IDS_BLOCKED_KEYGEN_UNBLOCK}, |
302 }; | 307 }; |
303 // Fields as for kBlockedAllowIDs, above. | 308 // Fields as for kBlockedAllowIDs, above. |
304 static const ContentSettingsTypeIdEntry kAllowedAllowIDs[] = { | 309 static const ContentSettingsTypeIdEntry kAllowedAllowIDs[] = { |
305 {CONTENT_SETTINGS_TYPE_COOKIES, IDS_ALLOWED_COOKIES_NO_ACTION}, | 310 {CONTENT_SETTINGS_TYPE_COOKIES, IDS_ALLOWED_COOKIES_NO_ACTION}, |
306 {CONTENT_SETTINGS_TYPE_PPAPI_BROKER, IDS_ALLOWED_PPAPI_BROKER_NO_ACTION}, | 311 {CONTENT_SETTINGS_TYPE_PPAPI_BROKER, IDS_ALLOWED_PPAPI_BROKER_NO_ACTION}, |
307 {CONTENT_SETTINGS_TYPE_AUTOMATIC_DOWNLOADS, IDS_ALLOWED_DOWNLOAD_NO_ACTION}, | 312 {CONTENT_SETTINGS_TYPE_AUTOMATIC_DOWNLOADS, IDS_ALLOWED_DOWNLOAD_NO_ACTION}, |
308 }; | 313 }; |
309 | 314 |
310 std::string radio_allow_label; | 315 std::string radio_allow_label; |
311 if (allowed) { | 316 if (allowed) { |
312 int resource_id = GetIdForContentType(kAllowedAllowIDs, | 317 int resource_id = GetIdForContentType(kAllowedAllowIDs, |
313 arraysize(kAllowedAllowIDs), | 318 arraysize(kAllowedAllowIDs), |
314 content_type()); | 319 content_type()); |
315 radio_allow_label = l10n_util::GetStringUTF8(resource_id); | 320 radio_allow_label = l10n_util::GetStringUTF8(resource_id); |
316 } else { | 321 } else { |
317 radio_allow_label = l10n_util::GetStringFUTF8( | 322 radio_allow_label = l10n_util::GetStringFUTF8( |
318 GetIdForContentType(kBlockedAllowIDs, arraysize(kBlockedAllowIDs), | 323 GetIdForContentType(kBlockedAllowIDs, arraysize(kBlockedAllowIDs), |
319 content_type()), | 324 content_type()), |
320 display_host); | 325 display_host); |
321 } | 326 } |
322 | 327 |
323 static const ContentSettingsTypeIdEntry kBlockedBlockIDs[] = { | 328 static const ContentSettingsTypeIdEntry kBlockedBlockIDs[] = { |
324 {CONTENT_SETTINGS_TYPE_COOKIES, IDS_BLOCKED_COOKIES_NO_ACTION}, | 329 {CONTENT_SETTINGS_TYPE_COOKIES, IDS_BLOCKED_COOKIES_NO_ACTION}, |
325 {CONTENT_SETTINGS_TYPE_IMAGES, IDS_BLOCKED_IMAGES_NO_ACTION}, | 330 {CONTENT_SETTINGS_TYPE_IMAGES, IDS_BLOCKED_IMAGES_NO_ACTION}, |
326 {CONTENT_SETTINGS_TYPE_JAVASCRIPT, IDS_BLOCKED_JAVASCRIPT_NO_ACTION}, | 331 {CONTENT_SETTINGS_TYPE_JAVASCRIPT, IDS_BLOCKED_JAVASCRIPT_NO_ACTION}, |
| 332 {CONTENT_SETTINGS_TYPE_KEYGEN, IDS_BLOCKED_KEYGEN_NO_ACTION}, |
327 {CONTENT_SETTINGS_TYPE_PLUGINS, IDS_BLOCKED_PLUGINS_NO_ACTION}, | 333 {CONTENT_SETTINGS_TYPE_PLUGINS, IDS_BLOCKED_PLUGINS_NO_ACTION}, |
328 {CONTENT_SETTINGS_TYPE_POPUPS, IDS_BLOCKED_POPUPS_NO_ACTION}, | 334 {CONTENT_SETTINGS_TYPE_POPUPS, IDS_BLOCKED_POPUPS_NO_ACTION}, |
329 {CONTENT_SETTINGS_TYPE_PPAPI_BROKER, IDS_BLOCKED_PPAPI_BROKER_NO_ACTION}, | 335 {CONTENT_SETTINGS_TYPE_PPAPI_BROKER, IDS_BLOCKED_PPAPI_BROKER_NO_ACTION}, |
330 {CONTENT_SETTINGS_TYPE_AUTOMATIC_DOWNLOADS, IDS_BLOCKED_DOWNLOAD_NO_ACTION}, | 336 {CONTENT_SETTINGS_TYPE_AUTOMATIC_DOWNLOADS, IDS_BLOCKED_DOWNLOAD_NO_ACTION}, |
| 337 {CONTENT_SETTINGS_TYPE_KEYGEN, IDS_BLOCKED_KEYGEN_NO_ACTION}, |
331 }; | 338 }; |
332 static const ContentSettingsTypeIdEntry kAllowedBlockIDs[] = { | 339 static const ContentSettingsTypeIdEntry kAllowedBlockIDs[] = { |
333 {CONTENT_SETTINGS_TYPE_COOKIES, IDS_ALLOWED_COOKIES_BLOCK}, | 340 {CONTENT_SETTINGS_TYPE_COOKIES, IDS_ALLOWED_COOKIES_BLOCK}, |
334 {CONTENT_SETTINGS_TYPE_PPAPI_BROKER, IDS_ALLOWED_PPAPI_BROKER_BLOCK}, | 341 {CONTENT_SETTINGS_TYPE_PPAPI_BROKER, IDS_ALLOWED_PPAPI_BROKER_BLOCK}, |
335 {CONTENT_SETTINGS_TYPE_AUTOMATIC_DOWNLOADS, IDS_ALLOWED_DOWNLOAD_BLOCK}, | 342 {CONTENT_SETTINGS_TYPE_AUTOMATIC_DOWNLOADS, IDS_ALLOWED_DOWNLOAD_BLOCK}, |
336 }; | 343 }; |
337 | 344 |
338 std::string radio_block_label; | 345 std::string radio_block_label; |
339 if (allowed) { | 346 if (allowed) { |
340 int resource_id = GetIdForContentType(kAllowedBlockIDs, | 347 int resource_id = GetIdForContentType(kAllowedBlockIDs, |
(...skipping 911 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1252 ProtocolHandlerRegistryFactory::GetForBrowserContext(profile); | 1259 ProtocolHandlerRegistryFactory::GetForBrowserContext(profile); |
1253 return new ContentSettingRPHBubbleModel(delegate, web_contents, profile, | 1260 return new ContentSettingRPHBubbleModel(delegate, web_contents, profile, |
1254 registry); | 1261 registry); |
1255 } | 1262 } |
1256 if (content_type == CONTENT_SETTINGS_TYPE_MIDI_SYSEX) { | 1263 if (content_type == CONTENT_SETTINGS_TYPE_MIDI_SYSEX) { |
1257 return new ContentSettingMidiSysExBubbleModel(delegate, web_contents, | 1264 return new ContentSettingMidiSysExBubbleModel(delegate, web_contents, |
1258 profile); | 1265 profile); |
1259 } | 1266 } |
1260 if (content_type == CONTENT_SETTINGS_TYPE_IMAGES || | 1267 if (content_type == CONTENT_SETTINGS_TYPE_IMAGES || |
1261 content_type == CONTENT_SETTINGS_TYPE_JAVASCRIPT || | 1268 content_type == CONTENT_SETTINGS_TYPE_JAVASCRIPT || |
| 1269 content_type == CONTENT_SETTINGS_TYPE_KEYGEN || |
1262 content_type == CONTENT_SETTINGS_TYPE_PPAPI_BROKER || | 1270 content_type == CONTENT_SETTINGS_TYPE_PPAPI_BROKER || |
1263 content_type == CONTENT_SETTINGS_TYPE_AUTOMATIC_DOWNLOADS) { | 1271 content_type == CONTENT_SETTINGS_TYPE_AUTOMATIC_DOWNLOADS) { |
1264 return new ContentSettingSingleRadioGroup(delegate, web_contents, profile, | 1272 return new ContentSettingSingleRadioGroup(delegate, web_contents, profile, |
1265 content_type); | 1273 content_type); |
1266 } | 1274 } |
1267 NOTREACHED() << "No bubble for the content type " << content_type << "."; | 1275 NOTREACHED() << "No bubble for the content type " << content_type << "."; |
1268 return nullptr; | 1276 return nullptr; |
1269 } | 1277 } |
1270 | 1278 |
1271 ContentSettingBubbleModel::ContentSettingBubbleModel( | 1279 ContentSettingBubbleModel::ContentSettingBubbleModel( |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1311 if (type == content::NOTIFICATION_WEB_CONTENTS_DESTROYED) { | 1319 if (type == content::NOTIFICATION_WEB_CONTENTS_DESTROYED) { |
1312 DCHECK_EQ(web_contents_, | 1320 DCHECK_EQ(web_contents_, |
1313 content::Source<WebContents>(source).ptr()); | 1321 content::Source<WebContents>(source).ptr()); |
1314 web_contents_ = NULL; | 1322 web_contents_ = NULL; |
1315 } else { | 1323 } else { |
1316 DCHECK_EQ(chrome::NOTIFICATION_PROFILE_DESTROYED, type); | 1324 DCHECK_EQ(chrome::NOTIFICATION_PROFILE_DESTROYED, type); |
1317 DCHECK_EQ(profile_, content::Source<Profile>(source).ptr()); | 1325 DCHECK_EQ(profile_, content::Source<Profile>(source).ptr()); |
1318 profile_ = NULL; | 1326 profile_ = NULL; |
1319 } | 1327 } |
1320 } | 1328 } |
OLD | NEW |