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

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

Issue 1412523003: Adding <keygen> Content Setting (UI) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Revert extra change. Created 5 years 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 "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
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},
msramek 2015/12/03 17:48:04 Please reorder according to the position of CONTEN
svaldez 2015/12/04 15:25:31 Done.
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 }; 131 };
132 // Fields as for kBlockedTitleIDs, above. 132 // Fields as for kBlockedTitleIDs, above.
133 static const ContentSettingsTypeIdEntry kAccessedTitleIDs[] = { 133 static const ContentSettingsTypeIdEntry kAccessedTitleIDs[] = {
134 {CONTENT_SETTINGS_TYPE_COOKIES, IDS_ACCESSED_COOKIES_TITLE}, 134 {CONTENT_SETTINGS_TYPE_COOKIES, IDS_ACCESSED_COOKIES_TITLE},
135 {CONTENT_SETTINGS_TYPE_PPAPI_BROKER, IDS_ALLOWED_PPAPI_BROKER_TITLE}, 135 {CONTENT_SETTINGS_TYPE_PPAPI_BROKER, IDS_ALLOWED_PPAPI_BROKER_TITLE},
136 {CONTENT_SETTINGS_TYPE_AUTOMATIC_DOWNLOADS, IDS_ALLOWED_DOWNLOAD_TITLE}, 136 {CONTENT_SETTINGS_TYPE_AUTOMATIC_DOWNLOADS, IDS_ALLOWED_DOWNLOAD_TITLE},
137 }; 137 };
138 const ContentSettingsTypeIdEntry *title_ids = kBlockedTitleIDs; 138 const ContentSettingsTypeIdEntry *title_ids = kBlockedTitleIDs;
139 size_t num_title_ids = arraysize(kBlockedTitleIDs); 139 size_t num_title_ids = arraysize(kBlockedTitleIDs);
140 if (content_settings && content_settings->IsContentAllowed(content_type()) && 140 if (content_settings && content_settings->IsContentAllowed(content_type()) &&
141 !content_settings->IsContentBlocked(content_type())) { 141 !content_settings->IsContentBlocked(content_type())) {
142 title_ids = kAccessedTitleIDs; 142 title_ids = kAccessedTitleIDs;
143 num_title_ids = arraysize(kAccessedTitleIDs); 143 num_title_ids = arraysize(kAccessedTitleIDs);
144 } 144 }
145 int title_id = 145 int title_id =
146 GetIdForContentType(title_ids, num_title_ids, content_type()); 146 GetIdForContentType(title_ids, num_title_ids, content_type());
147 if (title_id) 147 if (title_id)
148 set_title(l10n_util::GetStringUTF8(title_id)); 148 set_title(l10n_util::GetStringUTF8(title_id));
149 } 149 }
150 150
151 void ContentSettingTitleAndLinkModel::SetManageLink() { 151 void ContentSettingTitleAndLinkModel::SetManageLink() {
152 static const ContentSettingsTypeIdEntry kLinkIDs[] = { 152 static const ContentSettingsTypeIdEntry kLinkIDs[] = {
153 {CONTENT_SETTINGS_TYPE_COOKIES, IDS_BLOCKED_COOKIES_LINK}, 153 {CONTENT_SETTINGS_TYPE_COOKIES, IDS_BLOCKED_COOKIES_LINK},
154 {CONTENT_SETTINGS_TYPE_IMAGES, IDS_BLOCKED_IMAGES_LINK}, 154 {CONTENT_SETTINGS_TYPE_IMAGES, IDS_BLOCKED_IMAGES_LINK},
155 {CONTENT_SETTINGS_TYPE_JAVASCRIPT, IDS_BLOCKED_JAVASCRIPT_LINK}, 155 {CONTENT_SETTINGS_TYPE_JAVASCRIPT, IDS_BLOCKED_JAVASCRIPT_LINK},
156 {CONTENT_SETTINGS_TYPE_KEYGEN, IDS_BLOCKED_KEYGEN_LINK},
156 {CONTENT_SETTINGS_TYPE_PLUGINS, IDS_BLOCKED_PLUGINS_LINK}, 157 {CONTENT_SETTINGS_TYPE_PLUGINS, IDS_BLOCKED_PLUGINS_LINK},
157 {CONTENT_SETTINGS_TYPE_POPUPS, IDS_BLOCKED_POPUPS_LINK}, 158 {CONTENT_SETTINGS_TYPE_POPUPS, IDS_BLOCKED_POPUPS_LINK},
158 {CONTENT_SETTINGS_TYPE_GEOLOCATION, IDS_GEOLOCATION_BUBBLE_MANAGE_LINK}, 159 {CONTENT_SETTINGS_TYPE_GEOLOCATION, IDS_GEOLOCATION_BUBBLE_MANAGE_LINK},
159 {CONTENT_SETTINGS_TYPE_MIXEDSCRIPT, IDS_LEARN_MORE}, 160 {CONTENT_SETTINGS_TYPE_MIXEDSCRIPT, IDS_LEARN_MORE},
160 {CONTENT_SETTINGS_TYPE_PROTOCOL_HANDLERS, IDS_HANDLERS_BUBBLE_MANAGE_LINK}, 161 {CONTENT_SETTINGS_TYPE_PROTOCOL_HANDLERS, IDS_HANDLERS_BUBBLE_MANAGE_LINK},
161 {CONTENT_SETTINGS_TYPE_MEDIASTREAM, IDS_MEDIASTREAM_BUBBLE_MANAGE_LINK}, 162 {CONTENT_SETTINGS_TYPE_MEDIASTREAM, IDS_MEDIASTREAM_BUBBLE_MANAGE_LINK},
162 {CONTENT_SETTINGS_TYPE_PPAPI_BROKER, IDS_PPAPI_BROKER_BUBBLE_MANAGE_LINK}, 163 {CONTENT_SETTINGS_TYPE_PPAPI_BROKER, IDS_PPAPI_BROKER_BUBBLE_MANAGE_LINK},
163 {CONTENT_SETTINGS_TYPE_AUTOMATIC_DOWNLOADS, IDS_BLOCKED_DOWNLOADS_LINK}, 164 {CONTENT_SETTINGS_TYPE_AUTOMATIC_DOWNLOADS, IDS_BLOCKED_DOWNLOADS_LINK},
164 {CONTENT_SETTINGS_TYPE_MIDI_SYSEX, IDS_MIDI_SYSEX_BUBBLE_MANAGE_LINK}, 165 {CONTENT_SETTINGS_TYPE_MIDI_SYSEX, IDS_MIDI_SYSEX_BUBBLE_MANAGE_LINK},
165 }; 166 };
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 DCHECK(!allowed || 289 DCHECK(!allowed ||
289 content_settings->IsContentAllowed(content_type())); 290 content_settings->IsContentAllowed(content_type()));
290 291
291 RadioGroup radio_group; 292 RadioGroup radio_group;
292 radio_group.url = url; 293 radio_group.url = url;
293 294
294 static const ContentSettingsTypeIdEntry kBlockedAllowIDs[] = { 295 static const ContentSettingsTypeIdEntry kBlockedAllowIDs[] = {
295 {CONTENT_SETTINGS_TYPE_COOKIES, IDS_BLOCKED_COOKIES_UNBLOCK}, 296 {CONTENT_SETTINGS_TYPE_COOKIES, IDS_BLOCKED_COOKIES_UNBLOCK},
296 {CONTENT_SETTINGS_TYPE_IMAGES, IDS_BLOCKED_IMAGES_UNBLOCK}, 297 {CONTENT_SETTINGS_TYPE_IMAGES, IDS_BLOCKED_IMAGES_UNBLOCK},
297 {CONTENT_SETTINGS_TYPE_JAVASCRIPT, IDS_BLOCKED_JAVASCRIPT_UNBLOCK}, 298 {CONTENT_SETTINGS_TYPE_JAVASCRIPT, IDS_BLOCKED_JAVASCRIPT_UNBLOCK},
299 {CONTENT_SETTINGS_TYPE_KEYGEN, IDS_BLOCKED_KEYGEN_UNBLOCK},
298 {CONTENT_SETTINGS_TYPE_PLUGINS, IDS_BLOCKED_PLUGINS_UNBLOCK_ALL}, 300 {CONTENT_SETTINGS_TYPE_PLUGINS, IDS_BLOCKED_PLUGINS_UNBLOCK_ALL},
299 {CONTENT_SETTINGS_TYPE_POPUPS, IDS_BLOCKED_POPUPS_UNBLOCK}, 301 {CONTENT_SETTINGS_TYPE_POPUPS, IDS_BLOCKED_POPUPS_UNBLOCK},
300 {CONTENT_SETTINGS_TYPE_PPAPI_BROKER, IDS_BLOCKED_PPAPI_BROKER_UNBLOCK}, 302 {CONTENT_SETTINGS_TYPE_PPAPI_BROKER, IDS_BLOCKED_PPAPI_BROKER_UNBLOCK},
301 {CONTENT_SETTINGS_TYPE_AUTOMATIC_DOWNLOADS, IDS_BLOCKED_DOWNLOAD_UNBLOCK}, 303 {CONTENT_SETTINGS_TYPE_AUTOMATIC_DOWNLOADS, IDS_BLOCKED_DOWNLOAD_UNBLOCK},
302 }; 304 };
303 // Fields as for kBlockedAllowIDs, above. 305 // Fields as for kBlockedAllowIDs, above.
304 static const ContentSettingsTypeIdEntry kAllowedAllowIDs[] = { 306 static const ContentSettingsTypeIdEntry kAllowedAllowIDs[] = {
305 {CONTENT_SETTINGS_TYPE_COOKIES, IDS_ALLOWED_COOKIES_NO_ACTION}, 307 {CONTENT_SETTINGS_TYPE_COOKIES, IDS_ALLOWED_COOKIES_NO_ACTION},
306 {CONTENT_SETTINGS_TYPE_PPAPI_BROKER, IDS_ALLOWED_PPAPI_BROKER_NO_ACTION}, 308 {CONTENT_SETTINGS_TYPE_PPAPI_BROKER, IDS_ALLOWED_PPAPI_BROKER_NO_ACTION},
307 {CONTENT_SETTINGS_TYPE_AUTOMATIC_DOWNLOADS, IDS_ALLOWED_DOWNLOAD_NO_ACTION}, 309 {CONTENT_SETTINGS_TYPE_AUTOMATIC_DOWNLOADS, IDS_ALLOWED_DOWNLOAD_NO_ACTION},
308 }; 310 };
309 311
310 std::string radio_allow_label; 312 std::string radio_allow_label;
311 if (allowed) { 313 if (allowed) {
312 int resource_id = GetIdForContentType(kAllowedAllowIDs, 314 int resource_id = GetIdForContentType(kAllowedAllowIDs,
313 arraysize(kAllowedAllowIDs), 315 arraysize(kAllowedAllowIDs),
314 content_type()); 316 content_type());
315 radio_allow_label = l10n_util::GetStringUTF8(resource_id); 317 radio_allow_label = l10n_util::GetStringUTF8(resource_id);
316 } else { 318 } else {
317 radio_allow_label = l10n_util::GetStringFUTF8( 319 radio_allow_label = l10n_util::GetStringFUTF8(
318 GetIdForContentType(kBlockedAllowIDs, arraysize(kBlockedAllowIDs), 320 GetIdForContentType(kBlockedAllowIDs, arraysize(kBlockedAllowIDs),
319 content_type()), 321 content_type()),
320 display_host); 322 display_host);
321 } 323 }
322 324
323 static const ContentSettingsTypeIdEntry kBlockedBlockIDs[] = { 325 static const ContentSettingsTypeIdEntry kBlockedBlockIDs[] = {
324 {CONTENT_SETTINGS_TYPE_COOKIES, IDS_BLOCKED_COOKIES_NO_ACTION}, 326 {CONTENT_SETTINGS_TYPE_COOKIES, IDS_BLOCKED_COOKIES_NO_ACTION},
325 {CONTENT_SETTINGS_TYPE_IMAGES, IDS_BLOCKED_IMAGES_NO_ACTION}, 327 {CONTENT_SETTINGS_TYPE_IMAGES, IDS_BLOCKED_IMAGES_NO_ACTION},
326 {CONTENT_SETTINGS_TYPE_JAVASCRIPT, IDS_BLOCKED_JAVASCRIPT_NO_ACTION}, 328 {CONTENT_SETTINGS_TYPE_JAVASCRIPT, IDS_BLOCKED_JAVASCRIPT_NO_ACTION},
329 {CONTENT_SETTINGS_TYPE_KEYGEN, IDS_BLOCKED_KEYGEN_NO_ACTION},
327 {CONTENT_SETTINGS_TYPE_PLUGINS, IDS_BLOCKED_PLUGINS_NO_ACTION}, 330 {CONTENT_SETTINGS_TYPE_PLUGINS, IDS_BLOCKED_PLUGINS_NO_ACTION},
328 {CONTENT_SETTINGS_TYPE_POPUPS, IDS_BLOCKED_POPUPS_NO_ACTION}, 331 {CONTENT_SETTINGS_TYPE_POPUPS, IDS_BLOCKED_POPUPS_NO_ACTION},
329 {CONTENT_SETTINGS_TYPE_PPAPI_BROKER, IDS_BLOCKED_PPAPI_BROKER_NO_ACTION}, 332 {CONTENT_SETTINGS_TYPE_PPAPI_BROKER, IDS_BLOCKED_PPAPI_BROKER_NO_ACTION},
330 {CONTENT_SETTINGS_TYPE_AUTOMATIC_DOWNLOADS, IDS_BLOCKED_DOWNLOAD_NO_ACTION}, 333 {CONTENT_SETTINGS_TYPE_AUTOMATIC_DOWNLOADS, IDS_BLOCKED_DOWNLOAD_NO_ACTION},
331 }; 334 };
332 static const ContentSettingsTypeIdEntry kAllowedBlockIDs[] = { 335 static const ContentSettingsTypeIdEntry kAllowedBlockIDs[] = {
333 {CONTENT_SETTINGS_TYPE_COOKIES, IDS_ALLOWED_COOKIES_BLOCK}, 336 {CONTENT_SETTINGS_TYPE_COOKIES, IDS_ALLOWED_COOKIES_BLOCK},
334 {CONTENT_SETTINGS_TYPE_PPAPI_BROKER, IDS_ALLOWED_PPAPI_BROKER_BLOCK}, 337 {CONTENT_SETTINGS_TYPE_PPAPI_BROKER, IDS_ALLOWED_PPAPI_BROKER_BLOCK},
335 {CONTENT_SETTINGS_TYPE_AUTOMATIC_DOWNLOADS, IDS_ALLOWED_DOWNLOAD_BLOCK}, 338 {CONTENT_SETTINGS_TYPE_AUTOMATIC_DOWNLOADS, IDS_ALLOWED_DOWNLOAD_BLOCK},
336 }; 339 };
(...skipping 915 matching lines...) Expand 10 before | Expand all | Expand 10 after
1252 ProtocolHandlerRegistryFactory::GetForBrowserContext(profile); 1255 ProtocolHandlerRegistryFactory::GetForBrowserContext(profile);
1253 return new ContentSettingRPHBubbleModel(delegate, web_contents, profile, 1256 return new ContentSettingRPHBubbleModel(delegate, web_contents, profile,
1254 registry); 1257 registry);
1255 } 1258 }
1256 if (content_type == CONTENT_SETTINGS_TYPE_MIDI_SYSEX) { 1259 if (content_type == CONTENT_SETTINGS_TYPE_MIDI_SYSEX) {
1257 return new ContentSettingMidiSysExBubbleModel(delegate, web_contents, 1260 return new ContentSettingMidiSysExBubbleModel(delegate, web_contents,
1258 profile); 1261 profile);
1259 } 1262 }
1260 if (content_type == CONTENT_SETTINGS_TYPE_IMAGES || 1263 if (content_type == CONTENT_SETTINGS_TYPE_IMAGES ||
1261 content_type == CONTENT_SETTINGS_TYPE_JAVASCRIPT || 1264 content_type == CONTENT_SETTINGS_TYPE_JAVASCRIPT ||
1265 content_type == CONTENT_SETTINGS_TYPE_KEYGEN ||
1262 content_type == CONTENT_SETTINGS_TYPE_PPAPI_BROKER || 1266 content_type == CONTENT_SETTINGS_TYPE_PPAPI_BROKER ||
1263 content_type == CONTENT_SETTINGS_TYPE_AUTOMATIC_DOWNLOADS) { 1267 content_type == CONTENT_SETTINGS_TYPE_AUTOMATIC_DOWNLOADS) {
1264 return new ContentSettingSingleRadioGroup(delegate, web_contents, profile, 1268 return new ContentSettingSingleRadioGroup(delegate, web_contents, profile,
1265 content_type); 1269 content_type);
1266 } 1270 }
1267 NOTREACHED() << "No bubble for the content type " << content_type << "."; 1271 NOTREACHED() << "No bubble for the content type " << content_type << ".";
1268 return nullptr; 1272 return nullptr;
1269 } 1273 }
1270 1274
1271 ContentSettingBubbleModel::ContentSettingBubbleModel( 1275 ContentSettingBubbleModel::ContentSettingBubbleModel(
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
1311 if (type == content::NOTIFICATION_WEB_CONTENTS_DESTROYED) { 1315 if (type == content::NOTIFICATION_WEB_CONTENTS_DESTROYED) {
1312 DCHECK_EQ(web_contents_, 1316 DCHECK_EQ(web_contents_,
1313 content::Source<WebContents>(source).ptr()); 1317 content::Source<WebContents>(source).ptr());
1314 web_contents_ = NULL; 1318 web_contents_ = NULL;
1315 } else { 1319 } else {
1316 DCHECK_EQ(chrome::NOTIFICATION_PROFILE_DESTROYED, type); 1320 DCHECK_EQ(chrome::NOTIFICATION_PROFILE_DESTROYED, type);
1317 DCHECK_EQ(profile_, content::Source<Profile>(source).ptr()); 1321 DCHECK_EQ(profile_, content::Source<Profile>(source).ptr());
1318 profile_ = NULL; 1322 profile_ = NULL;
1319 } 1323 }
1320 } 1324 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698