| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <map> | 10 #include <map> |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 #include "chrome/common/url_constants.h" | 50 #include "chrome/common/url_constants.h" |
| 51 #include "chrome/grit/generated_resources.h" | 51 #include "chrome/grit/generated_resources.h" |
| 52 #include "chrome/grit/locale_settings.h" | 52 #include "chrome/grit/locale_settings.h" |
| 53 #include "components/content_settings/core/browser/content_settings_details.h" | 53 #include "components/content_settings/core/browser/content_settings_details.h" |
| 54 #include "components/content_settings/core/browser/content_settings_utils.h" | 54 #include "components/content_settings/core/browser/content_settings_utils.h" |
| 55 #include "components/content_settings/core/browser/host_content_settings_map.h" | 55 #include "components/content_settings/core/browser/host_content_settings_map.h" |
| 56 #include "components/content_settings/core/browser/website_settings_info.h" | 56 #include "components/content_settings/core/browser/website_settings_info.h" |
| 57 #include "components/content_settings/core/browser/website_settings_registry.h" | 57 #include "components/content_settings/core/browser/website_settings_registry.h" |
| 58 #include "components/content_settings/core/common/content_settings.h" | 58 #include "components/content_settings/core/common/content_settings.h" |
| 59 #include "components/content_settings/core/common/content_settings_pattern.h" | 59 #include "components/content_settings/core/common/content_settings_pattern.h" |
| 60 #include "components/content_settings/core/common/content_settings_utils.h" |
| 60 #include "components/google/core/browser/google_util.h" | 61 #include "components/google/core/browser/google_util.h" |
| 61 #include "components/prefs/pref_service.h" | 62 #include "components/prefs/pref_service.h" |
| 62 #include "components/signin/core/common/profile_management_switches.h" | 63 #include "components/signin/core/common/profile_management_switches.h" |
| 63 #include "components/user_prefs/user_prefs.h" | 64 #include "components/user_prefs/user_prefs.h" |
| 64 #include "content/public/browser/notification_service.h" | 65 #include "content/public/browser/notification_service.h" |
| 65 #include "content/public/browser/notification_source.h" | 66 #include "content/public/browser/notification_source.h" |
| 66 #include "content/public/browser/notification_types.h" | 67 #include "content/public/browser/notification_types.h" |
| 67 #include "content/public/browser/storage_partition.h" | 68 #include "content/public/browser/storage_partition.h" |
| 68 #include "content/public/browser/web_contents.h" | 69 #include "content/public/browser/web_contents.h" |
| 69 #include "content/public/browser/web_ui.h" | 70 #include "content/public/browser/web_ui.h" |
| (...skipping 760 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 830 site_settings::AllPatternsSettings all_patterns_settings; | 831 site_settings::AllPatternsSettings all_patterns_settings; |
| 831 for (ContentSettingsForOneType::iterator i = all_settings.begin(); | 832 for (ContentSettingsForOneType::iterator i = all_settings.begin(); |
| 832 i != all_settings.end(); ++i) { | 833 i != all_settings.end(); ++i) { |
| 833 // Don't add default settings. | 834 // Don't add default settings. |
| 834 if (i->primary_pattern == ContentSettingsPattern::Wildcard() && | 835 if (i->primary_pattern == ContentSettingsPattern::Wildcard() && |
| 835 i->secondary_pattern == ContentSettingsPattern::Wildcard() && | 836 i->secondary_pattern == ContentSettingsPattern::Wildcard() && |
| 836 i | 837 i |
| 837 ->source != site_settings::kPreferencesSource) { | 838 ->source != site_settings::kPreferencesSource) { |
| 838 continue; | 839 continue; |
| 839 } | 840 } |
| 840 all_patterns_settings[std::make_pair(i->primary_pattern, i->source)] | 841 all_patterns_settings[std::make_pair(i->primary_pattern, |
| 841 [i->secondary_pattern] = i->setting; | 842 i->source)][i->secondary_pattern] = |
| 843 content_settings::ValueToContentSetting(i->setting_value.get()); |
| 842 } | 844 } |
| 843 | 845 |
| 844 base::ListValue exceptions; | 846 base::ListValue exceptions; |
| 845 AddExceptionsGrantedByHostedApps( | 847 AddExceptionsGrantedByHostedApps( |
| 846 profile, | 848 profile, |
| 847 HostedAppHasPermission<APIPermission::kGeolocation>, | 849 HostedAppHasPermission<APIPermission::kGeolocation>, |
| 848 &exceptions); | 850 &exceptions); |
| 849 | 851 |
| 850 for (site_settings::AllPatternsSettings::iterator i = | 852 for (site_settings::AllPatternsSettings::iterator i = |
| 851 all_patterns_settings.begin(); i != all_patterns_settings.end(); ++i) { | 853 all_patterns_settings.begin(); i != all_patterns_settings.end(); ++i) { |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 902 i != settings.end(); | 904 i != settings.end(); |
| 903 ++i) { | 905 ++i) { |
| 904 // Don't add default settings. | 906 // Don't add default settings. |
| 905 if (i->primary_pattern == ContentSettingsPattern::Wildcard() && | 907 if (i->primary_pattern == ContentSettingsPattern::Wildcard() && |
| 906 i->secondary_pattern == ContentSettingsPattern::Wildcard() && | 908 i->secondary_pattern == ContentSettingsPattern::Wildcard() && |
| 907 i | 909 i |
| 908 ->source != site_settings::kPreferencesSource) { | 910 ->source != site_settings::kPreferencesSource) { |
| 909 continue; | 911 continue; |
| 910 } | 912 } |
| 911 | 913 |
| 912 exceptions.Append( | 914 exceptions.Append(GetNotificationExceptionForPage( |
| 913 GetNotificationExceptionForPage(i->primary_pattern, | 915 i->primary_pattern, i->secondary_pattern, |
| 914 i->secondary_pattern, | 916 content_settings::ValueToContentSetting(i->setting_value.get()), |
| 915 i->setting, | 917 i->source)); |
| 916 i->source)); | |
| 917 } | 918 } |
| 918 | 919 |
| 919 base::Value type_string(site_settings::ContentSettingsTypeToGroupName( | 920 base::Value type_string(site_settings::ContentSettingsTypeToGroupName( |
| 920 CONTENT_SETTINGS_TYPE_NOTIFICATIONS)); | 921 CONTENT_SETTINGS_TYPE_NOTIFICATIONS)); |
| 921 web_ui()->CallJavascriptFunctionUnsafe("ContentSettings.setExceptions", | 922 web_ui()->CallJavascriptFunctionUnsafe("ContentSettings.setExceptions", |
| 922 type_string, exceptions); | 923 type_string, exceptions); |
| 923 | 924 |
| 924 // This is mainly here to keep this function ideologically parallel to | 925 // This is mainly here to keep this function ideologically parallel to |
| 925 // UpdateExceptionsViewFromHostContentSettingsMap(). | 926 // UpdateExceptionsViewFromHostContentSettingsMap(). |
| 926 UpdateSettingDefaultFromModel(CONTENT_SETTINGS_TYPE_NOTIFICATIONS); | 927 UpdateSettingDefaultFromModel(CONTENT_SETTINGS_TYPE_NOTIFICATIONS); |
| (...skipping 558 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1485 | 1486 |
| 1486 // Exceptions apply only when the feature is enabled. | 1487 // Exceptions apply only when the feature is enabled. |
| 1487 PrefService* prefs = user_prefs::UserPrefs::Get(GetBrowserContext(web_ui())); | 1488 PrefService* prefs = user_prefs::UserPrefs::Get(GetBrowserContext(web_ui())); |
| 1488 bool enable_exceptions = prefs->GetBoolean(prefs::kEnableDRM); | 1489 bool enable_exceptions = prefs->GetBoolean(prefs::kEnableDRM); |
| 1489 web_ui()->CallJavascriptFunctionUnsafe( | 1490 web_ui()->CallJavascriptFunctionUnsafe( |
| 1490 "ContentSettings.enableProtectedContentExceptions", | 1491 "ContentSettings.enableProtectedContentExceptions", |
| 1491 base::Value(enable_exceptions)); | 1492 base::Value(enable_exceptions)); |
| 1492 } | 1493 } |
| 1493 | 1494 |
| 1494 } // namespace options | 1495 } // namespace options |
| OLD | NEW |