Changeset 68898 in webkit


Ignore:
Timestamp:
Oct 1, 2010 10:46:27 AM (14 years ago)
Author:
andersca@apple.com
Message:

Implement NPN_GetValueForURL/NPN_SetValueForURL and stub out PluginController functions
https://bugs.webkit.org/show_bug.cgi?id=46992

Reviewed by Dan Bernstein.

  • WebProcess/Plugins/Netscape/NetscapeBrowserFuncs.cpp:

(WebKit::copyCString):
Helper function for allocating a string using NPN_MemAlloc.

(WebKit::NPN_GetValueForURL):
Ask the plug-in for either the proxy or the cookies given an URL.

(WebKit::NPN_SetValueForURL):

  • WebProcess/Plugins/Netscape/NetscapePlugin.cpp:

Tell the plug-in to set the cookies for the given URL.

(WebKit::NetscapePlugin::proxiesForURL):
(WebKit::NetscapePlugin::cookiesForURL):
(WebKit::NetscapePlugin::setCookiesForURL):
Call the corresponding PluginController functions.

  • WebProcess/Plugins/PluginController.h:

Add new pure virtual member functions.

  • WebProcess/Plugins/PluginView.cpp:

(WebKit::PluginView::proxiesForURL):
(WebKit::PluginView::cookiesForURL):
(WebKit::PluginView::setCookiesForURL):
Add stubbed out implementations of the new PluginController functions.

  • WebProcess/Plugins/PluginView.h:
Location:
trunk/WebKit2
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebKit2/ChangeLog

    r68891 r68898  
     12010-10-01  Anders Carlsson  <andersca@apple.com>
     2
     3        Reviewed by Dan Bernstein.
     4
     5        Implement NPN_GetValueForURL/NPN_SetValueForURL and stub out PluginController functions
     6        https://bugs.webkit.org/show_bug.cgi?id=46992
     7
     8        * WebProcess/Plugins/Netscape/NetscapeBrowserFuncs.cpp:
     9        (WebKit::copyCString):
     10        Helper function for allocating a string using NPN_MemAlloc.
     11
     12        (WebKit::NPN_GetValueForURL):
     13        Ask the plug-in for either the proxy or the cookies given an URL.
     14
     15        (WebKit::NPN_SetValueForURL):
     16        * WebProcess/Plugins/Netscape/NetscapePlugin.cpp:
     17        Tell the plug-in to set the cookies for the given URL.
     18
     19        (WebKit::NetscapePlugin::proxiesForURL):
     20        (WebKit::NetscapePlugin::cookiesForURL):
     21        (WebKit::NetscapePlugin::setCookiesForURL):
     22        Call the corresponding PluginController functions.
     23
     24        * WebProcess/Plugins/PluginController.h:
     25        Add new pure virtual member functions.
     26
     27        * WebProcess/Plugins/PluginView.cpp:
     28        (WebKit::PluginView::proxiesForURL):
     29        (WebKit::PluginView::cookiesForURL):
     30        (WebKit::PluginView::setCookiesForURL):
     31        Add stubbed out implementations of the new PluginController functions.
     32
     33        * WebProcess/Plugins/PluginView.h:
     34
    1352010-10-01  Adam Roben  <aroben@apple.com>
    236
  • trunk/WebKit2/WebProcess/Plugins/Netscape/NetscapeBrowserFuncs.cpp

    r68891 r68898  
    676676}
    677677
    678 static NPError NPN_GetValueForURL(NPP instance, NPNURLVariable variable, const char* url, char** value, uint32_t* len)
    679 {
    680     notImplemented();
    681     return NPERR_GENERIC_ERROR;
    682 }
    683 
    684 static NPError NPN_SetValueForURL(NPP instance, NPNURLVariable variable, const char* url, const char* value, uint32_t len)
    685 {
    686     notImplemented();
    687     return NPERR_GENERIC_ERROR;
     678static NPError copyCString(const CString& string, char** value, uint32_t* len)
     679{
     680    ASSERT(!string.isNull());
     681    ASSERT(value);
     682    ASSERT(len);
     683
     684    *value = static_cast<char*>(NPN_MemAlloc(string.length()));
     685    if (!*value)
     686        return NPERR_GENERIC_ERROR;
     687
     688    memcpy(*value, string.data(), string.length());
     689    return NPERR_NO_ERROR;
     690}
     691
     692static NPError NPN_GetValueForURL(NPP npp, NPNURLVariable variable, const char* url, char** value, uint32_t* len)
     693{
     694    if (!value || !len)
     695        return NPERR_GENERIC_ERROR;
     696   
     697    switch (variable) {
     698        case NPNURLVCookie: {
     699            RefPtr<NetscapePlugin> plugin = NetscapePlugin::fromNPP(npp);
     700
     701            String cookies = plugin->cookiesForURL(makeURLString(url));
     702            if (cookies.isNull())
     703                return NPERR_GENERIC_ERROR;
     704
     705            return copyCString(cookies.utf8(), value, len);
     706        }
     707
     708        case NPNURLVProxy: {
     709            RefPtr<NetscapePlugin> plugin = NetscapePlugin::fromNPP(npp);
     710
     711            String proxies = plugin->proxiesForURL(makeURLString(url));
     712            if (proxies.isNull())
     713                return NPERR_GENERIC_ERROR;
     714
     715            return copyCString(proxies.utf8(), value, len);
     716        }
     717        default:
     718            notImplemented();
     719            return NPERR_GENERIC_ERROR;
     720    }
     721}
     722
     723static NPError NPN_SetValueForURL(NPP npp, NPNURLVariable variable, const char* url, const char* value, uint32_t len)
     724{
     725    switch (variable) {
     726        case NPNURLVCookie: {
     727            RefPtr<NetscapePlugin> plugin = NetscapePlugin::fromNPP(npp);
     728
     729            plugin->setCookiesForURL(makeURLString(url), String(value, len));
     730            return NPERR_NO_ERROR;
     731        }
     732
     733        case NPNURLVProxy:
     734            // Can't set the proxy for a URL.
     735            return NPERR_GENERIC_ERROR;
     736
     737        default:
     738            notImplemented();
     739            return NPERR_GENERIC_ERROR;
     740    }
    688741}
    689742
  • trunk/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.cpp

    r68662 r68898  
    207207}
    208208
     209String NetscapePlugin::proxiesForURL(const String& urlString)
     210{
     211    return m_pluginController->proxiesForURL(urlString);
     212}
     213   
     214String NetscapePlugin::cookiesForURL(const String& urlString)
     215{
     216    return m_pluginController->cookiesForURL(urlString);
     217}
     218
     219void NetscapePlugin::setCookiesForURL(const String& urlString, const String& cookieString)
     220{
     221    m_pluginController->setCookiesForURL(urlString, cookieString);
     222}
     223
    209224NPError NetscapePlugin::NPP_New(NPMIMEType pluginType, uint16_t mode, int16_t argc, char* argn[], char* argv[], NPSavedData* savedData)
    210225{
  • trunk/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.h

    r68891 r68898  
    7878
    7979    bool isAcceleratedCompositingEnabled();
     80
     81    String proxiesForURL(const String& urlString);
     82    String cookiesForURL(const String& urlString);
     83    void setCookiesForURL(const String& urlString, const String& cookieString);
    8084
    8185    // Member functions for calling into the plug-in.
  • trunk/WebKit2/WebProcess/Plugins/PluginController.h

    r68662 r68898  
    7171
    7272    // Evaluates the given script string in the context of the given NPObject.
    73     virtual bool evaluate(NPObject*, const String&scriptString, NPVariant* result, bool allowPopups) = 0;
     73    virtual bool evaluate(NPObject*, const String& scriptString, NPVariant* result, bool allowPopups) = 0;
    7474
    7575    // Set the statusbar text.
     
    8989#endif
    9090
     91    // Returns the proxies for the given URL or null on failure.
     92    virtual String proxiesForURL(const String&) = 0;
     93
     94    // Returns the cookies for the given URL or null on failure.
     95    virtual String cookiesForURL(const String&) = 0;
     96
     97    // Sets the cookies for the given URL.
     98    virtual void setCookiesForURL(const String& urlString, const String& cookieString) = 0;
     99   
    91100protected:
    92101    virtual ~PluginController() { }
  • trunk/WebKit2/WebProcess/Plugins/PluginView.cpp

    r68662 r68898  
    825825#endif
    826826
     827String PluginView::proxiesForURL(const String& urlString)
     828{
     829    // FIXME: Implement.
     830    return String();
     831}
     832
     833String PluginView::cookiesForURL(const String& urlString)
     834{
     835    // FIXME: Implement.
     836    return String();
     837}
     838
     839void PluginView::setCookiesForURL(const String& urlString, const String& cookieString)
     840{
     841    // FIXME: Implement.
     842}
     843   
    827844void PluginView::didFinishLoad(WebFrame* webFrame)
    828845{
  • trunk/WebKit2/WebProcess/Plugins/PluginView.h

    r68662 r68898  
    128128    virtual HWND nativeParentWindow();
    129129#endif
    130 
     130    virtual String proxiesForURL(const String&);
     131    virtual String cookiesForURL(const String&);
     132    virtual void setCookiesForURL(const String& urlString, const String& cookieString);
     133   
    131134    // WebFrame::LoadListener
    132135    virtual void didFinishLoad(WebFrame*);
Note: See TracChangeset for help on using the changeset viewer.