| 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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 NeedsRefresh | 49 NeedsRefresh |
| 50 }; | 50 }; |
| 51 | 51 |
| 52 Entry() | 52 Entry() |
| 53 : m_value(NeedsRefresh) | 53 : m_value(NeedsRefresh) |
| 54 , m_defaultValue(false) | 54 , m_defaultValue(false) |
| 55 { } | 55 { } |
| 56 | 56 |
| 57 bool isEnabled() const | 57 bool isEnabled() const |
| 58 { | 58 { |
| 59 ASSERT(m_value != NeedsRefresh); | 59 DCHECK_NE(m_value, NeedsRefresh); |
| 60 return m_value == IsEnabled; | 60 return m_value == IsEnabled; |
| 61 } | 61 } |
| 62 | 62 |
| 63 void set(bool value, bool defaultValue) | 63 void set(bool value, bool defaultValue) |
| 64 { | 64 { |
| 65 m_value = value ? IsEnabled : IsDisabled; | 65 m_value = value ? IsEnabled : IsDisabled; |
| 66 m_defaultValue = defaultValue; | 66 m_defaultValue = defaultValue; |
| 67 } | 67 } |
| 68 | 68 |
| 69 bool needsRefresh(bool defaultValue) const | 69 bool needsRefresh(bool defaultValue) const |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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; |
| 122 m_domain = currentDomain; | 122 m_domain = currentDomain; |
| 123 for (size_t i = 0; i < ContextFeatures::FeatureTypeSize; ++i) | 123 for (size_t i = 0; i < ContextFeatures::FeatureTypeSize; ++i) |
| 124 m_entries[i] = Entry(); | 124 m_entries[i] = Entry(); |
| 125 } | 125 } |
| 126 | 126 |
| 127 bool ContextFeaturesClientImpl::isEnabled(Document* document, ContextFeatures::F
eatureType type, bool defaultValue) | 127 bool ContextFeaturesClientImpl::isEnabled(Document* document, ContextFeatures::F
eatureType type, bool defaultValue) |
| 128 { | 128 { |
| 129 ASSERT(document); | 129 DCHECK(document); |
| 130 ContextFeaturesCache::Entry& cache = ContextFeaturesCache::from(*document).e
ntryFor(type); | 130 ContextFeaturesCache::Entry& cache = ContextFeaturesCache::from(*document).e
ntryFor(type); |
| 131 if (cache.needsRefresh(defaultValue)) | 131 if (cache.needsRefresh(defaultValue)) |
| 132 cache.set(askIfIsEnabled(document, type, defaultValue), defaultValue); | 132 cache.set(askIfIsEnabled(document, type, defaultValue), defaultValue); |
| 133 return cache.isEnabled(); | 133 return cache.isEnabled(); |
| 134 } | 134 } |
| 135 | 135 |
| 136 void ContextFeaturesClientImpl::urlDidChange(Document* document) | 136 void ContextFeaturesClientImpl::urlDidChange(Document* document) |
| 137 { | 137 { |
| 138 ASSERT(document); | 138 DCHECK(document); |
| 139 ContextFeaturesCache::from(*document).validateAgainst(document); | 139 ContextFeaturesCache::from(*document).validateAgainst(document); |
| 140 } | 140 } |
| 141 | 141 |
| 142 bool ContextFeaturesClientImpl::askIfIsEnabled(Document* document, ContextFeatur
es::FeatureType type, bool defaultValue) | 142 bool ContextFeaturesClientImpl::askIfIsEnabled(Document* document, ContextFeatur
es::FeatureType type, bool defaultValue) |
| 143 { | 143 { |
| 144 WebLocalFrameImpl* frame = WebLocalFrameImpl::fromFrame(document->frame()); | 144 WebLocalFrameImpl* frame = WebLocalFrameImpl::fromFrame(document->frame()); |
| 145 if (!frame || !frame->contentSettingsClient()) | 145 if (!frame || !frame->contentSettingsClient()) |
| 146 return defaultValue; | 146 return defaultValue; |
| 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 |