| 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 "base/callback.h" | 7 #include "base/callback.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.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 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 ContentSettingsHandler::ContentSettingsHandler() { | 170 ContentSettingsHandler::ContentSettingsHandler() { |
| 171 } | 171 } |
| 172 | 172 |
| 173 ContentSettingsHandler::~ContentSettingsHandler() { | 173 ContentSettingsHandler::~ContentSettingsHandler() { |
| 174 } | 174 } |
| 175 | 175 |
| 176 void ContentSettingsHandler::GetLocalizedValues( | 176 void ContentSettingsHandler::GetLocalizedValues( |
| 177 DictionaryValue* localized_strings) { | 177 DictionaryValue* localized_strings) { |
| 178 DCHECK(localized_strings); | 178 DCHECK(localized_strings); |
| 179 | 179 |
| 180 static OptionsStringResource resources[] = { |
| 181 { "content_exceptions", IDS_COOKIES_EXCEPTIONS_BUTTON }, |
| 182 { "allowException", IDS_EXCEPTIONS_ALLOW_BUTTON }, |
| 183 { "blockException", IDS_EXCEPTIONS_BLOCK_BUTTON }, |
| 184 { "sessionException", IDS_EXCEPTIONS_SESSION_ONLY_BUTTON }, |
| 185 { "askException", IDS_EXCEPTIONS_ASK_BUTTON }, |
| 186 { "addExceptionRow", IDS_EXCEPTIONS_ADD_BUTTON }, |
| 187 { "removeExceptionRow", IDS_EXCEPTIONS_REMOVE_BUTTON }, |
| 188 { "editExceptionRow", IDS_EXCEPTIONS_EDIT_BUTTON }, |
| 189 { "otr_exceptions_explanation", IDS_EXCEPTIONS_OTR_LABEL }, |
| 190 { "examplePattern", IDS_EXCEPTIONS_PATTERN_EXAMPLE }, |
| 191 { "addNewExceptionInstructions", IDS_EXCEPTIONS_ADD_NEW_INSTRUCTIONS }, |
| 192 { "manage_exceptions", IDS_EXCEPTIONS_MANAGE }, |
| 193 // Cookies filter. |
| 194 { "cookies_tab_label", IDS_COOKIES_TAB_LABEL }, |
| 195 { "cookies_header", IDS_COOKIES_HEADER }, |
| 196 { "cookies_allow", IDS_COOKIES_ALLOW_RADIO }, |
| 197 { "cookies_ask", IDS_COOKIES_ASK_EVERY_TIME_RADIO }, |
| 198 { "cookies_block", IDS_COOKIES_BLOCK_RADIO }, |
| 199 { "cookies_block_3rd_party", IDS_COOKIES_BLOCK_3RDPARTY_CHKBOX }, |
| 200 { "cookies_show_cookies", IDS_COOKIES_SHOW_COOKIES_BUTTON }, |
| 201 { "flash_storage_settings", IDS_FLASH_STORAGE_SETTINGS }, |
| 202 { "flash_storage_url", IDS_FLASH_STORAGE_URL }, |
| 203 // Image filter. |
| 204 { "images_tab_label", IDS_IMAGES_TAB_LABEL }, |
| 205 { "images_header", IDS_IMAGES_HEADER }, |
| 206 { "images_allow", IDS_IMAGES_LOAD_RADIO }, |
| 207 { "images_block", IDS_IMAGES_NOLOAD_RADIO }, |
| 208 // JavaScript filter. |
| 209 { "javascript_tab_label", IDS_JAVASCRIPT_TAB_LABEL }, |
| 210 { "javascript_header", IDS_JAVASCRIPT_HEADER }, |
| 211 { "javascript_allow", IDS_JS_ALLOW_RADIO }, |
| 212 { "javascript_block", IDS_JS_DONOTALLOW_RADIO }, |
| 213 // Plug-ins filter. |
| 214 { "plugins_tab_label", IDS_PLUGIN_TAB_LABEL }, |
| 215 { "plugins_header", IDS_PLUGIN_HEADER }, |
| 216 { "plugins_ask", IDS_PLUGIN_ASK_RADIO }, |
| 217 { "plugins_allow", IDS_PLUGIN_LOAD_RADIO }, |
| 218 { "plugins_block", IDS_PLUGIN_NOLOAD_RADIO }, |
| 219 { "disable_individual_plugins", IDS_PLUGIN_SELECTIVE_DISABLE }, |
| 220 // Pop-ups filter. |
| 221 { "popups_tab_label", IDS_POPUP_TAB_LABEL }, |
| 222 { "popups_header", IDS_POPUP_HEADER }, |
| 223 { "popups_allow", IDS_POPUP_ALLOW_RADIO }, |
| 224 { "popups_block", IDS_POPUP_BLOCK_RADIO }, |
| 225 // Location filter. |
| 226 { "location_tab_label", IDS_GEOLOCATION_TAB_LABEL }, |
| 227 { "location_header", IDS_GEOLOCATION_HEADER }, |
| 228 { "location_allow", IDS_GEOLOCATION_ALLOW_RADIO }, |
| 229 { "location_ask", IDS_GEOLOCATION_ASK_RADIO }, |
| 230 { "location_block", IDS_GEOLOCATION_BLOCK_RADIO }, |
| 231 // Notifications filter. |
| 232 { "notifications_tab_label", IDS_NOTIFICATIONS_TAB_LABEL }, |
| 233 { "notifications_header", IDS_NOTIFICATIONS_HEADER }, |
| 234 { "notifications_allow", IDS_NOTIFICATIONS_ALLOW_RADIO }, |
| 235 { "notifications_ask", IDS_NOTIFICATIONS_ASK_RADIO }, |
| 236 { "notifications_block", IDS_NOTIFICATIONS_BLOCK_RADIO }, |
| 237 }; |
| 238 |
| 239 RegisterStrings(localized_strings, resources, arraysize(resources)); |
| 180 RegisterTitle(localized_strings, "contentSettingsPage", | 240 RegisterTitle(localized_strings, "contentSettingsPage", |
| 181 IDS_CONTENT_SETTINGS_TITLE); | 241 IDS_CONTENT_SETTINGS_TITLE); |
| 182 | |
| 183 localized_strings->SetString("content_exceptions", | |
| 184 l10n_util::GetStringUTF16(IDS_COOKIES_EXCEPTIONS_BUTTON)); | |
| 185 localized_strings->SetString("allowException", | |
| 186 l10n_util::GetStringUTF16(IDS_EXCEPTIONS_ALLOW_BUTTON)); | |
| 187 localized_strings->SetString("blockException", | |
| 188 l10n_util::GetStringUTF16(IDS_EXCEPTIONS_BLOCK_BUTTON)); | |
| 189 localized_strings->SetString("sessionException", | |
| 190 l10n_util::GetStringUTF16(IDS_EXCEPTIONS_SESSION_ONLY_BUTTON)); | |
| 191 localized_strings->SetString("askException", | |
| 192 l10n_util::GetStringUTF16(IDS_EXCEPTIONS_ASK_BUTTON)); | |
| 193 localized_strings->SetString("addExceptionRow", | |
| 194 l10n_util::GetStringUTF16(IDS_EXCEPTIONS_ADD_BUTTON)); | |
| 195 localized_strings->SetString("removeExceptionRow", | |
| 196 l10n_util::GetStringUTF16(IDS_EXCEPTIONS_REMOVE_BUTTON)); | |
| 197 localized_strings->SetString("editExceptionRow", | |
| 198 l10n_util::GetStringUTF16(IDS_EXCEPTIONS_EDIT_BUTTON)); | |
| 199 localized_strings->SetString("otr_exceptions_explanation", | |
| 200 l10n_util::GetStringUTF16(IDS_EXCEPTIONS_OTR_LABEL)); | |
| 201 localized_strings->SetString("examplePattern", | |
| 202 l10n_util::GetStringUTF16(IDS_EXCEPTIONS_PATTERN_EXAMPLE)); | |
| 203 localized_strings->SetString("addNewExceptionInstructions", | |
| 204 l10n_util::GetStringUTF16(IDS_EXCEPTIONS_ADD_NEW_INSTRUCTIONS)); | |
| 205 localized_strings->SetString("manage_exceptions", | |
| 206 l10n_util::GetStringUTF16(IDS_EXCEPTIONS_MANAGE)); | |
| 207 | |
| 208 // Cookies filter. | |
| 209 localized_strings->SetString("cookies_tab_label", | |
| 210 l10n_util::GetStringUTF16(IDS_COOKIES_TAB_LABEL)); | |
| 211 localized_strings->SetString("cookies_header", | |
| 212 l10n_util::GetStringUTF16(IDS_COOKIES_HEADER)); | |
| 213 localized_strings->SetString("cookies_allow", | |
| 214 l10n_util::GetStringUTF16(IDS_COOKIES_ALLOW_RADIO)); | |
| 215 localized_strings->SetString("cookies_ask", | |
| 216 l10n_util::GetStringUTF16(IDS_COOKIES_ASK_EVERY_TIME_RADIO)); | |
| 217 localized_strings->SetString("cookies_block", | |
| 218 l10n_util::GetStringUTF16(IDS_COOKIES_BLOCK_RADIO)); | |
| 219 localized_strings->SetString("cookies_block_3rd_party", | |
| 220 l10n_util::GetStringUTF16(IDS_COOKIES_BLOCK_3RDPARTY_CHKBOX)); | |
| 221 localized_strings->SetString("cookies_show_cookies", | |
| 222 l10n_util::GetStringUTF16(IDS_COOKIES_SHOW_COOKIES_BUTTON)); | |
| 223 localized_strings->SetString("flash_storage_settings", | |
| 224 l10n_util::GetStringUTF16(IDS_FLASH_STORAGE_SETTINGS)); | |
| 225 localized_strings->SetString("flash_storage_url", | |
| 226 l10n_util::GetStringUTF16(IDS_FLASH_STORAGE_URL)); | |
| 227 | |
| 228 // Image filter. | |
| 229 localized_strings->SetString("images_tab_label", | |
| 230 l10n_util::GetStringUTF16(IDS_IMAGES_TAB_LABEL)); | |
| 231 localized_strings->SetString("images_header", | |
| 232 l10n_util::GetStringUTF16(IDS_IMAGES_HEADER)); | |
| 233 localized_strings->SetString("images_allow", | |
| 234 l10n_util::GetStringUTF16(IDS_IMAGES_LOAD_RADIO)); | |
| 235 localized_strings->SetString("images_block", | |
| 236 l10n_util::GetStringUTF16(IDS_IMAGES_NOLOAD_RADIO)); | |
| 237 | |
| 238 // JavaScript filter. | |
| 239 localized_strings->SetString("javascript_tab_label", | |
| 240 l10n_util::GetStringUTF16(IDS_JAVASCRIPT_TAB_LABEL)); | |
| 241 localized_strings->SetString("javascript_header", | |
| 242 l10n_util::GetStringUTF16(IDS_JAVASCRIPT_HEADER)); | |
| 243 localized_strings->SetString("javascript_allow", | |
| 244 l10n_util::GetStringUTF16(IDS_JS_ALLOW_RADIO)); | |
| 245 localized_strings->SetString("javascript_block", | |
| 246 l10n_util::GetStringUTF16(IDS_JS_DONOTALLOW_RADIO)); | |
| 247 | |
| 248 // Plug-ins filter. | |
| 249 localized_strings->SetString("plugins_tab_label", | |
| 250 l10n_util::GetStringUTF16(IDS_PLUGIN_TAB_LABEL)); | |
| 251 localized_strings->SetString("plugins_header", | |
| 252 l10n_util::GetStringUTF16(IDS_PLUGIN_HEADER)); | |
| 253 localized_strings->SetString("plugins_ask", | |
| 254 l10n_util::GetStringUTF16(IDS_PLUGIN_ASK_RADIO)); | |
| 255 localized_strings->SetString("plugins_allow", | |
| 256 l10n_util::GetStringUTF16(IDS_PLUGIN_LOAD_RADIO)); | |
| 257 localized_strings->SetString("plugins_block", | |
| 258 l10n_util::GetStringUTF16(IDS_PLUGIN_NOLOAD_RADIO)); | |
| 259 localized_strings->SetString("disable_individual_plugins", | |
| 260 l10n_util::GetStringUTF16(IDS_PLUGIN_SELECTIVE_DISABLE)); | |
| 261 localized_strings->SetBoolean("enable_click_to_play", | 242 localized_strings->SetBoolean("enable_click_to_play", |
| 262 CommandLine::ForCurrentProcess()->HasSwitch( | 243 CommandLine::ForCurrentProcess()->HasSwitch( |
| 263 switches::kEnableClickToPlay)); | 244 switches::kEnableClickToPlay)); |
| 264 | |
| 265 // Pop-ups filter. | |
| 266 localized_strings->SetString("popups_tab_label", | |
| 267 l10n_util::GetStringUTF16(IDS_POPUP_TAB_LABEL)); | |
| 268 localized_strings->SetString("popups_header", | |
| 269 l10n_util::GetStringUTF16(IDS_POPUP_HEADER)); | |
| 270 localized_strings->SetString("popups_allow", | |
| 271 l10n_util::GetStringUTF16(IDS_POPUP_ALLOW_RADIO)); | |
| 272 localized_strings->SetString("popups_block", | |
| 273 l10n_util::GetStringUTF16(IDS_POPUP_BLOCK_RADIO)); | |
| 274 | |
| 275 // Location filter. | |
| 276 localized_strings->SetString("location_tab_label", | |
| 277 l10n_util::GetStringUTF16(IDS_GEOLOCATION_TAB_LABEL)); | |
| 278 localized_strings->SetString("location_header", | |
| 279 l10n_util::GetStringUTF16(IDS_GEOLOCATION_HEADER)); | |
| 280 localized_strings->SetString("location_allow", | |
| 281 l10n_util::GetStringUTF16(IDS_GEOLOCATION_ALLOW_RADIO)); | |
| 282 localized_strings->SetString("location_ask", | |
| 283 l10n_util::GetStringUTF16(IDS_GEOLOCATION_ASK_RADIO)); | |
| 284 localized_strings->SetString("location_block", | |
| 285 l10n_util::GetStringUTF16(IDS_GEOLOCATION_BLOCK_RADIO)); | |
| 286 | |
| 287 // Notifications filter. | |
| 288 localized_strings->SetString("notifications_tab_label", | |
| 289 l10n_util::GetStringUTF16(IDS_NOTIFICATIONS_TAB_LABEL)); | |
| 290 localized_strings->SetString("notifications_header", | |
| 291 l10n_util::GetStringUTF16(IDS_NOTIFICATIONS_HEADER)); | |
| 292 localized_strings->SetString("notifications_allow", | |
| 293 l10n_util::GetStringUTF16(IDS_NOTIFICATIONS_ALLOW_RADIO)); | |
| 294 localized_strings->SetString("notifications_ask", | |
| 295 l10n_util::GetStringUTF16(IDS_NOTIFICATIONS_ASK_RADIO)); | |
| 296 localized_strings->SetString("notifications_block", | |
| 297 l10n_util::GetStringUTF16(IDS_NOTIFICATIONS_BLOCK_RADIO)); | |
| 298 } | 245 } |
| 299 | 246 |
| 300 void ContentSettingsHandler::Initialize() { | 247 void ContentSettingsHandler::Initialize() { |
| 301 const HostContentSettingsMap* settings_map = GetContentSettingsMap(); | 248 const HostContentSettingsMap* settings_map = GetContentSettingsMap(); |
| 302 scoped_ptr<Value> block_3rd_party(Value::CreateBooleanValue( | 249 scoped_ptr<Value> block_3rd_party(Value::CreateBooleanValue( |
| 303 settings_map->BlockThirdPartyCookies())); | 250 settings_map->BlockThirdPartyCookies())); |
| 304 dom_ui_->CallJavascriptFunction( | 251 dom_ui_->CallJavascriptFunction( |
| 305 L"ContentSettings.setBlockThirdPartyCookies", *block_3rd_party.get()); | 252 L"ContentSettings.setBlockThirdPartyCookies", *block_3rd_party.get()); |
| 306 | 253 |
| 307 clear_plugin_lso_data_enabled_.Init(prefs::kClearPluginLSODataEnabled, | 254 clear_plugin_lso_data_enabled_.Init(prefs::kClearPluginLSODataEnabled, |
| (...skipping 464 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 772 return dom_ui_->GetProfile()->GetHostContentSettingsMap(); | 719 return dom_ui_->GetProfile()->GetHostContentSettingsMap(); |
| 773 } | 720 } |
| 774 | 721 |
| 775 HostContentSettingsMap* | 722 HostContentSettingsMap* |
| 776 ContentSettingsHandler::GetOTRContentSettingsMap() { | 723 ContentSettingsHandler::GetOTRContentSettingsMap() { |
| 777 Profile* profile = dom_ui_->GetProfile(); | 724 Profile* profile = dom_ui_->GetProfile(); |
| 778 if (profile->HasOffTheRecordProfile()) | 725 if (profile->HasOffTheRecordProfile()) |
| 779 return profile->GetOffTheRecordProfile()->GetHostContentSettingsMap(); | 726 return profile->GetOffTheRecordProfile()->GetHostContentSettingsMap(); |
| 780 return NULL; | 727 return NULL; |
| 781 } | 728 } |
| OLD | NEW |