OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 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 are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * 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 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 size_t index = static_cast<size_t>(type); | 77 size_t index = static_cast<size_t>(type); |
78 SECURITY_DCHECK(index < ContextFeatures::FeatureTypeSize); | 78 SECURITY_DCHECK(index < ContextFeatures::FeatureTypeSize); |
79 return m_entries[index]; | 79 return m_entries[index]; |
80 } | 80 } |
81 | 81 |
82 void validateAgainst(Document*); | 82 void validateAgainst(Document*); |
83 | 83 |
84 DEFINE_INLINE_VIRTUAL_TRACE() { Supplement<Document>::trace(visitor); } | 84 DEFINE_INLINE_VIRTUAL_TRACE() { Supplement<Document>::trace(visitor); } |
85 | 85 |
86 private: | 86 private: |
| 87 explicit ContextFeaturesCache(Document& document) |
| 88 : Supplement<Document>(document) {} |
| 89 |
87 String m_domain; | 90 String m_domain; |
88 Entry m_entries[ContextFeatures::FeatureTypeSize]; | 91 Entry m_entries[ContextFeatures::FeatureTypeSize]; |
89 }; | 92 }; |
90 | 93 |
91 const char* ContextFeaturesCache::supplementName() { | 94 const char* ContextFeaturesCache::supplementName() { |
92 return "ContextFeaturesCache"; | 95 return "ContextFeaturesCache"; |
93 } | 96 } |
94 | 97 |
95 ContextFeaturesCache& ContextFeaturesCache::from(Document& document) { | 98 ContextFeaturesCache& ContextFeaturesCache::from(Document& document) { |
96 ContextFeaturesCache* cache = static_cast<ContextFeaturesCache*>( | 99 ContextFeaturesCache* cache = static_cast<ContextFeaturesCache*>( |
97 Supplement<Document>::from(document, supplementName())); | 100 Supplement<Document>::from(document, supplementName())); |
98 if (!cache) { | 101 if (!cache) { |
99 cache = new ContextFeaturesCache(); | 102 cache = new ContextFeaturesCache(document); |
100 Supplement<Document>::provideTo(document, supplementName(), cache); | 103 Supplement<Document>::provideTo(document, supplementName(), cache); |
101 } | 104 } |
102 | 105 |
103 return *cache; | 106 return *cache; |
104 } | 107 } |
105 | 108 |
106 void ContextFeaturesCache::validateAgainst(Document* document) { | 109 void ContextFeaturesCache::validateAgainst(Document* document) { |
107 String currentDomain = document->getSecurityOrigin()->domain(); | 110 String currentDomain = document->getSecurityOrigin()->domain(); |
108 if (currentDomain == m_domain) | 111 if (currentDomain == m_domain) |
109 return; | 112 return; |
(...skipping 28 matching lines...) Expand all Loading... |
138 | 141 |
139 switch (type) { | 142 switch (type) { |
140 case ContextFeatures::MutationEvents: | 143 case ContextFeatures::MutationEvents: |
141 return frame->contentSettingsClient()->allowMutationEvents(defaultValue); | 144 return frame->contentSettingsClient()->allowMutationEvents(defaultValue); |
142 default: | 145 default: |
143 return defaultValue; | 146 return defaultValue; |
144 } | 147 } |
145 } | 148 } |
146 | 149 |
147 } // namespace blink | 150 } // namespace blink |
OLD | NEW |