Changeset 47205 in webkit


Ignore:
Timestamp:
Aug 13, 2009 9:51:22 AM (15 years ago)
Author:
eric@webkit.org
Message:

2009-08-13 Joseph Pecoraro <joepeck02@gmail.com>

Reviewed by Darin Adler.

Inspector: Show Hidden Cookie Data
https://bugs.webkit.org/show_bug.cgi?id=28185

Added new file Cookie.h to the WebCore XCode

  • WebCore.xcodeproj/project.pbxproj:

InspectorController.cookies() binding

  • bindings/js/JSInspectorBackendCustom.cpp: (WebCore::JSInspectorBackend::cookies):
  • inspector/InspectorBackend.idl:

Struct for static Cookie information
(name, value, path, domain, expires, httpOnly, secure, session)

  • platform/Cookie.h: Added. (WebCore::Cookie::Cookie):

Getter for the a list of raw Cookies
getRawCookies(., ., out Vector<Cookie>)

  • platform/CookieJar.h:

Implementation of getRawCookies for the mac platform.

  • platform/mac/CookieJar.mm: (WebCore::getRawCookies):

Stub other CookieJar implementations to satisfy the interface.

  • platform/haiku/CookieJarHaiku.cpp: (WebCore::getRawCookies):
  • platform/network/chromium/CookieJarChromium.cpp: (WebCore::getRawCookies):
  • platform/network/curl/CookieJarCurl.cpp: (WebCore::getRawCookies):
  • platform/network/soup/CookieJarSoup.cpp: (WebCore::getRawCookies):
  • platform/network/win/CookieJarCFNetWin.cpp: (WebCore::getRawCookies):
  • platform/network/win/CookieJarWin.cpp: (WebCore::getRawCookies):
  • platform/qt/CookieJarQt.cpp: (WebCore::getRawCookies):
Location:
trunk/WebCore
Files:
13 edited
1 copied

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r47203 r47205  
     12009-08-13  Joseph Pecoraro  <joepeck02@gmail.com>
     2
     3        Reviewed by Darin Adler.
     4
     5        Inspector: Show Hidden Cookie Data
     6        https://bugs.webkit.org/show_bug.cgi?id=28185
     7
     8          Added new file Cookie.h to the WebCore XCode
     9
     10        * WebCore.xcodeproj/project.pbxproj:
     11
     12          InspectorController.cookies() binding
     13
     14        * bindings/js/JSInspectorBackendCustom.cpp:
     15        (WebCore::JSInspectorBackend::cookies):
     16        * inspector/InspectorBackend.idl:
     17
     18          Struct for static Cookie information
     19          (name, value, path, domain, expires, httpOnly, secure, session)
     20
     21        * platform/Cookie.h: Added.
     22        (WebCore::Cookie::Cookie):
     23       
     24          Getter for the a list of raw Cookies
     25          getRawCookies(., ., out Vector<Cookie>)
     26       
     27        * platform/CookieJar.h:
     28
     29          Implementation of getRawCookies for the mac platform.
     30
     31        * platform/mac/CookieJar.mm:
     32        (WebCore::getRawCookies):
     33
     34          Stub other CookieJar implementations to satisfy the interface.
     35
     36        * platform/haiku/CookieJarHaiku.cpp:
     37        (WebCore::getRawCookies):
     38        * platform/network/chromium/CookieJarChromium.cpp:
     39        (WebCore::getRawCookies):
     40        * platform/network/curl/CookieJarCurl.cpp:
     41        (WebCore::getRawCookies):
     42        * platform/network/soup/CookieJarSoup.cpp:
     43        (WebCore::getRawCookies):
     44        * platform/network/win/CookieJarCFNetWin.cpp:
     45        (WebCore::getRawCookies):
     46        * platform/network/win/CookieJarWin.cpp:
     47        (WebCore::getRawCookies):
     48        * platform/qt/CookieJarQt.cpp:
     49        (WebCore::getRawCookies):
     50
    1512009-08-13  Gustavo Noronha Silva  <gustavo.noronha@collabora.co.uk>
    252
  • trunk/WebCore/WebCore.xcodeproj/project.pbxproj

    r47195 r47205  
    44004400                D23CA55F0AB0EAB6005108A5 /* JSRangeException.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D23CA55E0AB0EAB6005108A5 /* JSRangeException.cpp */; };
    44014401                D23CA56C0AB0EB8D005108A5 /* RangeException.h in Headers */ = {isa = PBXBuildFile; fileRef = D23CA56B0AB0EB8D005108A5 /* RangeException.h */; };
     4402                D8B6152F1032495100C8554A /* Cookie.h in Headers */ = {isa = PBXBuildFile; fileRef = D8B6152E1032495100C8554A /* Cookie.h */; };
    44024403                DB23C2CB0A508D29002489EB /* IndentOutdentCommand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DB23C2C90A508D29002489EB /* IndentOutdentCommand.cpp */; };
    44034404                DB23C2CC0A508D29002489EB /* IndentOutdentCommand.h in Headers */ = {isa = PBXBuildFile; fileRef = DB23C2CA0A508D29002489EB /* IndentOutdentCommand.h */; };
     
    93319332                D23CA55E0AB0EAB6005108A5 /* JSRangeException.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = JSRangeException.cpp; sourceTree = "<group>"; };
    93329333                D23CA56B0AB0EB8D005108A5 /* RangeException.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = RangeException.h; sourceTree = "<group>"; };
     9334                D8B6152E1032495100C8554A /* Cookie.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Cookie.h; sourceTree = "<group>"; };
    93339335                DB23C2C90A508D29002489EB /* IndentOutdentCommand.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = IndentOutdentCommand.cpp; sourceTree = "<group>"; };
    93349336                DB23C2CA0A508D29002489EB /* IndentOutdentCommand.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = IndentOutdentCommand.h; sourceTree = "<group>"; };
     
    1413314135                                93B6A0E50B0BCA5C00F5027A /* ContextMenu.h */,
    1413414136                                06027CAC0B1CBFC000884B2D /* ContextMenuItem.h */,
     14137                                D8B6152E1032495100C8554A /* Cookie.h */,
    1413514138                                9352088109BD45E900F2038D /* CookieJar.h */,
    1413614139                                2E4346560F546A9900B0F1BA /* CrossThreadCopier.cpp */,
     
    1726017263                                416E29A6102FA962007FC14E /* WorkerReportingProxy.h in Headers */,
    1726117264                                B5C1123C102B6C4600096578 /* SQLTransactionCoordinator.h in Headers */,
     17265                                D8B6152F1032495100C8554A /* Cookie.h in Headers */,
    1726217266                        );
    1726317267                        runOnlyForDeploymentPostprocessing = 0;
  • trunk/WebCore/bindings/js/JSInspectorBackendCustom.cpp

    r47195 r47205  
    3535
    3636#include "Console.h"
     37#include "Cookie.h"
     38#include "CookieJar.h"
    3739#if ENABLE(DATABASE)
    3840#include "Database.h"
     
    157159    JSDOMWindow* inspectedWindow = toJSDOMWindow(ic->inspectedPage()->mainFrame());
    158160    return JSInspectedObjectWrapper::wrap(inspectedWindow->globalExec(), inspectedWindow);
     161}
     162
     163JSValue JSInspectorBackend::cookies(ExecState* exec, const ArgList&)
     164{
     165    InspectorController* ic = impl()->inspectorController();
     166    if (!ic)
     167        return jsUndefined();
     168
     169    Document* document = ic->inspectedPage()->mainFrame()->document();
     170    Vector<Cookie> cookies;
     171    getRawCookies(document, document->cookieURL(), cookies);
     172
     173    MarkedArgumentBuffer result;
     174    Identifier nameIdentifier(exec, "name");
     175    Identifier valueIdentifier(exec, "value");
     176    Identifier domainIdentifier(exec, "domain");
     177    Identifier pathIdentifier(exec, "path");
     178    Identifier expiresIdentifier(exec, "expires");
     179    Identifier sizeIdentifier(exec, "size");
     180    Identifier httpOnlyIdentifier(exec, "httpOnly");
     181    Identifier secureIdentifier(exec, "secure");
     182    Identifier sessionIdentifier(exec, "session");
     183
     184    unsigned length = cookies.size();
     185    for (unsigned i = 0; i < length; ++i) {
     186        const Cookie& cookie = cookies[i];
     187        JSObject* cookieObject = constructEmptyObject(exec);
     188        cookieObject->putDirect(nameIdentifier, jsString(exec, cookie.name));
     189        cookieObject->putDirect(valueIdentifier, jsString(exec, cookie.value));
     190        cookieObject->putDirect(domainIdentifier, jsString(exec, cookie.domain));
     191        cookieObject->putDirect(pathIdentifier, jsString(exec, cookie.path));
     192        cookieObject->putDirect(expiresIdentifier, jsNumber(exec, cookie.expires));
     193        cookieObject->putDirect(sizeIdentifier, jsNumber(exec, cookie.name.length() + cookie.value.length()));
     194        cookieObject->putDirect(httpOnlyIdentifier, jsBoolean(cookie.httpOnly));
     195        cookieObject->putDirect(secureIdentifier, jsBoolean(cookie.secure));
     196        cookieObject->putDirect(sessionIdentifier, jsBoolean(cookie.session));
     197        result.append(cookieObject);
     198    }
     199
     200    return constructArray(exec, result);
    159201}
    160202
  • trunk/WebCore/inspector/InspectorBackend.idl

    r47195 r47205  
    6969        void storeLastActivePanel(in DOMString panelName);
    7070
     71        [Custom] Array cookies();
     72
    7173#if defined(ENABLE_JAVASCRIPT_DEBUGGER) && ENABLE_JAVASCRIPT_DEBUGGER
    7274        boolean debuggerEnabled();
  • trunk/WebCore/platform/Cookie.h

    r47204 r47205  
    11/*
    2  * Copyright (C) 2006 George Staikos <staikos@kde.org>
    3  * Copyright (C) 2007 Ryan Leavengood <leavengood@gmail.com>
    4  *
    5  * All rights reserved.
     2 * Copyright (C) 2009 Joseph Pecoraro. All rights reserved.
    63 *
    74 * Redistribution and use in source and binary forms, with or without
     
    2724 */
    2825
    29 #include "config.h"
    30 #include "CookieJar.h"
     26#ifndef Cookie_h
     27#define Cookie_h
    3128
    32 #include "KURL.h"
    3329#include "PlatformString.h"
    34 #include "StringHash.h"
    35 
    36 #include <wtf/HashMap.h>
    37 
    3830
    3931namespace WebCore {
    4032
    41 // FIXME: Shouldn't this be saved to and restored from disk too?
    42 static HashMap<String, String> cookieJar;
     33    struct Cookie {
     34        Cookie(const String& name, const String& value, const String& domain,
     35                const String& path, double expires, bool httpOnly, bool secure,
     36                bool session)
     37            : name(name)
     38            , value(value)
     39            , domain(domain)
     40            , path(path)
     41            , expires(expires)
     42            , httpOnly(httpOnly)
     43            , secure(secure)
     44            , session(session)
     45        {
     46        }
    4347
    44 void setCookies(const KURL& url, const KURL& /*policyURL*/, const String& value)
    45 {
    46     cookieJar.set(url.string(), value);
     48        String name;
     49        String value;
     50        String domain;
     51        String path;
     52        double expires;
     53        bool httpOnly;
     54        bool secure;
     55        bool session;
     56    };
     57
    4758}
    4859
    49 String cookies(const KURL& url)
    50 {
    51     return cookieJar.get(url.string());
    52 }
    53 
    54 bool cookiesEnabled()
    55 {
    56     // FIXME: This should probably be a setting
    57     return true;
    58 }
    59 
    60 } // namespace WebCore
    61 
     60#endif
  • trunk/WebCore/platform/CookieJar.h

    r47195 r47205  
    2727#define CookieJar_h
    2828
     29#include <wtf/Vector.h>
     30
    2931namespace WebCore {
    3032
     33    class Document;
    3134    class KURL;
    3235    class String;
    33     class Document;
     36
     37    struct Cookie;
    3438
    3539    String cookies(const Document*, const KURL&);
    3640    void setCookies(Document*, const KURL&, const String&);
    3741    bool cookiesEnabled(const Document*);
     42    void getRawCookies(const Document*, const KURL&, Vector<Cookie>&);
    3843
    3944}
  • trunk/WebCore/platform/haiku/CookieJarHaiku.cpp

    r47195 r47205  
    3030#include "CookieJar.h"
    3131
     32#include "Cookie.h"
    3233#include "KURL.h"
    3334#include "PlatformString.h"
     
    4243static HashMap<String, String> cookieJar;
    4344
    44 void setCookies(const KURL& url, const KURL& /*policyURL*/, const String& value)
     45void setCookies(Document*, const KURL& url, const String& value)
    4546{
    4647    cookieJar.set(url.string(), value);
    4748}
    4849
    49 String cookies(const KURL& url)
     50String cookies(const Document*, const KURL& url)
    5051{
    5152    return cookieJar.get(url.string());
    5253}
    5354
    54 bool cookiesEnabled()
     55bool cookiesEnabled(const Document*)
    5556{
    5657    // FIXME: This should probably be a setting
     
    5859}
    5960
     61void getRawCookies(const Document*, const KURL&, Vector<Cookie>& rawCookies)
     62{
     63    // FIXME: Not yet implemented
     64    rawCookies.clear();
     65}
     66
    6067} // namespace WebCore
    6168
  • trunk/WebCore/platform/mac/CookieJar.mm

    r47195 r47205  
    2828
    2929#import "BlockExceptions.h"
     30#import "Cookie.h"
    3031#import "Document.h"
    3132#import "KURL.h"
     
    117118}
    118119
     120void getRawCookies(const Document*, const KURL& url, Vector<Cookie>& rawCookies)
     121{
     122    rawCookies.clear();
     123    BEGIN_BLOCK_OBJC_EXCEPTIONS;
     124
     125    NSURL *cookieURL = url;
     126    NSArray *cookies = [[NSHTTPCookieStorage sharedHTTPCookieStorage] cookiesForURL:cookieURL];
     127
     128    NSUInteger count = [cookies count];
     129    rawCookies.reserveCapacity(count);
     130    for (NSUInteger i = 0; i < count; ++i) {
     131        NSHTTPCookie *cookie = (NSHTTPCookie *)[cookies objectAtIndex:i];
     132        NSString *name = [cookie name];
     133        NSString *value = [cookie value];
     134        NSString *domain = [cookie domain];
     135        NSString *path = [cookie path];
     136        NSTimeInterval expires = [[cookie expiresDate] timeIntervalSince1970] * 1000;
     137        bool httpOnly = [cookie isHTTPOnly];
     138        bool secure = [cookie isSecure];
     139        bool session = [cookie isSessionOnly];
     140        rawCookies.uncheckedAppend(Cookie(name, value, domain, path, expires, httpOnly, secure, session));
     141    }
     142
     143    END_BLOCK_OBJC_EXCEPTIONS;
    119144}
     145
     146}
  • trunk/WebCore/platform/network/chromium/CookieJarChromium.cpp

    r47195 r47205  
    3232#include "CookieJar.h"
    3333
     34#include "Cookie.h"
    3435#include "ChromiumBridge.h"
    3536#include "Document.h"
     
    5354}
    5455
     56void getRawCookies(const Document*, const KURL&, Vector<Cookie>& rawCookies)
     57{
     58    // FIXME: Not yet implemented
     59    rawCookies.clear();
     60}
     61
    5562} // namespace WebCore
  • trunk/WebCore/platform/network/curl/CookieJarCurl.cpp

    r47195 r47205  
    1818#include "CookieJar.h"
    1919
     20#include "Cookie.h"
    2021#include "Document.h"
    2122#include "KURL.h"
     
    4445}
    4546
     47void getRawCookies(const Document*, const KURL&, Vector<Cookie>& rawCookies)
     48{
     49    // FIXME: Not yet implemented
     50    rawCookies.clear();
    4651}
     52
     53}
  • trunk/WebCore/platform/network/soup/CookieJarSoup.cpp

    r47195 r47205  
    2222#include "CookieJarSoup.h"
    2323
     24#include "Cookie.h"
    2425#include "CString.h"
    2526#include "Document.h"
     
    8788}
    8889
     90void getRawCookies(const Document*, const KURL&, Vector<Cookie>& rawCookies)
     91{
     92    // FIXME: Not yet implemented
     93    rawCookies.clear();
    8994}
     95
     96}
  • trunk/WebCore/platform/network/win/CookieJarCFNetWin.cpp

    r47195 r47205  
    2727#include "CookieJar.h"
    2828
     29#include "Cookie.h"
    2930#include "CookieStorageWin.h"
    3031#include "Document.h"
     
    114115}
    115116
     117void getRawCookies(const Document*, const KURL&, Vector<Cookie>& rawCookies)
     118{
     119    // FIXME: Not yet implemented
     120    rawCookies.clear();
    116121}
     122
     123}
  • trunk/WebCore/platform/network/win/CookieJarWin.cpp

    r47195 r47205  
    2727#include "CookieJar.h"
    2828
     29#include "Cookie.h"
    2930#include "KURL.h"
    3031#include "PlatformString.h"
     
    3536
    3637namespace WebCore {
    37 
    3838
    3939void setCookies(Document* /*document*/, const KURL& url, const String& value)
     
    6565}
    6666
     67void getRawCookies(const Document*, const KURL&, Vector<Cookie>& rawCookies)
     68{
     69    // FIXME: Not yet implemented
     70    rawCookies.clear();
    6771}
     72
     73}
  • trunk/WebCore/platform/qt/CookieJarQt.cpp

    r47195 r47205  
    2929#include "CookieJar.h"
    3030
     31#include "Cookie.h"
    3132#include "Document.h"
    3233#include "KURL.h"
     
    129130}
    130131
     132void getRawCookies(const Document*, const KURL&, Vector<Cookie>& rawCookies)
     133{
     134    // FIXME: Not yet implemented
     135    rawCookies.clear();
     136}
     137
    131138}
    132139
Note: See TracChangeset for help on using the changeset viewer.