| 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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 } | 65 } |
| 66 | 66 |
| 67 std::string ContentSettingToString(ContentSetting setting) { | 67 std::string ContentSettingToString(ContentSetting setting) { |
| 68 switch (setting) { | 68 switch (setting) { |
| 69 case CONTENT_SETTING_ALLOW: | 69 case CONTENT_SETTING_ALLOW: |
| 70 return "allow"; | 70 return "allow"; |
| 71 case CONTENT_SETTING_ASK: | 71 case CONTENT_SETTING_ASK: |
| 72 return "ask"; | 72 return "ask"; |
| 73 case CONTENT_SETTING_BLOCK: | 73 case CONTENT_SETTING_BLOCK: |
| 74 return "block"; | 74 return "block"; |
| 75 case CONTENT_SETTING_SESSION_ONLY: |
| 76 return "session"; |
| 75 | 77 |
| 76 default: | 78 default: |
| 77 NOTREACHED(); | 79 NOTREACHED(); |
| 78 return ""; | 80 return ""; |
| 79 } | 81 } |
| 80 } | 82 } |
| 81 | 83 |
| 82 ContentSetting ContentSettingFromString(const std::string& name) { | 84 ContentSetting ContentSettingFromString(const std::string& name) { |
| 83 if (name == "allow") | 85 if (name == "allow") |
| 84 return CONTENT_SETTING_ALLOW; | 86 return CONTENT_SETTING_ALLOW; |
| 85 if (name == "ask") | 87 if (name == "ask") |
| 86 return CONTENT_SETTING_ASK; | 88 return CONTENT_SETTING_ASK; |
| 87 if (name == "block") | 89 if (name == "block") |
| 88 return CONTENT_SETTING_BLOCK; | 90 return CONTENT_SETTING_BLOCK; |
| 91 if (name == "session") |
| 92 return CONTENT_SETTING_SESSION_ONLY; |
| 89 | 93 |
| 90 NOTREACHED(); | 94 NOTREACHED(); |
| 91 return CONTENT_SETTING_DEFAULT; | 95 return CONTENT_SETTING_DEFAULT; |
| 92 } | 96 } |
| 93 | 97 |
| 94 } // namespace | 98 } // namespace |
| 95 | 99 |
| 96 ContentSettingsHandler::ContentSettingsHandler() { | 100 ContentSettingsHandler::ContentSettingsHandler() { |
| 97 } | 101 } |
| 98 | 102 |
| 99 ContentSettingsHandler::~ContentSettingsHandler() { | 103 ContentSettingsHandler::~ContentSettingsHandler() { |
| 100 } | 104 } |
| 101 | 105 |
| 102 void ContentSettingsHandler::GetLocalizedValues( | 106 void ContentSettingsHandler::GetLocalizedValues( |
| 103 DictionaryValue* localized_strings) { | 107 DictionaryValue* localized_strings) { |
| 104 DCHECK(localized_strings); | 108 DCHECK(localized_strings); |
| 105 | 109 |
| 106 localized_strings->SetString("content_exceptions", | 110 localized_strings->SetString("content_exceptions", |
| 107 l10n_util::GetStringUTF16(IDS_COOKIES_EXCEPTIONS_BUTTON)); | 111 l10n_util::GetStringUTF16(IDS_COOKIES_EXCEPTIONS_BUTTON)); |
| 108 localized_strings->SetString("contentSettingsPage", | 112 localized_strings->SetString("contentSettingsPage", |
| 109 l10n_util::GetStringUTF16(IDS_CONTENT_SETTINGS_TITLE)); | 113 l10n_util::GetStringUTF16(IDS_CONTENT_SETTINGS_TITLE)); |
| 110 localized_strings->SetString("allowException", | 114 localized_strings->SetString("allowException", |
| 111 l10n_util::GetStringUTF16(IDS_EXCEPTIONS_ALLOW_BUTTON)); | 115 l10n_util::GetStringUTF16(IDS_EXCEPTIONS_ALLOW_BUTTON)); |
| 112 localized_strings->SetString("blockException", | 116 localized_strings->SetString("blockException", |
| 113 l10n_util::GetStringUTF16(IDS_EXCEPTIONS_BLOCK_BUTTON)); | 117 l10n_util::GetStringUTF16(IDS_EXCEPTIONS_BLOCK_BUTTON)); |
| 118 localized_strings->SetString("sessionException", |
| 119 l10n_util::GetStringUTF16(IDS_EXCEPTIONS_SESSION_ONLY_BUTTON)); |
| 114 localized_strings->SetString("addExceptionRow", | 120 localized_strings->SetString("addExceptionRow", |
| 115 l10n_util::GetStringUTF16(IDS_EXCEPTIONS_ADD_BUTTON)); | 121 l10n_util::GetStringUTF16(IDS_EXCEPTIONS_ADD_BUTTON)); |
| 116 localized_strings->SetString("removeExceptionRow", | 122 localized_strings->SetString("removeExceptionRow", |
| 117 l10n_util::GetStringUTF16(IDS_EXCEPTIONS_REMOVE_BUTTON)); | 123 l10n_util::GetStringUTF16(IDS_EXCEPTIONS_REMOVE_BUTTON)); |
| 118 localized_strings->SetString("editExceptionRow", | 124 localized_strings->SetString("editExceptionRow", |
| 119 l10n_util::GetStringUTF16(IDS_EXCEPTIONS_EDIT_BUTTON)); | 125 l10n_util::GetStringUTF16(IDS_EXCEPTIONS_EDIT_BUTTON)); |
| 120 | 126 |
| 121 // Cookies filter. | 127 // Cookies filter. |
| 122 localized_strings->SetString("cookies_tab_label", | 128 localized_strings->SetString("cookies_tab_label", |
| 123 l10n_util::GetStringUTF16(IDS_COOKIES_TAB_LABEL)); | 129 l10n_util::GetStringUTF16(IDS_COOKIES_TAB_LABEL)); |
| (...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 372 scoped_ptr<Value> pattern_value(Value::CreateStringValue( | 378 scoped_ptr<Value> pattern_value(Value::CreateStringValue( |
| 373 pattern_string)); | 379 pattern_string)); |
| 374 scoped_ptr<Value> valid_value(Value::CreateBooleanValue( | 380 scoped_ptr<Value> valid_value(Value::CreateBooleanValue( |
| 375 pattern.IsValid())); | 381 pattern.IsValid())); |
| 376 | 382 |
| 377 dom_ui_->CallJavascriptFunction( | 383 dom_ui_->CallJavascriptFunction( |
| 378 L"ContentSettings.patternValidityCheckComplete", *type, | 384 L"ContentSettings.patternValidityCheckComplete", *type, |
| 379 *pattern_value.get(), | 385 *pattern_value.get(), |
| 380 *valid_value.get()); | 386 *valid_value.get()); |
| 381 } | 387 } |
| OLD | NEW |