| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2008, 2009 Apple Inc. All rights reserved. | 2 * Copyright (C) 2008, 2009 Apple Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * | 7 * |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 if (data) | 87 if (data) |
| 88 cfData.adoptCF(data->createCFData()); | 88 cfData.adoptCF(data->createCFData()); |
| 89 else | 89 else |
| 90 cfData.adoptCF(CFDataCreate(0, 0, 0)); | 90 cfData.adoptCF(CFDataCreate(0, 0, 0)); |
| 91 CFDictionarySetValue(propertyList.get(), LegacyWebArchiveResourceDataKey, cf
Data.get()); | 91 CFDictionarySetValue(propertyList.get(), LegacyWebArchiveResourceDataKey, cf
Data.get()); |
| 92 | 92 |
| 93 // Resource URL cannot be null | 93 // Resource URL cannot be null |
| 94 if (RetainPtr<CFStringRef> cfURL = resource->url().string().createCFString()
) | 94 if (RetainPtr<CFStringRef> cfURL = resource->url().string().createCFString()
) |
| 95 CFDictionarySetValue(propertyList.get(), LegacyWebArchiveResourceURLKey,
cfURL.get()); | 95 CFDictionarySetValue(propertyList.get(), LegacyWebArchiveResourceURLKey,
cfURL.get()); |
| 96 else { | 96 else { |
| 97 LOG(Archives, "LegacyWebArchive - NULL resource URL is invalid - returni
ng null property list"); | 97 LOG_INFO(Archives, "LegacyWebArchive - NULL resource URL is invalid - re
turning null property list"); |
| 98 return 0; | 98 return 0; |
| 99 } | 99 } |
| 100 | 100 |
| 101 // FrameName should be left out if empty for subresources, but always includ
ed for main resources | 101 // FrameName should be left out if empty for subresources, but always includ
ed for main resources |
| 102 const String& frameName(resource->frameName()); | 102 const String& frameName(resource->frameName()); |
| 103 if (!frameName.isEmpty() || isMainResource) | 103 if (!frameName.isEmpty() || isMainResource) |
| 104 CFDictionarySetValue(propertyList.get(), LegacyWebArchiveResourceFrameNa
meKey, frameName.createCFString().get()); | 104 CFDictionarySetValue(propertyList.get(), LegacyWebArchiveResourceFrameNa
meKey, frameName.createCFString().get()); |
| 105 | 105 |
| 106 // Set MIMEType, TextEncodingName, and ResourceResponse only if they actuall
y exist | 106 // Set MIMEType, TextEncodingName, and ResourceResponse only if they actuall
y exist |
| 107 const String& mimeType(resource->mimeType()); | 107 const String& mimeType(resource->mimeType()); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 132 return 0; | 132 return 0; |
| 133 CFDictionarySetValue(propertyList.get(), LegacyWebArchiveMainResourceKey, ma
inResourceDict.get()); | 133 CFDictionarySetValue(propertyList.get(), LegacyWebArchiveMainResourceKey, ma
inResourceDict.get()); |
| 134 | 134 |
| 135 RetainPtr<CFMutableArrayRef> subresourcesArray(AdoptCF, CFArrayCreateMutable
(0, archive->subresources().size(), &kCFTypeArrayCallBacks)); | 135 RetainPtr<CFMutableArrayRef> subresourcesArray(AdoptCF, CFArrayCreateMutable
(0, archive->subresources().size(), &kCFTypeArrayCallBacks)); |
| 136 const Vector<RefPtr<ArchiveResource> >& subresources(archive->subresources()
); | 136 const Vector<RefPtr<ArchiveResource> >& subresources(archive->subresources()
); |
| 137 for (unsigned i = 0; i < subresources.size(); ++i) { | 137 for (unsigned i = 0; i < subresources.size(); ++i) { |
| 138 RetainPtr<CFDictionaryRef> subresource = createPropertyListRepresentatio
n(subresources[i].get(), Subresource); | 138 RetainPtr<CFDictionaryRef> subresource = createPropertyListRepresentatio
n(subresources[i].get(), Subresource); |
| 139 if (subresource) | 139 if (subresource) |
| 140 CFArrayAppendValue(subresourcesArray.get(), subresource.get()); | 140 CFArrayAppendValue(subresourcesArray.get(), subresource.get()); |
| 141 else | 141 else |
| 142 LOG(Archives, "LegacyWebArchive - Failed to create property list for
subresource"); | 142 LOG_INFO(Archives, "LegacyWebArchive - Failed to create property lis
t for subresource"); |
| 143 } | 143 } |
| 144 if (CFArrayGetCount(subresourcesArray.get())) | 144 if (CFArrayGetCount(subresourcesArray.get())) |
| 145 CFDictionarySetValue(propertyList.get(), LegacyWebArchiveSubresourcesKey
, subresourcesArray.get()); | 145 CFDictionarySetValue(propertyList.get(), LegacyWebArchiveSubresourcesKey
, subresourcesArray.get()); |
| 146 | 146 |
| 147 RetainPtr<CFMutableArrayRef> subframesArray(AdoptCF, CFArrayCreateMutable(0,
archive->subframeArchives().size(), &kCFTypeArrayCallBacks)); | 147 RetainPtr<CFMutableArrayRef> subframesArray(AdoptCF, CFArrayCreateMutable(0,
archive->subframeArchives().size(), &kCFTypeArrayCallBacks)); |
| 148 const Vector<RefPtr<Archive> >& subframeArchives(archive->subframeArchives()
); | 148 const Vector<RefPtr<Archive> >& subframeArchives(archive->subframeArchives()
); |
| 149 for (unsigned i = 0; i < subframeArchives.size(); ++i) { | 149 for (unsigned i = 0; i < subframeArchives.size(); ++i) { |
| 150 RetainPtr<CFDictionaryRef> subframeArchive = createPropertyListRepresent
ation(subframeArchives[i].get()); | 150 RetainPtr<CFDictionaryRef> subframeArchive = createPropertyListRepresent
ation(subframeArchives[i].get()); |
| 151 if (subframeArchive) | 151 if (subframeArchive) |
| 152 CFArrayAppendValue(subframesArray.get(), subframeArchive.get()); | 152 CFArrayAppendValue(subframesArray.get(), subframeArchive.get()); |
| 153 else | 153 else |
| 154 LOG(Archives, "LegacyWebArchive - Failed to create property list for
subframe archive"); | 154 LOG_INFO(Archives, "LegacyWebArchive - Failed to create property lis
t for subframe archive"); |
| 155 } | 155 } |
| 156 if (CFArrayGetCount(subframesArray.get())) | 156 if (CFArrayGetCount(subframesArray.get())) |
| 157 CFDictionarySetValue(propertyList.get(), LegacyWebArchiveSubframeArchive
sKey, subframesArray.get()); | 157 CFDictionarySetValue(propertyList.get(), LegacyWebArchiveSubframeArchive
sKey, subframesArray.get()); |
| 158 | 158 |
| 159 return propertyList; | 159 return propertyList; |
| 160 } | 160 } |
| 161 | 161 |
| 162 ResourceResponse LegacyWebArchive::createResourceResponseFromPropertyListData(CF
DataRef data, CFStringRef responseDataType) | 162 ResourceResponse LegacyWebArchive::createResourceResponseFromPropertyListData(CF
DataRef data, CFStringRef responseDataType) |
| 163 { | 163 { |
| 164 ASSERT(data); | 164 ASSERT(data); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 176 } | 176 } |
| 177 | 177 |
| 178 PassRefPtr<ArchiveResource> LegacyWebArchive::createResource(CFDictionaryRef dic
tionary) | 178 PassRefPtr<ArchiveResource> LegacyWebArchive::createResource(CFDictionaryRef dic
tionary) |
| 179 { | 179 { |
| 180 ASSERT(dictionary); | 180 ASSERT(dictionary); |
| 181 if (!dictionary) | 181 if (!dictionary) |
| 182 return 0; | 182 return 0; |
| 183 | 183 |
| 184 CFDataRef resourceData = static_cast<CFDataRef>(CFDictionaryGetValue(diction
ary, LegacyWebArchiveResourceDataKey)); | 184 CFDataRef resourceData = static_cast<CFDataRef>(CFDictionaryGetValue(diction
ary, LegacyWebArchiveResourceDataKey)); |
| 185 if (resourceData && CFGetTypeID(resourceData) != CFDataGetTypeID()) { | 185 if (resourceData && CFGetTypeID(resourceData) != CFDataGetTypeID()) { |
| 186 LOG(Archives, "LegacyWebArchive - Resource data is not of type CFData, c
annot create invalid resource"); | 186 LOG_INFO(Archives, "LegacyWebArchive - Resource data is not of type CFDa
ta, cannot create invalid resource"); |
| 187 return 0; | 187 return 0; |
| 188 } | 188 } |
| 189 | 189 |
| 190 CFStringRef frameName = static_cast<CFStringRef>(CFDictionaryGetValue(dictio
nary, LegacyWebArchiveResourceFrameNameKey)); | 190 CFStringRef frameName = static_cast<CFStringRef>(CFDictionaryGetValue(dictio
nary, LegacyWebArchiveResourceFrameNameKey)); |
| 191 if (frameName && CFGetTypeID(frameName) != CFStringGetTypeID()) { | 191 if (frameName && CFGetTypeID(frameName) != CFStringGetTypeID()) { |
| 192 LOG(Archives, "LegacyWebArchive - Frame name is not of type CFString, ca
nnot create invalid resource"); | 192 LOG_INFO(Archives, "LegacyWebArchive - Frame name is not of type CFStrin
g, cannot create invalid resource"); |
| 193 return 0; | 193 return 0; |
| 194 } | 194 } |
| 195 | 195 |
| 196 CFStringRef mimeType = static_cast<CFStringRef>(CFDictionaryGetValue(diction
ary, LegacyWebArchiveResourceMIMETypeKey)); | 196 CFStringRef mimeType = static_cast<CFStringRef>(CFDictionaryGetValue(diction
ary, LegacyWebArchiveResourceMIMETypeKey)); |
| 197 if (mimeType && CFGetTypeID(mimeType) != CFStringGetTypeID()) { | 197 if (mimeType && CFGetTypeID(mimeType) != CFStringGetTypeID()) { |
| 198 LOG(Archives, "LegacyWebArchive - MIME type is not of type CFString, can
not create invalid resource"); | 198 LOG_INFO(Archives, "LegacyWebArchive - MIME type is not of type CFString
, cannot create invalid resource"); |
| 199 return 0; | 199 return 0; |
| 200 } | 200 } |
| 201 | 201 |
| 202 CFStringRef url = static_cast<CFStringRef>(CFDictionaryGetValue(dictionary,
LegacyWebArchiveResourceURLKey)); | 202 CFStringRef url = static_cast<CFStringRef>(CFDictionaryGetValue(dictionary,
LegacyWebArchiveResourceURLKey)); |
| 203 if (url && CFGetTypeID(url) != CFStringGetTypeID()) { | 203 if (url && CFGetTypeID(url) != CFStringGetTypeID()) { |
| 204 LOG(Archives, "LegacyWebArchive - URL is not of type CFString, cannot cr
eate invalid resource"); | 204 LOG_INFO(Archives, "LegacyWebArchive - URL is not of type CFString, cann
ot create invalid resource"); |
| 205 return 0; | 205 return 0; |
| 206 } | 206 } |
| 207 | 207 |
| 208 CFStringRef textEncoding = static_cast<CFStringRef>(CFDictionaryGetValue(dic
tionary, LegacyWebArchiveResourceTextEncodingNameKey)); | 208 CFStringRef textEncoding = static_cast<CFStringRef>(CFDictionaryGetValue(dic
tionary, LegacyWebArchiveResourceTextEncodingNameKey)); |
| 209 if (textEncoding && CFGetTypeID(textEncoding) != CFStringGetTypeID()) { | 209 if (textEncoding && CFGetTypeID(textEncoding) != CFStringGetTypeID()) { |
| 210 LOG(Archives, "LegacyWebArchive - Text encoding is not of type CFString,
cannot create invalid resource"); | 210 LOG_INFO(Archives, "LegacyWebArchive - Text encoding is not of type CFSt
ring, cannot create invalid resource"); |
| 211 return 0; | 211 return 0; |
| 212 } | 212 } |
| 213 | 213 |
| 214 ResourceResponse response; | 214 ResourceResponse response; |
| 215 | 215 |
| 216 CFDataRef resourceResponseData = static_cast<CFDataRef>(CFDictionaryGetValue
(dictionary, LegacyWebArchiveResourceResponseKey)); | 216 CFDataRef resourceResponseData = static_cast<CFDataRef>(CFDictionaryGetValue
(dictionary, LegacyWebArchiveResourceResponseKey)); |
| 217 if (resourceResponseData) { | 217 if (resourceResponseData) { |
| 218 if (CFGetTypeID(resourceResponseData) != CFDataGetTypeID()) { | 218 if (CFGetTypeID(resourceResponseData) != CFDataGetTypeID()) { |
| 219 LOG(Archives, "LegacyWebArchive - Resource response data is not of t
ype CFData, cannot create invalid resource"); | 219 LOG_INFO(Archives, "LegacyWebArchive - Resource response data is not
of type CFData, cannot create invalid resource"); |
| 220 return 0; | 220 return 0; |
| 221 } | 221 } |
| 222 | 222 |
| 223 CFStringRef resourceResponseVersion = static_cast<CFStringRef>(CFDiction
aryGetValue(dictionary, LegacyWebArchiveResourceResponseVersionKey)); | 223 CFStringRef resourceResponseVersion = static_cast<CFStringRef>(CFDiction
aryGetValue(dictionary, LegacyWebArchiveResourceResponseVersionKey)); |
| 224 if (resourceResponseVersion && CFGetTypeID(resourceResponseVersion) != C
FStringGetTypeID()) { | 224 if (resourceResponseVersion && CFGetTypeID(resourceResponseVersion) != C
FStringGetTypeID()) { |
| 225 LOG(Archives, "LegacyWebArchive - Resource response version is not o
f type CFString, cannot create invalid resource"); | 225 LOG_INFO(Archives, "LegacyWebArchive - Resource response version is
not of type CFString, cannot create invalid resource"); |
| 226 return 0; | 226 return 0; |
| 227 } | 227 } |
| 228 | 228 |
| 229 response = createResourceResponseFromPropertyListData(resourceResponseDa
ta, resourceResponseVersion); | 229 response = createResourceResponseFromPropertyListData(resourceResponseDa
ta, resourceResponseVersion); |
| 230 } | 230 } |
| 231 | 231 |
| 232 return ArchiveResource::create(SharedBuffer::wrapCFData(resourceData), KURL(
KURL(), url), mimeType, textEncoding, frameName, response); | 232 return ArchiveResource::create(SharedBuffer::wrapCFData(resourceData), KURL(
KURL(), url), mimeType, textEncoding, frameName, response); |
| 233 } | 233 } |
| 234 | 234 |
| 235 PassRefPtr<LegacyWebArchive> LegacyWebArchive::create() | 235 PassRefPtr<LegacyWebArchive> LegacyWebArchive::create() |
| (...skipping 19 matching lines...) Expand all Loading... |
| 255 return archive.release(); | 255 return archive.release(); |
| 256 } | 256 } |
| 257 | 257 |
| 258 PassRefPtr<LegacyWebArchive> LegacyWebArchive::create(SharedBuffer* data) | 258 PassRefPtr<LegacyWebArchive> LegacyWebArchive::create(SharedBuffer* data) |
| 259 { | 259 { |
| 260 return create(KURL(), data); | 260 return create(KURL(), data); |
| 261 } | 261 } |
| 262 | 262 |
| 263 PassRefPtr<LegacyWebArchive> LegacyWebArchive::create(const KURL&, SharedBuffer*
data) | 263 PassRefPtr<LegacyWebArchive> LegacyWebArchive::create(const KURL&, SharedBuffer*
data) |
| 264 { | 264 { |
| 265 LOG(Archives, "LegacyWebArchive - Creating from raw data"); | 265 LOG_INFO(Archives, "LegacyWebArchive - Creating from raw data"); |
| 266 | 266 |
| 267 RefPtr<LegacyWebArchive> archive = create(); | 267 RefPtr<LegacyWebArchive> archive = create(); |
| 268 | 268 |
| 269 ASSERT(data); | 269 ASSERT(data); |
| 270 if (!data) | 270 if (!data) |
| 271 return 0; | 271 return 0; |
| 272 | 272 |
| 273 RetainPtr<CFDataRef> cfData(AdoptCF, data->createCFData()); | 273 RetainPtr<CFDataRef> cfData(AdoptCF, data->createCFData()); |
| 274 if (!cfData) | 274 if (!cfData) |
| 275 return 0; | 275 return 0; |
| 276 | 276 |
| 277 CFStringRef errorString = 0; | 277 CFStringRef errorString = 0; |
| 278 | 278 |
| 279 RetainPtr<CFDictionaryRef> plist(AdoptCF, static_cast<CFDictionaryRef>(CFPro
pertyListCreateFromXMLData(0, cfData.get(), kCFPropertyListImmutable, &errorStri
ng))); | 279 RetainPtr<CFDictionaryRef> plist(AdoptCF, static_cast<CFDictionaryRef>(CFPro
pertyListCreateFromXMLData(0, cfData.get(), kCFPropertyListImmutable, &errorStri
ng))); |
| 280 if (!plist) { | 280 if (!plist) { |
| 281 #ifndef NDEBUG | 281 #ifndef NDEBUG |
| 282 const char* cError = errorString ? CFStringGetCStringPtr(errorString, kC
FStringEncodingUTF8) : "unknown error"; | 282 const char* cError = errorString ? CFStringGetCStringPtr(errorString, kC
FStringEncodingUTF8) : "unknown error"; |
| 283 LOG(Archives, "LegacyWebArchive - Error parsing PropertyList from archiv
e data - %s", cError); | 283 LOG_INFO(Archives, "LegacyWebArchive - Error parsing PropertyList from a
rchive data - %s", cError); |
| 284 #endif | 284 #endif |
| 285 if (errorString) | 285 if (errorString) |
| 286 CFRelease(errorString); | 286 CFRelease(errorString); |
| 287 return 0; | 287 return 0; |
| 288 } | 288 } |
| 289 | 289 |
| 290 if (CFGetTypeID(plist.get()) != CFDictionaryGetTypeID()) { | 290 if (CFGetTypeID(plist.get()) != CFDictionaryGetTypeID()) { |
| 291 LOG(Archives, "LegacyWebArchive - Archive property list is not the expec
ted CFDictionary, aborting invalid WebArchive"); | 291 LOG_INFO(Archives, "LegacyWebArchive - Archive property list is not the
expected CFDictionary, aborting invalid WebArchive"); |
| 292 return 0; | 292 return 0; |
| 293 } | 293 } |
| 294 | 294 |
| 295 if (!archive->extract(plist.get())) | 295 if (!archive->extract(plist.get())) |
| 296 return 0; | 296 return 0; |
| 297 | 297 |
| 298 return archive.release(); | 298 return archive.release(); |
| 299 } | 299 } |
| 300 | 300 |
| 301 bool LegacyWebArchive::extract(CFDictionaryRef dictionary) | 301 bool LegacyWebArchive::extract(CFDictionaryRef dictionary) |
| 302 { | 302 { |
| 303 ASSERT(dictionary); | 303 ASSERT(dictionary); |
| 304 if (!dictionary) { | 304 if (!dictionary) { |
| 305 LOG(Archives, "LegacyWebArchive - Null root CFDictionary, aborting inval
id WebArchive"); | 305 LOG_INFO(Archives, "LegacyWebArchive - Null root CFDictionary, aborting
invalid WebArchive"); |
| 306 return false; | 306 return false; |
| 307 } | 307 } |
| 308 | 308 |
| 309 CFDictionaryRef mainResourceDict = static_cast<CFDictionaryRef>(CFDictionary
GetValue(dictionary, LegacyWebArchiveMainResourceKey)); | 309 CFDictionaryRef mainResourceDict = static_cast<CFDictionaryRef>(CFDictionary
GetValue(dictionary, LegacyWebArchiveMainResourceKey)); |
| 310 if (!mainResourceDict) { | 310 if (!mainResourceDict) { |
| 311 LOG(Archives, "LegacyWebArchive - No main resource in archive, aborting
invalid WebArchive"); | 311 LOG_INFO(Archives, "LegacyWebArchive - No main resource in archive, abor
ting invalid WebArchive"); |
| 312 return false; | 312 return false; |
| 313 } | 313 } |
| 314 if (CFGetTypeID(mainResourceDict) != CFDictionaryGetTypeID()) { | 314 if (CFGetTypeID(mainResourceDict) != CFDictionaryGetTypeID()) { |
| 315 LOG(Archives, "LegacyWebArchive - Main resource is not the expected CFDi
ctionary, aborting invalid WebArchive"); | 315 LOG_INFO(Archives, "LegacyWebArchive - Main resource is not the expected
CFDictionary, aborting invalid WebArchive"); |
| 316 return false; | 316 return false; |
| 317 } | 317 } |
| 318 | 318 |
| 319 setMainResource(createResource(mainResourceDict)); | 319 setMainResource(createResource(mainResourceDict)); |
| 320 if (!mainResource()) { | 320 if (!mainResource()) { |
| 321 LOG(Archives, "LegacyWebArchive - Failed to parse main resource from CFD
ictionary or main resource does not exist, aborting invalid WebArchive"); | 321 LOG_INFO(Archives, "LegacyWebArchive - Failed to parse main resource fro
m CFDictionary or main resource does not exist, aborting invalid WebArchive"); |
| 322 return false; | 322 return false; |
| 323 } | 323 } |
| 324 | 324 |
| 325 if (mainResource()->mimeType().isNull()) { | 325 if (mainResource()->mimeType().isNull()) { |
| 326 LOG(Archives, "LegacyWebArchive - Main resource MIME type is required, b
ut was null."); | 326 LOG_INFO(Archives, "LegacyWebArchive - Main resource MIME type is requir
ed, but was null."); |
| 327 return false; | 327 return false; |
| 328 } | 328 } |
| 329 | 329 |
| 330 CFArrayRef subresourceArray = static_cast<CFArrayRef>(CFDictionaryGetValue(d
ictionary, LegacyWebArchiveSubresourcesKey)); | 330 CFArrayRef subresourceArray = static_cast<CFArrayRef>(CFDictionaryGetValue(d
ictionary, LegacyWebArchiveSubresourcesKey)); |
| 331 if (subresourceArray && CFGetTypeID(subresourceArray) != CFArrayGetTypeID())
{ | 331 if (subresourceArray && CFGetTypeID(subresourceArray) != CFArrayGetTypeID())
{ |
| 332 LOG(Archives, "LegacyWebArchive - Subresources is not the expected Array
, aborting invalid WebArchive"); | 332 LOG_INFO(Archives, "LegacyWebArchive - Subresources is not the expected
Array, aborting invalid WebArchive"); |
| 333 return false; | 333 return false; |
| 334 } | 334 } |
| 335 | 335 |
| 336 if (subresourceArray) { | 336 if (subresourceArray) { |
| 337 CFIndex count = CFArrayGetCount(subresourceArray); | 337 CFIndex count = CFArrayGetCount(subresourceArray); |
| 338 for (CFIndex i = 0; i < count; ++i) { | 338 for (CFIndex i = 0; i < count; ++i) { |
| 339 CFDictionaryRef subresourceDict = static_cast<CFDictionaryRef>(CFArr
ayGetValueAtIndex(subresourceArray, i)); | 339 CFDictionaryRef subresourceDict = static_cast<CFDictionaryRef>(CFArr
ayGetValueAtIndex(subresourceArray, i)); |
| 340 if (CFGetTypeID(subresourceDict) != CFDictionaryGetTypeID()) { | 340 if (CFGetTypeID(subresourceDict) != CFDictionaryGetTypeID()) { |
| 341 LOG(Archives, "LegacyWebArchive - Subresource is not expected CF
Dictionary, aborting invalid WebArchive"); | 341 LOG_INFO(Archives, "LegacyWebArchive - Subresource is not expect
ed CFDictionary, aborting invalid WebArchive"); |
| 342 return false; | 342 return false; |
| 343 } | 343 } |
| 344 | 344 |
| 345 if (RefPtr<ArchiveResource> subresource = createResource(subresource
Dict)) | 345 if (RefPtr<ArchiveResource> subresource = createResource(subresource
Dict)) |
| 346 addSubresource(subresource.release()); | 346 addSubresource(subresource.release()); |
| 347 } | 347 } |
| 348 } | 348 } |
| 349 | 349 |
| 350 CFArrayRef subframeArray = static_cast<CFArrayRef>(CFDictionaryGetValue(dict
ionary, LegacyWebArchiveSubframeArchivesKey)); | 350 CFArrayRef subframeArray = static_cast<CFArrayRef>(CFDictionaryGetValue(dict
ionary, LegacyWebArchiveSubframeArchivesKey)); |
| 351 if (subframeArray && CFGetTypeID(subframeArray) != CFArrayGetTypeID()) { | 351 if (subframeArray && CFGetTypeID(subframeArray) != CFArrayGetTypeID()) { |
| 352 LOG(Archives, "LegacyWebArchive - Subframe archives is not the expected
Array, aborting invalid WebArchive"); | 352 LOG_INFO(Archives, "LegacyWebArchive - Subframe archives is not the expe
cted Array, aborting invalid WebArchive"); |
| 353 return false; | 353 return false; |
| 354 } | 354 } |
| 355 | 355 |
| 356 if (subframeArray) { | 356 if (subframeArray) { |
| 357 CFIndex count = CFArrayGetCount(subframeArray); | 357 CFIndex count = CFArrayGetCount(subframeArray); |
| 358 for (CFIndex i = 0; i < count; ++i) { | 358 for (CFIndex i = 0; i < count; ++i) { |
| 359 CFDictionaryRef subframeDict = static_cast<CFDictionaryRef>(CFArrayG
etValueAtIndex(subframeArray, i)); | 359 CFDictionaryRef subframeDict = static_cast<CFDictionaryRef>(CFArrayG
etValueAtIndex(subframeArray, i)); |
| 360 if (CFGetTypeID(subframeDict) != CFDictionaryGetTypeID()) { | 360 if (CFGetTypeID(subframeDict) != CFDictionaryGetTypeID()) { |
| 361 LOG(Archives, "LegacyWebArchive - Subframe array is not expected
CFDictionary, aborting invalid WebArchive"); | 361 LOG_INFO(Archives, "LegacyWebArchive - Subframe array is not exp
ected CFDictionary, aborting invalid WebArchive"); |
| 362 return false; | 362 return false; |
| 363 } | 363 } |
| 364 | 364 |
| 365 RefPtr<LegacyWebArchive> subframeArchive = create(); | 365 RefPtr<LegacyWebArchive> subframeArchive = create(); |
| 366 if (subframeArchive->extract(subframeDict)) | 366 if (subframeArchive->extract(subframeDict)) |
| 367 addSubframeArchive(subframeArchive.release()); | 367 addSubframeArchive(subframeArchive.release()); |
| 368 else | 368 else |
| 369 LOG(Archives, "LegacyWebArchive - Invalid subframe archive skipp
ed"); | 369 LOG_INFO(Archives, "LegacyWebArchive - Invalid subframe archive
skipped"); |
| 370 } | 370 } |
| 371 } | 371 } |
| 372 | 372 |
| 373 return true; | 373 return true; |
| 374 } | 374 } |
| 375 | 375 |
| 376 Archive::Type LegacyWebArchive::type() const | 376 Archive::Type LegacyWebArchive::type() const |
| 377 { | 377 { |
| 378 return Archive::WebArchive; | 378 return Archive::WebArchive; |
| 379 } | 379 } |
| 380 | 380 |
| 381 RetainPtr<CFDataRef> LegacyWebArchive::rawDataRepresentation() | 381 RetainPtr<CFDataRef> LegacyWebArchive::rawDataRepresentation() |
| 382 { | 382 { |
| 383 RetainPtr<CFDictionaryRef> propertyList = createPropertyListRepresentation(t
his); | 383 RetainPtr<CFDictionaryRef> propertyList = createPropertyListRepresentation(t
his); |
| 384 ASSERT(propertyList); | 384 ASSERT(propertyList); |
| 385 if (!propertyList) { | 385 if (!propertyList) { |
| 386 LOG(Archives, "LegacyWebArchive - Failed to create property list for arc
hive, returning no data"); | 386 LOG_INFO(Archives, "LegacyWebArchive - Failed to create property list fo
r archive, returning no data"); |
| 387 return 0; | 387 return 0; |
| 388 } | 388 } |
| 389 | 389 |
| 390 RetainPtr<CFWriteStreamRef> stream(AdoptCF, CFWriteStreamCreateWithAllocated
Buffers(0, 0)); | 390 RetainPtr<CFWriteStreamRef> stream(AdoptCF, CFWriteStreamCreateWithAllocated
Buffers(0, 0)); |
| 391 | 391 |
| 392 CFWriteStreamOpen(stream.get()); | 392 CFWriteStreamOpen(stream.get()); |
| 393 CFPropertyListWriteToStream(propertyList.get(), stream.get(), kCFPropertyLis
tBinaryFormat_v1_0, 0); | 393 CFPropertyListWriteToStream(propertyList.get(), stream.get(), kCFPropertyLis
tBinaryFormat_v1_0, 0); |
| 394 | 394 |
| 395 RetainPtr<CFDataRef> plistData(AdoptCF, static_cast<CFDataRef>(CFWriteStream
CopyProperty(stream.get(), kCFStreamPropertyDataWritten))); | 395 RetainPtr<CFDataRef> plistData(AdoptCF, static_cast<CFDataRef>(CFWriteStream
CopyProperty(stream.get(), kCFStreamPropertyDataWritten))); |
| 396 ASSERT(plistData); | 396 ASSERT(plistData); |
| 397 | 397 |
| 398 CFWriteStreamClose(stream.get()); | 398 CFWriteStreamClose(stream.get()); |
| 399 | 399 |
| 400 if (!plistData) { | 400 if (!plistData) { |
| 401 LOG(Archives, "LegacyWebArchive - Failed to convert property list into r
aw data, returning no data"); | 401 LOG_INFO(Archives, "LegacyWebArchive - Failed to convert property list i
nto raw data, returning no data"); |
| 402 return 0; | 402 return 0; |
| 403 } | 403 } |
| 404 | 404 |
| 405 return plistData; | 405 return plistData; |
| 406 } | 406 } |
| 407 | 407 |
| 408 #if !PLATFORM(MAC) | 408 #if !PLATFORM(MAC) |
| 409 | 409 |
| 410 ResourceResponse LegacyWebArchive::createResourceResponseFromMacArchivedData(CFD
ataRef responseData) | 410 ResourceResponse LegacyWebArchive::createResourceResponseFromMacArchivedData(CFD
ataRef responseData) |
| 411 { | 411 { |
| (...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 611 | 611 |
| 612 Vector<PassRefPtr<LegacyWebArchive> > subframeArchives; | 612 Vector<PassRefPtr<LegacyWebArchive> > subframeArchives; |
| 613 subframeArchives.append(archive); | 613 subframeArchives.append(archive); |
| 614 | 614 |
| 615 archive = create(iframeResource.release(), subresources, subframeArchives); | 615 archive = create(iframeResource.release(), subresources, subframeArchives); |
| 616 | 616 |
| 617 return archive.release(); | 617 return archive.release(); |
| 618 } | 618 } |
| 619 | 619 |
| 620 } | 620 } |
| OLD | NEW |