Page Speed Optimization Libraries
1.4.26.1
|
00001 // Copyright 2012 Google Inc. All Rights Reserved. 00014 00015 #ifndef NET_INSTAWEB_HTTP_PUBLIC_DEVICE_PROPERTIES_H_ 00016 #define NET_INSTAWEB_HTTP_PUBLIC_DEVICE_PROPERTIES_H_ 00017 00018 #include "net/instaweb/util/public/basictypes.h" 00019 #include "net/instaweb/util/public/gtest_prod.h" 00020 #include "net/instaweb/util/public/string.h" 00021 #include "net/instaweb/util/public/string_util.h" 00022 00023 namespace net_instaweb { 00024 00025 class UserAgentMatcher; 00026 00029 class DeviceProperties { 00030 public: 00031 explicit DeviceProperties(UserAgentMatcher* matcher); 00032 virtual ~DeviceProperties(); 00033 00034 void set_user_agent(const StringPiece& user_agent_string); 00035 bool SupportsImageInlining() const; 00036 bool SupportsLazyloadImages() const; 00037 bool SupportsCriticalImagesBeacon() const; 00038 bool SupportsJsDefer(bool enable_mobile) const; 00039 bool SupportsWebp() const; 00040 bool SupportsWebpLosslessAlpha() const; 00041 bool IsBot() const; 00042 bool IsMobileUserAgent() const; 00043 bool SupportsSplitHtml(bool enable_mobile) const; 00044 bool CanPreloadResources() const; 00045 bool GetScreenResolution(int* width, int* height) const; 00046 00047 private: 00048 friend class ImageRewriteTest; 00049 FRIEND_TEST(ImageRewriteTest, SquashImagesForMobileScreen); 00050 void SetScreenResolution(int width, int height) const; 00051 00052 GoogleString user_agent_; 00053 UserAgentMatcher* ua_matcher_; 00054 00055 mutable LazyBool supports_image_inlining_; 00056 mutable LazyBool supports_js_defer_; 00057 mutable LazyBool supports_lazyload_images_; 00058 mutable LazyBool supports_webp_; 00059 mutable LazyBool supports_webp_lossless_alpha_; 00060 mutable LazyBool is_bot_; 00061 mutable LazyBool is_mobile_user_agent_; 00062 mutable LazyBool supports_split_html_; 00063 mutable LazyBool supports_flush_early_; 00064 mutable LazyBool screen_dimensions_set_; 00065 mutable int screen_width_; 00066 mutable int screen_height_; 00067 00068 DISALLOW_COPY_AND_ASSIGN(DeviceProperties); 00069 }; 00070 00071 } 00072 00073 #endif ///< NET_INSTAWEB_HTTP_PUBLIC_DEVICE_PROPERTIES_H_