1/* 2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions 6 * are met: 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. 12 * 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. 24 * 25 */ 26 27#include "config.h" 28#include "NavigatorBase.h" 29 30#include "NetworkStateNotifier.h" 31#include "PlatformString.h" 32#if OS(LINUX) 33#include "sys/utsname.h" 34#include <wtf/StdLibExtras.h> 35#endif 36 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" 42#elif OS(WINDOWS) 43#define WEBCORE_NAVIGATOR_PLATFORM "Win32" 44#elif OS(SYMBIAN) 45#define WEBCORE_NAVIGATOR_PLATFORM "Symbian" 46#else 47#define WEBCORE_NAVIGATOR_PLATFORM "" 48#endif 49#endif // ifndef WEBCORE_NAVIGATOR_PLATFORM 50 51#ifndef WEBCORE_NAVIGATOR_PRODUCT 52#define WEBCORE_NAVIGATOR_PRODUCT "Gecko" 53#endif // ifndef WEBCORE_NAVIGATOR_PRODUCT 54 55#ifndef WEBCORE_NAVIGATOR_PRODUCT_SUB 56#define WEBCORE_NAVIGATOR_PRODUCT_SUB "20030107" 57#endif // ifndef WEBCORE_NAVIGATOR_PRODUCT_SUB 58 59#ifndef WEBCORE_NAVIGATOR_VENDOR 60#define WEBCORE_NAVIGATOR_VENDOR "Apple Inc." 61#endif // ifndef WEBCORE_NAVIGATOR_VENDOR 62 63#ifndef WEBCORE_NAVIGATOR_VENDOR_SUB 64#define WEBCORE_NAVIGATOR_VENDOR_SUB "" 65#endif // ifndef WEBCORE_NAVIGATOR_VENDOR_SUB 66 67 68namespace WebCore { 69 70NavigatorBase::~NavigatorBase() 71{ 72} 73 74String NavigatorBase::appName() const 75{ 76 return "Netscape"; 77} 78 79String NavigatorBase::appVersion() const 80{ 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); 84} 85 86String NavigatorBase::platform() const 87{ 88#if OS(LINUX) 89 if (String("") != WEBCORE_NAVIGATOR_PLATFORM) 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) : "")); 93 return platformName; 94#else 95 return WEBCORE_NAVIGATOR_PLATFORM; 96#endif 97} 98 99String NavigatorBase::appCodeName() const 100{ 101 return "Mozilla"; 102} 103 104String NavigatorBase::product() const 105{ 106 return WEBCORE_NAVIGATOR_PRODUCT; 107} 108 109String NavigatorBase::productSub() const 110{ 111 return WEBCORE_NAVIGATOR_PRODUCT_SUB; 112} 113 114String NavigatorBase::vendor() const 115{ 116 return WEBCORE_NAVIGATOR_VENDOR; 117} 118 119String NavigatorBase::vendorSub() const 120{ 121 return WEBCORE_NAVIGATOR_VENDOR_SUB; 122} 123 124bool NavigatorBase::onLine() const 125{ 126 return networkStateNotifier().onLine(); 127} 128 129} // namespace WebCore 130