2010-12-23 Anders Carlsson <andersca@apple.com>
authorandersca@apple.com <andersca@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 23 Dec 2010 18:16:02 +0000 (18:16 +0000)
committerandersca@apple.com <andersca@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 23 Dec 2010 18:16:02 +0000 (18:16 +0000)
        Reviewed by John Sullivan.

        Nothing happens clicking "launch live player" on live.cnn.com
        https://bugs.webkit.org/show_bug.cgi?id=51540
        <rdar://problem/8791086>

        Implement NPN_PushPopupsEnabledState/NPN_PopPopupsEnabledState.

        * WebProcess/Plugins/Netscape/NetscapeBrowserFuncs.cpp:
        (WebKit::NPN_PushPopupsEnabledState):
        Call NetscapePlugin::pushPopupsEnabledState.

        (WebKit::NPN_PopPopupsEnabledState):
        Call NetscapePlugin::popPopupsEnabledState.

        * WebProcess/Plugins/Netscape/NetscapePlugin.cpp:
        (WebKit::NetscapePlugin::pushPopupsEnabledState):
        Append the boolean to the vector.

        (WebKit::NetscapePlugin::popPopupsEnabledState):
        Remove the last boolean from the vector.

        (WebKit::NetscapePlugin::allowPopups):
        Return the last boolean from the vector.

        * WebProcess/Plugins/Netscape/NetscapePlugin.h:
        * WebProcess/Plugins/PluginView.cpp:
        (WebKit::PluginView::performJavaScriptURLRequest):
        Update the "allowPopupsFromPlugin" state.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@74564 268f45cc-cd09-0410-ab3c-d52691b4dbfc

WebKit2/ChangeLog
WebKit2/WebProcess/Plugins/Netscape/NetscapeBrowserFuncs.cpp
WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.cpp
WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.h
WebKit2/WebProcess/Plugins/PluginView.cpp

index 072c4b608d53b4fc967457d179aefe99fea562ca..3db872384ea7e95b6b166bdcd80cea77d96d4df3 100644 (file)
@@ -1,3 +1,35 @@
+2010-12-23  Anders Carlsson  <andersca@apple.com>
+
+        Reviewed by John Sullivan.
+
+        Nothing happens clicking "launch live player" on live.cnn.com
+        https://bugs.webkit.org/show_bug.cgi?id=51540
+        <rdar://problem/8791086>
+
+        Implement NPN_PushPopupsEnabledState/NPN_PopPopupsEnabledState.
+
+        * WebProcess/Plugins/Netscape/NetscapeBrowserFuncs.cpp:
+        (WebKit::NPN_PushPopupsEnabledState):
+        Call NetscapePlugin::pushPopupsEnabledState.
+
+        (WebKit::NPN_PopPopupsEnabledState):
+        Call NetscapePlugin::popPopupsEnabledState.
+
+        * WebProcess/Plugins/Netscape/NetscapePlugin.cpp:
+        (WebKit::NetscapePlugin::pushPopupsEnabledState):
+        Append the boolean to the vector.
+
+        (WebKit::NetscapePlugin::popPopupsEnabledState):
+        Remove the last boolean from the vector.
+
+        (WebKit::NetscapePlugin::allowPopups):
+        Return the last boolean from the vector.
+
+        * WebProcess/Plugins/Netscape/NetscapePlugin.h:
+        * WebProcess/Plugins/PluginView.cpp:
+        (WebKit::PluginView::performJavaScriptURLRequest):
+        Update the "allowPopupsFromPlugin" state.
+
 2010-12-22  Anders Carlsson  <andersca@apple.com>
 
         Reviewed by Sam Weinig.
index e84959824856edf20f62596329d4b2dd77f1a0f7..566d48d3fc8ce4f1851ac05ecb54536eb4e77f0c 100644 (file)
@@ -648,14 +648,16 @@ static void NPN_SetException(NPObject*, const NPUTF8* message)
     NetscapePlugin::setException(message);
 }
 
-static void NPN_PushPopupsEnabledState(NPP instance, NPBool enabled)
+static void NPN_PushPopupsEnabledState(NPP npp, NPBool enabled)
 {
-    notImplemented();
+    RefPtr<NetscapePlugin> plugin = NetscapePlugin::fromNPP(npp);
+    plugin->pushPopupsEnabledState(enabled);
 }
     
-static void NPN_PopPopupsEnabledState(NPP instance)
+static void NPN_PopPopupsEnabledState(NPP npp)
 {
-    notImplemented();
+    RefPtr<NetscapePlugin> plugin = NetscapePlugin::fromNPP(npp);
+    plugin->popPopupsEnabledState();
 }
     
 static bool NPN_Enumerate(NPP, NPObject* npObject, NPIdentifier** identifiers, uint32_t* identifierCount)
index 93095be95da958d45f2956eba1bc3d847121559e..0beade26a5e55dddf9326d3e9acf3e69928419be 100644 (file)
@@ -249,6 +249,18 @@ bool NetscapePlugin::isAcceleratedCompositingEnabled()
 #endif
 }
 
+void NetscapePlugin::pushPopupsEnabledState(bool state)
+{
+    m_popupEnabledStates.append(state);
+}
+void NetscapePlugin::popPopupsEnabledState()
+{
+    ASSERT(!m_popupEnabledStates.isEmpty());
+
+    m_popupEnabledStates.removeLast();
+}
+
 String NetscapePlugin::proxiesForURL(const String& urlString)
 {
     return m_pluginController->proxiesForURL(urlString);
@@ -371,7 +383,14 @@ void NetscapePlugin::stopAllStreams()
 
 bool NetscapePlugin::allowPopups() const
 {
-    // FIXME: Handle popups.
+    if (m_pluginModule->pluginFuncs().version >= NPVERS_HAS_POPUPS_ENABLED_STATE) {
+        if (!m_popupEnabledStates.isEmpty())
+            return m_popupEnabledStates.last();
+    }
+
+    // FIXME: Check if the current event is a user gesture.
+    // Really old versions of Flash required this for popups to work, but all newer versions
+    // support NPN_PushPopupEnabledState/NPN_PopPopupEnabledState.
     return false;
 }
 
index 683a3d1e1149af57fc6d9b232ed871037575e5b0..fb5d37e3f4e99e46c2a92b150e4a05fb18d0cf92 100644 (file)
@@ -87,6 +87,9 @@ public:
 
     bool isAcceleratedCompositingEnabled();
 
+    void pushPopupsEnabledState(bool enabled);
+    void popPopupsEnabledState();
+
     String proxiesForURL(const String& urlString);
     String cookiesForURL(const String& urlString);
     void setCookiesForURL(const String& urlString, const String& cookieString);
@@ -195,6 +198,7 @@ private:
     bool m_inNPPNew;
     bool m_loadManually;
     RefPtr<NetscapePluginStream> m_manualStream;
+    Vector<bool, 8> m_popupEnabledStates;
 
 #if PLATFORM(MAC)
     NPDrawingModel m_drawingModel;
index 88d315b80ba6fabd8bda4a64e7d4f53fc799209b..00271c13624fe1c8f2a89c31d114d933a90f3aba 100644 (file)
@@ -703,9 +703,14 @@ void PluginView::performJavaScriptURLRequest(URLRequest* request)
     // Evaluate the JavaScript code. Note that running JavaScript here could cause the plug-in to be destroyed, so we
     // grab references to the plug-in here.
     RefPtr<Plugin> plugin = m_plugin;
+
+    bool oldAllowPopups = frame->script()->allowPopupsFromPlugin();
+    frame->script()->setAllowPopupsFromPlugin(request->allowPopups());
     
     ScriptValue result = m_pluginElement->document()->frame()->script()->executeScript(jsString);
 
+    frame->script()->setAllowPopupsFromPlugin(oldAllowPopups);
+
     // Check if evaluating the JavaScript destroyed the plug-in.
     if (!plugin->controller())
         return;
@@ -888,7 +893,7 @@ NPObject* PluginView::pluginElementNPObject()
     return m_npRuntimeObjectMap.getOrCreateNPObject(object);
 }
 
-bool PluginView::evaluate(NPObject* npObject, const String&scriptString, NPVariant* result, bool allowPopups)
+bool PluginView::evaluate(NPObject* npObject, const String& scriptString, NPVariant* result, bool allowPopups)
 {
     if (!frame())
         return false;