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

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

Issue 12479005: Show strings in content settings bubble when access to cookies is allowed. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 7 years, 9 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 | chrome/browser/ui/content_settings/content_setting_bubble_model_unittest.cc » ('j') | 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 "base/prefs/pref_service.h" 7 #include "base/prefs/pref_service.h"
8 #include "base/utf_string_conversions.h" 8 #include "base/utf_string_conversions.h"
9 #include "chrome/browser/api/infobars/infobar_service.h" 9 #include "chrome/browser/api/infobars/infobar_service.h"
10 #include "chrome/browser/content_settings/content_settings_utils.h" 10 #include "chrome/browser/content_settings/content_settings_utils.h"
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 {CONTENT_SETTINGS_TYPE_JAVASCRIPT, IDS_BLOCKED_JAVASCRIPT_UNBLOCK}, 287 {CONTENT_SETTINGS_TYPE_JAVASCRIPT, IDS_BLOCKED_JAVASCRIPT_UNBLOCK},
288 {CONTENT_SETTINGS_TYPE_PLUGINS, IDS_BLOCKED_PLUGINS_UNBLOCK_ALL}, 288 {CONTENT_SETTINGS_TYPE_PLUGINS, IDS_BLOCKED_PLUGINS_UNBLOCK_ALL},
289 {CONTENT_SETTINGS_TYPE_POPUPS, IDS_BLOCKED_POPUPS_UNBLOCK}, 289 {CONTENT_SETTINGS_TYPE_POPUPS, IDS_BLOCKED_POPUPS_UNBLOCK},
290 {CONTENT_SETTINGS_TYPE_PPAPI_BROKER, IDS_BLOCKED_PPAPI_BROKER_UNBLOCK}, 290 {CONTENT_SETTINGS_TYPE_PPAPI_BROKER, IDS_BLOCKED_PPAPI_BROKER_UNBLOCK},
291 }; 291 };
292 // Fields as for kBlockedAllowIDs, above. 292 // Fields as for kBlockedAllowIDs, above.
293 static const ContentSettingsTypeIdEntry kResourceSpecificBlockedAllowIDs[] = { 293 static const ContentSettingsTypeIdEntry kResourceSpecificBlockedAllowIDs[] = {
294 {CONTENT_SETTINGS_TYPE_PLUGINS, IDS_BLOCKED_PLUGINS_UNBLOCK}, 294 {CONTENT_SETTINGS_TYPE_PLUGINS, IDS_BLOCKED_PLUGINS_UNBLOCK},
295 }; 295 };
296 static const ContentSettingsTypeIdEntry kAllowedAllowIDs[] = { 296 static const ContentSettingsTypeIdEntry kAllowedAllowIDs[] = {
297 // TODO(bauerb): The string shouldn't be "unblock" (they weren't blocked).
298 {CONTENT_SETTINGS_TYPE_COOKIES, IDS_BLOCKED_COOKIES_UNBLOCK},
297 {CONTENT_SETTINGS_TYPE_PPAPI_BROKER, IDS_ALLOWED_PPAPI_BROKER_NO_ACTION}, 299 {CONTENT_SETTINGS_TYPE_PPAPI_BROKER, IDS_ALLOWED_PPAPI_BROKER_NO_ACTION},
298 }; 300 };
299 301
300 std::string radio_allow_label; 302 std::string radio_allow_label;
301 if (allowed) { 303 if (allowed) {
302 radio_allow_label = l10n_util::GetStringUTF8( 304 int resource_id = GetIdForContentType(kAllowedAllowIDs,
303 GetIdForContentType(kAllowedAllowIDs, arraysize(kAllowedAllowIDs), 305 arraysize(kAllowedAllowIDs),
304 content_type())); 306 content_type());
307 radio_allow_label = (content_type() == CONTENT_SETTINGS_TYPE_COOKIES) ?
308 l10n_util::GetStringFUTF8(resource_id, display_host) :
309 l10n_util::GetStringUTF8(resource_id);
305 } else if (resources.empty()) { 310 } else if (resources.empty()) {
306 radio_allow_label = l10n_util::GetStringFUTF8( 311 radio_allow_label = l10n_util::GetStringFUTF8(
307 GetIdForContentType(kBlockedAllowIDs, arraysize(kBlockedAllowIDs), 312 GetIdForContentType(kBlockedAllowIDs, arraysize(kBlockedAllowIDs),
308 content_type()), 313 content_type()),
309 display_host); 314 display_host);
310 } else { 315 } else {
311 radio_allow_label = l10n_util::GetStringFUTF8( 316 radio_allow_label = l10n_util::GetStringFUTF8(
312 GetIdForContentType(kResourceSpecificBlockedAllowIDs, 317 GetIdForContentType(kResourceSpecificBlockedAllowIDs,
313 arraysize(kResourceSpecificBlockedAllowIDs), 318 arraysize(kResourceSpecificBlockedAllowIDs),
314 content_type()), 319 content_type()),
315 display_host); 320 display_host);
316 } 321 }
317 322
318 static const ContentSettingsTypeIdEntry kBlockedBlockIDs[] = { 323 static const ContentSettingsTypeIdEntry kBlockedBlockIDs[] = {
319 {CONTENT_SETTINGS_TYPE_COOKIES, IDS_BLOCKED_COOKIES_NO_ACTION}, 324 {CONTENT_SETTINGS_TYPE_COOKIES, IDS_BLOCKED_COOKIES_NO_ACTION},
320 {CONTENT_SETTINGS_TYPE_IMAGES, IDS_BLOCKED_IMAGES_NO_ACTION}, 325 {CONTENT_SETTINGS_TYPE_IMAGES, IDS_BLOCKED_IMAGES_NO_ACTION},
321 {CONTENT_SETTINGS_TYPE_JAVASCRIPT, IDS_BLOCKED_JAVASCRIPT_NO_ACTION}, 326 {CONTENT_SETTINGS_TYPE_JAVASCRIPT, IDS_BLOCKED_JAVASCRIPT_NO_ACTION},
322 {CONTENT_SETTINGS_TYPE_PLUGINS, IDS_BLOCKED_PLUGINS_NO_ACTION}, 327 {CONTENT_SETTINGS_TYPE_PLUGINS, IDS_BLOCKED_PLUGINS_NO_ACTION},
323 {CONTENT_SETTINGS_TYPE_POPUPS, IDS_BLOCKED_POPUPS_NO_ACTION}, 328 {CONTENT_SETTINGS_TYPE_POPUPS, IDS_BLOCKED_POPUPS_NO_ACTION},
324 {CONTENT_SETTINGS_TYPE_PPAPI_BROKER, IDS_BLOCKED_PPAPI_BROKER_NO_ACTION}, 329 {CONTENT_SETTINGS_TYPE_PPAPI_BROKER, IDS_BLOCKED_PPAPI_BROKER_NO_ACTION},
325 }; 330 };
326 static const ContentSettingsTypeIdEntry kAllowedBlockIDs[] = { 331 static const ContentSettingsTypeIdEntry kAllowedBlockIDs[] = {
332 // TODO(bauerb): The string should say "block".
333 {CONTENT_SETTINGS_TYPE_COOKIES, IDS_BLOCKED_COOKIES_NO_ACTION},
327 {CONTENT_SETTINGS_TYPE_PPAPI_BROKER, IDS_ALLOWED_PPAPI_BROKER_BLOCK}, 334 {CONTENT_SETTINGS_TYPE_PPAPI_BROKER, IDS_ALLOWED_PPAPI_BROKER_BLOCK},
328 }; 335 };
329 336
330 std::string radio_block_label; 337 std::string radio_block_label;
331 if (allowed) { 338 if (allowed) {
332 radio_block_label = l10n_util::GetStringFUTF8( 339 int resource_id = GetIdForContentType(kAllowedBlockIDs,
333 GetIdForContentType(kAllowedBlockIDs, arraysize(kAllowedBlockIDs), 340 arraysize(kAllowedBlockIDs),
334 content_type()), 341 content_type());
335 display_host); 342 radio_block_label = (content_type() == CONTENT_SETTINGS_TYPE_COOKIES) ?
343 l10n_util::GetStringUTF8(resource_id) :
344 l10n_util::GetStringFUTF8(resource_id, display_host);
336 } else { 345 } else {
337 radio_block_label = l10n_util::GetStringUTF8( 346 radio_block_label = l10n_util::GetStringUTF8(
338 GetIdForContentType(kBlockedBlockIDs, arraysize(kBlockedBlockIDs), 347 GetIdForContentType(kBlockedBlockIDs, arraysize(kBlockedBlockIDs),
339 content_type())); 348 content_type()));
340 } 349 }
341 350
342 radio_group.radio_items.push_back(radio_allow_label); 351 radio_group.radio_items.push_back(radio_allow_label);
343 radio_group.radio_items.push_back(radio_block_label); 352 radio_group.radio_items.push_back(radio_block_label);
344 HostContentSettingsMap* map = profile()->GetHostContentSettingsMap(); 353 HostContentSettingsMap* map = profile()->GetHostContentSettingsMap();
345 CookieSettings* cookie_settings = 354 CookieSettings* cookie_settings =
(...skipping 756 matching lines...) Expand 10 before | Expand all | Expand 10 after
1102 if (type == content::NOTIFICATION_WEB_CONTENTS_DESTROYED) { 1111 if (type == content::NOTIFICATION_WEB_CONTENTS_DESTROYED) {
1103 DCHECK_EQ(web_contents_, 1112 DCHECK_EQ(web_contents_,
1104 content::Source<WebContents>(source).ptr()); 1113 content::Source<WebContents>(source).ptr());
1105 web_contents_ = NULL; 1114 web_contents_ = NULL;
1106 } else { 1115 } else {
1107 DCHECK_EQ(chrome::NOTIFICATION_PROFILE_DESTROYED, type); 1116 DCHECK_EQ(chrome::NOTIFICATION_PROFILE_DESTROYED, type);
1108 DCHECK_EQ(profile_, content::Source<Profile>(source).ptr()); 1117 DCHECK_EQ(profile_, content::Source<Profile>(source).ptr());
1109 profile_ = NULL; 1118 profile_ = NULL;
1110 } 1119 }
1111 } 1120 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/content_settings/content_setting_bubble_model_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698