| 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/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 350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 361 } | 361 } |
| 362 | 362 |
| 363 default: | 363 default: |
| 364 OptionsPageUIHandler::Observe(type, source, details); | 364 OptionsPageUIHandler::Observe(type, source, details); |
| 365 } | 365 } |
| 366 } | 366 } |
| 367 | 367 |
| 368 void ContentSettingsHandler::UpdateSettingDefaultFromModel( | 368 void ContentSettingsHandler::UpdateSettingDefaultFromModel( |
| 369 ContentSettingsType type) { | 369 ContentSettingsType type) { |
| 370 DictionaryValue filter_settings; | 370 DictionaryValue filter_settings; |
| 371 filter_settings.SetString(ContentSettingsTypeToGroupName(type), | 371 filter_settings.SetString(ContentSettingsTypeToGroupName(type) + ".value", |
| 372 GetSettingDefaultFromModel(type)); | 372 GetSettingDefaultFromModel(type)); |
| 373 filter_settings.SetBoolean(ContentSettingsTypeToGroupName(type) + ".managed", |
| 374 GetDefaultSettingManagedFromModel(type)); |
| 373 | 375 |
| 374 dom_ui_->CallJavascriptFunction( | 376 dom_ui_->CallJavascriptFunction( |
| 375 L"ContentSettings.setContentFilterSettingsValue", filter_settings); | 377 L"ContentSettings.setContentFilterSettingsValue", filter_settings); |
| 376 } | 378 } |
| 377 | 379 |
| 378 std::string ContentSettingsHandler::GetSettingDefaultFromModel( | 380 std::string ContentSettingsHandler::GetSettingDefaultFromModel( |
| 379 ContentSettingsType type) { | 381 ContentSettingsType type) { |
| 380 ContentSetting default_setting; | 382 ContentSetting default_setting; |
| 381 if (type == CONTENT_SETTINGS_TYPE_GEOLOCATION) { | 383 if (type == CONTENT_SETTINGS_TYPE_GEOLOCATION) { |
| 382 default_setting = dom_ui_->GetProfile()-> | 384 default_setting = dom_ui_->GetProfile()-> |
| 383 GetGeolocationContentSettingsMap()->GetDefaultContentSetting(); | 385 GetGeolocationContentSettingsMap()->GetDefaultContentSetting(); |
| 384 } else if (type == CONTENT_SETTINGS_TYPE_NOTIFICATIONS) { | 386 } else if (type == CONTENT_SETTINGS_TYPE_NOTIFICATIONS) { |
| 385 default_setting = dom_ui_->GetProfile()-> | 387 default_setting = dom_ui_->GetProfile()-> |
| 386 GetDesktopNotificationService()->GetDefaultContentSetting(); | 388 GetDesktopNotificationService()->GetDefaultContentSetting(); |
| 387 } else { | 389 } else { |
| 388 default_setting = GetContentSettingsMap()->GetDefaultContentSetting(type); | 390 default_setting = GetContentSettingsMap()->GetDefaultContentSetting(type); |
| 389 } | 391 } |
| 390 | 392 |
| 391 return ContentSettingToString(default_setting); | 393 return ContentSettingToString(default_setting); |
| 392 } | 394 } |
| 393 | 395 |
| 396 bool ContentSettingsHandler::GetDefaultSettingManagedFromModel( |
| 397 ContentSettingsType type) { |
| 398 if (type == CONTENT_SETTINGS_TYPE_GEOLOCATION) { |
| 399 return dom_ui_->GetProfile()-> |
| 400 GetGeolocationContentSettingsMap()->IsDefaultContentSettingManaged(); |
| 401 } else if (type == CONTENT_SETTINGS_TYPE_NOTIFICATIONS) { |
| 402 return dom_ui_->GetProfile()-> |
| 403 GetDesktopNotificationService()->IsDefaultContentSettingManaged(); |
| 404 } else { |
| 405 return GetContentSettingsMap()->IsDefaultContentSettingManaged(type); |
| 406 } |
| 407 } |
| 408 |
| 394 void ContentSettingsHandler::UpdateAllExceptionsViewsFromModel() { | 409 void ContentSettingsHandler::UpdateAllExceptionsViewsFromModel() { |
| 395 for (int type = CONTENT_SETTINGS_TYPE_DEFAULT + 1; | 410 for (int type = CONTENT_SETTINGS_TYPE_DEFAULT + 1; |
| 396 type < CONTENT_SETTINGS_NUM_TYPES; ++type) { | 411 type < CONTENT_SETTINGS_NUM_TYPES; ++type) { |
| 397 UpdateExceptionsViewFromModel(static_cast<ContentSettingsType>(type)); | 412 UpdateExceptionsViewFromModel(static_cast<ContentSettingsType>(type)); |
| 398 } | 413 } |
| 399 } | 414 } |
| 400 | 415 |
| 401 void ContentSettingsHandler::UpdateAllOTRExceptionsViewsFromModel() { | 416 void ContentSettingsHandler::UpdateAllOTRExceptionsViewsFromModel() { |
| 402 for (int type = CONTENT_SETTINGS_TYPE_DEFAULT + 1; | 417 for (int type = CONTENT_SETTINGS_TYPE_DEFAULT + 1; |
| 403 type < CONTENT_SETTINGS_NUM_TYPES; ++type) { | 418 type < CONTENT_SETTINGS_NUM_TYPES; ++type) { |
| (...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 732 return dom_ui_->GetProfile()->GetHostContentSettingsMap(); | 747 return dom_ui_->GetProfile()->GetHostContentSettingsMap(); |
| 733 } | 748 } |
| 734 | 749 |
| 735 HostContentSettingsMap* | 750 HostContentSettingsMap* |
| 736 ContentSettingsHandler::GetOTRContentSettingsMap() { | 751 ContentSettingsHandler::GetOTRContentSettingsMap() { |
| 737 Profile* profile = dom_ui_->GetProfile(); | 752 Profile* profile = dom_ui_->GetProfile(); |
| 738 if (profile->HasOffTheRecordProfile()) | 753 if (profile->HasOffTheRecordProfile()) |
| 739 return profile->GetOffTheRecordProfile()->GetHostContentSettingsMap(); | 754 return profile->GetOffTheRecordProfile()->GetHostContentSettingsMap(); |
| 740 return NULL; | 755 return NULL; |
| 741 } | 756 } |
| OLD | NEW |