| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/dom_ui/content_settings_handler.h" | 5 #include "chrome/browser/dom_ui/content_settings_handler.h" |
| 6 | 6 |
| 7 #include "app/l10n_util.h" | 7 #include "app/l10n_util.h" |
| 8 #include "base/callback.h" | 8 #include "base/callback.h" |
| 9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
| 10 #include "base/values.h" | 10 #include "base/values.h" |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 localized_strings->SetString(L"contentSettingsPage", | 108 localized_strings->SetString(L"contentSettingsPage", |
| 109 l10n_util::GetString(IDS_CONTENT_SETTINGS_TITLE)); | 109 l10n_util::GetString(IDS_CONTENT_SETTINGS_TITLE)); |
| 110 localized_strings->SetString(L"allowException", | 110 localized_strings->SetString(L"allowException", |
| 111 l10n_util::GetString(IDS_EXCEPTIONS_ALLOW_BUTTON)); | 111 l10n_util::GetString(IDS_EXCEPTIONS_ALLOW_BUTTON)); |
| 112 localized_strings->SetString(L"blockException", | 112 localized_strings->SetString(L"blockException", |
| 113 l10n_util::GetString(IDS_EXCEPTIONS_BLOCK_BUTTON)); | 113 l10n_util::GetString(IDS_EXCEPTIONS_BLOCK_BUTTON)); |
| 114 localized_strings->SetString(L"addExceptionRow", | 114 localized_strings->SetString(L"addExceptionRow", |
| 115 l10n_util::GetString(IDS_EXCEPTIONS_ADD_BUTTON)); | 115 l10n_util::GetString(IDS_EXCEPTIONS_ADD_BUTTON)); |
| 116 localized_strings->SetString(L"removeExceptionRow", | 116 localized_strings->SetString(L"removeExceptionRow", |
| 117 l10n_util::GetString(IDS_EXCEPTIONS_REMOVE_BUTTON)); | 117 l10n_util::GetString(IDS_EXCEPTIONS_REMOVE_BUTTON)); |
| 118 localized_strings->SetString(L"editExceptionRow", |
| 119 l10n_util::GetString(IDS_EXCEPTIONS_EDIT_BUTTON)); |
| 118 | 120 |
| 119 // Cookies filter. | 121 // Cookies filter. |
| 120 localized_strings->SetString(L"cookies_tab_label", | 122 localized_strings->SetString(L"cookies_tab_label", |
| 121 l10n_util::GetString(IDS_COOKIES_TAB_LABEL)); | 123 l10n_util::GetString(IDS_COOKIES_TAB_LABEL)); |
| 122 localized_strings->SetString(L"cookies_modify", | 124 localized_strings->SetString(L"cookies_modify", |
| 123 l10n_util::GetString(IDS_MODIFY_COOKIE_STORING_LABEL)); | 125 l10n_util::GetString(IDS_MODIFY_COOKIE_STORING_LABEL)); |
| 124 localized_strings->SetString(L"cookies_allow", | 126 localized_strings->SetString(L"cookies_allow", |
| 125 l10n_util::GetString(IDS_COOKIES_ALLOW_RADIO)); | 127 l10n_util::GetString(IDS_COOKIES_ALLOW_RADIO)); |
| 126 localized_strings->SetString(L"cookies_block", | 128 localized_strings->SetString(L"cookies_block", |
| 127 l10n_util::GetString(IDS_COOKIES_BLOCK_RADIO)); | 129 l10n_util::GetString(IDS_COOKIES_BLOCK_RADIO)); |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 277 void ContentSettingsHandler::RegisterMessages() { | 279 void ContentSettingsHandler::RegisterMessages() { |
| 278 dom_ui_->RegisterMessageCallback("setContentFilter", | 280 dom_ui_->RegisterMessageCallback("setContentFilter", |
| 279 NewCallback(this, | 281 NewCallback(this, |
| 280 &ContentSettingsHandler::SetContentFilter)); | 282 &ContentSettingsHandler::SetContentFilter)); |
| 281 dom_ui_->RegisterMessageCallback("setAllowThirdPartyCookies", | 283 dom_ui_->RegisterMessageCallback("setAllowThirdPartyCookies", |
| 282 NewCallback(this, | 284 NewCallback(this, |
| 283 &ContentSettingsHandler::SetAllowThirdPartyCookies)); | 285 &ContentSettingsHandler::SetAllowThirdPartyCookies)); |
| 284 dom_ui_->RegisterMessageCallback("removeImageExceptions", | 286 dom_ui_->RegisterMessageCallback("removeImageExceptions", |
| 285 NewCallback(this, | 287 NewCallback(this, |
| 286 &ContentSettingsHandler::RemoveExceptions)); | 288 &ContentSettingsHandler::RemoveExceptions)); |
| 289 dom_ui_->RegisterMessageCallback("setImageException", |
| 290 NewCallback(this, |
| 291 &ContentSettingsHandler::SetException)); |
| 287 } | 292 } |
| 288 | 293 |
| 289 void ContentSettingsHandler::SetContentFilter(const Value* value) { | 294 void ContentSettingsHandler::SetContentFilter(const Value* value) { |
| 290 const ListValue* list_value = static_cast<const ListValue*>(value); | 295 const ListValue* list_value = static_cast<const ListValue*>(value); |
| 291 DCHECK_EQ(2U, list_value->GetSize()); | 296 DCHECK_EQ(2U, list_value->GetSize()); |
| 292 std::string group, setting; | 297 std::string group, setting; |
| 293 if (!(list_value->GetString(0, &group) && | 298 if (!(list_value->GetString(0, &group) && |
| 294 list_value->GetString(1, &setting))) { | 299 list_value->GetString(1, &setting))) { |
| 295 NOTREACHED(); | 300 NOTREACHED(); |
| 296 return; | 301 return; |
| (...skipping 20 matching lines...) Expand all Loading... |
| 317 dom_ui_->GetProfile()->GetHostContentSettingsMap(); | 322 dom_ui_->GetProfile()->GetHostContentSettingsMap(); |
| 318 for (size_t i = 0; i < list_value->GetSize(); ++i) { | 323 for (size_t i = 0; i < list_value->GetSize(); ++i) { |
| 319 std::string pattern; | 324 std::string pattern; |
| 320 bool rv = list_value->GetString(i, &pattern); | 325 bool rv = list_value->GetString(i, &pattern); |
| 321 DCHECK(rv); | 326 DCHECK(rv); |
| 322 settings_map->SetContentSetting(HostContentSettingsMap::Pattern(pattern), | 327 settings_map->SetContentSetting(HostContentSettingsMap::Pattern(pattern), |
| 323 CONTENT_SETTINGS_TYPE_IMAGES, | 328 CONTENT_SETTINGS_TYPE_IMAGES, |
| 324 CONTENT_SETTING_DEFAULT); | 329 CONTENT_SETTING_DEFAULT); |
| 325 } | 330 } |
| 326 } | 331 } |
| 332 |
| 333 // TODO(estade): generalize this function to work on all content settings types |
| 334 // rather than just images. |
| 335 void ContentSettingsHandler::SetException(const Value* value) { |
| 336 const ListValue* list_value = static_cast<const ListValue*>(value); |
| 337 std::string pattern; |
| 338 bool rv = list_value->GetString(0, &pattern); |
| 339 DCHECK(rv); |
| 340 std::string setting; |
| 341 rv = list_value->GetString(1, &setting); |
| 342 DCHECK(rv); |
| 343 |
| 344 HostContentSettingsMap* settings_map = |
| 345 dom_ui_->GetProfile()->GetHostContentSettingsMap(); |
| 346 settings_map->SetContentSetting(HostContentSettingsMap::Pattern(pattern), |
| 347 CONTENT_SETTINGS_TYPE_IMAGES, |
| 348 ContentSettingFromString(setting)); |
| 349 } |
| OLD | NEW |