~alinuxninja/nginx-edge/trunk

« back to all changes in this revision

Viewing changes to debian/modules/ngx_pagespeed/psol/include/net/instaweb/rewriter/public/js_disable_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 2010 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: gagansingh@google.com (Gagan Singh)
18
 
 
19
 
#ifndef NET_INSTAWEB_REWRITER_PUBLIC_JS_DISABLE_FILTER_H_
20
 
#define NET_INSTAWEB_REWRITER_PUBLIC_JS_DISABLE_FILTER_H_
21
 
 
22
 
#include "net/instaweb/http/public/user_agent_matcher.h"
23
 
#include "net/instaweb/rewriter/public/common_filter.h"
24
 
#include "net/instaweb/rewriter/public/script_tag_scanner.h"
25
 
#include "net/instaweb/util/public/basictypes.h"
26
 
#include "net/instaweb/util/public/string.h"
27
 
 
28
 
namespace net_instaweb {
29
 
 
30
 
class HtmlElement;
31
 
class RewriteDriver;
32
 
 
33
 
// Disables javscript by converting input html:
34
 
//   <script src="1.js">var a = 1...</script>
35
 
// to:
36
 
//   <noscript disabled="true">
37
 
//     <script src="1.js">var a = 1...</script>
38
 
//   </noscript>
39
 
//
40
 
class JsDisableFilter : public CommonFilter {
41
 
 public:
42
 
  explicit JsDisableFilter(RewriteDriver* driver);
43
 
  ~JsDisableFilter();
44
 
 
45
 
  static const char kEnableJsExperimental[];
46
 
  static const char kElementOnloadCode[];
47
 
 
48
 
  virtual void DetermineEnabled(GoogleString* disabled_reason);
49
 
 
50
 
  virtual const char* Name() const {
51
 
    return "JsDisableFilter";
52
 
  }
53
 
 
54
 
 private:
55
 
  virtual void StartDocumentImpl();
56
 
 
57
 
  virtual void StartElementImpl(HtmlElement* element);
58
 
 
59
 
  virtual void EndElementImpl(HtmlElement* element);
60
 
 
61
 
  virtual void EndDocument();
62
 
 
63
 
  // Inserts the experimental js enable/disable code.
64
 
  void InsertJsDeferExperimentalScript();
65
 
 
66
 
  // Insert meta tag with 'X-UA-Compatible'. This will avoid IE going to quirks
67
 
  // mode. More information about this can be found in
68
 
  // http://webdesign.about.com/od/metataglibraries/p/x-ua-compatible-meta-tag.htm
69
 
  void InsertMetaTagForIE(HtmlElement* element);
70
 
 
71
 
  ScriptTagScanner script_tag_scanner_;
72
 
  int index_;
73
 
  bool ie_meta_tag_written_;
74
 
  int prefetch_js_elements_count_;
75
 
  int max_prefetch_js_elements_;
76
 
  GoogleString prefetch_js_elements_;
77
 
  bool should_look_for_prefetch_js_elements_;
78
 
  UserAgentMatcher::PrefetchMechanism prefetch_mechanism_;
79
 
 
80
 
  DISALLOW_COPY_AND_ASSIGN(JsDisableFilter);
81
 
};
82
 
 
83
 
}  // namespace net_instaweb
84
 
 
85
 
#endif  // NET_INSTAWEB_REWRITER_PUBLIC_JS_DISABLE_FILTER_H_