Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
SeleniumHQ
GitHub Repository: SeleniumHQ/Selenium
Path: blob/trunk/third_party/closure/goog/useragent/product.js
4079 views
1
/**
2
* @license
3
* Copyright The Closure Library Authors.
4
* SPDX-License-Identifier: Apache-2.0
5
*/
6
7
/**
8
* @fileoverview Detects the specific browser and not just the rendering engine.
9
*/
10
11
goog.provide('goog.userAgent.product');
12
13
goog.require('goog.labs.userAgent.browser');
14
goog.require('goog.labs.userAgent.platform');
15
goog.require('goog.userAgent');
16
17
18
/**
19
* @define {boolean} Whether the code is running on the Firefox web browser.
20
*/
21
goog.userAgent.product.ASSUME_FIREFOX =
22
goog.define('goog.userAgent.product.ASSUME_FIREFOX', false);
23
24
25
/**
26
* @define {boolean} Whether we know at compile-time that the product is an
27
* iPhone.
28
*/
29
goog.userAgent.product.ASSUME_IPHONE =
30
goog.define('goog.userAgent.product.ASSUME_IPHONE', false);
31
32
33
/**
34
* @define {boolean} Whether we know at compile-time that the product is an
35
* iPad.
36
*/
37
goog.userAgent.product.ASSUME_IPAD =
38
goog.define('goog.userAgent.product.ASSUME_IPAD', false);
39
40
41
/**
42
* @define {boolean} Whether we know at compile-time that the product is an
43
* AOSP browser or WebView inside a pre KitKat Android phone or tablet.
44
*/
45
goog.userAgent.product.ASSUME_ANDROID =
46
goog.define('goog.userAgent.product.ASSUME_ANDROID', false);
47
48
49
/**
50
* @define {boolean} Whether the code is running on the Chrome web browser on
51
* any platform or AOSP browser or WebView in a KitKat+ Android phone or tablet.
52
*/
53
goog.userAgent.product.ASSUME_CHROME =
54
goog.define('goog.userAgent.product.ASSUME_CHROME', false);
55
56
57
/**
58
* @define {boolean} Whether the code is running on the Safari web browser.
59
*/
60
goog.userAgent.product.ASSUME_SAFARI =
61
goog.define('goog.userAgent.product.ASSUME_SAFARI', false);
62
63
64
/**
65
* Whether we know the product type at compile-time.
66
* @type {boolean}
67
* @private
68
*/
69
goog.userAgent.product.PRODUCT_KNOWN_ = goog.userAgent.ASSUME_IE ||
70
goog.userAgent.ASSUME_EDGE || goog.userAgent.ASSUME_OPERA ||
71
goog.userAgent.product.ASSUME_FIREFOX ||
72
goog.userAgent.product.ASSUME_IPHONE ||
73
goog.userAgent.product.ASSUME_IPAD ||
74
goog.userAgent.product.ASSUME_ANDROID ||
75
goog.userAgent.product.ASSUME_CHROME ||
76
goog.userAgent.product.ASSUME_SAFARI;
77
78
79
/**
80
* Whether the code is running on the Opera web browser.
81
* @type {boolean}
82
*/
83
goog.userAgent.product.OPERA = goog.userAgent.OPERA;
84
85
86
/**
87
* Whether the code is running on an IE web browser.
88
* @type {boolean}
89
*/
90
goog.userAgent.product.IE = goog.userAgent.IE;
91
92
93
/**
94
* Whether the code is running on an Edge web browser (EdgeHTML based).
95
* @type {boolean}
96
*/
97
goog.userAgent.product.EDGE = goog.userAgent.EDGE;
98
99
100
/**
101
* Whether the code is running on the Firefox web browser.
102
* @type {boolean}
103
*/
104
goog.userAgent.product.FIREFOX = goog.userAgent.product.PRODUCT_KNOWN_ ?
105
goog.userAgent.product.ASSUME_FIREFOX :
106
goog.labs.userAgent.browser.isFirefox();
107
108
109
/**
110
* Whether the user agent is an iPhone or iPod (as in iPod touch).
111
* @return {boolean}
112
* @private
113
*/
114
goog.userAgent.product.isIphoneOrIpod_ = function() {
115
'use strict';
116
return goog.labs.userAgent.platform.isIphone() ||
117
goog.labs.userAgent.platform.isIpod();
118
};
119
120
121
/**
122
* Whether the code is running on an iPhone or iPod touch.
123
*
124
* iPod touch is considered an iPhone for legacy reasons.
125
* @type {boolean}
126
*/
127
goog.userAgent.product.IPHONE = goog.userAgent.product.PRODUCT_KNOWN_ ?
128
goog.userAgent.product.ASSUME_IPHONE :
129
goog.userAgent.product.isIphoneOrIpod_();
130
131
132
/**
133
* Whether the code is running on an iPad.
134
* @type {boolean}
135
*/
136
goog.userAgent.product.IPAD = goog.userAgent.product.PRODUCT_KNOWN_ ?
137
goog.userAgent.product.ASSUME_IPAD :
138
goog.labs.userAgent.platform.isIpad();
139
140
141
/**
142
* Whether the code is running on AOSP browser or WebView inside
143
* a pre KitKat Android phone or tablet.
144
* @type {boolean}
145
*/
146
goog.userAgent.product.ANDROID = goog.userAgent.product.PRODUCT_KNOWN_ ?
147
goog.userAgent.product.ASSUME_ANDROID :
148
goog.labs.userAgent.browser.isAndroidBrowser();
149
150
151
/**
152
* Whether the code is running on any Chromium-based web browser on any platform
153
* or AOSP browser or WebView in a KitKat+ Android phone or tablet.
154
* @type {boolean}
155
*/
156
goog.userAgent.product.CHROME = goog.userAgent.product.PRODUCT_KNOWN_ ?
157
goog.userAgent.product.ASSUME_CHROME :
158
goog.labs.userAgent.browser.isChrome();
159
160
161
/**
162
* @return {boolean} Whether the browser is Safari on desktop.
163
* @private
164
*/
165
goog.userAgent.product.isSafariDesktop_ = function() {
166
'use strict';
167
return goog.labs.userAgent.browser.isSafari() &&
168
!goog.labs.userAgent.platform.isIos();
169
};
170
171
172
/**
173
* Whether the code is running on the desktop Safari web browser.
174
* Note: the legacy behavior here is only true for Safari not running
175
* on iOS.
176
* @type {boolean}
177
*/
178
goog.userAgent.product.SAFARI = goog.userAgent.product.PRODUCT_KNOWN_ ?
179
goog.userAgent.product.ASSUME_SAFARI :
180
goog.userAgent.product.isSafariDesktop_();
181
182