| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/site_settings_helper.h" | 5 #include "chrome/browser/ui/webui/site_settings_helper.h" |
| 6 | 6 |
| 7 #include "base/memory/ptr_util.h" | 7 #include "base/memory/ptr_util.h" |
| 8 #include "base/values.h" | 8 #include "base/values.h" |
| 9 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
| 10 #include "chrome/common/pref_names.h" | 10 #include "chrome/common/pref_names.h" |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 {CONTENT_SETTINGS_TYPE_MIDI_SYSEX, "midi-sysex"}, | 44 {CONTENT_SETTINGS_TYPE_MIDI_SYSEX, "midi-sysex"}, |
| 45 {CONTENT_SETTINGS_TYPE_PUSH_MESSAGING, "push-messaging"}, | 45 {CONTENT_SETTINGS_TYPE_PUSH_MESSAGING, "push-messaging"}, |
| 46 {CONTENT_SETTINGS_TYPE_SSL_CERT_DECISIONS, "ssl-cert-decisions"}, | 46 {CONTENT_SETTINGS_TYPE_SSL_CERT_DECISIONS, "ssl-cert-decisions"}, |
| 47 #if defined(OS_CHROMEOS) | 47 #if defined(OS_CHROMEOS) |
| 48 {CONTENT_SETTINGS_TYPE_PROTECTED_MEDIA_IDENTIFIER, "protectedContent"}, | 48 {CONTENT_SETTINGS_TYPE_PROTECTED_MEDIA_IDENTIFIER, "protectedContent"}, |
| 49 #endif | 49 #endif |
| 50 {CONTENT_SETTINGS_TYPE_KEYGEN, "keygen"}, | 50 {CONTENT_SETTINGS_TYPE_KEYGEN, "keygen"}, |
| 51 {CONTENT_SETTINGS_TYPE_BACKGROUND_SYNC, "background-sync"}, | 51 {CONTENT_SETTINGS_TYPE_BACKGROUND_SYNC, "background-sync"}, |
| 52 }; | 52 }; |
| 53 | 53 |
| 54 bool HasRegisteredGroupName(ContentSettingsType type) { |
| 55 for (size_t i = 0; i < arraysize(kContentSettingsTypeGroupNames); ++i) { |
| 56 if (type == kContentSettingsTypeGroupNames[i].type) |
| 57 return true; |
| 58 } |
| 59 return false; |
| 60 } |
| 61 |
| 54 ContentSettingsType ContentSettingsTypeFromGroupName(const std::string& name) { | 62 ContentSettingsType ContentSettingsTypeFromGroupName(const std::string& name) { |
| 55 for (size_t i = 0; i < arraysize(kContentSettingsTypeGroupNames); ++i) { | 63 for (size_t i = 0; i < arraysize(kContentSettingsTypeGroupNames); ++i) { |
| 56 if (name == kContentSettingsTypeGroupNames[i].name) | 64 if (name == kContentSettingsTypeGroupNames[i].name) |
| 57 return kContentSettingsTypeGroupNames[i].type; | 65 return kContentSettingsTypeGroupNames[i].type; |
| 58 } | 66 } |
| 59 | 67 |
| 60 NOTREACHED() << name << " is not a recognized content settings type."; | 68 NOTREACHED() << name << " is not a recognized content settings type."; |
| 61 return CONTENT_SETTINGS_TYPE_DEFAULT; | 69 return CONTENT_SETTINGS_TYPE_DEFAULT; |
| 62 } | 70 } |
| 63 | 71 |
| 64 std::string ContentSettingsTypeToGroupName(ContentSettingsType type) { | 72 std::string ContentSettingsTypeToGroupName(ContentSettingsType type) { |
| 65 for (size_t i = 0; i < arraysize(kContentSettingsTypeGroupNames); ++i) { | 73 for (size_t i = 0; i < arraysize(kContentSettingsTypeGroupNames); ++i) { |
| 66 if (type == kContentSettingsTypeGroupNames[i].type) | 74 if (type == kContentSettingsTypeGroupNames[i].type) |
| 67 return kContentSettingsTypeGroupNames[i].name; | 75 return kContentSettingsTypeGroupNames[i].name; |
| 68 } | 76 } |
| 69 | 77 |
| 70 NOTREACHED(); | 78 NOTREACHED() << type << " is not a recognized content settings type."; |
| 71 return std::string(); | 79 return std::string(); |
| 72 } | 80 } |
| 73 | 81 |
| 74 // Create a DictionaryValue* that will act as a data source for a single row | 82 // Create a DictionaryValue* that will act as a data source for a single row |
| 75 // in a HostContentSettingsMap-controlled exceptions table (e.g., cookies). | 83 // in a HostContentSettingsMap-controlled exceptions table (e.g., cookies). |
| 76 std::unique_ptr<base::DictionaryValue> GetExceptionForPage( | 84 std::unique_ptr<base::DictionaryValue> GetExceptionForPage( |
| 77 const ContentSettingsPattern& pattern, | 85 const ContentSettingsPattern& pattern, |
| 78 const ContentSettingsPattern& secondary_pattern, | 86 const ContentSettingsPattern& secondary_pattern, |
| 79 const ContentSetting& setting, | 87 const ContentSetting& setting, |
| 80 const std::string& provider_name) { | 88 const std::string& provider_name) { |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 219 patterns.begin(), patterns.end(), std::greater<ContentSettingsPattern>()); | 227 patterns.begin(), patterns.end(), std::greater<ContentSettingsPattern>()); |
| 220 | 228 |
| 221 for (const ContentSettingsPattern& pattern : patterns) { | 229 for (const ContentSettingsPattern& pattern : patterns) { |
| 222 exceptions->push_back(GetExceptionForPage(pattern, ContentSettingsPattern(), | 230 exceptions->push_back(GetExceptionForPage(pattern, ContentSettingsPattern(), |
| 223 CONTENT_SETTING_ALLOW, | 231 CONTENT_SETTING_ALLOW, |
| 224 kPolicyProviderId)); | 232 kPolicyProviderId)); |
| 225 } | 233 } |
| 226 } | 234 } |
| 227 | 235 |
| 228 } // namespace site_settings | 236 } // namespace site_settings |
| OLD | NEW |