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 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 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 <wtf/text/WTFString.h> 32 33#if OS(LINUX) 34#include "sys/utsname.h" 35#include <wtf/StdLibExtras.h> 36#endif 37 38#if PLATFORM(IOS) 39#include "WebCoreSystemInterface.h" 40#endif 41 42#ifndef WEBCORE_NAVIGATOR_PLATFORM 43#if PLATFORM(IOS) 44#define WEBCORE_NAVIGATOR_PLATFORM "" 45#elif OS(MAC_OS_X) && (CPU(PPC) || CPU(PPC64)) 46#define WEBCORE_NAVIGATOR_PLATFORM "MacPPC" 47#elif OS(MAC_OS_X) && (CPU(X86) || CPU(X86_64)) 48#define WEBCORE_NAVIGATOR_PLATFORM "MacIntel" 49#elif OS(WINDOWS) 50#define WEBCORE_NAVIGATOR_PLATFORM "Win32" 51#else 52#define WEBCORE_NAVIGATOR_PLATFORM "" 53#endif 54#endif // ifndef WEBCORE_NAVIGATOR_PLATFORM 55 56#ifndef WEBCORE_NAVIGATOR_PRODUCT 57#define WEBCORE_NAVIGATOR_PRODUCT "Gecko" 58#endif // ifndef WEBCORE_NAVIGATOR_PRODUCT 59 60#ifndef WEBCORE_NAVIGATOR_PRODUCT_SUB 61#define WEBCORE_NAVIGATOR_PRODUCT_SUB "20030107" 62#endif // ifndef WEBCORE_NAVIGATOR_PRODUCT_SUB 63 64#ifndef WEBCORE_NAVIGATOR_VENDOR 65#define WEBCORE_NAVIGATOR_VENDOR "Apple Computer, Inc." 66#endif // ifndef WEBCORE_NAVIGATOR_VENDOR 67 68#ifndef WEBCORE_NAVIGATOR_VENDOR_SUB 69#define WEBCORE_NAVIGATOR_VENDOR_SUB "" 70#endif // ifndef WEBCORE_NAVIGATOR_VENDOR_SUB 71 72 73namespace WebCore { 74 75NavigatorBase::~NavigatorBase() 76{ 77} 78 79String NavigatorBase::appName() const 80{ 81 return "Netscape"; 82} 83 84String NavigatorBase::appVersion() const 85{ 86 // Version is everything in the user agent string past the "Mozilla/" prefix. 87 const String& agent = userAgent(); 88 return agent.substring(agent.find('/') + 1); 89} 90 91String NavigatorBase::platform() const 92{ 93#if OS(LINUX) 94 if (!String(WEBCORE_NAVIGATOR_PLATFORM).isEmpty()) 95 return WEBCORE_NAVIGATOR_PLATFORM; 96 struct utsname osname; 97 DEPRECATED_DEFINE_STATIC_LOCAL(String, platformName, (uname(&osname) >= 0 ? String(osname.sysname) + String(" ") + String(osname.machine) : emptyString())); 98 return platformName; 99#else 100 return WEBCORE_NAVIGATOR_PLATFORM; 101#endif 102} 103 104String NavigatorBase::appCodeName() const 105{ 106 return "Mozilla"; 107} 108 109String NavigatorBase::product() const 110{ 111 return WEBCORE_NAVIGATOR_PRODUCT; 112} 113 114String NavigatorBase::productSub() const 115{ 116 return WEBCORE_NAVIGATOR_PRODUCT_SUB; 117} 118 119String NavigatorBase::vendor() const 120{ 121 return WEBCORE_NAVIGATOR_VENDOR; 122} 123 124String NavigatorBase::vendorSub() const 125{ 126 return WEBCORE_NAVIGATOR_VENDOR_SUB; 127} 128 129bool NavigatorBase::onLine() const 130{ 131 return networkStateNotifier().onLine(); 132} 133 134} // namespace WebCore 135