OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/webui/options/content_settings_handler.h" | 5 #include "chrome/browser/ui/webui/options/content_settings_handler.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
260 RegisterStrings(localized_strings, resources, arraysize(resources)); | 260 RegisterStrings(localized_strings, resources, arraysize(resources)); |
261 RegisterTitle(localized_strings, "contentSettingsPage", | 261 RegisterTitle(localized_strings, "contentSettingsPage", |
262 IDS_CONTENT_SETTINGS_TITLE); | 262 IDS_CONTENT_SETTINGS_TITLE); |
263 localized_strings->SetBoolean("enable_click_to_play", | 263 localized_strings->SetBoolean("enable_click_to_play", |
264 CommandLine::ForCurrentProcess()->HasSwitch( | 264 CommandLine::ForCurrentProcess()->HasSwitch( |
265 switches::kEnableClickToPlay)); | 265 switches::kEnableClickToPlay)); |
266 } | 266 } |
267 | 267 |
268 void ContentSettingsHandler::Initialize() { | 268 void ContentSettingsHandler::Initialize() { |
269 const HostContentSettingsMap* settings_map = GetContentSettingsMap(); | 269 const HostContentSettingsMap* settings_map = GetContentSettingsMap(); |
270 scoped_ptr<Value> block_3rd_party(Value::CreateBooleanValue( | |
271 settings_map->BlockThirdPartyCookies())); | |
272 web_ui_->CallJavascriptFunction("ContentSettings.setBlockThirdPartyCookies", | |
273 *block_3rd_party.get()); | |
274 | |
275 notification_registrar_.Add( | 270 notification_registrar_.Add( |
276 this, NotificationType::OTR_PROFILE_CREATED, | 271 this, NotificationType::OTR_PROFILE_CREATED, |
277 NotificationService::AllSources()); | 272 NotificationService::AllSources()); |
278 notification_registrar_.Add( | 273 notification_registrar_.Add( |
279 this, NotificationType::PROFILE_DESTROYED, | 274 this, NotificationType::PROFILE_DESTROYED, |
280 NotificationService::AllSources()); | 275 NotificationService::AllSources()); |
281 | 276 |
282 UpdateHandlersEnabledRadios(); | 277 UpdateHandlersEnabledRadios(); |
283 UpdateAllExceptionsViewsFromModel(); | 278 UpdateAllExceptionsViewsFromModel(); |
284 notification_registrar_.Add( | 279 notification_registrar_.Add( |
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
562 | 557 |
563 StringValue type_string(ContentSettingsTypeToGroupName(type)); | 558 StringValue type_string(ContentSettingsTypeToGroupName(type)); |
564 web_ui_->CallJavascriptFunction("ContentSettings.setOTRExceptions", | 559 web_ui_->CallJavascriptFunction("ContentSettings.setOTRExceptions", |
565 type_string, otr_exceptions); | 560 type_string, otr_exceptions); |
566 } | 561 } |
567 | 562 |
568 void ContentSettingsHandler::RegisterMessages() { | 563 void ContentSettingsHandler::RegisterMessages() { |
569 web_ui_->RegisterMessageCallback("setContentFilter", | 564 web_ui_->RegisterMessageCallback("setContentFilter", |
570 NewCallback(this, | 565 NewCallback(this, |
571 &ContentSettingsHandler::SetContentFilter)); | 566 &ContentSettingsHandler::SetContentFilter)); |
572 web_ui_->RegisterMessageCallback("setAllowThirdPartyCookies", | |
573 NewCallback(this, | |
574 &ContentSettingsHandler::SetAllowThirdPartyCookies)); | |
575 web_ui_->RegisterMessageCallback("removeException", | 567 web_ui_->RegisterMessageCallback("removeException", |
576 NewCallback(this, | 568 NewCallback(this, |
577 &ContentSettingsHandler::RemoveException)); | 569 &ContentSettingsHandler::RemoveException)); |
578 web_ui_->RegisterMessageCallback("setException", | 570 web_ui_->RegisterMessageCallback("setException", |
579 NewCallback(this, | 571 NewCallback(this, |
580 &ContentSettingsHandler::SetException)); | 572 &ContentSettingsHandler::SetException)); |
581 web_ui_->RegisterMessageCallback("checkExceptionPatternValidity", | 573 web_ui_->RegisterMessageCallback("checkExceptionPatternValidity", |
582 NewCallback(this, | 574 NewCallback(this, |
583 &ContentSettingsHandler::CheckExceptionPatternValidity)); | 575 &ContentSettingsHandler::CheckExceptionPatternValidity)); |
584 } | 576 } |
(...skipping 14 matching lines...) Expand all Loading... |
599 SetDefaultContentSetting(default_setting); | 591 SetDefaultContentSetting(default_setting); |
600 } else if (content_type == CONTENT_SETTINGS_TYPE_NOTIFICATIONS) { | 592 } else if (content_type == CONTENT_SETTINGS_TYPE_NOTIFICATIONS) { |
601 DesktopNotificationServiceFactory::GetForProfile(web_ui_->GetProfile())-> | 593 DesktopNotificationServiceFactory::GetForProfile(web_ui_->GetProfile())-> |
602 SetDefaultContentSetting(default_setting); | 594 SetDefaultContentSetting(default_setting); |
603 } else { | 595 } else { |
604 GetContentSettingsMap()-> | 596 GetContentSettingsMap()-> |
605 SetDefaultContentSetting(content_type, default_setting); | 597 SetDefaultContentSetting(content_type, default_setting); |
606 } | 598 } |
607 } | 599 } |
608 | 600 |
609 void ContentSettingsHandler::SetAllowThirdPartyCookies(const ListValue* args) { | |
610 string16 allow = ExtractStringValue(args); | |
611 | |
612 GetContentSettingsMap()->SetBlockThirdPartyCookies( | |
613 LowerCaseEqualsASCII(allow, "true")); | |
614 } | |
615 | |
616 void ContentSettingsHandler::RemoveException(const ListValue* args) { | 601 void ContentSettingsHandler::RemoveException(const ListValue* args) { |
617 size_t arg_i = 0; | 602 size_t arg_i = 0; |
618 std::string type_string; | 603 std::string type_string; |
619 CHECK(args->GetString(arg_i++, &type_string)); | 604 CHECK(args->GetString(arg_i++, &type_string)); |
620 | 605 |
621 ContentSettingsType type = ContentSettingsTypeFromGroupName(type_string); | 606 ContentSettingsType type = ContentSettingsTypeFromGroupName(type_string); |
622 if (type == CONTENT_SETTINGS_TYPE_GEOLOCATION) { | 607 if (type == CONTENT_SETTINGS_TYPE_GEOLOCATION) { |
623 std::string origin; | 608 std::string origin; |
624 std::string embedding_origin; | 609 std::string embedding_origin; |
625 bool rv = args->GetString(arg_i++, &origin); | 610 bool rv = args->GetString(arg_i++, &origin); |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
750 return web_ui_->GetProfile()->GetProtocolHandlerRegistry(); | 735 return web_ui_->GetProfile()->GetProtocolHandlerRegistry(); |
751 } | 736 } |
752 | 737 |
753 HostContentSettingsMap* | 738 HostContentSettingsMap* |
754 ContentSettingsHandler::GetOTRContentSettingsMap() { | 739 ContentSettingsHandler::GetOTRContentSettingsMap() { |
755 Profile* profile = web_ui_->GetProfile(); | 740 Profile* profile = web_ui_->GetProfile(); |
756 if (profile->HasOffTheRecordProfile()) | 741 if (profile->HasOffTheRecordProfile()) |
757 return profile->GetOffTheRecordProfile()->GetHostContentSettingsMap(); | 742 return profile->GetOffTheRecordProfile()->GetHostContentSettingsMap(); |
758 return NULL; | 743 return NULL; |
759 } | 744 } |
OLD | NEW |