| 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/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 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 270 {CONTENT_SETTINGS_TYPE_JAVASCRIPT, IDS_BLOCKED_JAVASCRIPT_UNBLOCK}, | 270 {CONTENT_SETTINGS_TYPE_JAVASCRIPT, IDS_BLOCKED_JAVASCRIPT_UNBLOCK}, |
| 271 {CONTENT_SETTINGS_TYPE_PLUGINS, IDS_BLOCKED_PLUGINS_UNBLOCK_ALL}, | 271 {CONTENT_SETTINGS_TYPE_PLUGINS, IDS_BLOCKED_PLUGINS_UNBLOCK_ALL}, |
| 272 {CONTENT_SETTINGS_TYPE_POPUPS, IDS_BLOCKED_POPUPS_UNBLOCK}, | 272 {CONTENT_SETTINGS_TYPE_POPUPS, IDS_BLOCKED_POPUPS_UNBLOCK}, |
| 273 {CONTENT_SETTINGS_TYPE_PPAPI_BROKER, IDS_BLOCKED_PPAPI_BROKER_UNBLOCK}, | 273 {CONTENT_SETTINGS_TYPE_PPAPI_BROKER, IDS_BLOCKED_PPAPI_BROKER_UNBLOCK}, |
| 274 }; | 274 }; |
| 275 // Fields as for kBlockedAllowIDs, above. | 275 // Fields as for kBlockedAllowIDs, above. |
| 276 static const ContentSettingsTypeIdEntry kResourceSpecificBlockedAllowIDs[] = { | 276 static const ContentSettingsTypeIdEntry kResourceSpecificBlockedAllowIDs[] = { |
| 277 {CONTENT_SETTINGS_TYPE_PLUGINS, IDS_BLOCKED_PLUGINS_UNBLOCK}, | 277 {CONTENT_SETTINGS_TYPE_PLUGINS, IDS_BLOCKED_PLUGINS_UNBLOCK}, |
| 278 }; | 278 }; |
| 279 static const ContentSettingsTypeIdEntry kAllowedAllowIDs[] = { | 279 static const ContentSettingsTypeIdEntry kAllowedAllowIDs[] = { |
| 280 // TODO(bauerb): The string shouldn't be "unblock" (they weren't blocked). |
| 281 {CONTENT_SETTINGS_TYPE_COOKIES, IDS_BLOCKED_COOKIES_UNBLOCK}, |
| 280 {CONTENT_SETTINGS_TYPE_PPAPI_BROKER, IDS_ALLOWED_PPAPI_BROKER_NO_ACTION}, | 282 {CONTENT_SETTINGS_TYPE_PPAPI_BROKER, IDS_ALLOWED_PPAPI_BROKER_NO_ACTION}, |
| 281 }; | 283 }; |
| 282 | 284 |
| 283 std::string radio_allow_label; | 285 std::string radio_allow_label; |
| 284 if (allowed) { | 286 if (allowed) { |
| 285 radio_allow_label = l10n_util::GetStringUTF8( | 287 int resource_id = GetIdForContentType(kAllowedAllowIDs, |
| 286 GetIdForContentType(kAllowedAllowIDs, arraysize(kAllowedAllowIDs), | 288 arraysize(kAllowedAllowIDs), |
| 287 content_type())); | 289 content_type()); |
| 290 radio_allow_label = (content_type() == CONTENT_SETTINGS_TYPE_COOKIES) ? |
| 291 l10n_util::GetStringFUTF8(resource_id, display_host) : |
| 292 l10n_util::GetStringUTF8(resource_id); |
| 288 } else if (resources.empty()) { | 293 } else if (resources.empty()) { |
| 289 radio_allow_label = l10n_util::GetStringFUTF8( | 294 radio_allow_label = l10n_util::GetStringFUTF8( |
| 290 GetIdForContentType(kBlockedAllowIDs, arraysize(kBlockedAllowIDs), | 295 GetIdForContentType(kBlockedAllowIDs, arraysize(kBlockedAllowIDs), |
| 291 content_type()), | 296 content_type()), |
| 292 display_host); | 297 display_host); |
| 293 } else { | 298 } else { |
| 294 radio_allow_label = l10n_util::GetStringFUTF8( | 299 radio_allow_label = l10n_util::GetStringFUTF8( |
| 295 GetIdForContentType(kResourceSpecificBlockedAllowIDs, | 300 GetIdForContentType(kResourceSpecificBlockedAllowIDs, |
| 296 arraysize(kResourceSpecificBlockedAllowIDs), | 301 arraysize(kResourceSpecificBlockedAllowIDs), |
| 297 content_type()), | 302 content_type()), |
| 298 display_host); | 303 display_host); |
| 299 } | 304 } |
| 300 | 305 |
| 301 static const ContentSettingsTypeIdEntry kBlockedBlockIDs[] = { | 306 static const ContentSettingsTypeIdEntry kBlockedBlockIDs[] = { |
| 302 {CONTENT_SETTINGS_TYPE_COOKIES, IDS_BLOCKED_COOKIES_NO_ACTION}, | 307 {CONTENT_SETTINGS_TYPE_COOKIES, IDS_BLOCKED_COOKIES_NO_ACTION}, |
| 303 {CONTENT_SETTINGS_TYPE_IMAGES, IDS_BLOCKED_IMAGES_NO_ACTION}, | 308 {CONTENT_SETTINGS_TYPE_IMAGES, IDS_BLOCKED_IMAGES_NO_ACTION}, |
| 304 {CONTENT_SETTINGS_TYPE_JAVASCRIPT, IDS_BLOCKED_JAVASCRIPT_NO_ACTION}, | 309 {CONTENT_SETTINGS_TYPE_JAVASCRIPT, IDS_BLOCKED_JAVASCRIPT_NO_ACTION}, |
| 305 {CONTENT_SETTINGS_TYPE_PLUGINS, IDS_BLOCKED_PLUGINS_NO_ACTION}, | 310 {CONTENT_SETTINGS_TYPE_PLUGINS, IDS_BLOCKED_PLUGINS_NO_ACTION}, |
| 306 {CONTENT_SETTINGS_TYPE_POPUPS, IDS_BLOCKED_POPUPS_NO_ACTION}, | 311 {CONTENT_SETTINGS_TYPE_POPUPS, IDS_BLOCKED_POPUPS_NO_ACTION}, |
| 307 {CONTENT_SETTINGS_TYPE_PPAPI_BROKER, IDS_BLOCKED_PPAPI_BROKER_NO_ACTION}, | 312 {CONTENT_SETTINGS_TYPE_PPAPI_BROKER, IDS_BLOCKED_PPAPI_BROKER_NO_ACTION}, |
| 308 }; | 313 }; |
| 309 static const ContentSettingsTypeIdEntry kAllowedBlockIDs[] = { | 314 static const ContentSettingsTypeIdEntry kAllowedBlockIDs[] = { |
| 315 // TODO(bauerb): The string should say "block". |
| 316 {CONTENT_SETTINGS_TYPE_COOKIES, IDS_BLOCKED_COOKIES_NO_ACTION}, |
| 310 {CONTENT_SETTINGS_TYPE_PPAPI_BROKER, IDS_ALLOWED_PPAPI_BROKER_BLOCK}, | 317 {CONTENT_SETTINGS_TYPE_PPAPI_BROKER, IDS_ALLOWED_PPAPI_BROKER_BLOCK}, |
| 311 }; | 318 }; |
| 312 | 319 |
| 313 std::string radio_block_label; | 320 std::string radio_block_label; |
| 314 if (allowed) { | 321 if (allowed) { |
| 315 radio_block_label = l10n_util::GetStringFUTF8( | 322 int resource_id = GetIdForContentType(kAllowedBlockIDs, |
| 316 GetIdForContentType(kAllowedBlockIDs, arraysize(kAllowedBlockIDs), | 323 arraysize(kAllowedBlockIDs), |
| 317 content_type()), | 324 content_type()); |
| 318 display_host); | 325 radio_block_label = (content_type() == CONTENT_SETTINGS_TYPE_COOKIES) ? |
| 326 l10n_util::GetStringUTF8(resource_id) : |
| 327 l10n_util::GetStringFUTF8(resource_id, display_host); |
| 319 } else { | 328 } else { |
| 320 radio_block_label = l10n_util::GetStringUTF8( | 329 radio_block_label = l10n_util::GetStringUTF8( |
| 321 GetIdForContentType(kBlockedBlockIDs, arraysize(kBlockedBlockIDs), | 330 GetIdForContentType(kBlockedBlockIDs, arraysize(kBlockedBlockIDs), |
| 322 content_type())); | 331 content_type())); |
| 323 } | 332 } |
| 324 | 333 |
| 325 radio_group.radio_items.push_back(radio_allow_label); | 334 radio_group.radio_items.push_back(radio_allow_label); |
| 326 radio_group.radio_items.push_back(radio_block_label); | 335 radio_group.radio_items.push_back(radio_block_label); |
| 327 HostContentSettingsMap* map = profile()->GetHostContentSettingsMap(); | 336 HostContentSettingsMap* map = profile()->GetHostContentSettingsMap(); |
| 328 CookieSettings* cookie_settings = | 337 CookieSettings* cookie_settings = |
| (...skipping 673 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1002 if (type == content::NOTIFICATION_WEB_CONTENTS_DESTROYED) { | 1011 if (type == content::NOTIFICATION_WEB_CONTENTS_DESTROYED) { |
| 1003 DCHECK_EQ(web_contents_, | 1012 DCHECK_EQ(web_contents_, |
| 1004 content::Source<WebContents>(source).ptr()); | 1013 content::Source<WebContents>(source).ptr()); |
| 1005 web_contents_ = NULL; | 1014 web_contents_ = NULL; |
| 1006 } else { | 1015 } else { |
| 1007 DCHECK_EQ(chrome::NOTIFICATION_PROFILE_DESTROYED, type); | 1016 DCHECK_EQ(chrome::NOTIFICATION_PROFILE_DESTROYED, type); |
| 1008 DCHECK_EQ(profile_, content::Source<Profile>(source).ptr()); | 1017 DCHECK_EQ(profile_, content::Source<Profile>(source).ptr()); |
| 1009 profile_ = NULL; | 1018 profile_ = NULL; |
| 1010 } | 1019 } |
| 1011 } | 1020 } |
| OLD | NEW |