Changeset 89001 in webkit


Ignore:
Timestamp:
Jun 15, 2011 9:10:36 PM (13 years ago)
Author:
abarth@webkit.org
Message:

2011-06-15 Adam Barth <abarth@webkit.org>

Reviewed by Eric Seidel.

Remove ScriptController::setAllowPopupsFromPlugin
https://bugs.webkit.org/show_bug.cgi?id=62706

  • Plugins/Hosted/NetscapePluginInstanceProxy.mm: (WebKit::NetscapePluginInstanceProxy::evaluate):
  • Plugins/WebNetscapePluginView.mm: (-[WebNetscapePluginView sendEvent:isDrawRect:]):

2011-06-15 Adam Barth <abarth@webkit.org>

Reviewed by Eric Seidel.

Remove ScriptController::setAllowPopupsFromPlugin
https://bugs.webkit.org/show_bug.cgi?id=62706

This API is just a poor man's UserGestureIndicator. We should use the
real deal.

  • bindings/js/ScriptController.cpp: (WebCore::ScriptController::ScriptController): (WebCore::ScriptController::processingUserGesture):
  • bindings/js/ScriptController.h:
  • bindings/v8/NPV8Object.cpp: (_NPN_EvaluateHelper):
  • bindings/v8/ScriptController.cpp: (WebCore::ScriptController::ScriptController): (WebCore::ScriptController::processingUserGesture):
  • bindings/v8/ScriptController.h:

2011-06-15 Adam Barth <abarth@webkit.org>

Reviewed by Eric Seidel.

Remove ScriptController::setAllowPopupsFromPlugin
https://bugs.webkit.org/show_bug.cgi?id=62706

  • WebProcess/Plugins/PluginView.cpp: (WebKit::PluginView::performJavaScriptURLRequest): (WebKit::PluginView::evaluate):
Location:
trunk/Source
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r88998 r89001  
     12011-06-15  Adam Barth  <abarth@webkit.org>
     2
     3        Reviewed by Eric Seidel.
     4
     5        Remove ScriptController::setAllowPopupsFromPlugin
     6        https://bugs.webkit.org/show_bug.cgi?id=62706
     7
     8        This API is just a poor man's UserGestureIndicator.  We should use the
     9        real deal.
     10
     11        * bindings/js/ScriptController.cpp:
     12        (WebCore::ScriptController::ScriptController):
     13        (WebCore::ScriptController::processingUserGesture):
     14        * bindings/js/ScriptController.h:
     15        * bindings/v8/NPV8Object.cpp:
     16        (_NPN_EvaluateHelper):
     17        * bindings/v8/ScriptController.cpp:
     18        (WebCore::ScriptController::ScriptController):
     19        (WebCore::ScriptController::processingUserGesture):
     20        * bindings/v8/ScriptController.h:
     21
    1222011-06-15  Adam Barth  <abarth@webkit.org>
    223
  • trunk/Source/WebCore/bindings/js/ScriptController.cpp

    r88998 r89001  
    6666    , m_processingTimerCallback(false)
    6767    , m_paused(false)
    68     , m_allowPopupsFromPlugin(false)
    6968#if ENABLE(NETSCAPE_PLUGIN_API)
    7069    , m_windowScriptNPObject(0)
     
    253252        return UserGestureIndicator::getUserGestureState() != DefinitelyNotProcessingUserGesture;
    254253
    255     // FIXME: We check the plugin popup flag and javascript anchor navigation
    256     // from the dynamic frame becuase they should only be initiated on the
    257     // dynamic frame in which execution began if they do happen.
    258     ScriptController* scriptController = frame->script();
    259     ASSERT(scriptController);
    260     if (scriptController->allowPopupsFromPlugin() || scriptController->isJavaScriptAnchorNavigation())
     254    // FIXME: Remove the isJavaScriptAnchorNavigation check once https://bugs.webkit.org/show_bug.cgi?id=62702 is fixed.
     255    if (frame->script()->isJavaScriptAnchorNavigation())
    261256        return true;
    262257
    263258    // If a DOM event is being processed, check that it was initiated by the user
    264259    // and that it is in the whitelist of event types allowed to generate pop-ups.
    265     if (JSDOMWindowShell* shell = scriptController->existingWindowShell(currentWorld(exec)))
     260    if (JSDOMWindowShell* shell = frame->script()->existingWindowShell(currentWorld(exec)))
    266261        if (Event* event = shell->window()->currentEvent())
    267262            return event->fromUserGesture();
  • trunk/Source/WebCore/bindings/js/ScriptController.h

    r88731 r89001  
    122122    bool isPaused() const { return m_paused; }
    123123
    124     void setAllowPopupsFromPlugin(bool allowPopupsFromPlugin) { m_allowPopupsFromPlugin = allowPopupsFromPlugin; }
    125     bool allowPopupsFromPlugin() const { return m_allowPopupsFromPlugin; }
    126    
    127124    const String* sourceURL() const { return m_sourceURL; } // 0 if we are not evaluating any script
    128125
     
    183180    bool m_processingTimerCallback;
    184181    bool m_paused;
    185     bool m_allowPopupsFromPlugin;
    186182
    187183    // The root object used for objects bound outside the context of a plugin, such
  • trunk/Source/WebCore/bindings/v8/NPV8Object.cpp

    r88679 r89001  
    3535#include "PlatformString.h"
    3636#include "ScriptSourceCode.h"
     37#include "UserGestureIndicator.h"
    3738#include "V8GCController.h"
    3839#include "V8Helpers.h"
     
    303304    ExceptionCatcher exceptionCatcher;
    304305
     306    // FIXME: Is this branch still needed after switching to using UserGestureIndicator?
    305307    String filename;
    306308    if (!popupsAllowed)
    307309        filename = "npscript";
    308310
    309     // Set popupsAllowed flag to the current execution frame, so WebKit can get
    310     // right gesture status for popups initiated from plugins.
    311     Frame* frame = proxy->frame();
    312     ASSERT(frame);
    313     bool oldAllowPopups = frame->script()->allowPopupsFromPlugin();
    314     frame->script()->setAllowPopupsFromPlugin(popupsAllowed);
    315 
    316311    String script = String::fromUTF8(npScript->UTF8Characters, npScript->UTF8Length);
     312
     313    UserGestureIndicator gestureIndicator(popupsAllowed ? DefinitelyProcessingUserGesture : PossiblyProcessingUserGesture);
    317314    v8::Local<v8::Value> v8result = proxy->evaluate(ScriptSourceCode(script, KURL(ParsedURLString, filename)), 0);
    318     // Restore the old flag.
    319     frame->script()->setAllowPopupsFromPlugin(oldAllowPopups);
    320315
    321316    if (v8result.IsEmpty())
  • trunk/Source/WebCore/bindings/v8/ScriptController.cpp

    r88731 r89001  
    112112    , m_processingTimerCallback(false)
    113113    , m_paused(false)
    114     , m_allowPopupsFromPlugin(false)
    115114    , m_proxy(adoptPtr(new V8Proxy(frame)))
    116115#if ENABLE(NETSCAPE_PLUGIN_API)
     
    156155bool ScriptController::processingUserGesture()
    157156{
    158     Frame* activeFrame = V8Proxy::retrieveFrameForEnteredContext();
    159     // No script is running, so it is user-initiated unless the gesture stack
    160     // explicitly says it is not.
    161     if (!activeFrame)
     157    Frame* firstFrame = V8Proxy::retrieveFrameForEnteredContext();
     158    if (!firstFrame)
    162159        return UserGestureIndicator::getUserGestureState() != DefinitelyNotProcessingUserGesture;
    163160
    164     V8Proxy* activeProxy = activeFrame->script()->proxy();
    165 
    166     v8::HandleScope handleScope;
    167     v8::Handle<v8::Context> v8Context = V8Proxy::mainWorldContext(activeFrame);
    168     // FIXME: find all cases context can be empty:
    169     //  1) JS is disabled;
    170     //  2) page is NULL;
     161    v8::HandleScope handleScope;
     162    v8::Handle<v8::Context> v8Context = V8Proxy::mainWorldContext(firstFrame);
    171163    if (v8Context.IsEmpty())
    172164        return true;
    173 
    174165    v8::Context::Scope scope(v8Context);
    175 
    176166    v8::Handle<v8::Object> global = v8Context->Global();
    177167    v8::Handle<v8::String> eventSymbol = V8HiddenPropertyName::event();
    178168    v8::Handle<v8::Value> jsEvent = global->GetHiddenValue(eventSymbol);
    179169    Event* event = V8DOMWrapper::isValidDOMObject(jsEvent) ? V8Event::toNative(v8::Handle<v8::Object>::Cast(jsEvent)) : 0;
    180 
    181     // Based on code from JSC's ScriptController::processingUserGesture.
    182     // Note: This is more liberal than Firefox's implementation.
    183     if (event) {
    184         // Event::fromUserGesture will return false when UserGestureIndicator::processingUserGesture() returns false.
     170    if (event)
    185171        return event->fromUserGesture();
    186     }
    187     // FIXME: We check the javascript anchor navigation from the last entered
    188     // frame becuase it should only be initiated on the last entered frame in
    189     // which execution began if it does happen.   
    190     const String* sourceURL = activeFrame->script()->sourceURL();
    191     if (sourceURL && sourceURL->isNull() && !activeProxy->timerCallback()) {
    192         // This is the <a href="javascript:window.open('...')> case -> we let it through.
     172
     173    // FIXME: Remove this check once https://bugs.webkit.org/show_bug.cgi?id=62702 is fixed.
     174    const String* sourceURL = firstFrame->script()->sourceURL();
     175    if (sourceURL && sourceURL->isNull() && !firstFrame->script()->proxy()->timerCallback())
    193176        return true;
    194     }
    195     if (activeFrame->script()->allowPopupsFromPlugin())
    196         return true;
    197     // This is the <script>window.open(...)</script> case or a timer callback -> block it.
    198     // Based on JSC version, use returned value of UserGestureIndicator::processingUserGesture for all other situations.
     177
    199178    return UserGestureIndicator::processingUserGesture();
    200179}
  • trunk/Source/WebCore/bindings/v8/ScriptController.h

    r88731 r89001  
    190190    static void getAllWorlds(Vector<DOMWrapperWorld*>& worlds);
    191191
    192     void setAllowPopupsFromPlugin(bool allowPopupsFromPlugin) { m_allowPopupsFromPlugin = allowPopupsFromPlugin; }
    193     bool allowPopupsFromPlugin() const { return m_allowPopupsFromPlugin; }
    194 
    195192private:
    196193    Frame* m_frame;
     
    201198    bool m_processingTimerCallback;
    202199    bool m_paused;
    203     bool m_allowPopupsFromPlugin;
    204200
    205201    OwnPtr<V8Proxy> m_proxy;
  • trunk/Source/WebKit/mac/ChangeLog

    r88968 r89001  
     12011-06-15  Adam Barth  <abarth@webkit.org>
     2
     3        Reviewed by Eric Seidel.
     4
     5        Remove ScriptController::setAllowPopupsFromPlugin
     6        https://bugs.webkit.org/show_bug.cgi?id=62706
     7
     8        * Plugins/Hosted/NetscapePluginInstanceProxy.mm:
     9        (WebKit::NetscapePluginInstanceProxy::evaluate):
     10        * Plugins/WebNetscapePluginView.mm:
     11        (-[WebNetscapePluginView sendEvent:isDrawRect:]):
     12
    1132011-06-15  David Kilzer  <ddkilzer@apple.com>
    214
  • trunk/Source/WebKit/mac/Plugins/Hosted/NetscapePluginInstanceProxy.mm

    r83385 r89001  
    5656#import <WebCore/ScriptValue.h>
    5757#import <WebCore/StringSourceProvider.h>
     58#import <WebCore/UserGestureIndicator.h>
    5859#import <WebCore/npruntime_impl.h>
    5960#import <WebCore/runtime_object.h>
     
    870871    ExecState* exec = globalObject->globalExec();
    871872
    872     bool oldAllowPopups = frame->script()->allowPopupsFromPlugin();
    873     frame->script()->setAllowPopupsFromPlugin(allowPopups);
    874    
    875873    globalObject->globalData().timeoutChecker.start();
     874
     875    UserGestureIndicator gestureIndicator(allowPopups ? DefinitelyProcessingUserGesture : PossiblyProcessingUserGesture);
    876876    Completion completion = JSC::evaluate(exec, globalObject->globalScopeChain(), makeSource(script));
     877
    877878    globalObject->globalData().timeoutChecker.stop();
    878879    ComplType type = completion.complType();
    879880
    880     frame->script()->setAllowPopupsFromPlugin(oldAllowPopups);
    881    
    882881    JSValue result;
    883882    if (type == Normal)
  • trunk/Source/WebKit/mac/Plugins/WebNetscapePluginView.mm

    r85036 r89001  
    7171#import <WebCore/SecurityOrigin.h>
    7272#import <WebCore/SoftLinking.h>
     73#import <WebCore/UserGestureIndicator.h>
    7374#import <WebCore/WebCoreObjCExtras.h>
    7475#import <WebCore/WebCoreURLResponse.h>
     
    666667    // Set the pluginAllowPopup flag.
    667668    ASSERT(_eventHandler);
    668     bool oldAllowPopups = frame->script()->allowPopupsFromPlugin();
    669     frame->script()->setAllowPopupsFromPlugin(_eventHandler->currentEventIsUserGesture());   
    670669    {
    671670        JSC::JSLock::DropAllLocks dropAllLocks(JSC::SilenceAssertionsOnly);
     671        UserGestureIndicator gestureIndicator(_eventHandler->currentEventIsUserGesture() ? DefinitelyProcessingUserGesture : PossiblyProcessingUserGesture);
    672672        acceptedEvent = [_pluginPackage.get() pluginFuncs]->event(plugin, event);
    673673    }
    674     // Restore the old pluginAllowPopup flag.
    675     frame->script()->setAllowPopupsFromPlugin(oldAllowPopups);     
    676674    [self didCallPlugInFunction];
    677        
     675
    678676    if (portState) {
    679677        if ([self currentWindow])
  • trunk/Source/WebKit2/ChangeLog

    r88991 r89001  
     12011-06-15  Adam Barth  <abarth@webkit.org>
     2
     3        Reviewed by Eric Seidel.
     4
     5        Remove ScriptController::setAllowPopupsFromPlugin
     6        https://bugs.webkit.org/show_bug.cgi?id=62706
     7
     8        * WebProcess/Plugins/PluginView.cpp:
     9        (WebKit::PluginView::performJavaScriptURLRequest):
     10        (WebKit::PluginView::evaluate):
     11
    1122011-06-15  Ryuan Choi  <ryuan.choi@samsung.com>
    213
  • trunk/Source/WebKit2/WebProcess/Plugins/PluginView.cpp

    r87806 r89001  
    5959#include <WebCore/ScrollView.h>
    6060#include <WebCore/Settings.h>
     61#include <WebCore/UserGestureIndicator.h>
    6162
    6263using namespace JSC;
     
    779780    // grab references to the plug-in here.
    780781    RefPtr<Plugin> plugin = m_plugin;
    781 
    782     bool oldAllowPopups = frame->script()->allowPopupsFromPlugin();
    783     frame->script()->setAllowPopupsFromPlugin(request->allowPopups());
    784    
    785     ScriptValue result = frame->script()->executeScript(jsString);
    786 
    787     frame->script()->setAllowPopupsFromPlugin(oldAllowPopups);
     782    ScriptValue result = frame->script()->executeScript(jsString, request->allowPopups());
    788783
    789784    // Check if evaluating the JavaScript destroyed the plug-in.
     
    980975bool PluginView::evaluate(NPObject* npObject, const String& scriptString, NPVariant* result, bool allowPopups)
    981976{
    982     RefPtr<Frame> frame = m_pluginElement->document()->frame();
    983     if (!frame)
     977    // FIXME: Is this check necessary?
     978    if (!m_pluginElement->document()->frame())
    984979        return false;
    985 
    986     bool oldAllowPopups = frame->script()->allowPopupsFromPlugin();
    987     frame->script()->setAllowPopupsFromPlugin(allowPopups);
    988980
    989981    // Calling evaluate will run JavaScript that can potentially remove the plug-in element, so we need to
     
    991983    NPRuntimeObjectMap::PluginProtector pluginProtector(&m_npRuntimeObjectMap);
    992984
    993     bool returnValue = m_npRuntimeObjectMap.evaluate(npObject, scriptString, result);
    994 
    995     frame->script()->setAllowPopupsFromPlugin(oldAllowPopups);
    996 
    997     return returnValue;
     985    UserGestureIndicator gestureIndicator(allowPopups ? DefinitelyProcessingUserGesture : PossiblyProcessingUserGesture);
     986    return m_npRuntimeObjectMap.evaluate(npObject, scriptString, result);
    998987}
    999988
Note: See TracChangeset for help on using the changeset viewer.