Title: [132421] trunk/Source
Revision
132421
Author
mih...@chromium.org
Date
2012-10-24 16:26:58 -0700 (Wed, 24 Oct 2012)

Log Message

[Chromium] Allow pushState and related history APIs to be disabled per context
https://bugs.webkit.org/show_bug.cgi?id=99780

Reviewed by Adam Barth.

Source/WebCore:

Chrome Apps do not support the history API (or navigation in general).
Since pushState is generally feature detected, it's cleanest to disable
it via a V8 per-context feature, so that applications can have the
appropriate fallback behavior (other history APIs are re-mapped to throw
exceptions, since history.back() and the link are not feature detected).

* dom/ContextFeatures.cpp:
(WebCore::ContextFeatures::pushStateEnabled):
(WebCore):
* dom/ContextFeatures.h:
* dom/Document.cpp:
(WebCore::Document::enqueuePopstateEvent):
* page/History.idl:

Source/WebKit/chromium:

Add pushState context feature.

* public/WebPermissionClient.h:
(WebPermissionClient):
(WebKit::WebPermissionClient::allowPushState):
* src/ContextFeaturesClientImpl.cpp:
(WebKit::ContextFeaturesClientImpl::askIfIsEnabled):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (132420 => 132421)


--- trunk/Source/WebCore/ChangeLog	2012-10-24 23:24:05 UTC (rev 132420)
+++ trunk/Source/WebCore/ChangeLog	2012-10-24 23:26:58 UTC (rev 132421)
@@ -1,3 +1,24 @@
+2012-10-24  Mihai Parparita  <mih...@chromium.org>
+
+        [Chromium] Allow pushState and related history APIs to be disabled per context
+        https://bugs.webkit.org/show_bug.cgi?id=99780
+
+        Reviewed by Adam Barth.
+
+        Chrome Apps do not support the history API (or navigation in general).
+        Since pushState is generally feature detected, it's cleanest to disable
+        it via a V8 per-context feature, so that applications can have the
+        appropriate fallback behavior (other history APIs are re-mapped to throw
+        exceptions, since history.back() and the link are not feature detected).
+
+        * dom/ContextFeatures.cpp:
+        (WebCore::ContextFeatures::pushStateEnabled):
+        (WebCore):
+        * dom/ContextFeatures.h:
+        * dom/Document.cpp:
+        (WebCore::Document::enqueuePopstateEvent):
+        * page/History.idl:
+
 2012-10-24  Tommy Widenflycht  <tom...@google.com>
 
         MediaStream API: Make sure all events are dispatched asynchronously

Modified: trunk/Source/WebCore/dom/ContextFeatures.cpp (132420 => 132421)


--- trunk/Source/WebCore/dom/ContextFeatures.cpp	2012-10-24 23:24:05 UTC (rev 132420)
+++ trunk/Source/WebCore/dom/ContextFeatures.cpp	2012-10-24 23:26:58 UTC (rev 132421)
@@ -107,6 +107,11 @@
     return document->contextFeatures()->isEnabled(document, MutationEvents, true);
 }
 
+bool ContextFeatures::pushStateEnabled(Document* document)
+{
+    return document->contextFeatures()->isEnabled(document, PushState, true);
+}
+
 void provideContextFeaturesTo(Page* page, ContextFeaturesClient* client)
 {
     RefCountedSupplement<Page, ContextFeatures>::provideTo(page, ContextFeatures::supplementName(), ContextFeatures::create(client));

Modified: trunk/Source/WebCore/dom/ContextFeatures.h (132420 => 132421)


--- trunk/Source/WebCore/dom/ContextFeatures.h	2012-10-24 23:24:05 UTC (rev 132420)
+++ trunk/Source/WebCore/dom/ContextFeatures.h	2012-10-24 23:26:58 UTC (rev 132421)
@@ -44,6 +44,7 @@
         PagePopup,
         HTMLNotifications,
         MutationEvents,
+        PushState,
         FeatureTypeSize // Should be the last entry.
     };
 
@@ -56,6 +57,7 @@
     static bool pagePopupEnabled(Document*);
     static bool htmlNotificationsEnabled(Document*);
     static bool mutationEventsEnabled(Document*);
+    static bool pushStateEnabled(Document*);
 
     bool isEnabled(Document*, FeatureType, bool) const;
     void urlDidChange(Document*);

Modified: trunk/Source/WebCore/dom/Document.cpp (132420 => 132421)


--- trunk/Source/WebCore/dom/Document.cpp	2012-10-24 23:24:05 UTC (rev 132420)
+++ trunk/Source/WebCore/dom/Document.cpp	2012-10-24 23:26:58 UTC (rev 132421)
@@ -5017,6 +5017,9 @@
 
 void Document::enqueuePopstateEvent(PassRefPtr<SerializedScriptValue> stateObject)
 {
+    if (!ContextFeatures::pushStateEnabled(this))
+        return;
+
     // FIXME: https://bugs.webkit.org/show_bug.cgi?id=36202 Popstate event needs to fire asynchronously
     dispatchWindowEvent(PopStateEvent::create(stateObject, domWindow() ? domWindow()->history() : 0));
 }

Modified: trunk/Source/WebCore/page/History.idl (132420 => 132421)


--- trunk/Source/WebCore/page/History.idl	2012-10-24 23:24:05 UTC (rev 132420)
+++ trunk/Source/WebCore/page/History.idl	2012-10-24 23:26:58 UTC (rev 132421)
@@ -41,9 +41,8 @@
     [DoNotCheckSecurity, CallWith=ScriptExecutionContext] void forward();
     [DoNotCheckSecurity, CallWith=ScriptExecutionContext] void go(in [Optional=DefaultIsUndefined] long distance);
 
-    [Custom] void pushState(in any data, in DOMString title, in [Optional] DOMString url)
+    [Custom, V8EnabledPerContext=pushState] void pushState(in any data, in DOMString title, in [Optional] DOMString url)
         raises(DOMException);
-    [Custom] void replaceState(in any data, in DOMString title, in [Optional] DOMString url)
+    [Custom, V8EnabledPerContext=pushState] void replaceState(in any data, in DOMString title, in [Optional] DOMString url)
         raises(DOMException);
 };
-

Modified: trunk/Source/WebKit/chromium/ChangeLog (132420 => 132421)


--- trunk/Source/WebKit/chromium/ChangeLog	2012-10-24 23:24:05 UTC (rev 132420)
+++ trunk/Source/WebKit/chromium/ChangeLog	2012-10-24 23:26:58 UTC (rev 132421)
@@ -1,3 +1,18 @@
+2012-10-24  Mihai Parparita  <mih...@chromium.org>
+
+        [Chromium] Allow pushState and related history APIs to be disabled per context
+        https://bugs.webkit.org/show_bug.cgi?id=99780
+
+        Reviewed by Adam Barth.
+
+        Add pushState context feature.
+
+        * public/WebPermissionClient.h:
+        (WebPermissionClient):
+        (WebKit::WebPermissionClient::allowPushState):
+        * src/ContextFeaturesClientImpl.cpp:
+        (WebKit::ContextFeaturesClientImpl::askIfIsEnabled):
+
 2012-10-24  Mark Pilgrim  <pilg...@chromium.org>
 
         [Chromium] Remove screen-related functions from PlatformSupport

Modified: trunk/Source/WebKit/chromium/public/WebPermissionClient.h (132420 => 132421)


--- trunk/Source/WebKit/chromium/public/WebPermissionClient.h	2012-10-24 23:24:05 UTC (rev 132420)
+++ trunk/Source/WebKit/chromium/public/WebPermissionClient.h	2012-10-24 23:26:58 UTC (rev 132421)
@@ -101,6 +101,9 @@
     // but it's been named for consistency with the rest of the interface.
     virtual bool allowMutationEvents(const WebDocument&, bool defaultValue) { return defaultValue; }
 
+    // Controls whether pushState and related History APIs are enabled for this frame.
+    virtual bool allowPushState(const WebDocument&) { return true; }
+
     // Notifies the client that the frame would have instantiated a plug-in if plug-ins were enabled.
     virtual void didNotAllowPlugins(WebFrame*) { }
 

Modified: trunk/Source/WebKit/chromium/src/ContextFeaturesClientImpl.cpp (132420 => 132421)


--- trunk/Source/WebKit/chromium/src/ContextFeaturesClientImpl.cpp	2012-10-24 23:24:05 UTC (rev 132420)
+++ trunk/Source/WebKit/chromium/src/ContextFeaturesClientImpl.cpp	2012-10-24 23:26:58 UTC (rev 132421)
@@ -146,6 +146,8 @@
         return m_client->allowHTMLNotifications(WebDocument(document));
     case ContextFeatures::MutationEvents:
         return m_client->allowMutationEvents(WebDocument(document), defaultValue);
+    case ContextFeatures::PushState:
+        return m_client->allowPushState(WebDocument(document));
     default:
         return defaultValue;
     }
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to