2 * Copyright (C) 2008 Apple Inc. All Rights Reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
13 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 #include "NavigatorBase.h"
30 #include "NetworkStateNotifier.h"
31 #include "PlatformString.h"
33 #include "sys/utsname.h"
34 #include <wtf/StdLibExtras.h>
37 #ifndef WEBCORE_NAVIGATOR_PLATFORM
38 #if OS(MAC_OS_X) && (CPU(PPC) || CPU(PPC64))
39 #define WEBCORE_NAVIGATOR_PLATFORM "MacPPC"
40 #elif OS(MAC_OS_X) && (CPU(X86) || CPU(X86_64))
41 #define WEBCORE_NAVIGATOR_PLATFORM "MacIntel"
43 #define WEBCORE_NAVIGATOR_PLATFORM "Win32"
44 #elif PLATFORM(BLACKBERRY)
45 #define WEBCORE_NAVIGATOR_PLATFORM "BlackBerry"
47 #define WEBCORE_NAVIGATOR_PLATFORM ""
49 #endif // ifndef WEBCORE_NAVIGATOR_PLATFORM
51 #ifndef WEBCORE_NAVIGATOR_PRODUCT
52 #define WEBCORE_NAVIGATOR_PRODUCT "Gecko"
53 #endif // ifndef WEBCORE_NAVIGATOR_PRODUCT
55 #ifndef WEBCORE_NAVIGATOR_PRODUCT_SUB
56 #define WEBCORE_NAVIGATOR_PRODUCT_SUB "20030107"
57 #endif // ifndef WEBCORE_NAVIGATOR_PRODUCT_SUB
59 #ifndef WEBCORE_NAVIGATOR_VENDOR
60 #define WEBCORE_NAVIGATOR_VENDOR "Apple Computer, Inc."
61 #endif // ifndef WEBCORE_NAVIGATOR_VENDOR
63 #ifndef WEBCORE_NAVIGATOR_VENDOR_SUB
64 #define WEBCORE_NAVIGATOR_VENDOR_SUB ""
65 #endif // ifndef WEBCORE_NAVIGATOR_VENDOR_SUB
70 NavigatorBase::~NavigatorBase()
74 String NavigatorBase::appName() const
79 String NavigatorBase::appVersion() const
81 // Version is everything in the user agent string past the "Mozilla/" prefix.
82 const String& agent = userAgent();
83 return agent.substring(agent.find('/') + 1);
86 String NavigatorBase::platform() const
89 if (!String(WEBCORE_NAVIGATOR_PLATFORM).isEmpty())
90 return WEBCORE_NAVIGATOR_PLATFORM;
91 struct utsname osname;
92 DEFINE_STATIC_LOCAL(String, platformName, (uname(&osname) >= 0 ? String(osname.sysname) + String(" ") + String(osname.machine) : emptyString()));
95 return WEBCORE_NAVIGATOR_PLATFORM;
99 String NavigatorBase::appCodeName() const
104 String NavigatorBase::product() const
106 return WEBCORE_NAVIGATOR_PRODUCT;
109 String NavigatorBase::productSub() const
111 return WEBCORE_NAVIGATOR_PRODUCT_SUB;
114 String NavigatorBase::vendor() const
116 return WEBCORE_NAVIGATOR_VENDOR;
119 String NavigatorBase::vendorSub() const
121 return WEBCORE_NAVIGATOR_VENDOR_SUB;
124 bool NavigatorBase::onLine() const
126 return networkStateNotifier().onLine();
129 } // namespace WebCore