*/
#include "config.h"
-#include "ContextFeaturesClientImpl.h"
+#include "web/ContextFeaturesClientImpl.h"
-#include "WebDocument.h"
-#include "WebPermissionClient.h"
#include "core/dom/Document.h"
-#include "weborigin/SecurityOrigin.h"
+#include "platform/weborigin/SecurityOrigin.h"
+#include "public/web/WebDocument.h"
+#include "public/web/WebPermissionClient.h"
+#include "web/WebLocalFrameImpl.h"
-using namespace WebCore;
+namespace blink {
-namespace WebKit {
-
-class ContextFeaturesCache : public DocumentSupplement {
+class ContextFeaturesCache final : public NoBaseWillBeGarbageCollectedFinalized<ContextFeaturesCache>, public DocumentSupplement {
+ WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(ContextFeaturesCache);
public:
class Entry {
public:
};
static const char* supplementName();
- static ContextFeaturesCache* from(Document*);
+ static ContextFeaturesCache& from(Document&);
Entry& entryFor(ContextFeatures::FeatureType type)
{
return "ContextFeaturesCache";
}
-ContextFeaturesCache* ContextFeaturesCache::from(Document* document)
+ContextFeaturesCache& ContextFeaturesCache::from(Document& document)
{
ContextFeaturesCache* cache = static_cast<ContextFeaturesCache*>(DocumentSupplement::from(document, supplementName()));
if (!cache) {
cache = new ContextFeaturesCache();
- DocumentSupplement::provideTo(document, supplementName(), adoptPtr(cache));
+ DocumentSupplement::provideTo(document, supplementName(), adoptPtrWillBeNoop(cache));
}
- return cache;
+ return *cache;
}
void ContextFeaturesCache::validateAgainst(Document* document)
bool ContextFeaturesClientImpl::isEnabled(Document* document, ContextFeatures::FeatureType type, bool defaultValue)
{
- ContextFeaturesCache::Entry& cache = ContextFeaturesCache::from(document)->entryFor(type);
+ ASSERT(document);
+ ContextFeaturesCache::Entry& cache = ContextFeaturesCache::from(*document).entryFor(type);
if (cache.needsRefresh(defaultValue))
cache.set(askIfIsEnabled(document, type, defaultValue), defaultValue);
return cache.isEnabled();
void ContextFeaturesClientImpl::urlDidChange(Document* document)
{
- ContextFeaturesCache::from(document)->validateAgainst(document);
+ ASSERT(document);
+ ContextFeaturesCache::from(*document).validateAgainst(document);
}
bool ContextFeaturesClientImpl::askIfIsEnabled(Document* document, ContextFeatures::FeatureType type, bool defaultValue)
{
- if (!m_client)
+ WebLocalFrameImpl* frame = WebLocalFrameImpl::fromFrame(document->frame());
+ if (!frame || !frame->permissionClient())
return defaultValue;
switch (type) {
- case ContextFeatures::StyleScoped:
- return m_client->allowWebComponents(WebDocument(document), defaultValue);
case ContextFeatures::MutationEvents:
- return m_client->allowMutationEvents(WebDocument(document), defaultValue);
+ return frame->permissionClient()->allowMutationEvents(defaultValue);
case ContextFeatures::PushState:
- return m_client->allowPushState(WebDocument(document));
+ return frame->permissionClient()->allowPushState();
default:
return defaultValue;
}
}
-} // namespace WebKit
+} // namespace blink