Page Speed Optimization Libraries  1.13.35.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
make_show_ads_async_filter.h
Go to the documentation of this file.
1 /*
2  * Copyright 2014 Google Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http:///www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
17 
18 #ifndef NET_INSTAWEB_REWRITER_PUBLIC_MAKE_SHOW_ADS_ASYNC_FILTER_H_
19 #define NET_INSTAWEB_REWRITER_PUBLIC_MAKE_SHOW_ADS_ASYNC_FILTER_H_
20 
29 
30 namespace net_instaweb {
31 
32 class Statistics;
33 class Variable;
34 
38  public:
39  static const char kShowAdsSnippetsConverted[];
40  static const char kShowAdsSnippetsNotConverted[];
41  static const char kShowAdsApiReplacedForAsync[];
42 
43  explicit MakeShowAdsAsyncFilter(RewriteDriver* rewrite_driver);
44  virtual ~MakeShowAdsAsyncFilter();
45 
46  static void InitStats(Statistics* statistics);
47 
49  virtual void StartDocumentImpl();
50  virtual void StartElementImpl(HtmlElement* element);
51  virtual void EndElementImpl(HtmlElement* element);
52 
54  virtual const char* Name() const {
55  return "MakeShowAdsAsyncFilter";
56  }
57  virtual void Characters(HtmlCharactersNode* characters);
58  ScriptUsage GetScriptUsage() const override { return kWillInjectScripts; }
59 
60  private:
68  bool IsApplicableShowAds(
69  const GoogleString& content,
70  ShowAdsSnippetParser::AttributeMap* parsed_attributes) const;
71 
75  void ReplaceShowAdsWithAdsByGoogleElement(
76  const ShowAdsSnippetParser::AttributeMap& parsed_attributes,
77  HtmlElement* show_ads_elment);
78  void ReplaceShowAdsApiCallWithAdsByGoogleApiCall(
79  HtmlElement* show_ads_elment);
80 
82  HtmlElement* current_script_element_;
84  GoogleString current_script_element_contents_;
85 
114  bool has_ads_by_google_js_;
120  int32 num_pending_show_ads_api_call_replacements_;
121 
122  ShowAdsSnippetParser show_ads_snippet_parser_;
123 
125  Variable* show_ads_snippets_converted_count_;
126  Variable* show_ads_snippets_not_converted_count_;
127  Variable* show_ads_api_replaced_for_async_;
128 
129 
130 };
131 
132 }
133 
134 #endif
Definition: common_filter.h:47
ScriptUsage GetScriptUsage() const override
Definition: make_show_ads_async_filter.h:58
virtual const char * Name() const
Overrides HtmlFilter.
Definition: make_show_ads_async_filter.h:54
Definition: statistics.h:43
Leaf node representing raw characters in HTML.
Definition: html_node.h:167
Class that parses showads snippets.
Definition: show_ads_snippet_parser.h:30
Base class for implementations of monitoring statistics.
Definition: statistics.h:342
virtual void StartDocumentImpl()
Overrides CommonFilter.
Definition: html_element.h:42
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: rewrite_driver.h:100
virtual void Characters(HtmlCharactersNode *characters)
Definition: make_show_ads_async_filter.h:37