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 30 matching lines...) Expand all Loading... |
41 | 41 |
42 namespace blink { | 42 namespace blink { |
43 | 43 |
44 class Attribute; | 44 class Attribute; |
45 class CSSRule; | 45 class CSSRule; |
46 class CSSStyleSheet; | 46 class CSSStyleSheet; |
47 class CSSValue; | 47 class CSSValue; |
48 class Document; | 48 class Document; |
49 class Element; | 49 class Element; |
50 class FontResource; | 50 class FontResource; |
51 class ImageResource; | 51 class ImageResourceContent; |
52 class LocalFrame; | 52 class LocalFrame; |
53 class Resource; | |
54 class SharedBuffer; | 53 class SharedBuffer; |
55 class StylePropertySet; | 54 class StylePropertySet; |
56 | 55 |
57 struct SerializedResource; | 56 struct SerializedResource; |
58 | 57 |
59 // This class is used to serialize frame's contents back to text (typically | 58 // This class is used to serialize frame's contents back to text (typically |
60 // HTML). It serializes frame's document and resources such as images and CSS | 59 // HTML). It serializes frame's document and resources such as images and CSS |
61 // stylesheets. | 60 // stylesheets. |
62 class CORE_EXPORT FrameSerializer final { | 61 class CORE_EXPORT FrameSerializer final { |
63 STACK_ALLOCATED(); | 62 STACK_ALLOCATED(); |
64 | 63 |
65 public: | 64 public: |
| 65 enum ResourceHasCacheControlNoStoreHeader { |
| 66 NoCacheControlNoStoreHeader, |
| 67 HasCacheControlNoStoreHeader |
| 68 }; |
| 69 |
66 class Delegate { | 70 class Delegate { |
67 public: | 71 public: |
68 // Controls whether HTML serialization should skip the given attribute. | 72 // Controls whether HTML serialization should skip the given attribute. |
69 virtual bool shouldIgnoreAttribute(const Element&, const Attribute&) { | 73 virtual bool shouldIgnoreAttribute(const Element&, const Attribute&) { |
70 return false; | 74 return false; |
71 } | 75 } |
72 | 76 |
73 // Method allowing the Delegate control which URLs are written into the | 77 // Method allowing the Delegate control which URLs are written into the |
74 // generated html document. | 78 // generated html document. |
75 // | 79 // |
76 // When URL of the element needs to be rewritten, this method should | 80 // When URL of the element needs to be rewritten, this method should |
77 // return true and populate |rewrittenLink| with a desired value of the | 81 // return true and populate |rewrittenLink| with a desired value of the |
78 // html attribute value to be used in place of the original link. | 82 // html attribute value to be used in place of the original link. |
79 // (i.e. in place of img.src or iframe.src or object.data). | 83 // (i.e. in place of img.src or iframe.src or object.data). |
80 // | 84 // |
81 // If no link rewriting is desired, this method should return false. | 85 // If no link rewriting is desired, this method should return false. |
82 virtual bool rewriteLink(const Element&, String& rewrittenLink) { | 86 virtual bool rewriteLink(const Element&, String& rewrittenLink) { |
83 return false; | 87 return false; |
84 } | 88 } |
85 | 89 |
86 // Tells whether to skip serialization of a subresource or CSSStyleSheet | 90 // Tells whether to skip serialization of a subresource or CSSStyleSheet |
87 // with a given URI. Used to deduplicate resources across multiple frames. | 91 // with a given URI. Used to deduplicate resources across multiple frames. |
88 virtual bool shouldSkipResourceWithURL(const KURL&) { return false; } | 92 virtual bool shouldSkipResourceWithURL(const KURL&) { return false; } |
89 | 93 |
90 // Tells whether to skip serialization of a subresource. | 94 // Tells whether to skip serialization of a subresource. |
91 virtual bool shouldSkipResource(const Resource&) { return false; } | 95 virtual bool shouldSkipResource(ResourceHasCacheControlNoStoreHeader) { |
| 96 return false; |
| 97 } |
92 | 98 |
93 // Returns custom attributes that need to add in order to serialize the | 99 // Returns custom attributes that need to add in order to serialize the |
94 // element. | 100 // element. |
95 virtual Vector<Attribute> getCustomAttributes(const Element&) { | 101 virtual Vector<Attribute> getCustomAttributes(const Element&) { |
96 return Vector<Attribute>(); | 102 return Vector<Attribute>(); |
97 } | 103 } |
98 }; | 104 }; |
99 | 105 |
100 // Constructs a serializer that will write output to the given vector of | 106 // Constructs a serializer that will write output to the given vector of |
101 // SerializedResources and uses the Delegate for controlling some | 107 // SerializedResources and uses the Delegate for controlling some |
(...skipping 14 matching lines...) Expand all Loading... |
116 // is not-empty. It also adds any resources included in that stylesheet | 122 // is not-empty. It also adds any resources included in that stylesheet |
117 // (including any imported stylesheets and their own resources). | 123 // (including any imported stylesheets and their own resources). |
118 void serializeCSSStyleSheet(CSSStyleSheet&, const KURL&); | 124 void serializeCSSStyleSheet(CSSStyleSheet&, const KURL&); |
119 | 125 |
120 // Serializes the css rule (including any imported stylesheets), adding | 126 // Serializes the css rule (including any imported stylesheets), adding |
121 // referenced resources. | 127 // referenced resources. |
122 void serializeCSSRule(CSSRule*); | 128 void serializeCSSRule(CSSRule*); |
123 | 129 |
124 bool shouldAddURL(const KURL&); | 130 bool shouldAddURL(const KURL&); |
125 | 131 |
126 void addToResources(const Resource&, | 132 void addToResources(const String& mimeType, |
| 133 ResourceHasCacheControlNoStoreHeader, |
127 PassRefPtr<const SharedBuffer>, | 134 PassRefPtr<const SharedBuffer>, |
128 const KURL&); | 135 const KURL&); |
129 void addImageToResources(ImageResource*, const KURL&); | 136 void addImageToResources(ImageResourceContent*, const KURL&); |
130 void addFontToResources(FontResource*); | 137 void addFontToResources(FontResource*); |
131 | 138 |
132 void retrieveResourcesForProperties(const StylePropertySet*, Document&); | 139 void retrieveResourcesForProperties(const StylePropertySet*, Document&); |
133 void retrieveResourcesForCSSValue(const CSSValue&, Document&); | 140 void retrieveResourcesForCSSValue(const CSSValue&, Document&); |
134 | 141 |
135 Vector<SerializedResource>* m_resources; | 142 Vector<SerializedResource>* m_resources; |
136 HashSet<KURL> m_resourceURLs; | 143 HashSet<KURL> m_resourceURLs; |
137 | 144 |
138 bool m_isSerializingCss; | 145 bool m_isSerializingCss; |
139 | 146 |
140 Delegate& m_delegate; | 147 Delegate& m_delegate; |
141 }; | 148 }; |
142 | 149 |
143 } // namespace blink | 150 } // namespace blink |
144 | 151 |
145 #endif // FrameSerializer_h | 152 #endif // FrameSerializer_h |
OLD | NEW |