Page Speed Optimization Libraries
1.8.31.3
|
00001 // Copyright 2013 Google Inc. All Rights Reserved. 00014 00015 #ifndef NET_INSTAWEB_REWRITER_PUBLIC_REQUEST_PROPERTIES_H_ 00016 #define NET_INSTAWEB_REWRITER_PUBLIC_REQUEST_PROPERTIES_H_ 00017 00018 #include <vector> 00019 00020 #include "net/instaweb/http/public/user_agent_matcher.h" 00021 #include "net/instaweb/rewriter/public/device_properties.h" 00022 #include "net/instaweb/util/public/basictypes.h" 00023 #include "net/instaweb/util/public/gtest_prod.h" 00024 #include "net/instaweb/util/public/string_util.h" 00025 #include "pagespeed/kernel/base/scoped_ptr.h" 00026 00027 namespace net_instaweb { 00028 00029 class DownstreamCachingDirectives; 00030 class AbstractLogRecord; 00031 class RequestHeaders; 00032 00039 class RequestProperties { 00040 public: 00041 explicit RequestProperties(UserAgentMatcher* matcher); 00042 virtual ~RequestProperties(); 00043 00045 void SetUserAgent(const StringPiece& user_agent_string); 00048 void ParseRequestHeaders(const RequestHeaders& request_headers); 00049 00050 bool SupportsImageInlining() const; 00051 bool SupportsLazyloadImages() const; 00052 bool SupportsCriticalCss() const; 00053 bool SupportsCriticalCssBeacon() const; 00054 bool SupportsCriticalImagesBeacon() const; 00055 bool SupportsJsDefer(bool enable_mobile) const; 00059 bool SupportsWebpInPlace() const; 00060 bool SupportsWebpRewrittenUrls() const; 00061 bool SupportsWebpLosslessAlpha() const; 00062 bool IsBot() const; 00063 bool SupportsSplitHtml(bool enable_mobile) const; 00064 bool CanPreloadResources() const; 00065 bool GetScreenResolution(int* width, int* height) const; 00066 UserAgentMatcher::DeviceType GetDeviceType() const; 00067 bool IsMobile() const; 00068 00071 void SetPreferredImageQualities( 00072 const std::vector<int>* webp, const std::vector<int>* jpeg); 00074 bool GetPreferredImageQualities( 00075 DeviceProperties::ImageQualityPreference preference, int* webp, int* jpeg) 00076 const; 00077 static int GetPreferredImageQualityCount(); 00078 00079 void LogDeviceInfo(AbstractLogRecord* log_record, 00080 bool enable_aggressive_rewriters_for_mobile); 00081 00082 private: 00083 friend class ImageRewriteTest; 00084 FRIEND_TEST(ImageRewriteTest, SquashImagesForMobileScreen); 00085 FRIEND_TEST(RequestPropertiesTest, GetScreenGroupIndex); 00086 00087 void SetScreenResolution(int width, int height) const; 00088 00089 scoped_ptr<DeviceProperties> device_properties_; 00090 scoped_ptr<DownstreamCachingDirectives> downstream_caching_directives_; 00091 00092 mutable LazyBool supports_image_inlining_; 00093 mutable LazyBool supports_js_defer_; 00094 mutable LazyBool supports_lazyload_images_; 00095 mutable LazyBool supports_webp_in_place_; 00096 mutable LazyBool supports_webp_rewritten_urls_; 00097 mutable LazyBool supports_webp_lossless_alpha_; 00098 00099 DISALLOW_COPY_AND_ASSIGN(RequestProperties); 00100 }; 00101 00102 } 00103 00104 #endif ///< NET_INSTAWEB_REWRITER_PUBLIC_REQUEST_PROPERTIES_H_