OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2011 Google 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 are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * 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 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 13 matching lines...) Expand all Loading... |
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
29 */ | 29 */ |
30 | 30 |
31 #include "config.h" | 31 #include "config.h" |
32 #include "platform/mhtml/MHTMLArchive.h" | 32 #include "platform/mhtml/MHTMLArchive.h" |
33 | 33 |
| 34 #include "platform/DateComponents.h" |
34 #include "platform/MIMETypeRegistry.h" | 35 #include "platform/MIMETypeRegistry.h" |
35 #include "platform/SerializedResource.h" | 36 #include "platform/SerializedResource.h" |
36 #include "platform/SharedBuffer.h" | 37 #include "platform/SharedBuffer.h" |
37 #include "platform/mhtml/MHTMLParser.h" | 38 #include "platform/mhtml/MHTMLParser.h" |
38 #include "platform/text/QuotedPrintable.h" | 39 #include "platform/text/QuotedPrintable.h" |
39 #include "platform/weborigin/SchemeRegistry.h" | 40 #include "platform/weborigin/SchemeRegistry.h" |
40 #include "wtf/CryptographicallyRandomNumber.h" | 41 #include "wtf/CryptographicallyRandomNumber.h" |
41 #include "wtf/DateMath.h" | 42 #include "wtf/DateMath.h" |
42 #include "wtf/GregorianDateTime.h" | |
43 #include "wtf/text/Base64.h" | 43 #include "wtf/text/Base64.h" |
44 #include "wtf/text/StringBuilder.h" | 44 #include "wtf/text/StringBuilder.h" |
45 | 45 |
46 namespace WebCore { | 46 namespace WebCore { |
47 | 47 |
48 const char* const quotedPrintable = "quoted-printable"; | 48 const char* const quotedPrintable = "quoted-printable"; |
49 const char* const base64 = "base64"; | 49 const char* const base64 = "base64"; |
50 const char* const binary = "binary"; | 50 const char* const binary = "binary"; |
51 | 51 |
52 static String generateRandomBoundary() | 52 static String generateRandomBoundary() |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 archive->addSubresource(parser.subResourceAt(j)); | 117 archive->addSubresource(parser.subResourceAt(j)); |
118 } | 118 } |
119 return mainArchive.release(); | 119 return mainArchive.release(); |
120 } | 120 } |
121 | 121 |
122 PassRefPtr<SharedBuffer> MHTMLArchive::generateMHTMLData(const Vector<Serialized
Resource>& resources, EncodingPolicy encodingPolicy, const String& title, const
String& mimeType) | 122 PassRefPtr<SharedBuffer> MHTMLArchive::generateMHTMLData(const Vector<Serialized
Resource>& resources, EncodingPolicy encodingPolicy, const String& title, const
String& mimeType) |
123 { | 123 { |
124 String boundary = generateRandomBoundary(); | 124 String boundary = generateRandomBoundary(); |
125 String endOfResourceBoundary = "--" + boundary + "\r\n"; | 125 String endOfResourceBoundary = "--" + boundary + "\r\n"; |
126 | 126 |
127 GregorianDateTime now; | 127 DateComponents now; |
128 now.setToCurrentLocalTime(); | 128 now.setMillisecondsSinceEpochForDateTime(currentTimeMS()); |
129 String dateString = makeRFC2822DateString(now.weekDay(), now.monthDay(), now
.month(), now.year(), now.hour(), now.minute(), now.second(), now.utcOffset() /
60); | 129 String dateString = makeRFC2822DateString(now.weekDay(), now.monthDay(), now
.month(), now.fullYear(), now.hour(), now.minute(), now.second(), 0); |
130 | 130 |
131 StringBuilder stringBuilder; | 131 StringBuilder stringBuilder; |
132 stringBuilder.append("From: <Saved by WebKit>\r\n"); | 132 stringBuilder.append("From: <Saved by WebKit>\r\n"); |
133 stringBuilder.append("Subject: "); | 133 stringBuilder.append("Subject: "); |
134 // We replace non ASCII characters with '?' characters to match IE's behavio
r. | 134 // We replace non ASCII characters with '?' characters to match IE's behavio
r. |
135 stringBuilder.append(replaceNonPrintableCharacters(title)); | 135 stringBuilder.append(replaceNonPrintableCharacters(title)); |
136 stringBuilder.append("\r\nDate: "); | 136 stringBuilder.append("\r\nDate: "); |
137 stringBuilder.append(dateString); | 137 stringBuilder.append(dateString); |
138 stringBuilder.append("\r\nMIME-Version: 1.0\r\n"); | 138 stringBuilder.append("\r\nMIME-Version: 1.0\r\n"); |
139 stringBuilder.append("Content-Type: multipart/related;\r\n"); | 139 stringBuilder.append("Content-Type: multipart/related;\r\n"); |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
225 for (Vector<RefPtr<MHTMLArchive> >::iterator it = m_subframeArchives.begin()
; it != m_subframeArchives.end(); ++it) { | 225 for (Vector<RefPtr<MHTMLArchive> >::iterator it = m_subframeArchives.begin()
; it != m_subframeArchives.end(); ++it) { |
226 if (!clearedArchives->contains(*it)) { | 226 if (!clearedArchives->contains(*it)) { |
227 clearedArchives->append(*it); | 227 clearedArchives->append(*it); |
228 (*it)->clearAllSubframeArchivesImpl(clearedArchives); | 228 (*it)->clearAllSubframeArchivesImpl(clearedArchives); |
229 } | 229 } |
230 } | 230 } |
231 m_subframeArchives.clear(); | 231 m_subframeArchives.clear(); |
232 } | 232 } |
233 | 233 |
234 } | 234 } |
OLD | NEW |