Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit dbaf68d

Browse filesBrowse files
authored
Merge pull request #72 from kulor/master
Add Chromebook detection as a "pc"
2 parents 684a37c + 7121f98 commit dbaf68d
Copy full SHA for dbaf68d

File tree

Expand file treeCollapse file tree

3 files changed

+14
-1
lines changed
Filter options
Expand file treeCollapse file tree

3 files changed

+14
-1
lines changed

‎user_agents/devices.json

Copy file name to clipboardExpand all lines: user_agents/devices.json
+9-1Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,14 @@
348348
"is_touch_capable": false,
349349
"ua_string": "Mozilla/5.0 (X11; U; SunOS sun4u; en-US; rv:1.6) Gecko/20040503",
350350
"str": "Other / Solaris / Other"
351+
},
352+
"chrome_os": {
353+
"is_bot": false,
354+
"is_mobile": false,
355+
"is_pc": true,
356+
"is_tablet": false,
357+
"is_touch_capable": false,
358+
"ua_string": "Mozilla/5.0 (X11; CrOS i686 0.12.433) AppleWebKit/534.30 (KHTML, like Gecko) Chrome/12.0.742.77 Safari/534.30",
359+
"str": "CrOS"
351360
}
352361
}
353-

‎user_agents/parsers.py

Copy file name to clipboardExpand all lines: user_agents/parsers.py
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,8 @@ def is_pc(self):
234234
# Maemo has 'Linux' and 'X11' in UA, but it is not for PC
235235
if 'Maemo' in self.ua_string:
236236
return False
237+
if 'Chrome OS' in self.os.family:
238+
return True
237239
if 'Linux' in self.ua_string and 'X11' in self.ua_string:
238240
return True
239241
return False

‎user_agents/tests.py

Copy file name to clipboardExpand all lines: user_agents/tests.py
+3Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
android_firefox_aurora_ua_string = 'Mozilla/5.0 (Android; Mobile; rv:27.0) Gecko/27.0 Firefox/27.0'
3131
thunderbird_ua_string = 'Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 Lightning/4.0.2'
3232
outlook_usa_string = 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; Trident/6.0; Microsoft Outlook 15.0.4420)'
33+
chromebook_ua_string = 'Mozilla/5.0 (X11; CrOS i686 0.12.433) AppleWebKit/534.30 (KHTML, like Gecko) Chrome/12.0.742.77 Safari/534.30'
3334

3435
iphone_ua = parse(iphone_ua_string)
3536
ipad_ua = parse(ipad_ua_string)
@@ -54,6 +55,7 @@
5455
android_firefox_aurora_ua = parse(android_firefox_aurora_ua_string)
5556
thunderbird_ua = parse(thunderbird_ua_string)
5657
outlook_ua = parse(outlook_usa_string)
58+
chromebook_ua = parse(chromebook_ua_string)
5759

5860

5961
class UserAgentsTest(unittest.TestCase):
@@ -165,6 +167,7 @@ def test_is_pc(self):
165167
self.assertTrue(ie_touch_ua.is_pc)
166168
self.assertTrue(ie_ua.is_pc)
167169
self.assertFalse(android_firefox_aurora_ua.is_pc)
170+
self.assertTrue(chromebook_ua.is_pc)
168171

169172
def test_is_bot(self):
170173
self.assertTrue(google_bot_ua.is_bot)

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.