Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / Source / web / ContextFeaturesClientImpl.cpp
index 4d1edf4..a50ff69 100644 (file)
  */
 
 #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:
@@ -78,7 +78,7 @@ public:
     };
 
     static const char* supplementName();
-    static ContextFeaturesCache* from(Document*);
+    static ContextFeaturesCache& from(Document&);
 
     Entry& entryFor(ContextFeatures::FeatureType type)
     {
@@ -99,15 +99,15 @@ const char* ContextFeaturesCache::supplementName()
     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)
@@ -122,7 +122,8 @@ 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();
@@ -130,24 +131,24 @@ bool ContextFeaturesClientImpl::isEnabled(Document* document, ContextFeatures::F
 
 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