Changeset 68962 in webkit


Ignore:
Timestamp:
Oct 1, 2010 5:45:10 PM (14 years ago)
Author:
andersca@apple.com
Message:

WebCore: Plug-ins should have access to the private browsing state.
https://bugs.webkit.org/show_bug.cgi?id=47031
<rdar://problem/8505405>

Reviewed by Sam Weinig.

  • page/Page.cpp:

(WebCore::Page::privateBrowsingStateChanged):
When iterating over all widgets, also look for PluginViewBase classes and invoke their
privateBrowsingStateChange member function.

  • plugins/PluginViewBase.h:

(WebCore::PluginViewBase::privateBrowsingStateChanged):
Add function.

WebKit2: Plug-ins should have access to the private browsing state.
https://bugs.webkit.org/show_bug.cgi?id=47031
<rdar://problem/8505405>

Reviewed by Sam Weinig.

  • WebProcess/Plugins/Netscape/NetscapeBrowserFuncs.cpp:

(WebKit::NPN_GetValue):
Handle NPNVprivateModeBool.

  • WebProcess/Plugins/Netscape/NetscapePlugin.cpp:

(WebKit::NetscapePlugin::isPrivateBrowsingEnabled):
Call PluginController::isPrivateBrowsingEnabled.

(WebKit::NetscapePlugin::NPP_SetValue):
Add NPP_SetValue wrapper.

(WebKit::NetscapePlugin::privateBrowsingStateChanged):
Call NPP_SetValue with the updated state.

  • WebProcess/Plugins/Plugin.h:

Add privateBrowsingStateChanged pure virtual member function.

  • WebProcess/Plugins/PluginController.h:

Add isPrivateBrowsingEnabled pure virtual member function.

  • WebProcess/Plugins/PluginView.cpp:

(WebKit::PluginView::privateBrowsingStateChanged):
Call Plugin::privateBrowsingStateChanged.

Location:
trunk
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r68960 r68962  
     12010-10-01  Anders Carlsson  <andersca@apple.com>
     2
     3        Reviewed by Sam Weinig.
     4
     5        Plug-ins should have access to the private browsing state.
     6        https://bugs.webkit.org/show_bug.cgi?id=47031
     7        <rdar://problem/8505405>
     8
     9        * page/Page.cpp:
     10        (WebCore::Page::privateBrowsingStateChanged):
     11        When iterating over all widgets, also look for PluginViewBase classes and invoke their
     12        privateBrowsingStateChange member function.
     13
     14        * plugins/PluginViewBase.h:
     15        (WebCore::PluginViewBase::privateBrowsingStateChanged):
     16        Add function.
     17
    1182010-10-01  Brian Weinstein  <bweinstein@apple.com>
    219
  • trunk/WebCore/page/Page.cpp

    r67122 r68962  
    5656#include "PluginHalter.h"
    5757#include "PluginView.h"
     58#include "PluginViewBase.h"
    5859#include "ProgressTracker.h"
    5960#include "RenderTheme.h"
     
    844845    // Collect the PluginViews in to a vector to ensure that action the plug-in takes
    845846    // from below privateBrowsingStateChanged does not affect their lifetime.
    846 
     847    // FIXME: When PluginViewBase and PluginView are merged we don't need this extra Vector.
    847848    Vector<RefPtr<PluginView>, 32> pluginViews;
     849    Vector<RefPtr<PluginViewBase>, 32> pluginViewBases;
    848850    for (Frame* frame = mainFrame(); frame; frame = frame->tree()->traverseNext()) {
    849851        FrameView* view = frame->view();
     
    857859        for (HashSet<RefPtr<Widget> >::const_iterator it = children->begin(); it != end; ++it) {
    858860            Widget* widget = (*it).get();
    859             if (!widget->isPluginView())
    860                 continue;
    861             pluginViews.append(static_cast<PluginView*>(widget));
     861            if (widget->isPluginView())
     862                pluginViews.append(static_cast<PluginView*>(widget));
     863            if (widget->isPluginViewBase())
     864                pluginViewBases.append(static_cast<PluginViewBase*>(widget));
    862865        }
    863866    }
    864867
    865     for (size_t i = 0; i < pluginViews.size(); i++)
     868    for (size_t i = 0; i < pluginViews.size(); ++i)
    866869        pluginViews[i]->privateBrowsingStateChanged(privateBrowsingEnabled);
     870    for (size_t i = 0; i < pluginViewBases.size(); ++i)
     871        pluginViewBases[i]->privateBrowsingStateChanged(privateBrowsingEnabled);
    867872}
    868873
  • trunk/WebCore/plugins/PluginViewBase.h

    r64365 r68962  
    4646
    4747    virtual JSC::JSObject* scriptObject(JSC::JSGlobalObject*) { return 0; }
     48    virtual void privateBrowsingStateChanged(bool) { }
    4849
    4950protected:
  • trunk/WebKit2/ChangeLog

    r68961 r68962  
     12010-10-01  Anders Carlsson  <andersca@apple.com>
     2
     3        Reviewed by Sam Weinig.
     4
     5        Plug-ins should have access to the private browsing state.
     6        https://bugs.webkit.org/show_bug.cgi?id=47031
     7        <rdar://problem/8505405>
     8   
     9        * WebProcess/Plugins/Netscape/NetscapeBrowserFuncs.cpp:
     10        (WebKit::NPN_GetValue):
     11        Handle NPNVprivateModeBool.
     12
     13        * WebProcess/Plugins/Netscape/NetscapePlugin.cpp:
     14        (WebKit::NetscapePlugin::isPrivateBrowsingEnabled):
     15        Call PluginController::isPrivateBrowsingEnabled.
     16
     17        (WebKit::NetscapePlugin::NPP_SetValue):
     18        Add NPP_SetValue wrapper.
     19
     20        (WebKit::NetscapePlugin::privateBrowsingStateChanged):
     21        Call NPP_SetValue with the updated state.
     22
     23        * WebProcess/Plugins/Plugin.h:
     24        Add privateBrowsingStateChanged pure virtual member function.
     25
     26        * WebProcess/Plugins/PluginController.h:
     27        Add isPrivateBrowsingEnabled pure virtual member function.
     28
     29        * WebProcess/Plugins/PluginView.cpp:
     30        (WebKit::PluginView::privateBrowsingStateChanged):
     31        Call Plugin::privateBrowsingStateChanged.
     32
    1332010-10-01  Sam Weinig  <sam@webkit.org>
    234
  • trunk/WebKit2/WebProcess/Plugins/Netscape/NetscapeBrowserFuncs.cpp

    r68898 r68962  
    415415            NPObject* pluginElementNPObject = plugin->pluginElementNPObject();
    416416            *(NPObject**)value = pluginElementNPObject;
     417            break;
     418        }
     419        case NPNVprivateModeBool: {
     420            RefPtr<NetscapePlugin> plugin = NetscapePlugin::fromNPP(npp);
     421
     422            *(NPBool*)value = plugin->isPrivateBrowsingEnabled();
    417423            break;
    418424        }
  • trunk/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.cpp

    r68898 r68962  
    166166}
    167167
     168bool NetscapePlugin::isPrivateBrowsingEnabled()
     169{
     170    return m_pluginController->isPrivateBrowsingEnabled();
     171}
     172
    168173NPObject* NetscapePlugin::windowScriptNPObject()
    169174{
     
    275280{
    276281    return m_pluginModule->pluginFuncs().getvalue(&m_npp, variable, value);
     282}
     283
     284NPError NetscapePlugin::NPP_SetValue(NPNVariable variable, void *value)
     285{
     286    return m_pluginModule->pluginFuncs().setvalue(&m_npp, variable, value);
    277287}
    278288
     
    543553}
    544554
     555void NetscapePlugin::privateBrowsingStateChanged(bool privateBrowsingEnabled)
     556{
     557    // From https://wiki.mozilla.org/Plugins:PrivateMode
     558    //   When the browser turns private mode on or off it will call NPP_SetValue for "NPNVprivateModeBool"
     559    //   (assigned enum value 18) with a pointer to an NPBool value on all applicable instances.
     560    //   Plugins should check the boolean value pointed to, not the pointer itself.
     561    //   The value will be true when private mode is on.
     562    NPBool value = privateBrowsingEnabled;
     563    NPP_SetValue(NPNVprivateModeBool, &value);
     564}
     565
    545566PluginController* NetscapePlugin::controller()
    546567{
  • trunk/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.h

    r68898 r68962  
    6969    static void setException(const String&);
    7070    bool evaluate(NPObject*, const String&scriptString, NPVariant* result);
     71    bool isPrivateBrowsingEnabled();
    7172
    7273    // These return retained objects.
     
    9596    void NPP_URLNotify(const char* url, NPReason, void* notifyData);
    9697    NPError NPP_GetValue(NPPVariable, void *value);
     98    NPError NPP_SetValue(NPNVariable, void *value);
    9799
    98100private:
     
    143145    virtual bool handleMouseLeaveEvent(const WebMouseEvent&);
    144146    virtual void setFocus(bool);
     147    virtual NPObject* pluginScriptableNPObject();
    145148
    146149#if PLATFORM(MAC)
     
    150153#endif
    151154
    152     virtual NPObject* pluginScriptableNPObject();
     155    virtual void privateBrowsingStateChanged(bool);
    153156
    154157    virtual PluginController* controller();
  • trunk/WebKit2/WebProcess/Plugins/Plugin.h

    r68058 r68962  
    149149#endif
    150150
     151    // Called when the private browsing state for this plug-in changes.
     152    virtual void privateBrowsingStateChanged(bool) = 0;
     153
    151154    // Returns the plug-in controller for this plug-in.
    152155    // FIXME: We could just have the controller be a member variable of Plugin.
  • trunk/WebKit2/WebProcess/Plugins/PluginController.h

    r68898 r68962  
    9797    // Sets the cookies for the given URL.
    9898    virtual void setCookiesForURL(const String& urlString, const String& cookieString) = 0;
    99    
     99
     100    // Returns whether private browsing is enabled.
     101    virtual bool isPrivateBrowsingEnabled() = 0;
     102
    100103protected:
    101104    virtual ~PluginController() { }
  • trunk/WebKit2/WebProcess/Plugins/PluginView.cpp

    r68952 r68962  
    418418}
    419419
     420void PluginView::privateBrowsingStateChanged(bool privateBrowsingEnabled)
     421{
     422    // The plug-in can be null here if it failed to initialize.
     423    if (!m_plugin)
     424        return;
     425
     426    m_plugin->privateBrowsingStateChanged(privateBrowsingEnabled);
     427}
     428
    420429void PluginView::setFrameRect(const WebCore::IntRect& rect)
    421430{
     
    842851    setCookies(m_pluginElement->document(), KURL(KURL(), urlString), cookieString);
    843852}
    844    
     853
     854bool PluginView::isPrivateBrowsingEnabled()
     855{
     856    // If we can't get the real setting, we'll assume that private browsing is enabled.
     857    if (!frame())
     858        return true;
     859
     860    Settings* settings = frame()->settings();
     861    if (!settings)
     862        return true;
     863
     864    return settings->privateBrowsingEnabled();
     865}
     866
    845867void PluginView::didFinishLoad(WebFrame* webFrame)
    846868{
  • trunk/WebKit2/WebProcess/Plugins/PluginView.h

    r68898 r68962  
    9999#endif
    100100    virtual JSC::JSObject* scriptObject(JSC::JSGlobalObject*);
     101    virtual void privateBrowsingStateChanged(bool);
    101102   
    102103    // WebCore::Widget
     
    131132    virtual String cookiesForURL(const String&);
    132133    virtual void setCookiesForURL(const String& urlString, const String& cookieString);
    133    
     134    virtual bool isPrivateBrowsingEnabled();
     135
    134136    // WebFrame::LoadListener
    135137    virtual void didFinishLoad(WebFrame*);
Note: See TracChangeset for help on using the changeset viewer.