15 #ifndef NET_INSTAWEB_REWRITER_PUBLIC_DEVICE_PROPERTIES_H_
16 #define NET_INSTAWEB_REWRITER_PUBLIC_DEVICE_PROPERTIES_H_
20 #include "pagespeed/kernel/base/basictypes.h"
21 #include "pagespeed/kernel/base/gtest_prod.h"
22 #include "pagespeed/kernel/base/string.h"
23 #include "pagespeed/kernel/base/string_util.h"
24 #include "pagespeed/kernel/http/user_agent_matcher.h"
26 namespace net_instaweb {
37 void SetUserAgent(
const StringPiece& user_agent_string);
41 bool SupportsImageInlining()
const;
42 bool SupportsLazyloadImages()
const;
43 bool SupportsCriticalCss()
const;
44 bool SupportsCriticalImagesBeacon()
const;
45 bool SupportsJsDefer(
bool enable_mobile)
const;
57 bool SupportsWebpLosslessAlpha()
const;
59 bool SupportsSplitHtml(
bool enable_mobile)
const;
60 bool CanPreloadResources()
const;
61 bool GetScreenResolution(
int* width,
int* height)
const;
62 UserAgentMatcher::DeviceType GetDeviceType()
const;
63 bool IsMobile()
const {
64 return GetDeviceType() == UserAgentMatcher::kMobile;
77 static const int kMediumScreenWidthThreshold = 720;
78 static const int kLargeScreenWidthThreshold = 1500;
83 const std::vector<int>* webp,
const std::vector<int>* jpeg);
87 static int GetPreferredImageQualityCount();
88 bool ForbidWebpInlining()
const;
91 friend class ImageRewriteTest;
93 FRIEND_TEST(ImageRewriteTest, SquashImagesForMobileScreen);
94 FRIEND_TEST(DevicePropertiesTest, GetScreenGroupIndex);
98 static bool GetScreenGroupIndex(
int screen_width,
int* screen_index);
99 void SetScreenResolution(
int width,
int height)
const;
101 bool HasPreferredImageQualities()
const;
102 bool PossiblyMasqueradingAsChrome()
const;
104 GoogleString user_agent_;
105 GoogleString accept_header_;
106 UserAgentMatcher* ua_matcher_;
108 mutable LazyBool supports_critical_css_;
109 mutable LazyBool supports_image_inlining_;
110 mutable LazyBool supports_js_defer_;
111 mutable LazyBool supports_lazyload_images_;
112 mutable LazyBool accepts_webp_;
113 mutable LazyBool supports_webp_rewritten_urls_;
114 mutable LazyBool supports_webp_lossless_alpha_;
115 mutable LazyBool is_bot_;
116 mutable LazyBool is_mobile_user_agent_;
117 mutable LazyBool supports_split_html_;
118 mutable LazyBool supports_flush_early_;
119 mutable LazyBool screen_dimensions_set_;
120 mutable int screen_width_;
121 mutable int screen_height_;
122 const std::vector<int>* preferred_webp_qualities_;
123 const std::vector<int>* preferred_jpeg_qualities_;
125 mutable LazyBool device_type_set_;
126 mutable UserAgentMatcher::DeviceType device_type_;
ImageQualityPreference
Definition: device_properties.h:67
bool SupportsWebpInPlace() const
void SetPreferredImageQualities(const std::vector< int > *webp, const std::vector< int > *jpeg)
The request asks for high image quality.
Definition: device_properties.h:75
The request asks for low image quality.
Definition: device_properties.h:71
Definition: device_properties.h:32
Server uses its own default image quality.
Definition: device_properties.h:69
The request asks for medium image quality.
Definition: device_properties.h:73
bool SupportsWebpRewrittenUrls() const
void ParseRequestHeaders(const RequestHeaders &request_headers)
bool GetPreferredImageQualities(ImageQualityPreference preference, int *webp, int *jpeg) const
Returns true iff WebP and Jpeg image quality are set for the preference.
Definition: request_properties.h:39