| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2011 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * | 7 * |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 ASSERT(!sourceOrigin.isUnique()); | 112 ASSERT(!sourceOrigin.isUnique()); |
| 113 if (sourceOrigin.isUnique()) | 113 if (sourceOrigin.isUnique()) |
| 114 return; | 114 return; |
| 115 | 115 |
| 116 String sourceString = sourceOrigin.toString(); | 116 String sourceString = sourceOrigin.toString(); |
| 117 OriginAccessMap::AddResult result = originAccessMap().add(sourceString, null
ptr); | 117 OriginAccessMap::AddResult result = originAccessMap().add(sourceString, null
ptr); |
| 118 if (result.isNewEntry) | 118 if (result.isNewEntry) |
| 119 result.iterator->value = adoptPtr(new OriginAccessWhiteList); | 119 result.iterator->value = adoptPtr(new OriginAccessWhiteList); |
| 120 | 120 |
| 121 OriginAccessWhiteList* list = result.iterator->value.get(); | 121 OriginAccessWhiteList* list = result.iterator->value.get(); |
| 122 list->append(OriginAccessEntry(destinationProtocol, destinationDomain, allow
DestinationSubdomains ? OriginAccessEntry::AllowSubdomains : OriginAccessEntry::
DisallowSubdomains)); | 122 list->append(OriginAccessEntry(destinationProtocol, destinationDomain, allow
DestinationSubdomains ? OriginAccessEntry::AllowSubdomains : OriginAccessEntry::
DisallowSubdomains, OriginAccessEntry::TreatIPAddressAsIPAddress)); |
| 123 } | 123 } |
| 124 | 124 |
| 125 void SecurityPolicy::removeOriginAccessWhitelistEntry(const SecurityOrigin& sour
ceOrigin, const String& destinationProtocol, const String& destinationDomain, bo
ol allowDestinationSubdomains) | 125 void SecurityPolicy::removeOriginAccessWhitelistEntry(const SecurityOrigin& sour
ceOrigin, const String& destinationProtocol, const String& destinationDomain, bo
ol allowDestinationSubdomains) |
| 126 { | 126 { |
| 127 ASSERT(isMainThread()); | 127 ASSERT(isMainThread()); |
| 128 ASSERT(!sourceOrigin.isUnique()); | 128 ASSERT(!sourceOrigin.isUnique()); |
| 129 if (sourceOrigin.isUnique()) | 129 if (sourceOrigin.isUnique()) |
| 130 return; | 130 return; |
| 131 | 131 |
| 132 String sourceString = sourceOrigin.toString(); | 132 String sourceString = sourceOrigin.toString(); |
| 133 OriginAccessMap& map = originAccessMap(); | 133 OriginAccessMap& map = originAccessMap(); |
| 134 OriginAccessMap::iterator it = map.find(sourceString); | 134 OriginAccessMap::iterator it = map.find(sourceString); |
| 135 if (it == map.end()) | 135 if (it == map.end()) |
| 136 return; | 136 return; |
| 137 | 137 |
| 138 OriginAccessWhiteList* list = it->value.get(); | 138 OriginAccessWhiteList* list = it->value.get(); |
| 139 size_t index = list->find(OriginAccessEntry(destinationProtocol, destination
Domain, allowDestinationSubdomains ? OriginAccessEntry::AllowSubdomains : Origin
AccessEntry::DisallowSubdomains)); | 139 size_t index = list->find(OriginAccessEntry(destinationProtocol, destination
Domain, allowDestinationSubdomains ? OriginAccessEntry::AllowSubdomains : Origin
AccessEntry::DisallowSubdomains, OriginAccessEntry::TreatIPAddressAsIPAddress)); |
| 140 if (index == kNotFound) | 140 if (index == kNotFound) |
| 141 return; | 141 return; |
| 142 | 142 |
| 143 list->remove(index); | 143 list->remove(index); |
| 144 | 144 |
| 145 if (list->isEmpty()) | 145 if (list->isEmpty()) |
| 146 map.remove(it); | 146 map.remove(it); |
| 147 } | 147 } |
| 148 | 148 |
| 149 void SecurityPolicy::resetOriginAccessWhitelists() | 149 void SecurityPolicy::resetOriginAccessWhitelists() |
| 150 { | 150 { |
| 151 ASSERT(isMainThread()); | 151 ASSERT(isMainThread()); |
| 152 originAccessMap().clear(); | 152 originAccessMap().clear(); |
| 153 } | 153 } |
| 154 | 154 |
| 155 } // namespace WebCore | 155 } // namespace WebCore |
| OLD | NEW |