00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00018
00019 #ifndef NET_INSTAWEB_REWRITER_PUBLIC_STATIC_JAVASCRIPT_MANAGER_H_
00020 #define NET_INSTAWEB_REWRITER_PUBLIC_STATIC_JAVASCRIPT_MANAGER_H_
00021
00022 #include <vector>
00023 #include "net/instaweb/util/public/basictypes.h"
00024 #include "net/instaweb/util/public/string.h"
00025
00026 namespace net_instaweb {
00027
00028 class RewriteOptions;
00029 class UrlNamer;
00030
00032 class StaticJavascriptManager {
00033 public:
00034 static const char kGStaticBase[];
00035 static const char kBlinkGstaticSuffix[];
00036 static const char kBlinkRelativePath[];
00037
00038 enum JsModule {
00039 kDeferJs,
00040 kDelayImagesJs,
00041 kDelayImagesInlineJs,
00042 kDeterministicJs,
00043 kLazyloadImagesJs,
00044 kDetectReflowJs,
00045 kLocalStorageCacheJs,
00046 kEndOfModules,
00047 };
00048
00049 StaticJavascriptManager(
00050 UrlNamer* url_namer,
00051 bool serve_js_from_gstatic,
00052 const GoogleString& blink_hash);
00053
00054 ~StaticJavascriptManager();
00055
00058 const GoogleString& GetBlinkJsUrl(const RewriteOptions* options) const;
00059
00060 const char* GetJsSnippet(JsModule module,
00061 const RewriteOptions* options);
00062
00063 private:
00064 typedef std::vector<const char*> StaticJsVector;
00066 StaticJsVector opt_js_vector_;
00067 StaticJsVector debug_js_vector_;
00068
00070 void InitBlink(const GoogleString& hash);
00071
00072 void InitializeJsStrings();
00073
00075 UrlNamer* url_namer_;
00076 bool serve_js_from_gstatic_;
00077 GoogleString blink_javascript_gstatic_url_;
00078 GoogleString blink_javascript_handler_url_;
00079
00080 DISALLOW_COPY_AND_ASSIGN(StaticJavascriptManager);
00081 };
00082
00083 }
00084
00085 #endif ///< NET_INSTAWEB_REWRITER_PUBLIC_STATIC_JAVASCRIPT_MANAGER_H_