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