Changeset 171747 in webkit


Ignore:
Timestamp:
Jul 29, 2014 9:40:17 AM (10 years ago)
Author:
mitz@apple.com
Message:

Moved the Cocoa-specific parts of CredentialBase into a Cocoa-specific Credential class.
Work towards fixing https://bugs.webkit.org/show_bug.cgi?id=135327

Reviewed by Alexey Proskuryakov.

No change in functionality.

  • WebCore.exp.in: Updated for functions moved in the class hierarchy.
  • WebCore.xcodeproj/project.pbxproj: Added CredentialCocoa.{h,mm}.
  • platform/network/Credential.h: For Cocoa, include CredentialCocoa.h instead of the generic

class.
(WebCore::Credential::Credential): Removed #if CERTIFICATE_CREDENTIALS_SUPPORTED code.

  • platform/network/CredentialBase.cpp:

(WebCore::CredentialBase::CredentialBase): Changed to use emptyString instead of "", removed
#if CERTIFICATE_CREDENTIALS_SUPPORTED code.
(WebCore::CredentialBase::isEmpty): Ditto.
(WebCore::CredentialBase::compare): Renamed operator== to this, removed
#if CERTIFICATE_CREDENTIALS_SUPPORTED code, but changed the end to call platformCompare.
(WebCore::CredentialBase::identity): Deleted.
(WebCore::CredentialBase::certificates): Deleted.
(WebCore::CredentialBase::type): Deleted.

  • platform/network/CredentialBase.h: Removed #if CERTIFICATE_CREDENTIALS_SUPPORTED members.

(WebCore::CredentialBase::platformCompare): Added a base implementation that returns true.
(WebCore::operator==): Changed to use CredentialBase::compare.

  • platform/network/cocoa/CredentialCocoa.h: Added.

(WebCore::Credential::Credential):

  • platform/network/cocoa/CredentialCocoa.mm: Added.

(WebCore::Credential::Credential): Moved the constructor that takes an identity and
certificates here.
(WebCore::Credential::isEmpty): Moved here.
(WebCore::Credential::identity): Ditto.
(WebCore::Credential::certificates): Ditto.
(WebCore::Credential::type): Ditto.
(WebCore::Credential::platformCompare): Moved the code that compares client-certificate
credentials here.

  • platform/network/mac/AuthenticationMac.mm:

(WebCore::mac): Removed #if CERTIFICATE_CREDENTIALS_SUPPORTED guards in this Cocoa-only
file.
(WebCore::core): Ditto.

Location:
trunk/Source/WebCore
Files:
2 added
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r171746 r171747  
     12014-07-29  Dan Bernstein  <mitz@apple.com>
     2
     3        Moved the Cocoa-specific parts of CredentialBase into a Cocoa-specific Credential class.
     4        Work towards fixing https://bugs.webkit.org/show_bug.cgi?id=135327
     5
     6        Reviewed by Alexey Proskuryakov.
     7
     8        No change in functionality.
     9
     10        * WebCore.exp.in: Updated for functions moved in the class hierarchy.
     11
     12        * WebCore.xcodeproj/project.pbxproj: Added CredentialCocoa.{h,mm}.
     13
     14        * platform/network/Credential.h: For Cocoa, include CredentialCocoa.h instead of the generic
     15        class.
     16        (WebCore::Credential::Credential): Removed #if CERTIFICATE_CREDENTIALS_SUPPORTED code.
     17
     18        * platform/network/CredentialBase.cpp:
     19        (WebCore::CredentialBase::CredentialBase): Changed to use emptyString instead of "", removed
     20        #if CERTIFICATE_CREDENTIALS_SUPPORTED code.
     21        (WebCore::CredentialBase::isEmpty): Ditto.
     22        (WebCore::CredentialBase::compare): Renamed operator== to this, removed
     23        #if CERTIFICATE_CREDENTIALS_SUPPORTED code, but changed the end to call platformCompare.
     24        (WebCore::CredentialBase::identity): Deleted.
     25        (WebCore::CredentialBase::certificates): Deleted.
     26        (WebCore::CredentialBase::type): Deleted.
     27        * platform/network/CredentialBase.h: Removed #if CERTIFICATE_CREDENTIALS_SUPPORTED members.
     28        (WebCore::CredentialBase::platformCompare): Added a base implementation that returns true.
     29        (WebCore::operator==): Changed to use CredentialBase::compare.
     30
     31        * platform/network/cocoa/CredentialCocoa.h: Added.
     32        (WebCore::Credential::Credential):
     33        * platform/network/cocoa/CredentialCocoa.mm: Added.
     34        (WebCore::Credential::Credential): Moved the constructor that takes an identity and
     35        certificates here.
     36        (WebCore::Credential::isEmpty): Moved here.
     37        (WebCore::Credential::identity): Ditto.
     38        (WebCore::Credential::certificates): Ditto.
     39        (WebCore::Credential::type): Ditto.
     40        (WebCore::Credential::platformCompare): Moved the code that compares client-certificate
     41        credentials here.
     42
     43        * platform/network/mac/AuthenticationMac.mm:
     44        (WebCore::mac): Removed #if CERTIFICATE_CREDENTIALS_SUPPORTED guards in this Cocoa-only
     45        file.
     46        (WebCore::core): Ditto.
     47
    1482014-07-29  Daniel Bates  <dabates@apple.com>
    249
  • trunk/Source/WebCore/WebCore.exp.in

    r171723 r171747  
    15351535__ZNK3JSC8Bindings10RootObject12globalObjectEv
    15361536__ZNK3WTF6String14createCFStringEv
     1537__ZNK7WebCore10Credential12certificatesEv
     1538__ZNK7WebCore10Credential4typeEv
     1539__ZNK7WebCore10Credential7isEmptyEv
     1540__ZNK7WebCore10Credential8identityEv
    15371541__ZNK7WebCore10FloatPointcv7CGPointEv
    15381542__ZNK7WebCore10FontGlyphs17realizeFontDataAtERKNS_15FontDescriptionEj
     
    16541658__ZNK7WebCore14CredentialBase11hasPasswordEv
    16551659__ZNK7WebCore14CredentialBase11persistenceEv
    1656 __ZNK7WebCore14CredentialBase12certificatesEv
    1657 __ZNK7WebCore14CredentialBase4typeEv
    16581660__ZNK7WebCore14CredentialBase4userEv
    1659 __ZNK7WebCore14CredentialBase7isEmptyEv
    1660 __ZNK7WebCore14CredentialBase8identityEv
    16611661__ZNK7WebCore14CredentialBase8passwordEv
    16621662__ZNK7WebCore14DocumentLoader10requestURLEv
     
    22202220.objc_class_name_WebWindowFadeAnimation
    22212221.objc_class_name_WebWindowScaleAnimation
     2222__ZN7WebCore10CredentialC1EP20OpaqueSecIdentityRefPK9__CFArrayNS_21CredentialPersistenceE
    22222223__ZN7WebCore10FloatPointC1ERK8_NSPoint
    22232224__ZN7WebCore10handCursorEv
     
    22372238__ZN7WebCore13getRawCookiesERKNS_21NetworkStorageSessionERKNS_3URLES5_RN3WTF6VectorINS_6CookieELm0ENS6_15CrashOnOverflowEEE
    22382239__ZN7WebCore13toDeviceSpaceERKNS_9FloatRectEP8NSWindow
    2239 __ZN7WebCore14CredentialBaseC2EP20OpaqueSecIdentityRefPK9__CFArrayNS_21CredentialPersistenceE
    22402240__ZN7WebCore14cookiesEnabledERKNS_21NetworkStorageSessionERKNS_3URLES5_
    22412241__ZN7WebCore15GraphicsContext15drawNativeImageEP7CGImageRKNS_9FloatSizeENS_10ColorSpaceERKNS_9FloatRectES9_fNS_17CompositeOperatorENS_9BlendModeENS_16ImageOrientationE
     
    25262526_WebUIApplicationWillEnterForegroundNotification
    25272527_WebUIApplicationWillResignActiveNotification
     2528__ZN7WebCore10CredentialC1EP13__SecIdentityPK9__CFArrayNS_21CredentialPersistenceE
    25282529__ZN7WebCore10RenderView35resumePausedImageAnimationsIfNeededEv
    25292530__ZN7WebCore10ScrollView15setScrollOffsetERKNS_8IntPointE
     
    25622563__ZN7WebCore13getRawCookiesERKNS_21NetworkStorageSessionERKNS_3URLES5_RN3WTF6VectorINS_6CookieELm0ENS6_15CrashOnOverflowEEE
    25632564__ZN7WebCore13isStartOfLineERKNS_15VisiblePositionE
    2564 __ZN7WebCore14CredentialBaseC1EP13__SecIdentityPK9__CFArrayNS_21CredentialPersistenceE
    25652565__ZN7WebCore14DocumentLoader19setResponseMIMETypeERKN3WTF6StringE
    25662566__ZN7WebCore14DocumentWriter3endEv
  • trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj

    r171744 r171747  
    13151315                37919C240B7D188600A56998 /* PositionIterator.h in Headers */ = {isa = PBXBuildFile; fileRef = 37919C220B7D188600A56998 /* PositionIterator.h */; settings = {ATTRIBUTES = (); }; };
    13161316                3792917A1985EF3900F4B661 /* CredentialBase.h in Headers */ = {isa = PBXBuildFile; fileRef = 379291781985EF3900F4B661 /* CredentialBase.h */; settings = {ATTRIBUTES = (Private, ); }; };
     1317                3792917D1987678F00F4B661 /* CredentialCocoa.mm in Sources */ = {isa = PBXBuildFile; fileRef = 3792917B1987678F00F4B661 /* CredentialCocoa.mm */; };
     1318                3792917E1987678F00F4B661 /* CredentialCocoa.h in Headers */ = {isa = PBXBuildFile; fileRef = 3792917C1987678F00F4B661 /* CredentialCocoa.h */; settings = {ATTRIBUTES = (Private, ); }; };
    13171319                379919961200DDF400EA041C /* WOFFFileFormat.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 379919941200DDF400EA041C /* WOFFFileFormat.cpp */; };
    13181320                379919971200DDF400EA041C /* WOFFFileFormat.h in Headers */ = {isa = PBXBuildFile; fileRef = 379919951200DDF400EA041C /* WOFFFileFormat.h */; };
     
    83418343                37919C220B7D188600A56998 /* PositionIterator.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = PositionIterator.h; sourceTree = "<group>"; };
    83428344                379291781985EF3900F4B661 /* CredentialBase.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CredentialBase.h; sourceTree = "<group>"; };
     8345                3792917B1987678F00F4B661 /* CredentialCocoa.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = CredentialCocoa.mm; path = cocoa/CredentialCocoa.mm; sourceTree = "<group>"; };
     8346                3792917C1987678F00F4B661 /* CredentialCocoa.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CredentialCocoa.h; path = cocoa/CredentialCocoa.h; sourceTree = "<group>"; };
    83438347                379919941200DDF400EA041C /* WOFFFileFormat.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WOFFFileFormat.cpp; sourceTree = "<group>"; };
    83448348                379919951200DDF400EA041C /* WOFFFileFormat.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WOFFFileFormat.h; sourceTree = "<group>"; };
     
    1676816772                        isa = PBXGroup;
    1676916773                        children = (
     16774                                3792917C1987678F00F4B661 /* CredentialCocoa.h */,
     16775                                3792917B1987678F00F4B661 /* CredentialCocoa.mm */,
    1677016776                                372ADA37197F47B900FC501E /* ProtectionSpaceCocoa.h */,
    1677116777                                372ADA39197F687600FC501E /* ProtectionSpaceCocoa.mm */,
     
    2567525681                                ABB5419F0ACDDFE4002820EB /* RenderListBox.h in Headers */,
    2567625682                                A8EA7A520A191A5200A8EF5F /* RenderListItem.h in Headers */,
     25683                                3792917E1987678F00F4B661 /* CredentialCocoa.h in Headers */,
    2567725684                                A8EA7A500A191A5200A8EF5F /* RenderListMarker.h in Headers */,
    2567825685                                0F56028F0E4B76580065B038 /* RenderMarquee.h in Headers */,
     
    2866528672                                B2FA3DC60AB75A6F000E5AC4 /* JSSVGPathSegCurvetoQuadraticAbs.cpp in Sources */,
    2866628673                                B2FA3DC80AB75A6F000E5AC4 /* JSSVGPathSegCurvetoQuadraticRel.cpp in Sources */,
     28674                                3792917D1987678F00F4B661 /* CredentialCocoa.mm in Sources */,
    2866728675                                B2FA3DCA0AB75A6F000E5AC4 /* JSSVGPathSegCurvetoQuadraticSmoothAbs.cpp in Sources */,
    2866828676                                B2FA3DCC0AB75A6F000E5AC4 /* JSSVGPathSegCurvetoQuadraticSmoothRel.cpp in Sources */,
  • trunk/Source/WebCore/platform/network/Credential.h

    r171722 r171747  
    2727#define Credential_h
    2828
     29#if PLATFORM(COCOA)
     30#include "CredentialCocoa.h"
     31#else
     32
    2933#include "CredentialBase.h"
     34
     35// FIXME: Remove this macro once it is not used in WebKit.
     36#define CERTIFICATE_CREDENTIALS_SUPPORTED 0
    3037
    3138namespace WebCore {
     
    4754    {
    4855    }
    49 
    50 #if CERTIFICATE_CREDENTIALS_SUPPORTED
    51     Credential(SecIdentityRef identity, CFArrayRef certificates, CredentialPersistence persistence)
    52         : CredentialBase(identity, certificates, persistence)
    53     {
    54     }
    55 #endif
    5656};
    5757
    5858}
    5959
     60#endif
     61
    6062#endif // Credential_h
  • trunk/Source/WebCore/platform/network/CredentialBase.cpp

    r171722 r171747  
    3434// combined with the semantics of the String(NSString*) constructor
    3535CredentialBase::CredentialBase()
    36     : m_user("")
    37     , m_password("")
     36    : m_user(emptyString())
     37    , m_password(emptyString())
    3838    , m_persistence(CredentialPersistenceNone)
    39 #if CERTIFICATE_CREDENTIALS_SUPPORTED
    40     , m_type(CredentialTypePassword)
    41 #endif   
    4239{
    4340}
     
    4643// combined with the semantics of the String(NSString*) constructor
    4744CredentialBase::CredentialBase(const String& user, const String& password, CredentialPersistence persistence)
    48     : m_user(user.length() ? user : "")
    49     , m_password(password.length() ? password : "")
     45    : m_user(user.length() ? user : emptyString())
     46    , m_password(password.length() ? password : emptyString())
    5047    , m_persistence(persistence)
    51 #if CERTIFICATE_CREDENTIALS_SUPPORTED
    52     , m_type(CredentialTypePassword)
    53 #endif
    5448{
    5549}
     
    5953    , m_password(original.password())
    6054    , m_persistence(persistence)
    61 #if CERTIFICATE_CREDENTIALS_SUPPORTED
    62     , m_identity(original.identity())
    63     , m_certificates(original.certificates())
    64     , m_type(original.type())
    65 #endif
    6655{
    6756}
     
    6958bool CredentialBase::isEmpty() const
    7059{
    71 #if CERTIFICATE_CREDENTIALS_SUPPORTED
    72     if (m_type == CredentialTypeClientCertificate && (m_identity || m_certificates))
    73         return false;
    74 #endif
    75    
    7660    return m_user.isEmpty() && m_password.isEmpty();
    7761}
     
    9680    return m_persistence;
    9781}
    98    
    99 #if CERTIFICATE_CREDENTIALS_SUPPORTED
    100 CredentialBase::CredentialBase(SecIdentityRef identity, CFArrayRef certificates, CredentialPersistence persistence)
    101     : m_user("")
    102     , m_password("")
    103     , m_persistence(persistence)
    104     , m_identity(identity)
    105     , m_certificates(certificates)
    106     , m_type(CredentialTypeClientCertificate)
    107 {
    108 }
    109    
    110 SecIdentityRef CredentialBase::identity() const
    111 {
    112     return m_identity.get();
    113 }
    114    
    115 CFArrayRef CredentialBase::certificates() const
    116 {
    117     return m_certificates.get();
    118 }
    119    
    120 CredentialType CredentialBase::type() const
    121 {
    122     return m_type;
    123 }
    124 #endif
    12582
    126 bool operator==(const Credential& a, const Credential& b)
     83bool CredentialBase::compare(const Credential& a, const Credential& b)
    12784{
    12885    // Check persistence first since all credential types
     
    13087    if (a.persistence() != b.persistence())
    13188        return false;
    132    
    133 #if CERTIFICATE_CREDENTIALS_SUPPORTED
    134     CredentialType aType = a.type();
    135     if (aType != b.type())
    136         return false;
    137    
    138     // Comparing identity and certificate chain pointers is valid only
    139     // for client certificate type credentials.
    140     //
    141     // FIXME: Is pointer comparison of the identity and certificates properties sufficient?
    142     if (aType == CredentialTypeClientCertificate) {
    143         if (a.identity() != b.identity())
    144             return false;
    145         if (a.certificates() != b.certificates())
    146             return false;
    147        
    148         // We only need to check identity and certificates to compare
    149         // client certificate based credentials.
    150         return true;
    151     }
    152    
    153     ASSERT(a.type() == CredentialTypePassword && b.type() == CredentialTypePassword);
    154 #endif   
    155    
    15689    if (a.user() != b.user())
    15790        return false;
     
    15992        return false;
    16093       
    161     return true;
     94    return Credential::platformCompare(a, b);
    16295}
    16396
  • trunk/Source/WebCore/platform/network/CredentialBase.h

    r171722 r171747  
    2929#include <wtf/text/WTFString.h>
    3030
    31 #define CERTIFICATE_CREDENTIALS_SUPPORTED (PLATFORM(COCOA))
    32 
    33 #if CERTIFICATE_CREDENTIALS_SUPPORTED
    34 #include <Security/SecBase.h>
    35 #include <wtf/RetainPtr.h>
    36 #endif
    37 
    3831namespace WebCore {
    3932
     
    4538    CredentialPersistencePermanent
    4639};
    47 
    48 #if CERTIFICATE_CREDENTIALS_SUPPORTED
    49 enum CredentialType {
    50     CredentialTypePassword,
    51     CredentialTypeClientCertificate
    52 };
    53 #endif
    5440
    5541class CredentialBase {
     
    6349    CredentialPersistence persistence() const;
    6450   
    65 #if CERTIFICATE_CREDENTIALS_SUPPORTED
    66     SecIdentityRef identity() const;
    67     CFArrayRef certificates() const;
    68     CredentialType type() const;
    69 #endif   
    70    
     51    static bool compare(const Credential&, const Credential&);
     52
    7153protected:
    7254    CredentialBase();
    7355    CredentialBase(const String& user, const String& password, CredentialPersistence);
    7456    CredentialBase(const Credential& original, CredentialPersistence);
    75 #if CERTIFICATE_CREDENTIALS_SUPPORTED
    76     CredentialBase(SecIdentityRef, CFArrayRef certificates, CredentialPersistence);
    77 #endif
    78    
     57
     58    static bool platformCompare(const Credential&, const Credential&) { return true; }
     59
    7960private:
    8061    String m_user;
    8162    String m_password;
    8263    CredentialPersistence m_persistence;
    83 #if CERTIFICATE_CREDENTIALS_SUPPORTED
    84     RetainPtr<SecIdentityRef> m_identity;
    85     RetainPtr<CFArrayRef> m_certificates;
    86     CredentialType m_type;
    87 #endif
    8864};
    8965
    90 bool operator==(const Credential& a, const Credential& b);
     66inline bool operator==(const Credential& a, const Credential& b) { return CredentialBase::compare(a, b); }
    9167inline bool operator!=(const Credential& a, const Credential& b) { return !(a == b); }
    9268   
    9369};
     70
    9471#endif
  • trunk/Source/WebCore/platform/network/mac/AuthenticationMac.mm

    r171540 r171747  
    243243    }
    244244
    245 #if CERTIFICATE_CREDENTIALS_SUPPORTED
    246245    if (coreCredential.type() == CredentialTypeClientCertificate) {
    247246        return [[[NSURLCredential alloc] initWithIdentity:coreCredential.identity()
     
    250249                                              autorelease];
    251250    }
    252 #endif
    253251
    254252    return [[[NSURLCredential alloc] initWithUser:coreCredential.user()
     
    279277    }
    280278
    281 #if CERTIFICATE_CREDENTIALS_SUPPORTED
    282279    SecIdentityRef identity = [macCredential identity];
    283280    if (identity)
    284281        return Credential(identity, (CFArrayRef)[macCredential certificates], persistence);
    285 #endif
    286282   
    287283    return Credential([macCredential user], [macCredential password], persistence);
Note: See TracChangeset for help on using the changeset viewer.