| 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/options/content_settings_handler.h" | 5 #include "chrome/browser/dom_ui/options/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/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 193 localized_strings->SetString("removeExceptionRow", | 193 localized_strings->SetString("removeExceptionRow", |
| 194 l10n_util::GetStringUTF16(IDS_EXCEPTIONS_REMOVE_BUTTON)); | 194 l10n_util::GetStringUTF16(IDS_EXCEPTIONS_REMOVE_BUTTON)); |
| 195 localized_strings->SetString("editExceptionRow", | 195 localized_strings->SetString("editExceptionRow", |
| 196 l10n_util::GetStringUTF16(IDS_EXCEPTIONS_EDIT_BUTTON)); | 196 l10n_util::GetStringUTF16(IDS_EXCEPTIONS_EDIT_BUTTON)); |
| 197 localized_strings->SetString("otr_exceptions_explanation", | 197 localized_strings->SetString("otr_exceptions_explanation", |
| 198 l10n_util::GetStringUTF16(IDS_EXCEPTIONS_OTR_LABEL)); | 198 l10n_util::GetStringUTF16(IDS_EXCEPTIONS_OTR_LABEL)); |
| 199 localized_strings->SetString("examplePattern", | 199 localized_strings->SetString("examplePattern", |
| 200 l10n_util::GetStringUTF16(IDS_EXCEPTIONS_PATTERN_EXAMPLE)); | 200 l10n_util::GetStringUTF16(IDS_EXCEPTIONS_PATTERN_EXAMPLE)); |
| 201 localized_strings->SetString("addNewExceptionInstructions", | 201 localized_strings->SetString("addNewExceptionInstructions", |
| 202 l10n_util::GetStringUTF16(IDS_EXCEPTIONS_ADD_NEW_INSTRUCTIONS)); | 202 l10n_util::GetStringUTF16(IDS_EXCEPTIONS_ADD_NEW_INSTRUCTIONS)); |
| 203 localized_strings->SetString("manage_exceptions", |
| 204 l10n_util::GetStringUTF16(IDS_EXCEPTIONS_MANAGE)); |
| 203 | 205 |
| 204 // Cookies filter. | 206 // Cookies filter. |
| 205 localized_strings->SetString("cookies_tab_label", | 207 localized_strings->SetString("cookies_tab_label", |
| 206 l10n_util::GetStringUTF16(IDS_COOKIES_TAB_LABEL)); | 208 l10n_util::GetStringUTF16(IDS_COOKIES_TAB_LABEL)); |
| 209 localized_strings->SetString("cookies_header", |
| 210 l10n_util::GetStringUTF16(IDS_COOKIES_HEADER)); |
| 207 localized_strings->SetString("cookies_allow", | 211 localized_strings->SetString("cookies_allow", |
| 208 l10n_util::GetStringUTF16(IDS_COOKIES_ALLOW_RADIO)); | 212 l10n_util::GetStringUTF16(IDS_COOKIES_ALLOW_RADIO)); |
| 209 localized_strings->SetString("cookies_ask", | 213 localized_strings->SetString("cookies_ask", |
| 210 l10n_util::GetStringUTF16(IDS_COOKIES_ASK_EVERY_TIME_RADIO)); | 214 l10n_util::GetStringUTF16(IDS_COOKIES_ASK_EVERY_TIME_RADIO)); |
| 211 localized_strings->SetString("cookies_block", | 215 localized_strings->SetString("cookies_block", |
| 212 l10n_util::GetStringUTF16(IDS_COOKIES_BLOCK_RADIO)); | 216 l10n_util::GetStringUTF16(IDS_COOKIES_BLOCK_RADIO)); |
| 213 localized_strings->SetString("cookies_block_3rd_party", | 217 localized_strings->SetString("cookies_block_3rd_party", |
| 214 l10n_util::GetStringUTF16(IDS_COOKIES_BLOCK_3RDPARTY_CHKBOX)); | 218 l10n_util::GetStringUTF16(IDS_COOKIES_BLOCK_3RDPARTY_CHKBOX)); |
| 215 localized_strings->SetString("cookies_clear_on_exit", | 219 localized_strings->SetString("cookies_clear_on_exit", |
| 216 l10n_util::GetStringUTF16(IDS_COOKIES_CLEAR_WHEN_CLOSE_CHKBOX)); | 220 l10n_util::GetStringUTF16(IDS_COOKIES_CLEAR_WHEN_CLOSE_CHKBOX)); |
| 217 localized_strings->SetString("cookies_show_cookies", | 221 localized_strings->SetString("cookies_show_cookies", |
| 218 l10n_util::GetStringUTF16(IDS_COOKIES_SHOW_COOKIES_BUTTON)); | 222 l10n_util::GetStringUTF16(IDS_COOKIES_SHOW_COOKIES_BUTTON)); |
| 219 localized_strings->SetString("flash_storage_settings", | 223 localized_strings->SetString("flash_storage_settings", |
| 220 l10n_util::GetStringUTF16(IDS_FLASH_STORAGE_SETTINGS)); | 224 l10n_util::GetStringUTF16(IDS_FLASH_STORAGE_SETTINGS)); |
| 221 localized_strings->SetString("flash_storage_url", | 225 localized_strings->SetString("flash_storage_url", |
| 222 l10n_util::GetStringUTF16(IDS_FLASH_STORAGE_URL)); | 226 l10n_util::GetStringUTF16(IDS_FLASH_STORAGE_URL)); |
| 223 | 227 |
| 224 // Image filter. | 228 // Image filter. |
| 225 localized_strings->SetString("images_tab_label", | 229 localized_strings->SetString("images_tab_label", |
| 226 l10n_util::GetStringUTF16(IDS_IMAGES_TAB_LABEL)); | 230 l10n_util::GetStringUTF16(IDS_IMAGES_TAB_LABEL)); |
| 231 localized_strings->SetString("images_header", |
| 232 l10n_util::GetStringUTF16(IDS_IMAGES_HEADER)); |
| 227 localized_strings->SetString("images_allow", | 233 localized_strings->SetString("images_allow", |
| 228 l10n_util::GetStringUTF16(IDS_IMAGES_LOAD_RADIO)); | 234 l10n_util::GetStringUTF16(IDS_IMAGES_LOAD_RADIO)); |
| 229 localized_strings->SetString("images_block", | 235 localized_strings->SetString("images_block", |
| 230 l10n_util::GetStringUTF16(IDS_IMAGES_NOLOAD_RADIO)); | 236 l10n_util::GetStringUTF16(IDS_IMAGES_NOLOAD_RADIO)); |
| 231 | 237 |
| 232 // JavaScript filter. | 238 // JavaScript filter. |
| 233 localized_strings->SetString("javascript_tab_label", | 239 localized_strings->SetString("javascript_tab_label", |
| 234 l10n_util::GetStringUTF16(IDS_JAVASCRIPT_TAB_LABEL)); | 240 l10n_util::GetStringUTF16(IDS_JAVASCRIPT_TAB_LABEL)); |
| 241 localized_strings->SetString("javascript_header", |
| 242 l10n_util::GetStringUTF16(IDS_JAVASCRIPT_HEADER)); |
| 235 localized_strings->SetString("javascript_allow", | 243 localized_strings->SetString("javascript_allow", |
| 236 l10n_util::GetStringUTF16(IDS_JS_ALLOW_RADIO)); | 244 l10n_util::GetStringUTF16(IDS_JS_ALLOW_RADIO)); |
| 237 localized_strings->SetString("javascript_block", | 245 localized_strings->SetString("javascript_block", |
| 238 l10n_util::GetStringUTF16(IDS_JS_DONOTALLOW_RADIO)); | 246 l10n_util::GetStringUTF16(IDS_JS_DONOTALLOW_RADIO)); |
| 239 | 247 |
| 240 // Plug-ins filter. | 248 // Plug-ins filter. |
| 241 localized_strings->SetString("plugins_tab_label", | 249 localized_strings->SetString("plugins_tab_label", |
| 242 l10n_util::GetStringUTF16(IDS_PLUGIN_TAB_LABEL)); | 250 l10n_util::GetStringUTF16(IDS_PLUGIN_TAB_LABEL)); |
| 251 localized_strings->SetString("plugins_header", |
| 252 l10n_util::GetStringUTF16(IDS_PLUGIN_HEADER)); |
| 243 localized_strings->SetString("plugins_ask", | 253 localized_strings->SetString("plugins_ask", |
| 244 l10n_util::GetStringUTF16(IDS_PLUGIN_ASK_RADIO)); | 254 l10n_util::GetStringUTF16(IDS_PLUGIN_ASK_RADIO)); |
| 245 localized_strings->SetString("plugins_allow", | 255 localized_strings->SetString("plugins_allow", |
| 246 l10n_util::GetStringUTF16(IDS_PLUGIN_LOAD_RADIO)); | 256 l10n_util::GetStringUTF16(IDS_PLUGIN_LOAD_RADIO)); |
| 247 localized_strings->SetString("plugins_block", | 257 localized_strings->SetString("plugins_block", |
| 248 l10n_util::GetStringUTF16(IDS_PLUGIN_NOLOAD_RADIO)); | 258 l10n_util::GetStringUTF16(IDS_PLUGIN_NOLOAD_RADIO)); |
| 249 localized_strings->SetString("disable_individual_plugins", | 259 localized_strings->SetString("disable_individual_plugins", |
| 250 l10n_util::GetStringUTF16(IDS_PLUGIN_SELECTIVE_DISABLE)); | 260 l10n_util::GetStringUTF16(IDS_PLUGIN_SELECTIVE_DISABLE)); |
| 251 localized_strings->SetBoolean("enable_click_to_play", | 261 localized_strings->SetBoolean("enable_click_to_play", |
| 252 CommandLine::ForCurrentProcess()->HasSwitch( | 262 CommandLine::ForCurrentProcess()->HasSwitch( |
| 253 switches::kEnableClickToPlay)); | 263 switches::kEnableClickToPlay)); |
| 254 | 264 |
| 255 | |
| 256 // Pop-ups filter. | 265 // Pop-ups filter. |
| 257 localized_strings->SetString("popups_tab_label", | 266 localized_strings->SetString("popups_tab_label", |
| 258 l10n_util::GetStringUTF16(IDS_POPUP_TAB_LABEL)); | 267 l10n_util::GetStringUTF16(IDS_POPUP_TAB_LABEL)); |
| 268 localized_strings->SetString("popups_header", |
| 269 l10n_util::GetStringUTF16(IDS_POPUP_HEADER)); |
| 259 localized_strings->SetString("popups_allow", | 270 localized_strings->SetString("popups_allow", |
| 260 l10n_util::GetStringUTF16(IDS_POPUP_ALLOW_RADIO)); | 271 l10n_util::GetStringUTF16(IDS_POPUP_ALLOW_RADIO)); |
| 261 localized_strings->SetString("popups_block", | 272 localized_strings->SetString("popups_block", |
| 262 l10n_util::GetStringUTF16(IDS_POPUP_BLOCK_RADIO)); | 273 l10n_util::GetStringUTF16(IDS_POPUP_BLOCK_RADIO)); |
| 263 | 274 |
| 264 // Location filter. | 275 // Location filter. |
| 265 localized_strings->SetString("location_tab_label", | 276 localized_strings->SetString("location_tab_label", |
| 266 l10n_util::GetStringUTF16(IDS_GEOLOCATION_TAB_LABEL)); | 277 l10n_util::GetStringUTF16(IDS_GEOLOCATION_TAB_LABEL)); |
| 278 localized_strings->SetString("location_header", |
| 279 l10n_util::GetStringUTF16(IDS_GEOLOCATION_HEADER)); |
| 267 localized_strings->SetString("location_allow", | 280 localized_strings->SetString("location_allow", |
| 268 l10n_util::GetStringUTF16(IDS_GEOLOCATION_ALLOW_RADIO)); | 281 l10n_util::GetStringUTF16(IDS_GEOLOCATION_ALLOW_RADIO)); |
| 269 localized_strings->SetString("location_ask", | 282 localized_strings->SetString("location_ask", |
| 270 l10n_util::GetStringUTF16(IDS_GEOLOCATION_ASK_RADIO)); | 283 l10n_util::GetStringUTF16(IDS_GEOLOCATION_ASK_RADIO)); |
| 271 localized_strings->SetString("location_block", | 284 localized_strings->SetString("location_block", |
| 272 l10n_util::GetStringUTF16(IDS_GEOLOCATION_BLOCK_RADIO)); | 285 l10n_util::GetStringUTF16(IDS_GEOLOCATION_BLOCK_RADIO)); |
| 273 | 286 |
| 274 // Notifications filter. | 287 // Notifications filter. |
| 275 localized_strings->SetString("notifications_tab_label", | 288 localized_strings->SetString("notifications_tab_label", |
| 276 l10n_util::GetStringUTF16(IDS_NOTIFICATIONS_TAB_LABEL)); | 289 l10n_util::GetStringUTF16(IDS_NOTIFICATIONS_TAB_LABEL)); |
| 290 localized_strings->SetString("notifications_header", |
| 291 l10n_util::GetStringUTF16(IDS_NOTIFICATIONS_HEADER)); |
| 277 localized_strings->SetString("notifications_allow", | 292 localized_strings->SetString("notifications_allow", |
| 278 l10n_util::GetStringUTF16(IDS_NOTIFICATIONS_ALLOW_RADIO)); | 293 l10n_util::GetStringUTF16(IDS_NOTIFICATIONS_ALLOW_RADIO)); |
| 279 localized_strings->SetString("notifications_ask", | 294 localized_strings->SetString("notifications_ask", |
| 280 l10n_util::GetStringUTF16(IDS_NOTIFICATIONS_ASK_RADIO)); | 295 l10n_util::GetStringUTF16(IDS_NOTIFICATIONS_ASK_RADIO)); |
| 281 localized_strings->SetString("notifications_block", | 296 localized_strings->SetString("notifications_block", |
| 282 l10n_util::GetStringUTF16(IDS_NOTIFICATIONS_BLOCK_RADIO)); | 297 l10n_util::GetStringUTF16(IDS_NOTIFICATIONS_BLOCK_RADIO)); |
| 283 } | 298 } |
| 284 | 299 |
| 285 void ContentSettingsHandler::Initialize() { | 300 void ContentSettingsHandler::Initialize() { |
| 286 const HostContentSettingsMap* settings_map = GetContentSettingsMap(); | 301 const HostContentSettingsMap* settings_map = GetContentSettingsMap(); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 312 pref_change_registrar_.Add(prefs::kGeolocationDefaultContentSetting, this); | 327 pref_change_registrar_.Add(prefs::kGeolocationDefaultContentSetting, this); |
| 313 pref_change_registrar_.Add(prefs::kGeolocationContentSettings, this); | 328 pref_change_registrar_.Add(prefs::kGeolocationContentSettings, this); |
| 314 } | 329 } |
| 315 | 330 |
| 316 void ContentSettingsHandler::Observe(NotificationType type, | 331 void ContentSettingsHandler::Observe(NotificationType type, |
| 317 const NotificationSource& source, | 332 const NotificationSource& source, |
| 318 const NotificationDetails& details) { | 333 const NotificationDetails& details) { |
| 319 switch (type.value) { | 334 switch (type.value) { |
| 320 case NotificationType::PROFILE_DESTROYED: { | 335 case NotificationType::PROFILE_DESTROYED: { |
| 321 Profile* profile = static_cast<Source<Profile> >(source).ptr(); | 336 Profile* profile = static_cast<Source<Profile> >(source).ptr(); |
| 322 if (profile->IsOffTheRecord()) | 337 if (profile->IsOffTheRecord()) { |
| 323 dom_ui_->CallJavascriptFunction(L"ContentSettings.OTRProfileDestroyed"); | 338 dom_ui_->CallJavascriptFunction( |
| 339 L"ContentSettingsExceptionsArea.OTRProfileDestroyed"); |
| 340 } |
| 324 break; | 341 break; |
| 325 } | 342 } |
| 326 | 343 |
| 327 case NotificationType::OTR_PROFILE_CREATED: { | 344 case NotificationType::OTR_PROFILE_CREATED: { |
| 328 UpdateAllOTRExceptionsViewsFromModel(); | 345 UpdateAllOTRExceptionsViewsFromModel(); |
| 329 break; | 346 break; |
| 330 } | 347 } |
| 331 | 348 |
| 332 case NotificationType::CONTENT_SETTINGS_CHANGED: { | 349 case NotificationType::CONTENT_SETTINGS_CHANGED: { |
| 333 const ContentSettingsDetails* settings_details = | 350 const ContentSettingsDetails* settings_details = |
| (...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 548 L"ContentSettings.setOTRExceptions", type_string, otr_exceptions); | 565 L"ContentSettings.setOTRExceptions", type_string, otr_exceptions); |
| 549 } | 566 } |
| 550 | 567 |
| 551 void ContentSettingsHandler::RegisterMessages() { | 568 void ContentSettingsHandler::RegisterMessages() { |
| 552 dom_ui_->RegisterMessageCallback("setContentFilter", | 569 dom_ui_->RegisterMessageCallback("setContentFilter", |
| 553 NewCallback(this, | 570 NewCallback(this, |
| 554 &ContentSettingsHandler::SetContentFilter)); | 571 &ContentSettingsHandler::SetContentFilter)); |
| 555 dom_ui_->RegisterMessageCallback("setAllowThirdPartyCookies", | 572 dom_ui_->RegisterMessageCallback("setAllowThirdPartyCookies", |
| 556 NewCallback(this, | 573 NewCallback(this, |
| 557 &ContentSettingsHandler::SetAllowThirdPartyCookies)); | 574 &ContentSettingsHandler::SetAllowThirdPartyCookies)); |
| 558 dom_ui_->RegisterMessageCallback("removeExceptions", | 575 dom_ui_->RegisterMessageCallback("removeException", |
| 559 NewCallback(this, | 576 NewCallback(this, |
| 560 &ContentSettingsHandler::RemoveExceptions)); | 577 &ContentSettingsHandler::RemoveException)); |
| 561 dom_ui_->RegisterMessageCallback("setException", | 578 dom_ui_->RegisterMessageCallback("setException", |
| 562 NewCallback(this, | 579 NewCallback(this, |
| 563 &ContentSettingsHandler::SetException)); | 580 &ContentSettingsHandler::SetException)); |
| 564 dom_ui_->RegisterMessageCallback("checkExceptionPatternValidity", | 581 dom_ui_->RegisterMessageCallback("checkExceptionPatternValidity", |
| 565 NewCallback(this, | 582 NewCallback(this, |
| 566 &ContentSettingsHandler::CheckExceptionPatternValidity)); | 583 &ContentSettingsHandler::CheckExceptionPatternValidity)); |
| 567 dom_ui_->RegisterMessageCallback( | 584 dom_ui_->RegisterMessageCallback( |
| 568 "openPluginsTab", | 585 "openPluginsTab", |
| 569 NewCallback(this, &ContentSettingsHandler::OpenPluginsTab)); | 586 NewCallback(this, &ContentSettingsHandler::OpenPluginsTab)); |
| 570 } | 587 } |
| (...skipping 20 matching lines...) Expand all Loading... |
| 591 SetDefaultContentSetting(content_type, default_setting); | 608 SetDefaultContentSetting(content_type, default_setting); |
| 592 } | 609 } |
| 593 } | 610 } |
| 594 | 611 |
| 595 void ContentSettingsHandler::SetAllowThirdPartyCookies(const ListValue* args) { | 612 void ContentSettingsHandler::SetAllowThirdPartyCookies(const ListValue* args) { |
| 596 std::wstring allow = ExtractStringValue(args); | 613 std::wstring allow = ExtractStringValue(args); |
| 597 | 614 |
| 598 GetContentSettingsMap()->SetBlockThirdPartyCookies(allow == L"true"); | 615 GetContentSettingsMap()->SetBlockThirdPartyCookies(allow == L"true"); |
| 599 } | 616 } |
| 600 | 617 |
| 601 void ContentSettingsHandler::RemoveExceptions(const ListValue* args) { | 618 void ContentSettingsHandler::RemoveException(const ListValue* args) { |
| 602 size_t arg_i = 0; | 619 size_t arg_i = 0; |
| 603 std::string type_string; | 620 std::string type_string; |
| 604 CHECK(args->GetString(arg_i++, &type_string)); | 621 CHECK(args->GetString(arg_i++, &type_string)); |
| 605 | 622 |
| 606 ContentSettingsType type = ContentSettingsTypeFromGroupName(type_string); | 623 ContentSettingsType type = ContentSettingsTypeFromGroupName(type_string); |
| 607 while (arg_i < args->GetSize()) { | 624 if (type == CONTENT_SETTINGS_TYPE_GEOLOCATION) { |
| 608 if (type == CONTENT_SETTINGS_TYPE_GEOLOCATION) { | 625 std::string origin; |
| 609 std::string origin; | 626 std::string embedding_origin; |
| 610 std::string embedding_origin; | 627 bool rv = args->GetString(arg_i++, &origin); |
| 611 bool rv = args->GetString(arg_i++, &origin); | 628 DCHECK(rv); |
| 612 DCHECK(rv); | 629 rv = args->GetString(arg_i++, &embedding_origin); |
| 613 rv = args->GetString(arg_i++, &embedding_origin); | 630 DCHECK(rv); |
| 614 DCHECK(rv); | |
| 615 | 631 |
| 616 dom_ui_->GetProfile()->GetGeolocationContentSettingsMap()-> | 632 dom_ui_->GetProfile()->GetGeolocationContentSettingsMap()-> |
| 617 SetContentSetting(GURL(origin), | 633 SetContentSetting(GURL(origin), |
| 618 GURL(embedding_origin), | 634 GURL(embedding_origin), |
| 619 CONTENT_SETTING_DEFAULT); | 635 CONTENT_SETTING_DEFAULT); |
| 620 } else if (type == CONTENT_SETTINGS_TYPE_NOTIFICATIONS) { | 636 } else if (type == CONTENT_SETTINGS_TYPE_NOTIFICATIONS) { |
| 621 std::string origin; | 637 std::string origin; |
| 622 std::string setting; | 638 std::string setting; |
| 623 bool rv = args->GetString(arg_i++, &origin); | 639 bool rv = args->GetString(arg_i++, &origin); |
| 624 DCHECK(rv); | 640 DCHECK(rv); |
| 625 rv = args->GetString(arg_i++, &setting); | 641 rv = args->GetString(arg_i++, &setting); |
| 626 DCHECK(rv); | 642 DCHECK(rv); |
| 627 ContentSetting content_setting = ContentSettingFromString(setting); | 643 ContentSetting content_setting = ContentSettingFromString(setting); |
| 628 if (content_setting == CONTENT_SETTING_ALLOW) { | 644 if (content_setting == CONTENT_SETTING_ALLOW) { |
| 629 dom_ui_->GetProfile()->GetDesktopNotificationService()-> | 645 dom_ui_->GetProfile()->GetDesktopNotificationService()-> |
| 630 ResetAllowedOrigin(GURL(origin)); | 646 ResetAllowedOrigin(GURL(origin)); |
| 631 } else { | |
| 632 DCHECK_EQ(content_setting, CONTENT_SETTING_BLOCK); | |
| 633 dom_ui_->GetProfile()->GetDesktopNotificationService()-> | |
| 634 ResetBlockedOrigin(GURL(origin)); | |
| 635 } | |
| 636 } else { | 647 } else { |
| 637 std::string mode; | 648 DCHECK_EQ(content_setting, CONTENT_SETTING_BLOCK); |
| 638 bool rv = args->GetString(arg_i++, &mode); | 649 dom_ui_->GetProfile()->GetDesktopNotificationService()-> |
| 639 DCHECK(rv); | 650 ResetBlockedOrigin(GURL(origin)); |
| 651 } |
| 652 } else { |
| 653 std::string mode; |
| 654 bool rv = args->GetString(arg_i++, &mode); |
| 655 DCHECK(rv); |
| 640 | 656 |
| 641 std::string pattern; | 657 std::string pattern; |
| 642 rv = args->GetString(arg_i++, &pattern); | 658 rv = args->GetString(arg_i++, &pattern); |
| 643 DCHECK(rv); | 659 DCHECK(rv); |
| 644 | 660 |
| 645 HostContentSettingsMap* settings_map = | 661 HostContentSettingsMap* settings_map = |
| 646 mode == "normal" ? GetContentSettingsMap() : | 662 mode == "normal" ? GetContentSettingsMap() : |
| 647 GetOTRContentSettingsMap(); | 663 GetOTRContentSettingsMap(); |
| 648 // The settings map could be null if the mode was OTR but the OTR profile | 664 // The settings map could be null if the mode was OTR but the OTR profile |
| 649 // got destroyed before we received this message. | 665 // got destroyed before we received this message. |
| 650 if (settings_map) { | 666 if (settings_map) { |
| 651 settings_map->SetContentSetting( | 667 settings_map->SetContentSetting( |
| 652 ContentSettingsPattern(pattern), | 668 ContentSettingsPattern(pattern), |
| 653 ContentSettingsTypeFromGroupName(type_string), | 669 ContentSettingsTypeFromGroupName(type_string), |
| 654 "", | 670 "", |
| 655 CONTENT_SETTING_DEFAULT); | 671 CONTENT_SETTING_DEFAULT); |
| 656 } | |
| 657 } | 672 } |
| 658 } | 673 } |
| 659 } | 674 } |
| 660 | 675 |
| 661 void ContentSettingsHandler::SetException(const ListValue* args) { | 676 void ContentSettingsHandler::SetException(const ListValue* args) { |
| 662 size_t arg_i = 0; | 677 size_t arg_i = 0; |
| 663 std::string type_string; | 678 std::string type_string; |
| 664 CHECK(args->GetString(arg_i++, &type_string)); | 679 CHECK(args->GetString(arg_i++, &type_string)); |
| 665 std::string mode; | 680 std::string mode; |
| 666 CHECK(args->GetString(arg_i++, &mode)); | 681 CHECK(args->GetString(arg_i++, &mode)); |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 747 return dom_ui_->GetProfile()->GetHostContentSettingsMap(); | 762 return dom_ui_->GetProfile()->GetHostContentSettingsMap(); |
| 748 } | 763 } |
| 749 | 764 |
| 750 HostContentSettingsMap* | 765 HostContentSettingsMap* |
| 751 ContentSettingsHandler::GetOTRContentSettingsMap() { | 766 ContentSettingsHandler::GetOTRContentSettingsMap() { |
| 752 Profile* profile = dom_ui_->GetProfile(); | 767 Profile* profile = dom_ui_->GetProfile(); |
| 753 if (profile->HasOffTheRecordProfile()) | 768 if (profile->HasOffTheRecordProfile()) |
| 754 return profile->GetOffTheRecordProfile()->GetHostContentSettingsMap(); | 769 return profile->GetOffTheRecordProfile()->GetHostContentSettingsMap(); |
| 755 return NULL; | 770 return NULL; |
| 756 } | 771 } |
| OLD | NEW |