Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(60)

Side by Side Diff: chrome/browser/dom_ui/options/content_settings_handler.cc

Issue 6260003: Clear plugin data together with cookies on shutdown. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: sync Created 9 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/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"
11 #include "base/values.h" 11 #include "base/values.h"
12 #include "chrome/browser/browser_list.h" 12 #include "chrome/browser/browser_list.h"
13 #include "chrome/browser/browser_process.h"
13 #include "chrome/browser/content_settings/content_settings_details.h" 14 #include "chrome/browser/content_settings/content_settings_details.h"
14 #include "chrome/browser/content_settings/host_content_settings_map.h" 15 #include "chrome/browser/content_settings/host_content_settings_map.h"
15 #include "chrome/browser/geolocation/geolocation_content_settings_map.h" 16 #include "chrome/browser/geolocation/geolocation_content_settings_map.h"
16 #include "chrome/browser/notifications/desktop_notification_service.h" 17 #include "chrome/browser/notifications/desktop_notification_service.h"
17 #include "chrome/browser/profiles/profile.h" 18 #include "chrome/browser/profiles/profile.h"
18 #include "chrome/common/chrome_switches.h" 19 #include "chrome/common/chrome_switches.h"
19 #include "chrome/common/content_settings_helper.h" 20 #include "chrome/common/content_settings_helper.h"
20 #include "chrome/common/notification_service.h" 21 #include "chrome/common/notification_service.h"
21 #include "chrome/common/notification_source.h" 22 #include "chrome/common/notification_source.h"
22 #include "chrome/common/notification_type.h" 23 #include "chrome/common/notification_type.h"
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 localized_strings->SetString("cookies_header", 210 localized_strings->SetString("cookies_header",
210 l10n_util::GetStringUTF16(IDS_COOKIES_HEADER)); 211 l10n_util::GetStringUTF16(IDS_COOKIES_HEADER));
211 localized_strings->SetString("cookies_allow", 212 localized_strings->SetString("cookies_allow",
212 l10n_util::GetStringUTF16(IDS_COOKIES_ALLOW_RADIO)); 213 l10n_util::GetStringUTF16(IDS_COOKIES_ALLOW_RADIO));
213 localized_strings->SetString("cookies_ask", 214 localized_strings->SetString("cookies_ask",
214 l10n_util::GetStringUTF16(IDS_COOKIES_ASK_EVERY_TIME_RADIO)); 215 l10n_util::GetStringUTF16(IDS_COOKIES_ASK_EVERY_TIME_RADIO));
215 localized_strings->SetString("cookies_block", 216 localized_strings->SetString("cookies_block",
216 l10n_util::GetStringUTF16(IDS_COOKIES_BLOCK_RADIO)); 217 l10n_util::GetStringUTF16(IDS_COOKIES_BLOCK_RADIO));
217 localized_strings->SetString("cookies_block_3rd_party", 218 localized_strings->SetString("cookies_block_3rd_party",
218 l10n_util::GetStringUTF16(IDS_COOKIES_BLOCK_3RDPARTY_CHKBOX)); 219 l10n_util::GetStringUTF16(IDS_COOKIES_BLOCK_3RDPARTY_CHKBOX));
219 localized_strings->SetString("cookies_clear_on_exit",
220 l10n_util::GetStringUTF16(IDS_COOKIES_CLEAR_WHEN_CLOSE_CHKBOX));
221 localized_strings->SetString("cookies_show_cookies", 220 localized_strings->SetString("cookies_show_cookies",
222 l10n_util::GetStringUTF16(IDS_COOKIES_SHOW_COOKIES_BUTTON)); 221 l10n_util::GetStringUTF16(IDS_COOKIES_SHOW_COOKIES_BUTTON));
223 localized_strings->SetString("flash_storage_settings", 222 localized_strings->SetString("flash_storage_settings",
224 l10n_util::GetStringUTF16(IDS_FLASH_STORAGE_SETTINGS)); 223 l10n_util::GetStringUTF16(IDS_FLASH_STORAGE_SETTINGS));
225 localized_strings->SetString("flash_storage_url", 224 localized_strings->SetString("flash_storage_url",
226 l10n_util::GetStringUTF16(IDS_FLASH_STORAGE_URL)); 225 l10n_util::GetStringUTF16(IDS_FLASH_STORAGE_URL));
227 226
228 // Image filter. 227 // Image filter.
229 localized_strings->SetString("images_tab_label", 228 localized_strings->SetString("images_tab_label",
230 l10n_util::GetStringUTF16(IDS_IMAGES_TAB_LABEL)); 229 l10n_util::GetStringUTF16(IDS_IMAGES_TAB_LABEL));
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
297 l10n_util::GetStringUTF16(IDS_NOTIFICATIONS_BLOCK_RADIO)); 296 l10n_util::GetStringUTF16(IDS_NOTIFICATIONS_BLOCK_RADIO));
298 } 297 }
299 298
300 void ContentSettingsHandler::Initialize() { 299 void ContentSettingsHandler::Initialize() {
301 const HostContentSettingsMap* settings_map = GetContentSettingsMap(); 300 const HostContentSettingsMap* settings_map = GetContentSettingsMap();
302 scoped_ptr<Value> block_3rd_party(Value::CreateBooleanValue( 301 scoped_ptr<Value> block_3rd_party(Value::CreateBooleanValue(
303 settings_map->BlockThirdPartyCookies())); 302 settings_map->BlockThirdPartyCookies()));
304 dom_ui_->CallJavascriptFunction( 303 dom_ui_->CallJavascriptFunction(
305 L"ContentSettings.setBlockThirdPartyCookies", *block_3rd_party.get()); 304 L"ContentSettings.setBlockThirdPartyCookies", *block_3rd_party.get());
306 305
306 clear_plugin_lso_data_enabled_.Init(prefs::kClearPluginLSODataEnabled,
307 g_browser_process->local_state(),
308 this);
309 UpdateClearPluginLSOData();
310
307 notification_registrar_.Add( 311 notification_registrar_.Add(
308 this, NotificationType::OTR_PROFILE_CREATED, 312 this, NotificationType::OTR_PROFILE_CREATED,
309 NotificationService::AllSources()); 313 NotificationService::AllSources());
310 notification_registrar_.Add( 314 notification_registrar_.Add(
311 this, NotificationType::PROFILE_DESTROYED, 315 this, NotificationType::PROFILE_DESTROYED,
312 NotificationService::AllSources()); 316 NotificationService::AllSources());
313 317
314 UpdateAllExceptionsViewsFromModel(); 318 UpdateAllExceptionsViewsFromModel();
315 notification_registrar_.Add( 319 notification_registrar_.Add(
316 this, NotificationType::CONTENT_SETTINGS_CHANGED, 320 this, NotificationType::CONTENT_SETTINGS_CHANGED,
317 NotificationService::AllSources()); 321 NotificationService::AllSources());
318 notification_registrar_.Add( 322 notification_registrar_.Add(
319 this, NotificationType::DESKTOP_NOTIFICATION_DEFAULT_CHANGED, 323 this, NotificationType::DESKTOP_NOTIFICATION_DEFAULT_CHANGED,
320 NotificationService::AllSources()); 324 NotificationService::AllSources());
321 notification_registrar_.Add( 325 notification_registrar_.Add(
322 this, NotificationType::DESKTOP_NOTIFICATION_SETTINGS_CHANGED, 326 this, NotificationType::DESKTOP_NOTIFICATION_SETTINGS_CHANGED,
323 NotificationService::AllSources()); 327 NotificationService::AllSources());
324 328
325 PrefService* prefs = dom_ui_->GetProfile()->GetPrefs(); 329 PrefService* prefs = dom_ui_->GetProfile()->GetPrefs();
326 pref_change_registrar_.Init(prefs); 330 pref_change_registrar_.Init(prefs);
327 pref_change_registrar_.Add(prefs::kGeolocationDefaultContentSetting, this); 331 pref_change_registrar_.Add(prefs::kGeolocationDefaultContentSetting, this);
328 pref_change_registrar_.Add(prefs::kGeolocationContentSettings, this); 332 pref_change_registrar_.Add(prefs::kGeolocationContentSettings, this);
Evan Stade 2011/01/13 19:31:51 need prefs::kClearPluginLSODataEnabled here?
329 } 333 }
330 334
331 void ContentSettingsHandler::Observe(NotificationType type, 335 void ContentSettingsHandler::Observe(NotificationType type,
332 const NotificationSource& source, 336 const NotificationSource& source,
333 const NotificationDetails& details) { 337 const NotificationDetails& details) {
334 switch (type.value) { 338 switch (type.value) {
335 case NotificationType::PROFILE_DESTROYED: { 339 case NotificationType::PROFILE_DESTROYED: {
336 Profile* profile = static_cast<Source<Profile> >(source).ptr(); 340 Profile* profile = static_cast<Source<Profile> >(source).ptr();
337 if (profile->IsOffTheRecord()) { 341 if (profile->IsOffTheRecord()) {
338 dom_ui_->CallJavascriptFunction( 342 dom_ui_->CallJavascriptFunction(
(...skipping 18 matching lines...) Expand all
357 UpdateExceptionsViewFromModel(settings_details->type()); 361 UpdateExceptionsViewFromModel(settings_details->type());
358 break; 362 break;
359 } 363 }
360 364
361 case NotificationType::PREF_CHANGED: { 365 case NotificationType::PREF_CHANGED: {
362 const std::string& pref_name = *Details<std::string>(details).ptr(); 366 const std::string& pref_name = *Details<std::string>(details).ptr();
363 if (pref_name == prefs::kGeolocationDefaultContentSetting) 367 if (pref_name == prefs::kGeolocationDefaultContentSetting)
364 UpdateSettingDefaultFromModel(CONTENT_SETTINGS_TYPE_GEOLOCATION); 368 UpdateSettingDefaultFromModel(CONTENT_SETTINGS_TYPE_GEOLOCATION);
365 else if (pref_name == prefs::kGeolocationContentSettings) 369 else if (pref_name == prefs::kGeolocationContentSettings)
366 UpdateGeolocationExceptionsView(); 370 UpdateGeolocationExceptionsView();
371 else if (pref_name == prefs::kClearPluginLSODataEnabled)
372 UpdateClearPluginLSOData();
367 break; 373 break;
368 } 374 }
369 375
370 case NotificationType::DESKTOP_NOTIFICATION_DEFAULT_CHANGED: { 376 case NotificationType::DESKTOP_NOTIFICATION_DEFAULT_CHANGED: {
371 UpdateSettingDefaultFromModel(CONTENT_SETTINGS_TYPE_NOTIFICATIONS); 377 UpdateSettingDefaultFromModel(CONTENT_SETTINGS_TYPE_NOTIFICATIONS);
372 break; 378 break;
373 } 379 }
374 380
375 case NotificationType::DESKTOP_NOTIFICATION_SETTINGS_CHANGED: { 381 case NotificationType::DESKTOP_NOTIFICATION_SETTINGS_CHANGED: {
376 UpdateNotificationExceptionsView(); 382 UpdateNotificationExceptionsView();
377 break; 383 break;
378 } 384 }
379 385
380 default: 386 default:
381 OptionsPageUIHandler::Observe(type, source, details); 387 OptionsPageUIHandler::Observe(type, source, details);
382 } 388 }
383 } 389 }
384 390
391 void ContentSettingsHandler::UpdateClearPluginLSOData() {
392 int label_id = clear_plugin_lso_data_enabled_.GetValue() ?
393 IDS_COOKIES_LSO_CLEAR_WHEN_CLOSE_CHKBOX :
394 IDS_COOKIES_CLEAR_WHEN_CLOSE_CHKBOX;
395 scoped_ptr<Value> label(
396 Value::CreateStringValue(l10n_util::GetStringUTF16(label_id)));
397 dom_ui_->CallJavascriptFunction(
398 L"ContentSettings.setClearLocalDataOnShutdownLabel", *label);
399 }
400
385 void ContentSettingsHandler::UpdateSettingDefaultFromModel( 401 void ContentSettingsHandler::UpdateSettingDefaultFromModel(
386 ContentSettingsType type) { 402 ContentSettingsType type) {
387 DictionaryValue filter_settings; 403 DictionaryValue filter_settings;
388 filter_settings.SetString(ContentSettingsTypeToGroupName(type) + ".value", 404 filter_settings.SetString(ContentSettingsTypeToGroupName(type) + ".value",
389 GetSettingDefaultFromModel(type)); 405 GetSettingDefaultFromModel(type));
390 filter_settings.SetBoolean(ContentSettingsTypeToGroupName(type) + ".managed", 406 filter_settings.SetBoolean(ContentSettingsTypeToGroupName(type) + ".managed",
391 GetDefaultSettingManagedFromModel(type)); 407 GetDefaultSettingManagedFromModel(type));
392 408
393 dom_ui_->CallJavascriptFunction( 409 dom_ui_->CallJavascriptFunction(
394 L"ContentSettings.setContentFilterSettingsValue", filter_settings); 410 L"ContentSettings.setContentFilterSettingsValue", filter_settings);
(...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after
762 return dom_ui_->GetProfile()->GetHostContentSettingsMap(); 778 return dom_ui_->GetProfile()->GetHostContentSettingsMap();
763 } 779 }
764 780
765 HostContentSettingsMap* 781 HostContentSettingsMap*
766 ContentSettingsHandler::GetOTRContentSettingsMap() { 782 ContentSettingsHandler::GetOTRContentSettingsMap() {
767 Profile* profile = dom_ui_->GetProfile(); 783 Profile* profile = dom_ui_->GetProfile();
768 if (profile->HasOffTheRecordProfile()) 784 if (profile->HasOffTheRecordProfile())
769 return profile->GetOffTheRecordProfile()->GetHostContentSettingsMap(); 785 return profile->GetOffTheRecordProfile()->GetHostContentSettingsMap();
770 return NULL; 786 return NULL;
771 } 787 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698