OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. | 2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. |
3 * Copyright (C) 2013 Samsung Electronics. All rights reserved. | 3 * Copyright (C) 2013 Samsung Electronics. All rights reserved. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions are | 6 * modification, are permitted provided that the following conditions are |
7 * met: | 7 * met: |
8 * | 8 * |
9 * * Redistributions of source code must retain the above copyright | 9 * * Redistributions of source code must retain the above copyright |
10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
(...skipping 18 matching lines...) Expand all Loading... |
29 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 29 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
30 */ | 30 */ |
31 | 31 |
32 #include "config.h" | 32 #include "config.h" |
33 #include "NavigatorID.h" | 33 #include "NavigatorID.h" |
34 | 34 |
35 #include "core/page/NavigatorBase.h" | 35 #include "core/page/NavigatorBase.h" |
36 #include "wtf/CPU.h" | 36 #include "wtf/CPU.h" |
37 | 37 |
38 #if OS(LINUX) | 38 #if OS(LINUX) |
39 #include "sys/utsname.h" | |
40 #include "wtf/StdLibExtras.h" | 39 #include "wtf/StdLibExtras.h" |
| 40 #include <sys/utsname.h> |
41 #endif | 41 #endif |
42 | 42 |
43 #ifndef WEBCORE_NAVIGATOR_PLATFORM | |
44 #if OS(DARWIN) && (CPU(PPC) || CPU(PPC64)) | |
45 #define WEBCORE_NAVIGATOR_PLATFORM "MacPPC" | |
46 #elif OS(DARWIN) && (CPU(X86) || CPU(X86_64)) | |
47 #define WEBCORE_NAVIGATOR_PLATFORM "MacIntel" | |
48 #elif OS(WINDOWS) | |
49 #define WEBCORE_NAVIGATOR_PLATFORM "Win32" | |
50 #else | |
51 #define WEBCORE_NAVIGATOR_PLATFORM "" | |
52 #endif | |
53 #endif // ifndef WEBCORE_NAVIGATOR_PLATFORM | |
54 | |
55 namespace WebCore { | 43 namespace WebCore { |
56 | 44 |
57 String NavigatorID::appName(const NavigatorBase*) | 45 String NavigatorID::appName(const NavigatorBase*) |
58 { | 46 { |
59 return "Netscape"; | 47 return "Netscape"; |
60 } | 48 } |
61 | 49 |
62 String NavigatorID::appVersion(const NavigatorBase* navigator) | 50 String NavigatorID::appVersion(const NavigatorBase* navigator) |
63 { | 51 { |
64 // Version is everything in the user agent string past the "Mozilla/" prefix
. | 52 // Version is everything in the user agent string past the "Mozilla/" prefix
. |
65 const String& agent = navigator->userAgent(); | 53 const String& agent = navigator->userAgent(); |
66 return agent.substring(agent.find('/') + 1); | 54 return agent.substring(agent.find('/') + 1); |
67 } | 55 } |
68 | 56 |
69 String NavigatorID::userAgent(const NavigatorBase* navigator) | 57 String NavigatorID::userAgent(const NavigatorBase* navigator) |
70 { | 58 { |
71 return navigator->userAgent(); | 59 return navigator->userAgent(); |
72 } | 60 } |
73 | 61 |
74 String NavigatorID::platform(const NavigatorBase*) | 62 String NavigatorID::platform(const NavigatorBase*) |
75 { | 63 { |
| 64 #if defined(WEBCORE_NAVIGATOR_PLATFORM) |
| 65 return WEBCORE_NAVIGATOR_PLATFORM; |
| 66 #else |
76 #if OS(LINUX) | 67 #if OS(LINUX) |
77 if (!String(WEBCORE_NAVIGATOR_PLATFORM).isEmpty()) | |
78 return WEBCORE_NAVIGATOR_PLATFORM; | |
79 struct utsname osname; | 68 struct utsname osname; |
80 DEFINE_STATIC_LOCAL(String, platformName, (uname(&osname) >= 0 ? String(osna
me.sysname) + String(" ") + String(osname.machine) : emptyString())); | 69 DEFINE_STATIC_LOCAL(String, platformName, (uname(&osname) >= 0 ? String(osna
me.sysname) + String(" ") + String(osname.machine) : emptyString())); |
81 return platformName; | 70 return platformName; |
82 #else | 71 #else |
83 return WEBCORE_NAVIGATOR_PLATFORM; | 72 #error Non-Linux ports must define WEBCORE_NAVIGATOR_PLATFORM. |
| 73 #endif |
84 #endif | 74 #endif |
85 } | 75 } |
86 | 76 |
87 } // namespace WebCore | 77 } // namespace WebCore |
OLD | NEW |