| 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/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 579 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 590 &ContentSettingsHandler::SetAllowThirdPartyCookies)); | 590 &ContentSettingsHandler::SetAllowThirdPartyCookies)); |
| 591 dom_ui_->RegisterMessageCallback("removeException", | 591 dom_ui_->RegisterMessageCallback("removeException", |
| 592 NewCallback(this, | 592 NewCallback(this, |
| 593 &ContentSettingsHandler::RemoveException)); | 593 &ContentSettingsHandler::RemoveException)); |
| 594 dom_ui_->RegisterMessageCallback("setException", | 594 dom_ui_->RegisterMessageCallback("setException", |
| 595 NewCallback(this, | 595 NewCallback(this, |
| 596 &ContentSettingsHandler::SetException)); | 596 &ContentSettingsHandler::SetException)); |
| 597 dom_ui_->RegisterMessageCallback("checkExceptionPatternValidity", | 597 dom_ui_->RegisterMessageCallback("checkExceptionPatternValidity", |
| 598 NewCallback(this, | 598 NewCallback(this, |
| 599 &ContentSettingsHandler::CheckExceptionPatternValidity)); | 599 &ContentSettingsHandler::CheckExceptionPatternValidity)); |
| 600 dom_ui_->RegisterMessageCallback( | |
| 601 "openPluginsTab", | |
| 602 NewCallback(this, &ContentSettingsHandler::OpenPluginsTab)); | |
| 603 } | 600 } |
| 604 | 601 |
| 605 void ContentSettingsHandler::SetContentFilter(const ListValue* args) { | 602 void ContentSettingsHandler::SetContentFilter(const ListValue* args) { |
| 606 DCHECK_EQ(2U, args->GetSize()); | 603 DCHECK_EQ(2U, args->GetSize()); |
| 607 std::string group, setting; | 604 std::string group, setting; |
| 608 if (!(args->GetString(0, &group) && | 605 if (!(args->GetString(0, &group) && |
| 609 args->GetString(1, &setting))) { | 606 args->GetString(1, &setting))) { |
| 610 NOTREACHED(); | 607 NOTREACHED(); |
| 611 return; | 608 return; |
| 612 } | 609 } |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 738 scoped_ptr<Value> pattern_value(Value::CreateStringValue(pattern_string)); | 735 scoped_ptr<Value> pattern_value(Value::CreateStringValue(pattern_string)); |
| 739 scoped_ptr<Value> valid_value(Value::CreateBooleanValue(pattern.IsValid())); | 736 scoped_ptr<Value> valid_value(Value::CreateBooleanValue(pattern.IsValid())); |
| 740 | 737 |
| 741 dom_ui_->CallJavascriptFunction( | 738 dom_ui_->CallJavascriptFunction( |
| 742 L"ContentSettings.patternValidityCheckComplete", *type, | 739 L"ContentSettings.patternValidityCheckComplete", *type, |
| 743 *mode_value.get(), | 740 *mode_value.get(), |
| 744 *pattern_value.get(), | 741 *pattern_value.get(), |
| 745 *valid_value.get()); | 742 *valid_value.get()); |
| 746 } | 743 } |
| 747 | 744 |
| 748 void ContentSettingsHandler::OpenPluginsTab(const ListValue* args) { | |
| 749 BrowserList::GetLastActive()->OpenPluginsTabAndActivate(); | |
| 750 } | |
| 751 | |
| 752 // static | 745 // static |
| 753 std::string ContentSettingsHandler::ContentSettingsTypeToGroupName( | 746 std::string ContentSettingsHandler::ContentSettingsTypeToGroupName( |
| 754 ContentSettingsType type) { | 747 ContentSettingsType type) { |
| 755 switch (type) { | 748 switch (type) { |
| 756 case CONTENT_SETTINGS_TYPE_COOKIES: | 749 case CONTENT_SETTINGS_TYPE_COOKIES: |
| 757 return "cookies"; | 750 return "cookies"; |
| 758 case CONTENT_SETTINGS_TYPE_IMAGES: | 751 case CONTENT_SETTINGS_TYPE_IMAGES: |
| 759 return "images"; | 752 return "images"; |
| 760 case CONTENT_SETTINGS_TYPE_JAVASCRIPT: | 753 case CONTENT_SETTINGS_TYPE_JAVASCRIPT: |
| 761 return "javascript"; | 754 return "javascript"; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 778 return dom_ui_->GetProfile()->GetHostContentSettingsMap(); | 771 return dom_ui_->GetProfile()->GetHostContentSettingsMap(); |
| 779 } | 772 } |
| 780 | 773 |
| 781 HostContentSettingsMap* | 774 HostContentSettingsMap* |
| 782 ContentSettingsHandler::GetOTRContentSettingsMap() { | 775 ContentSettingsHandler::GetOTRContentSettingsMap() { |
| 783 Profile* profile = dom_ui_->GetProfile(); | 776 Profile* profile = dom_ui_->GetProfile(); |
| 784 if (profile->HasOffTheRecordProfile()) | 777 if (profile->HasOffTheRecordProfile()) |
| 785 return profile->GetOffTheRecordProfile()->GetHostContentSettingsMap(); | 778 return profile->GetOffTheRecordProfile()->GetHostContentSettingsMap(); |
| 786 return NULL; | 779 return NULL; |
| 787 } | 780 } |
| OLD | NEW |