Page Speed Optimization Libraries  1.3.25.1
net/instaweb/http/public/device_properties.h
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_util.h"
00021 
00022 namespace net_instaweb {
00023 
00024 class UserAgentMatcher;
00025 class RequestHeaders;
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 SupportsCriticalImagesBeacon() const;
00037   bool SupportsJsDefer(bool enable_mobile) const;
00038   bool SupportsWebp() const;
00039   bool SupportsWebpLosslessAlpha() const;
00040   bool IsMobileUserAgent() const;
00041   bool SupportsSplitHtml(bool enable_mobile) const;
00042   bool CanPreloadResources(const RequestHeaders* request_headers) const;
00043   bool GetScreenResolution(int* width, int* height) const;
00044 
00045  private:
00046   friend class ImageRewriteTest;
00047   FRIEND_TEST(ImageRewriteTest, SquashImagesForMobileScreen);
00048   void SetScreenResolution(int width, int height) const;
00049 
00050   GoogleString user_agent_;
00051   UserAgentMatcher* ua_matcher_;
00052 
00053   mutable LazyBool supports_image_inlining_;
00054   mutable LazyBool supports_js_defer_;
00055   mutable LazyBool supports_webp_;
00056   mutable LazyBool supports_webp_lossless_alpha_;
00057   mutable LazyBool is_mobile_user_agent_;
00058   mutable LazyBool supports_split_html_;
00059   mutable LazyBool supports_flush_early_;
00060   mutable LazyBool screen_dimensions_set_;
00061   mutable int screen_width_;
00062   mutable int screen_height_;
00063 
00064   DISALLOW_COPY_AND_ASSIGN(DeviceProperties);
00065 };
00066 
00067 }  
00068 
00069 #endif  ///< NET_INSTAWEB_HTTP_PUBLIC_DEVICE_PROPERTIES_H_
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines