Skip to content

Commit

Permalink
Merge pull request #89 from dougwilson/feature/chrome-os
Browse files Browse the repository at this point in the history
Add detection for Chrome OS
  • Loading branch information
oalders committed Aug 27, 2014
2 parents 3900c4b + a931c93 commit e4d672a
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 4 deletions.
3 changes: 2 additions & 1 deletion README
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ Detecting OS Platform and Version
winphone7 winphone7_5 winphone8

dotnet()
chromeos()
firefoxos()
mac()
mac68k macppc macosx ios
Expand All @@ -216,7 +217,7 @@ Detecting OS Platform and Version

Win95, Win98, WinNT, Win2K, WinXP, Win2k3, WinVista, Win7, Win8,
Win8.1, Windows Phone, Mac, Mac OS X, iOS, Win3x, OS2, Unix, Linux,
Firefox OS, Playstation 3 GameOS, Playstation Portable GameOS,
Chrome OS, Firefox OS, Playstation 3 GameOS, Playstation Portable GameOS,
RIM Tablet OS, BlackBerry 10

Detecting Browser Vendor
Expand Down
15 changes: 12 additions & 3 deletions lib/HTTP/BrowserDetect.pm
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ our @OS_TESTS = qw(
unix linux vms
bsd amiga firefoxos
bb10 rimtabletos
chromeos
);

# More precise Windows
Expand Down Expand Up @@ -982,8 +983,13 @@ sub _os_tests {
$tests->{FREEBSD} = ( index( $ua, "freebsd" ) != -1 );
$tests->{BSD} = ( index( $ua, "bsd" ) != -1 );
$tests->{X11} = ( index( $ua, "x11" ) != -1 );

$tests->{CHROMEOS}
= ( $tests->{X11} && index( $ua, "cros" ) != -1 );

$tests->{UNIX}
= ( $tests->{X11}
= ( !$tests->{CHROMEOS}
&& ($tests->{X11}
|| $tests->{SUN}
|| $tests->{IRIX}
|| $tests->{HPUX}
Expand All @@ -993,7 +999,7 @@ sub _os_tests {
|| $tests->{RELIANT}
|| $tests->{DEC}
|| $tests->{LINUX}
|| $tests->{BSD} );
|| $tests->{BSD} ) );

$tests->{VMS}
= ( index( $ua, "vax" ) != -1 || index( $ua, "openvms" ) != -1 );
Expand Down Expand Up @@ -1112,6 +1118,7 @@ sub os_string {
return 'Android' if $self->android;
return 'Linux' if $self->linux;
return 'Unix' if $self->unix;
return 'Chrome OS' if $self->chromeos;
return 'Firefox OS' if $self->firefoxos;
return 'BlackBerry 10' if $self->bb10;
return 'RIM Tablet OS' if $self->rimtabletos;
Expand Down Expand Up @@ -1707,6 +1714,8 @@ winnt, which is a type of win32)
=head2 dotnet()
=head2 chromeos()
=head2 firefoxos()
=head2 mac()
Expand Down Expand Up @@ -1744,7 +1753,7 @@ compatibility with the L<HTTP::Headers::UserAgent> module.
Win95, Win98, WinNT, Win2K, WinXP, Win2k3, WinVista, Win7, Win8,
Win8.1, Windows Phone, Mac, Mac OS X, iOS, Win3x, OS2, Unix, Linux,
Firefox OS, Playstation 3 GameOS, Playstation Portable GameOS,
Chrome OS, Firefox OS, Playstation 3 GameOS, Playstation Portable GameOS,
RIM Tablet OS, BlackBerry 10
=head1 Detecting Browser Vendor
Expand Down
14 changes: 14 additions & 0 deletions t/useragents.json
Original file line number Diff line number Diff line change
Expand Up @@ -2247,6 +2247,20 @@
"robot"
]
},
"Mozilla/5.0 (X11; CrOS x86_64 5841.87.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/36.0.1985.0 Safari/537.36": {
"major" : "36",
"minor" : "0",
"match" : [
"chrome",
"chromeos",
"x11"
],
"os_string" : "Chrome OS",
"public_major" : "36",
"public_minor" : "0",
"public_version" : "36.0",
"version" : "36.0"
},
"Mozilla/5.0 (X11; U; FreeBSD i386; en-US; rv:1.7) Gecko/20040619 Firefox/0.9" : {
"browser_string" : "Firefox",
"country" : "US",
Expand Down

0 comments on commit e4d672a

Please sign in to comment.