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 "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 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
201 { "manage_exceptions", IDS_EXCEPTIONS_MANAGE }, | 201 { "manage_exceptions", IDS_EXCEPTIONS_MANAGE }, |
202 { "exceptionPatternHeader", IDS_EXCEPTIONS_PATTERN_HEADER }, | 202 { "exceptionPatternHeader", IDS_EXCEPTIONS_PATTERN_HEADER }, |
203 { "exceptionBehaviorHeader", IDS_EXCEPTIONS_ACTION_HEADER }, | 203 { "exceptionBehaviorHeader", IDS_EXCEPTIONS_ACTION_HEADER }, |
204 // Cookies filter. | 204 // Cookies filter. |
205 { "cookies_tab_label", IDS_COOKIES_TAB_LABEL }, | 205 { "cookies_tab_label", IDS_COOKIES_TAB_LABEL }, |
206 { "cookies_header", IDS_COOKIES_HEADER }, | 206 { "cookies_header", IDS_COOKIES_HEADER }, |
207 { "cookies_allow", IDS_COOKIES_ALLOW_RADIO }, | 207 { "cookies_allow", IDS_COOKIES_ALLOW_RADIO }, |
208 { "cookies_ask", IDS_COOKIES_ASK_EVERY_TIME_RADIO }, | 208 { "cookies_ask", IDS_COOKIES_ASK_EVERY_TIME_RADIO }, |
209 { "cookies_block", IDS_COOKIES_BLOCK_RADIO }, | 209 { "cookies_block", IDS_COOKIES_BLOCK_RADIO }, |
210 { "cookies_block_3rd_party", IDS_COOKIES_BLOCK_3RDPARTY_CHKBOX }, | 210 { "cookies_block_3rd_party", IDS_COOKIES_BLOCK_3RDPARTY_CHKBOX }, |
| 211 { "cookies_clear_when_close", IDS_COOKIES_CLEAR_WHEN_CLOSE_CHKBOX }, |
| 212 { "cookies_lso_clear_when_close", IDS_COOKIES_LSO_CLEAR_WHEN_CLOSE_CHKBOX }, |
211 { "cookies_show_cookies", IDS_COOKIES_SHOW_COOKIES_BUTTON }, | 213 { "cookies_show_cookies", IDS_COOKIES_SHOW_COOKIES_BUTTON }, |
212 { "flash_storage_settings", IDS_FLASH_STORAGE_SETTINGS }, | 214 { "flash_storage_settings", IDS_FLASH_STORAGE_SETTINGS }, |
213 { "flash_storage_url", IDS_FLASH_STORAGE_URL }, | 215 { "flash_storage_url", IDS_FLASH_STORAGE_URL }, |
214 // Image filter. | 216 // Image filter. |
215 { "images_tab_label", IDS_IMAGES_TAB_LABEL }, | 217 { "images_tab_label", IDS_IMAGES_TAB_LABEL }, |
216 { "images_header", IDS_IMAGES_HEADER }, | 218 { "images_header", IDS_IMAGES_HEADER }, |
217 { "images_allow", IDS_IMAGES_LOAD_RADIO }, | 219 { "images_allow", IDS_IMAGES_LOAD_RADIO }, |
218 { "images_block", IDS_IMAGES_NOLOAD_RADIO }, | 220 { "images_block", IDS_IMAGES_NOLOAD_RADIO }, |
219 // JavaScript filter. | 221 // JavaScript filter. |
220 { "javascript_tab_label", IDS_JAVASCRIPT_TAB_LABEL }, | 222 { "javascript_tab_label", IDS_JAVASCRIPT_TAB_LABEL }, |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
255 switches::kEnableClickToPlay)); | 257 switches::kEnableClickToPlay)); |
256 } | 258 } |
257 | 259 |
258 void ContentSettingsHandler::Initialize() { | 260 void ContentSettingsHandler::Initialize() { |
259 const HostContentSettingsMap* settings_map = GetContentSettingsMap(); | 261 const HostContentSettingsMap* settings_map = GetContentSettingsMap(); |
260 scoped_ptr<Value> block_3rd_party(Value::CreateBooleanValue( | 262 scoped_ptr<Value> block_3rd_party(Value::CreateBooleanValue( |
261 settings_map->BlockThirdPartyCookies())); | 263 settings_map->BlockThirdPartyCookies())); |
262 web_ui_->CallJavascriptFunction("ContentSettings.setBlockThirdPartyCookies", | 264 web_ui_->CallJavascriptFunction("ContentSettings.setBlockThirdPartyCookies", |
263 *block_3rd_party.get()); | 265 *block_3rd_party.get()); |
264 | 266 |
265 clear_plugin_lso_data_enabled_.Init(prefs::kClearPluginLSODataEnabled, | |
266 g_browser_process->local_state(), | |
267 this); | |
268 UpdateClearPluginLSOData(); | |
269 | |
270 notification_registrar_.Add( | 267 notification_registrar_.Add( |
271 this, NotificationType::OTR_PROFILE_CREATED, | 268 this, NotificationType::OTR_PROFILE_CREATED, |
272 NotificationService::AllSources()); | 269 NotificationService::AllSources()); |
273 notification_registrar_.Add( | 270 notification_registrar_.Add( |
274 this, NotificationType::PROFILE_DESTROYED, | 271 this, NotificationType::PROFILE_DESTROYED, |
275 NotificationService::AllSources()); | 272 NotificationService::AllSources()); |
276 | 273 |
277 UpdateAllExceptionsViewsFromModel(); | 274 UpdateAllExceptionsViewsFromModel(); |
278 notification_registrar_.Add( | 275 notification_registrar_.Add( |
279 this, NotificationType::CONTENT_SETTINGS_CHANGED, | 276 this, NotificationType::CONTENT_SETTINGS_CHANGED, |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
320 UpdateExceptionsViewFromModel(settings_details->type()); | 317 UpdateExceptionsViewFromModel(settings_details->type()); |
321 break; | 318 break; |
322 } | 319 } |
323 | 320 |
324 case NotificationType::PREF_CHANGED: { | 321 case NotificationType::PREF_CHANGED: { |
325 const std::string& pref_name = *Details<std::string>(details).ptr(); | 322 const std::string& pref_name = *Details<std::string>(details).ptr(); |
326 if (pref_name == prefs::kGeolocationDefaultContentSetting) | 323 if (pref_name == prefs::kGeolocationDefaultContentSetting) |
327 UpdateSettingDefaultFromModel(CONTENT_SETTINGS_TYPE_GEOLOCATION); | 324 UpdateSettingDefaultFromModel(CONTENT_SETTINGS_TYPE_GEOLOCATION); |
328 else if (pref_name == prefs::kGeolocationContentSettings) | 325 else if (pref_name == prefs::kGeolocationContentSettings) |
329 UpdateGeolocationExceptionsView(); | 326 UpdateGeolocationExceptionsView(); |
330 else if (pref_name == prefs::kClearPluginLSODataEnabled) | |
331 UpdateClearPluginLSOData(); | |
332 break; | 327 break; |
333 } | 328 } |
334 | 329 |
335 case NotificationType::DESKTOP_NOTIFICATION_DEFAULT_CHANGED: { | 330 case NotificationType::DESKTOP_NOTIFICATION_DEFAULT_CHANGED: { |
336 UpdateSettingDefaultFromModel(CONTENT_SETTINGS_TYPE_NOTIFICATIONS); | 331 UpdateSettingDefaultFromModel(CONTENT_SETTINGS_TYPE_NOTIFICATIONS); |
337 break; | 332 break; |
338 } | 333 } |
339 | 334 |
340 case NotificationType::DESKTOP_NOTIFICATION_SETTINGS_CHANGED: { | 335 case NotificationType::DESKTOP_NOTIFICATION_SETTINGS_CHANGED: { |
341 UpdateNotificationExceptionsView(); | 336 UpdateNotificationExceptionsView(); |
342 break; | 337 break; |
343 } | 338 } |
344 | 339 |
345 default: | 340 default: |
346 OptionsPageUIHandler::Observe(type, source, details); | 341 OptionsPageUIHandler::Observe(type, source, details); |
347 } | 342 } |
348 } | 343 } |
349 | 344 |
350 void ContentSettingsHandler::UpdateClearPluginLSOData() { | |
351 int label_id = clear_plugin_lso_data_enabled_.GetValue() ? | |
352 IDS_COOKIES_LSO_CLEAR_WHEN_CLOSE_CHKBOX : | |
353 IDS_COOKIES_CLEAR_WHEN_CLOSE_CHKBOX; | |
354 scoped_ptr<Value> label( | |
355 Value::CreateStringValue(l10n_util::GetStringUTF16(label_id))); | |
356 web_ui_->CallJavascriptFunction( | |
357 "ContentSettings.setClearLocalDataOnShutdownLabel", *label); | |
358 } | |
359 | |
360 void ContentSettingsHandler::UpdateSettingDefaultFromModel( | 345 void ContentSettingsHandler::UpdateSettingDefaultFromModel( |
361 ContentSettingsType type) { | 346 ContentSettingsType type) { |
362 DictionaryValue filter_settings; | 347 DictionaryValue filter_settings; |
363 filter_settings.SetString(ContentSettingsTypeToGroupName(type) + ".value", | 348 filter_settings.SetString(ContentSettingsTypeToGroupName(type) + ".value", |
364 GetSettingDefaultFromModel(type)); | 349 GetSettingDefaultFromModel(type)); |
365 filter_settings.SetBoolean(ContentSettingsTypeToGroupName(type) + ".managed", | 350 filter_settings.SetBoolean(ContentSettingsTypeToGroupName(type) + ".managed", |
366 GetDefaultSettingManagedFromModel(type)); | 351 GetDefaultSettingManagedFromModel(type)); |
367 | 352 |
368 web_ui_->CallJavascriptFunction( | 353 web_ui_->CallJavascriptFunction( |
369 "ContentSettings.setContentFilterSettingsValue", filter_settings); | 354 "ContentSettings.setContentFilterSettingsValue", filter_settings); |
(...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
736 return web_ui_->GetProfile()->GetHostContentSettingsMap(); | 721 return web_ui_->GetProfile()->GetHostContentSettingsMap(); |
737 } | 722 } |
738 | 723 |
739 HostContentSettingsMap* | 724 HostContentSettingsMap* |
740 ContentSettingsHandler::GetOTRContentSettingsMap() { | 725 ContentSettingsHandler::GetOTRContentSettingsMap() { |
741 Profile* profile = web_ui_->GetProfile(); | 726 Profile* profile = web_ui_->GetProfile(); |
742 if (profile->HasOffTheRecordProfile()) | 727 if (profile->HasOffTheRecordProfile()) |
743 return profile->GetOffTheRecordProfile()->GetHostContentSettingsMap(); | 728 return profile->GetOffTheRecordProfile()->GetHostContentSettingsMap(); |
744 return NULL; | 729 return NULL; |
745 } | 730 } |
OLD | NEW |