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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 #include "wtf/text/StringHash.h" | 42 #include "wtf/text/StringHash.h" |
43 | 43 |
44 namespace blink { | 44 namespace blink { |
45 | 45 |
46 using OriginAccessWhiteList = Vector<OriginAccessEntry>; | 46 using OriginAccessWhiteList = Vector<OriginAccessEntry>; |
47 using OriginAccessMap = HashMap<String, OwnPtr<OriginAccessWhiteList>>; | 47 using OriginAccessMap = HashMap<String, OwnPtr<OriginAccessWhiteList>>; |
48 using OriginSet = HashSet<String>; | 48 using OriginSet = HashSet<String>; |
49 | 49 |
50 static OriginAccessMap& originAccessMap() | 50 static OriginAccessMap& originAccessMap() |
51 { | 51 { |
52 AtomicallyInitializedStaticReference(OriginAccessMap, originAccessMap, new O
riginAccessMap); | 52 DEFINE_STATIC_LOCAL(OriginAccessMap, originAccessMap, ()); |
53 return originAccessMap; | 53 return originAccessMap; |
54 } | 54 } |
55 | 55 |
56 static OriginSet& trustworthyOriginSet() | 56 static OriginSet& trustworthyOriginSet() |
57 { | 57 { |
58 AtomicallyInitializedStaticReference(OriginSet, trustworthyOriginSet, new Or
iginSet); | 58 DEFINE_STATIC_LOCAL(OriginSet, trustworthyOriginSet, ()); |
59 return trustworthyOriginSet; | 59 return trustworthyOriginSet; |
60 } | 60 } |
61 | 61 |
| 62 void SecurityPolicy::init() |
| 63 { |
| 64 originAccessMap(); |
| 65 trustworthyOriginSet(); |
| 66 } |
| 67 |
62 bool SecurityPolicy::shouldHideReferrer(const KURL& url, const String& referrer) | 68 bool SecurityPolicy::shouldHideReferrer(const KURL& url, const String& referrer) |
63 { | 69 { |
64 bool referrerIsSecureURL = protocolIs(referrer, "https"); | 70 bool referrerIsSecureURL = protocolIs(referrer, "https"); |
65 bool referrerIsWebURL = referrerIsSecureURL || protocolIs(referrer, "http"); | 71 bool referrerIsWebURL = referrerIsSecureURL || protocolIs(referrer, "http"); |
66 | 72 |
67 if (!referrerIsWebURL) | 73 if (!referrerIsWebURL) |
68 return true; | 74 return true; |
69 | 75 |
70 if (!referrerIsSecureURL) | 76 if (!referrerIsSecureURL) |
71 return false; | 77 return false; |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
197 map.remove(it); | 203 map.remove(it); |
198 } | 204 } |
199 | 205 |
200 void SecurityPolicy::resetOriginAccessWhitelists() | 206 void SecurityPolicy::resetOriginAccessWhitelists() |
201 { | 207 { |
202 ASSERT(isMainThread()); | 208 ASSERT(isMainThread()); |
203 originAccessMap().clear(); | 209 originAccessMap().clear(); |
204 } | 210 } |
205 | 211 |
206 } // namespace blink | 212 } // namespace blink |
OLD | NEW |