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;
58 bool SupportsWebpAnimated()
const;
60 bool CanPreloadResources()
const;
61 bool AcceptsGzip()
const;
62 UserAgentMatcher::DeviceType GetDeviceType()
const;
63 bool IsMobile()
const {
64 return GetDeviceType() == UserAgentMatcher::kMobile;
66 bool IsTablet()
const {
67 return GetDeviceType() == UserAgentMatcher::kTablet;
80 static const int kMediumScreenWidthThreshold = 720;
81 static const int kLargeScreenWidthThreshold = 1500;
82 bool ForbidWebpInlining()
const;
84 bool RequestsSaveData()
const;
85 bool HasViaHeader()
const;
88 friend class ImageRewriteTest;
91 GoogleString user_agent_;
92 GoogleString accept_header_;
93 UserAgentMatcher* ua_matcher_;
95 mutable LazyBool supports_critical_css_;
96 mutable LazyBool supports_image_inlining_;
97 mutable LazyBool supports_js_defer_;
98 mutable LazyBool supports_lazyload_images_;
99 mutable LazyBool requests_save_data_;
100 mutable LazyBool accepts_webp_;
101 mutable LazyBool accepts_gzip_;
102 mutable LazyBool supports_webp_rewritten_urls_;
103 mutable LazyBool supports_webp_lossless_alpha_;
104 mutable LazyBool supports_webp_animated_;
105 mutable LazyBool is_bot_;
106 mutable LazyBool is_mobile_user_agent_;
107 mutable LazyBool supports_split_html_;
108 mutable LazyBool supports_flush_early_;
109 const std::vector<int>* preferred_webp_qualities_;
110 const std::vector<int>* preferred_jpeg_qualities_;
112 mutable LazyBool device_type_set_;
113 mutable UserAgentMatcher::DeviceType device_type_;
114 mutable LazyBool has_via_header_;
ImageQualityPreference
Definition: device_properties.h:70
bool SupportsWebpInPlace() const
The request asks for high image quality.
Definition: device_properties.h:78
The request asks for low image quality.
Definition: device_properties.h:74
Definition: device_properties.h:32
Server uses its own default image quality.
Definition: device_properties.h:72
The request asks for medium image quality.
Definition: device_properties.h:76
bool SupportsWebpRewrittenUrls() const
void ParseRequestHeaders(const RequestHeaders &request_headers)
Definition: request_properties.h:37