Page Speed Optimization Libraries
1.6.29.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 RequestHeaders; 00031 00037 class RequestProperties { 00038 public: 00039 explicit RequestProperties(UserAgentMatcher* matcher); 00040 virtual ~RequestProperties(); 00041 00043 void set_user_agent(const StringPiece& user_agent_string); 00046 void ParseRequestHeaders(const RequestHeaders& request_headers); 00047 00048 bool SupportsImageInlining() const; 00049 bool SupportsLazyloadImages() const; 00050 bool SupportsCriticalImagesBeacon() const; 00051 bool SupportsJsDefer(bool enable_mobile) const; 00052 bool SupportsWebp() const; 00053 bool SupportsWebpLosslessAlpha() const; 00054 bool IsBot() const; 00055 bool SupportsSplitHtml(bool enable_mobile) const; 00056 bool CanPreloadResources() const; 00057 bool GetScreenResolution(int* width, int* height) const; 00058 UserAgentMatcher::DeviceType GetDeviceType() const; 00059 bool IsMobile() const; 00060 00063 void SetPreferredImageQualities( 00064 const std::vector<int>* webp, const std::vector<int>* jpeg); 00066 bool GetPreferredImageQualities( 00067 DeviceProperties::ImageQualityPreference preference, int* webp, int* jpeg) 00068 const; 00069 static int GetPreferredImageQualityCount(); 00070 00071 private: 00072 friend class ImageRewriteTest; 00073 FRIEND_TEST(ImageRewriteTest, SquashImagesForMobileScreen); 00074 FRIEND_TEST(RequestPropertiesTest, GetScreenGroupIndex); 00075 00076 void SetScreenResolution(int width, int height) const; 00077 00078 scoped_ptr<DeviceProperties> device_properties_; 00079 scoped_ptr<DownstreamCachingDirectives> downstream_caching_directives_; 00080 00081 mutable LazyBool supports_image_inlining_; 00082 mutable LazyBool supports_js_defer_; 00083 mutable LazyBool supports_lazyload_images_; 00084 mutable LazyBool supports_webp_; 00085 mutable LazyBool supports_webp_lossless_alpha_; 00086 00087 DISALLOW_COPY_AND_ASSIGN(RequestProperties); 00088 }; 00089 00090 } 00091 00092 #endif ///< NET_INSTAWEB_REWRITER_PUBLIC_REQUEST_PROPERTIES_H_