~alinuxninja/nginx-edge/trunk

« back to all changes in this revision

Viewing changes to debian/modules/ngx_pagespeed/psol/include/net/instaweb/rewriter/public/defer_iframe_filter.h

  • Committer: Vivian
  • Date: 2015-12-04 18:20:11 UTC
  • Revision ID: git-v1:a36f2bc32e884f7473b3a47040e5411306144d7d
* Do not extract psol.tar.gz

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * Copyright 2012 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
 
 */
16
 
 
17
 
// Author: pulkitg@google.com (Pulkit Goyal)
18
 
//
19
 
// Contains the implementation of the DeferIframeFilter which defers the iframe
20
 
// using JsDeferDisabledJavascriptFilter. This filter should be called before
21
 
// JsDeferDisabledJavascriptFilter. This filter renames all the iframe tags to
22
 
// pagespeed_iframe and add a script which converts pagespeed_iframe back to
23
 
// iframe and the added script is deferred by JsDeferDisabledJavascriptFilter.
24
 
//
25
 
// Html input to this filter looks like:
26
 
// <html>
27
 
//  <head>
28
 
//  </head>
29
 
//  <body>
30
 
//   <iframe src="1.html"></iframe>
31
 
//  </body>
32
 
// </html>
33
 
//
34
 
// Output for the above html will be:
35
 
// <html>
36
 
//  <head>
37
 
//  </head>
38
 
//  <body>
39
 
//   <script>
40
 
//    defer_iframe script.
41
 
//   </script>
42
 
//   <pagespeed_iframe src="1.html">
43
 
//    <script>
44
 
//     Script which changes above pagespeed_iframe tag name to iframe.
45
 
//    </script>
46
 
//   </pagespeed_iframe>
47
 
//  </body>
48
 
// </html>
49
 
//
50
 
// Above script which converts pagespeed_iframe to iframe will be deferred
51
 
// by JsDeferDisabledJavascriptFilter, hence loading of iframe is also deferred.
52
 
 
53
 
#ifndef NET_INSTAWEB_REWRITER_PUBLIC_DEFER_IFRAME_FILTER_H_
54
 
#define NET_INSTAWEB_REWRITER_PUBLIC_DEFER_IFRAME_FILTER_H_
55
 
 
56
 
#include "net/instaweb/rewriter/public/common_filter.h"
57
 
#include "net/instaweb/util/public/basictypes.h"
58
 
 
59
 
namespace net_instaweb {
60
 
 
61
 
class HtmlElement;
62
 
class RewriteDriver;
63
 
class StaticAssetManager;
64
 
 
65
 
class DeferIframeFilter : public CommonFilter {
66
 
 public:
67
 
  static const char kDeferIframeInit[];
68
 
  static const char kDeferIframeIframeJs[];
69
 
  explicit DeferIframeFilter(RewriteDriver* driver);
70
 
  ~DeferIframeFilter();
71
 
 
72
 
  virtual void StartDocumentImpl();
73
 
  virtual void StartElementImpl(HtmlElement* element);
74
 
  virtual void EndElementImpl(HtmlElement* element);
75
 
  virtual void DetermineEnabled(GoogleString* disabled_reason);
76
 
 
77
 
  virtual const char* Name() const { return "DeferIframe"; }
78
 
 
79
 
 private:
80
 
  StaticAssetManager* static_asset_manager_;
81
 
  bool script_inserted_;
82
 
 
83
 
  DISALLOW_COPY_AND_ASSIGN(DeferIframeFilter);
84
 
};
85
 
 
86
 
}  // namespace net_instaweb
87
 
 
88
 
#endif  // NET_INSTAWEB_REWRITER_PUBLIC_DEFER_IFRAME_FILTER_H_