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 20 matching lines...) Expand all Loading... |
31 #include "web/ContextFeaturesClientImpl.h" | 31 #include "web/ContextFeaturesClientImpl.h" |
32 | 32 |
33 #include "core/dom/Document.h" | 33 #include "core/dom/Document.h" |
34 #include "platform/weborigin/SecurityOrigin.h" | 34 #include "platform/weborigin/SecurityOrigin.h" |
35 #include "public/web/WebContentSettingsClient.h" | 35 #include "public/web/WebContentSettingsClient.h" |
36 #include "public/web/WebDocument.h" | 36 #include "public/web/WebDocument.h" |
37 #include "web/WebLocalFrameImpl.h" | 37 #include "web/WebLocalFrameImpl.h" |
38 | 38 |
39 namespace blink { | 39 namespace blink { |
40 | 40 |
41 class ContextFeaturesCache final : public GarbageCollectedFinalized<ContextFeatu
resCache>, public HeapSupplement<Document> { | 41 class ContextFeaturesCache final : public GarbageCollectedFinalized<ContextFeatu
resCache>, public Supplement<Document> { |
42 USING_GARBAGE_COLLECTED_MIXIN(ContextFeaturesCache); | 42 USING_GARBAGE_COLLECTED_MIXIN(ContextFeaturesCache); |
43 public: | 43 public: |
44 class Entry { | 44 class Entry { |
45 public: | 45 public: |
46 enum Value { | 46 enum Value { |
47 IsEnabled, | 47 IsEnabled, |
48 IsDisabled, | 48 IsDisabled, |
49 NeedsRefresh | 49 NeedsRefresh |
50 }; | 50 }; |
51 | 51 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 { | 83 { |
84 size_t index = static_cast<size_t>(type); | 84 size_t index = static_cast<size_t>(type); |
85 ASSERT_WITH_SECURITY_IMPLICATION(index < ContextFeatures::FeatureTypeSiz
e); | 85 ASSERT_WITH_SECURITY_IMPLICATION(index < ContextFeatures::FeatureTypeSiz
e); |
86 return m_entries[index]; | 86 return m_entries[index]; |
87 } | 87 } |
88 | 88 |
89 void validateAgainst(Document*); | 89 void validateAgainst(Document*); |
90 | 90 |
91 DEFINE_INLINE_VIRTUAL_TRACE() | 91 DEFINE_INLINE_VIRTUAL_TRACE() |
92 { | 92 { |
93 HeapSupplement<Document>::trace(visitor); | 93 Supplement<Document>::trace(visitor); |
94 } | 94 } |
95 | 95 |
96 private: | 96 private: |
97 String m_domain; | 97 String m_domain; |
98 Entry m_entries[ContextFeatures::FeatureTypeSize]; | 98 Entry m_entries[ContextFeatures::FeatureTypeSize]; |
99 }; | 99 }; |
100 | 100 |
101 const char* ContextFeaturesCache::supplementName() | 101 const char* ContextFeaturesCache::supplementName() |
102 { | 102 { |
103 return "ContextFeaturesCache"; | 103 return "ContextFeaturesCache"; |
104 } | 104 } |
105 | 105 |
106 ContextFeaturesCache& ContextFeaturesCache::from(Document& document) | 106 ContextFeaturesCache& ContextFeaturesCache::from(Document& document) |
107 { | 107 { |
108 ContextFeaturesCache* cache = static_cast<ContextFeaturesCache*>(HeapSupplem
ent<Document>::from(document, supplementName())); | 108 ContextFeaturesCache* cache = static_cast<ContextFeaturesCache*>(Supplement<
Document>::from(document, supplementName())); |
109 if (!cache) { | 109 if (!cache) { |
110 cache = new ContextFeaturesCache(); | 110 cache = new ContextFeaturesCache(); |
111 HeapSupplement<Document>::provideTo(document, supplementName(), cache); | 111 Supplement<Document>::provideTo(document, supplementName(), cache); |
112 } | 112 } |
113 | 113 |
114 return *cache; | 114 return *cache; |
115 } | 115 } |
116 | 116 |
117 void ContextFeaturesCache::validateAgainst(Document* document) | 117 void ContextFeaturesCache::validateAgainst(Document* document) |
118 { | 118 { |
119 String currentDomain = document->getSecurityOrigin()->domain(); | 119 String currentDomain = document->getSecurityOrigin()->domain(); |
120 if (currentDomain == m_domain) | 120 if (currentDomain == m_domain) |
121 return; | 121 return; |
(...skipping 25 matching lines...) Expand all Loading... |
147 | 147 |
148 switch (type) { | 148 switch (type) { |
149 case ContextFeatures::MutationEvents: | 149 case ContextFeatures::MutationEvents: |
150 return frame->contentSettingsClient()->allowMutationEvents(defaultValue)
; | 150 return frame->contentSettingsClient()->allowMutationEvents(defaultValue)
; |
151 default: | 151 default: |
152 return defaultValue; | 152 return defaultValue; |
153 } | 153 } |
154 } | 154 } |
155 | 155 |
156 } // namespace blink | 156 } // namespace blink |
OLD | NEW |