18 #ifndef NET_INSTAWEB_REWRITER_PUBLIC_MAKE_SHOW_ADS_ASYNC_FILTER_H_
19 #define NET_INSTAWEB_REWRITER_PUBLIC_MAKE_SHOW_ADS_ASYNC_FILTER_H_
23 #include "pagespeed/kernel/base/basictypes.h"
24 #include "pagespeed/kernel/base/string.h"
25 #include "pagespeed/kernel/html/html_element.h"
26 #include "pagespeed/kernel/html/html_filter.h"
27 #include "pagespeed/kernel/html/html_node.h"
28 #include "pagespeed/opt/ads/show_ads_snippet_parser.h"
30 namespace net_instaweb {
39 static const char kShowAdsSnippetsConverted[];
40 static const char kShowAdsSnippetsNotConverted[];
41 static const char kShowAdsApiReplacedForAsync[];
46 static void InitStats(Statistics* statistics);
50 virtual void StartElementImpl(HtmlElement* element);
51 virtual void EndElementImpl(HtmlElement* element);
54 virtual const char*
Name()
const {
55 return "MakeShowAdsAsyncFilter";
57 virtual void Characters(HtmlCharactersNode* characters);
58 ScriptUsage GetScriptUsage()
const override {
return kWillInjectScripts; }
68 bool IsApplicableShowAds(
69 const GoogleString& content,
70 ShowAdsSnippetParser::AttributeMap* parsed_attributes)
const;
75 void ReplaceShowAdsWithAdsByGoogleElement(
76 const ShowAdsSnippetParser::AttributeMap& parsed_attributes,
77 HtmlElement* show_ads_elment);
78 void ReplaceShowAdsApiCallWithAdsByGoogleApiCall(
79 HtmlElement* show_ads_elment);
82 HtmlElement* current_script_element_;
84 GoogleString current_script_element_contents_;
114 bool has_ads_by_google_js_;
120 int32 num_pending_show_ads_api_call_replacements_;
122 ShowAdsSnippetParser show_ads_snippet_parser_;
125 Variable* show_ads_snippets_converted_count_;
126 Variable* show_ads_snippets_not_converted_count_;
127 Variable* show_ads_api_replaced_for_async_;
Definition: common_filter.h:47
virtual const char * Name() const
Overrides HtmlFilter.
Definition: make_show_ads_async_filter.h:54
virtual void StartDocumentImpl()
Overrides CommonFilter.
Definition: rewrite_driver.h:98
virtual void Characters(HtmlCharactersNode *characters)
Definition: make_show_ads_async_filter.h:37