Changeset 55433 in webkit


Ignore:
Timestamp:
Mar 2, 2010 3:13:57 PM (14 years ago)
Author:
mrowe@apple.com
Message:

Bug 35576: WebKit should tell plug-in instances when private browsing state changes
<http://webkit.org/b/35576>

Reviewed by Darin Adler.

WebCore:

Notify plug-in instances when the private browsing state changes to match the behavior of the
Mac plug-in code.

  • page/Page.cpp:

(WebCore::Page::privateBrowsingStateChanged): Walk the frame tree and notify each PluginView that
the private browsing state has changed.

  • page/Page.h:
  • page/Settings.cpp:

(WebCore::Settings::setPrivateBrowsingEnabled): Notify the page that the private browsing state
has changed.

  • plugins/PluginView.cpp:

(WebCore::PluginView::privateBrowsingStateChanged): Notify the plug-in instance of the new private
browsing state.

  • plugins/PluginView.h:

WebKitTools:

TestNetscapePlugin is another bit of plug-in code where copy-paste was heavily used
when porting. Update the Windows and UNIX implementations of NPP_New and NPP_SetValue
to provide the expected behavior related to NPNVprivateModeBool. Hopefully this code
duplication can be cleaned up in the future.

  • DumpRenderTree/unix/TestNetscapePlugin/TestNetscapePlugin.cpp:

(webkit_test_plugin_new_instance):
(webkit_test_plugin_set_value):

  • DumpRenderTree/win/TestNetscapePlugin/main.cpp:

(NPP_New):
(NPP_SetValue):

LayoutTests:

  • platform/win/Skipped: Remove plugins/private-browsing-mode.html now that it passes.
Location:
trunk
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r55432 r55433  
     12010-03-02  Mark Rowe  <mrowe@apple.com>
     2
     3        Reviewed by Darin Adler.
     4
     5        Bug 35576: WebKit should tell plug-in instances when private browsing state changes
     6        <http://webkit.org/b/35576>
     7
     8        * platform/win/Skipped: Remove plugins/private-browsing-mode.html now that it passes.
     9
    1102010-03-02  Mark Rowe  <mrowe@apple.com>
    211
  • trunk/LayoutTests/platform/win/Skipped

    r55432 r55433  
    672672fast/dom/Window/slow-unload-handler-only-frame-is-stopped.html
    673673
    674 # <https://bugs.webkit.org/show_bug.cgi?id=30348>
    675 plugins/private-browsing-mode.html
    676 
    677674# Skip these two failures I introduced this morning while I explore them.
    678675http/tests/globalhistory/history-delegate-basic-visited-links.html
  • trunk/WebCore/ChangeLog

    r55432 r55433  
     12010-03-02  Mark Rowe  <mrowe@apple.com>
     2
     3        Reviewed by Darin Adler.
     4
     5        Bug 35576: WebKit should tell plug-in instances when private browsing state changes
     6        <http://webkit.org/b/35576>
     7
     8        Notify plug-in instances when the private browsing state changes to match the behavior of the
     9        Mac plug-in code.
     10
     11        * page/Page.cpp:
     12        (WebCore::Page::privateBrowsingStateChanged): Walk the frame tree and notify each PluginView that
     13        the private browsing state has changed.
     14        * page/Page.h:
     15        * page/Settings.cpp:
     16        (WebCore::Settings::setPrivateBrowsingEnabled): Notify the page that the private browsing state
     17        has changed.
     18        * plugins/PluginView.cpp:
     19        (WebCore::PluginView::privateBrowsingStateChanged): Notify the plug-in instance of the new private
     20        browsing state.
     21        * plugins/PluginView.h:
     22
    1232010-03-02  Mark Rowe  <mrowe@apple.com>
    224
  • trunk/WebCore/page/Page.cpp

    r55375 r55433  
    5353#include "PluginData.h"
    5454#include "PluginHalter.h"
     55#include "PluginView.h"
    5556#include "ProgressTracker.h"
    5657#include "RenderWidget.h"
     
    776777#endif
    777778
     779void Page::privateBrowsingStateChanged()
     780{
     781    bool privateBrowsingEnabled = m_settings->privateBrowsingEnabled();
     782
     783    // Collect the PluginViews in to a vector to ensure that action the plug-in takes
     784    // from below privateBrowsingStateChanged does not affect their lifetime.
     785
     786    Vector<RefPtr<PluginView>, 32> pluginViews;
     787    for (Frame* frame = mainFrame(); frame; frame = frame->tree()->traverseNext()) {
     788        FrameView* view = frame->view();
     789        if (!view)
     790            return;
     791
     792        const HashSet<RefPtr<Widget> >* children = view->children();
     793        ASSERT(children);
     794
     795        HashSet<RefPtr<Widget> >::const_iterator end = children->end();
     796        for (HashSet<RefPtr<Widget> >::const_iterator it = children->begin(); it != end; ++it) {
     797            Widget* widget = (*it).get();
     798            if (!widget->isPluginView())
     799                continue;
     800            pluginViews.append(static_cast<PluginView*>(widget));
     801        }
     802    }
     803
     804    for (size_t i = 0; i < pluginViews.size(); i++)
     805        pluginViews[i]->privateBrowsingStateChanged(privateBrowsingEnabled);
     806}
     807
    778808void Page::pluginAllowedRunTimeChanged()
    779809{
  • trunk/WebCore/page/Page.h

    r54849 r55433  
    198198        const String& userStyleSheet() const;
    199199
     200        void privateBrowsingStateChanged();
     201
    200202        void didStartPlugin(HaltablePlugin*);
    201203        void didStopPlugin(HaltablePlugin*);
  • trunk/WebCore/page/Settings.cpp

    r55387 r55433  
    278278void Settings::setPrivateBrowsingEnabled(bool privateBrowsingEnabled)
    279279{
     280    if (m_privateBrowsingEnabled == privateBrowsingEnabled)
     281        return;
     282
    280283    m_privateBrowsingEnabled = privateBrowsingEnabled;
     284    m_page->privateBrowsingStateChanged();
    281285}
    282286
  • trunk/WebCore/plugins/PluginView.cpp

    r55432 r55433  
    13741374}
    13751375
     1376void PluginView::privateBrowsingStateChanged(bool privateBrowsingEnabled)
     1377{
     1378    NPP_SetValueProcPtr setValue = m_plugin->pluginFuncs()->setvalue;
     1379    if (!setValue)
     1380        return;
     1381
     1382    PluginView::setCurrentPluginView(this);
     1383    JSC::JSLock::DropAllLocks dropAllLocks(JSC::SilenceAssertionsOnly);
     1384    setCallingPlugin(true);
     1385    NPBool value = privateBrowsingEnabled;
     1386    setValue(m_instance, NPNVprivateModeBool, &value);
     1387    setCallingPlugin(false);
     1388    PluginView::setCurrentPluginView(0);
     1389}
     1390
    13761391} // namespace WebCore
  • trunk/WebCore/plugins/PluginView.h

    r55432 r55433  
    157157        void setJavaScriptPaused(bool);
    158158
     159        void privateBrowsingStateChanged(bool);
     160
    159161        void disconnectStream(PluginStream*);
    160162        void streamDidFinishLoading(PluginStream* stream) { disconnectStream(stream); }
  • trunk/WebKitTools/ChangeLog

    r55415 r55433  
     12010-03-02  Mark Rowe  <mrowe@apple.com>
     2
     3        Reviewed by Darin Adler.
     4
     5        Bug 35576: WebKit should tell plug-in instances when private browsing state changes
     6        <http://webkit.org/b/35576>
     7
     8        TestNetscapePlugin is another bit of plug-in code where copy-paste was heavily used
     9        when porting.  Update the Windows and UNIX implementations of NPP_New and NPP_SetValue
     10        to provide the expected behavior related to NPNVprivateModeBool.  Hopefully this code
     11        duplication can be cleaned up in the future.
     12
     13        * DumpRenderTree/unix/TestNetscapePlugin/TestNetscapePlugin.cpp:
     14        (webkit_test_plugin_new_instance):
     15        (webkit_test_plugin_set_value):
     16        * DumpRenderTree/win/TestNetscapePlugin/main.cpp:
     17        (NPP_New):
     18        (NPP_SetValue):
     19
    1202010-03-02  Gustavo Noronha Silva  <gustavo.noronha@collabora.co.uk>
    221
  • trunk/WebKitTools/DumpRenderTree/unix/TestNetscapePlugin/TestNetscapePlugin.cpp

    r51044 r55433  
    5959    if (browser->version >= 14) {
    6060        PluginObject* obj = (PluginObject*)browser->createobject(instance, getPluginClass());
     61        instance->pdata = obj;
    6162
    6263        for (int i = 0; i < argc; i++) {
     
    8788                obj->testWindowOpen = TRUE;
    8889        }
    89         instance->pdata = obj;
     90
     91        browser->getvalue(instance, NPNVprivateModeBool, (void *)&obj->cachedPrivateBrowsingMode);
    9092    }
    9193
     
    283285
    284286static NPError
    285 webkit_test_plugin_set_value(NPP /*instance*/, NPNVariable /*variable*/, void* /*value*/)
    286 {
    287     return NPERR_NO_ERROR;
     287webkit_test_plugin_set_value(NPP instance, NPNVariable variable, void* value)
     288{
     289    PluginObject* obj = static_cast<PluginObject*>(instance->pdata);
     290
     291    switch (variable) {
     292        case NPNVprivateModeBool:
     293            obj->cachedPrivateBrowsingMode = *(NPBool*)value;
     294            return NPERR_NO_ERROR;
     295        default:
     296            return NPERR_GENERIC_ERROR;
     297    }
    288298}
    289299
  • trunk/WebKitTools/DumpRenderTree/win/TestNetscapePlugin/main.cpp

    r54614 r55433  
    9090    if (browser->version >= 14) {
    9191        PluginObject* obj = (PluginObject*)browser->createobject(instance, getPluginClass());
    92        
     92        instance->pdata = obj;
     93
    9394        for (int16 i = 0; i < argc; i++) {
    9495            if (_stricmp(argn[i], "onstreamload") == 0 && !obj->onStreamLoad)
     
    109110                obj->testWindowOpen = TRUE;
    110111        }
    111        
    112         instance->pdata = obj;
     112
     113        browser->getvalue(instance, NPNVprivateModeBool, (void *)&obj->cachedPrivateBrowsingMode);
    113114    }
    114115
     
    239240NPError NPP_SetValue(NPP instance, NPNVariable variable, void *value)
    240241{
    241     return NPERR_GENERIC_ERROR;
    242 }
     242    PluginObject* obj = static_cast<PluginObject*>(instance->pdata);
     243
     244    switch (variable) {
     245        case NPNVprivateModeBool:
     246            obj->cachedPrivateBrowsingMode = *(NPBool*)value;
     247            return NPERR_NO_ERROR;
     248        default:
     249            return NPERR_GENERIC_ERROR;
     250    }
     251}
Note: See TracChangeset for help on using the changeset viewer.