Page Speed Optimization Libraries  1.13.35.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | List of all members
net_instaweb::UserAgentMatcher Class Reference

#include "user_agent_matcher.h"

Public Types

enum  DeviceType { kDesktop, kTablet, kMobile, kEndOfDeviceType }
 

Public Member Functions

bool IsIe (const StringPiece &user_agent) const
 
bool IsIe9 (const StringPiece &user_agent) const
 
virtual bool SupportsImageInlining (const StringPiece &user_agent) const
 
bool SupportsLazyloadImages (StringPiece user_agent) const
 
virtual DeviceType GetDeviceTypeForUA (const StringPiece &user_agent) const
 Returns the DeviceType for the given user agent string.
 
virtual DeviceType GetDeviceTypeForUAAndHeaders (const StringPiece &user_agent, const RequestHeaders *request_headers) const
 
bool SupportsJsDefer (const StringPiece &user_agent, bool allow_mobile) const
 
bool LegacyWebp (const StringPiece &user_agent) const
 
bool SupportsWebpLosslessAlpha (const StringPiece &user_agent) const
 
bool SupportsWebpAnimated (const StringPiece &user_agent) const
 
bool SupportsDnsPrefetchUsingRelPrefetch (const StringPiece &user_agent) const
 
bool SupportsDnsPrefetch (const StringPiece &user_agent) const
 
virtual bool IsAndroidUserAgent (const StringPiece &user_agent) const
 
virtual bool IsiOSUserAgent (const StringPiece &user_agent) const
 
virtual bool GetChromeBuildNumber (const StringPiece &user_agent, int *major, int *minor, int *build, int *patch) const
 
bool UserAgentExceedsChromeAndroidBuildAndPatch (const StringPiece &user_agent, int required_build, int required_patch) const
 
bool UserAgentExceedsChromeiOSBuildAndPatch (const StringPiece &user_agent, int required_build, int required_patch) const
 
bool UserAgentExceedsChromeBuildAndPatch (const StringPiece &user_agent, int required_build, int required_patch) const
 
bool SupportsMobilization (StringPiece user_agent) const
 

Static Public Member Functions

static StringPiece DeviceTypeString (DeviceType device_type)
 
static StringPiece DeviceTypeSuffix (DeviceType device_type)
 Returns the suffix for the given device_type.
 

Static Public Attributes

static const char kTestUserAgentWebP []
 
static const char kTestUserAgentNoWebP []
 Note that this must not contain the substring "webp". More...
 

Detailed Description

This class contains various user agent based checks. Currently all of these are based on simple wildcard based white- and black-lists.

Todo:
TODO(sriharis): Split the functionality here into two: a matcher that pulls out all relevant information from UA strings (browser-family, version, mobile/tablet/desktop, etc.), and a query interface that can be used by clients.

Member Enumeration Documentation

Enumerator
kEndOfDeviceType 

This should always be the last type. This is used to mark the size of an array containing various DeviceTypes.

Member Function Documentation

static StringPiece net_instaweb::UserAgentMatcher::DeviceTypeString ( DeviceType  device_type)
static

Returns a string representing the device_type ("desktop", "tablet", or "mobile").

virtual bool net_instaweb::UserAgentMatcher::GetChromeBuildNumber ( const StringPiece &  user_agent,
int *  major,
int *  minor,
int *  build,
int *  patch 
) const
virtual

Returns false if this is not a Chrome user agent, or parsing the string build number fails.

virtual DeviceType net_instaweb::UserAgentMatcher::GetDeviceTypeForUAAndHeaders ( const StringPiece &  user_agent,
const RequestHeaders request_headers 
) const
virtual

Returns the DeviceType using the given user agent string and request headers.

bool net_instaweb::UserAgentMatcher::IsIe ( const StringPiece &  user_agent) const

Before calling IsIe, ask if you're doing the right thing: are you doing something that will mess up IE 11 in standards mode? Are you in a position where you can't tell what compatibility mode IE 11 is in? Right now we use this only to force edge compatibility mode and to work around a persistent IE Vary: caching bug.

bool net_instaweb::UserAgentMatcher::LegacyWebp ( const StringPiece &  user_agent) const

Returns true if the user agent includes a legacy browser that supports webp, but does not issue Accept:image/webp. At the moment, this means only Android 4.0+ (excluding Firefox).

bool net_instaweb::UserAgentMatcher::SupportsDnsPrefetchUsingRelPrefetch ( const StringPiece &  user_agent) const

IE9 does not implement <link rel=dns-prefetch ...>. Instead it does DNS preresolution when it sees <link rel=prefetch ...>. This method returns true if the browser support DNS prefetch using rel=prefetch. Refer: http://blogs.msdn.com/b/ie/archive/2011/03/17/internet-explorer-9-network-performance-improvements.aspx NOLINT

bool net_instaweb::UserAgentMatcher::SupportsWebpAnimated ( const StringPiece &  user_agent) const

Returns true if the user agent includes an animated WebP capable sub-string. If the browser does indeed support WebP, it also needs to send out an "accept: webp" header.

bool net_instaweb::UserAgentMatcher::SupportsWebpLosslessAlpha ( const StringPiece &  user_agent) const

Returns true if the user agent includes a string indicating WebP lossy or WebP alpha support. If the browser does indeed support WebP, it also needs to send out an "accept: webp" header.

Member Data Documentation

const char net_instaweb::UserAgentMatcher::kTestUserAgentNoWebP[]
static

Note that this must not contain the substring "webp".

non-webp user agent

const char net_instaweb::UserAgentMatcher::kTestUserAgentWebP[]
static

webp user agent


The documentation for this class was generated from the following file: