Path: blob/trunk/third_party/closure/goog/useragent/product.js
4079 views
/**1* @license2* Copyright The Closure Library Authors.3* SPDX-License-Identifier: Apache-2.04*/56/**7* @fileoverview Detects the specific browser and not just the rendering engine.8*/910goog.provide('goog.userAgent.product');1112goog.require('goog.labs.userAgent.browser');13goog.require('goog.labs.userAgent.platform');14goog.require('goog.userAgent');151617/**18* @define {boolean} Whether the code is running on the Firefox web browser.19*/20goog.userAgent.product.ASSUME_FIREFOX =21goog.define('goog.userAgent.product.ASSUME_FIREFOX', false);222324/**25* @define {boolean} Whether we know at compile-time that the product is an26* iPhone.27*/28goog.userAgent.product.ASSUME_IPHONE =29goog.define('goog.userAgent.product.ASSUME_IPHONE', false);303132/**33* @define {boolean} Whether we know at compile-time that the product is an34* iPad.35*/36goog.userAgent.product.ASSUME_IPAD =37goog.define('goog.userAgent.product.ASSUME_IPAD', false);383940/**41* @define {boolean} Whether we know at compile-time that the product is an42* AOSP browser or WebView inside a pre KitKat Android phone or tablet.43*/44goog.userAgent.product.ASSUME_ANDROID =45goog.define('goog.userAgent.product.ASSUME_ANDROID', false);464748/**49* @define {boolean} Whether the code is running on the Chrome web browser on50* any platform or AOSP browser or WebView in a KitKat+ Android phone or tablet.51*/52goog.userAgent.product.ASSUME_CHROME =53goog.define('goog.userAgent.product.ASSUME_CHROME', false);545556/**57* @define {boolean} Whether the code is running on the Safari web browser.58*/59goog.userAgent.product.ASSUME_SAFARI =60goog.define('goog.userAgent.product.ASSUME_SAFARI', false);616263/**64* Whether we know the product type at compile-time.65* @type {boolean}66* @private67*/68goog.userAgent.product.PRODUCT_KNOWN_ = goog.userAgent.ASSUME_IE ||69goog.userAgent.ASSUME_EDGE || goog.userAgent.ASSUME_OPERA ||70goog.userAgent.product.ASSUME_FIREFOX ||71goog.userAgent.product.ASSUME_IPHONE ||72goog.userAgent.product.ASSUME_IPAD ||73goog.userAgent.product.ASSUME_ANDROID ||74goog.userAgent.product.ASSUME_CHROME ||75goog.userAgent.product.ASSUME_SAFARI;767778/**79* Whether the code is running on the Opera web browser.80* @type {boolean}81*/82goog.userAgent.product.OPERA = goog.userAgent.OPERA;838485/**86* Whether the code is running on an IE web browser.87* @type {boolean}88*/89goog.userAgent.product.IE = goog.userAgent.IE;909192/**93* Whether the code is running on an Edge web browser (EdgeHTML based).94* @type {boolean}95*/96goog.userAgent.product.EDGE = goog.userAgent.EDGE;979899/**100* Whether the code is running on the Firefox web browser.101* @type {boolean}102*/103goog.userAgent.product.FIREFOX = goog.userAgent.product.PRODUCT_KNOWN_ ?104goog.userAgent.product.ASSUME_FIREFOX :105goog.labs.userAgent.browser.isFirefox();106107108/**109* Whether the user agent is an iPhone or iPod (as in iPod touch).110* @return {boolean}111* @private112*/113goog.userAgent.product.isIphoneOrIpod_ = function() {114'use strict';115return goog.labs.userAgent.platform.isIphone() ||116goog.labs.userAgent.platform.isIpod();117};118119120/**121* Whether the code is running on an iPhone or iPod touch.122*123* iPod touch is considered an iPhone for legacy reasons.124* @type {boolean}125*/126goog.userAgent.product.IPHONE = goog.userAgent.product.PRODUCT_KNOWN_ ?127goog.userAgent.product.ASSUME_IPHONE :128goog.userAgent.product.isIphoneOrIpod_();129130131/**132* Whether the code is running on an iPad.133* @type {boolean}134*/135goog.userAgent.product.IPAD = goog.userAgent.product.PRODUCT_KNOWN_ ?136goog.userAgent.product.ASSUME_IPAD :137goog.labs.userAgent.platform.isIpad();138139140/**141* Whether the code is running on AOSP browser or WebView inside142* a pre KitKat Android phone or tablet.143* @type {boolean}144*/145goog.userAgent.product.ANDROID = goog.userAgent.product.PRODUCT_KNOWN_ ?146goog.userAgent.product.ASSUME_ANDROID :147goog.labs.userAgent.browser.isAndroidBrowser();148149150/**151* Whether the code is running on any Chromium-based web browser on any platform152* or AOSP browser or WebView in a KitKat+ Android phone or tablet.153* @type {boolean}154*/155goog.userAgent.product.CHROME = goog.userAgent.product.PRODUCT_KNOWN_ ?156goog.userAgent.product.ASSUME_CHROME :157goog.labs.userAgent.browser.isChrome();158159160/**161* @return {boolean} Whether the browser is Safari on desktop.162* @private163*/164goog.userAgent.product.isSafariDesktop_ = function() {165'use strict';166return goog.labs.userAgent.browser.isSafari() &&167!goog.labs.userAgent.platform.isIos();168};169170171/**172* Whether the code is running on the desktop Safari web browser.173* Note: the legacy behavior here is only true for Safari not running174* on iOS.175* @type {boolean}176*/177goog.userAgent.product.SAFARI = goog.userAgent.product.PRODUCT_KNOWN_ ?178goog.userAgent.product.ASSUME_SAFARI :179goog.userAgent.product.isSafariDesktop_();180181182