48 #ifndef NET_INSTAWEB_REWRITER_PUBLIC_GOOGLE_ANALYTICS_FILTER_H_
49 #define NET_INSTAWEB_REWRITER_PUBLIC_GOOGLE_ANALYTICS_FILTER_H_
60 namespace net_instaweb {
62 class HtmlCharactersNode;
63 class HtmlCommentNode;
65 class HtmlIEDirectiveNode;
75 kGaJsScriptSrcLoad = 0,
81 GoogleString::size_type pos,
82 GoogleString::size_type len,
85 HtmlElement* GetScriptElement()
const {
return script_element_; }
87 return script_characters_node_;
89 Type GetType()
const {
return editor_type_; }
91 void NewContents(
const StringPiece &replacement,
98 GoogleString::size_type pos_;
99 GoogleString::size_type len_;
110 typedef StringPieceVector MethodVector;
119 MethodVector* glue_methods,
120 MethodVector* unhandled_methods);
122 static void InitStats(
Statistics* statistics);
129 virtual void Flush();
139 virtual const char*
Name()
const {
return "GoogleAnalytics"; }
142 static const char kPageLoadCount[];
143 static const char kRewrittenCount[];
148 bool MatchSyncLoad(StringPiece contents,
149 GoogleString::size_type* pos,
150 GoogleString::size_type* len)
const;
151 bool MatchSyncInit(StringPiece contents,
152 GoogleString::size_type start_pos,
153 GoogleString::size_type* pos,
154 GoogleString::size_type* len)
const;
155 bool MatchUnhandledCalls(StringPiece contents,
156 GoogleString::size_type start_pos)
const;
157 void FindRewritableScripts();
159 bool RewriteAsAsync();
163 std::vector<ScriptEditor*> script_editors_;
virtual void StartDocument()
virtual void StartElement(HtmlElement *element)
Definition: google_analytics_filter.h:108
virtual void Cdata(HtmlCdataNode *cdata)
Called for CDATA blocks (e.g. <![CDATA[foobar]]>)
Definition: statistics.h:43
Leaf node representing raw characters in HTML.
Definition: html_node.h:167
Definition: empty_html_filter.h:37
Base class for implementations of monitoring statistics.
Definition: statistics.h:342
Definition: html_parse.h:88
virtual void IEDirective(HtmlIEDirectiveNode *directive)
Definition: html_element.h:42
virtual void EndDocument()
ScriptUsage GetScriptUsage() const override
Definition: google_analytics_filter.h:140
std::string GoogleString
PAGESPEED_KERNEL_BASE_STRING_H_.
Definition: string.h:24
ScriptUsage
Describes a filter's relationship with scripts.
Definition: html_filter.h:38
Definition: html_filter.h:43
virtual const char * Name() const
The name of this filter – used for logging and debugging.
Definition: google_analytics_filter.h:139
virtual void Characters(HtmlCharactersNode *characters_node)
Expected HTML Events in <script> elements.
Leaf node representing a CDATA section.
Definition: html_node.h:147
Leaf node representing an HTML IE directive.
Definition: html_node.h:213
Edit a substring in a script element.
Definition: google_analytics_filter.h:72
virtual void Comment(HtmlCommentNode *comment)
Unexpected HTML Events in <script> elements.