1/* 2 * Copyright (C) 2011 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. AND ITS CONTRIBUTORS ``AS IS'' 14 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS 17 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 19 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 20 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 23 * THE POSSIBILITY OF SUCH DAMAGE. 24 */ 25 26#include "config.h" 27#include "RuntimeApplicationChecks.h" 28 29#if USE(CF) 30#include <CoreFoundation/CoreFoundation.h> 31#include <wtf/RetainPtr.h> 32#endif 33 34#include <wtf/text/WTFString.h> 35 36namespace WebCore { 37 38static bool mainBundleIsEqualTo(const String& bundleIdentifierString) 39{ 40 // FIXME: We should consider merging this file with RuntimeApplicationChecksIOS.mm. 41 // Then we can remove the PLATFORM(IOS)-guard. 42#if USE(CF) && !PLATFORM(IOS) 43 CFBundleRef mainBundle = CFBundleGetMainBundle(); 44 if (!mainBundle) 45 return false; 46 47 CFStringRef bundleIdentifier = CFBundleGetIdentifier(mainBundle); 48 if (!bundleIdentifier) 49 return false; 50 51 return CFStringCompare(bundleIdentifier, bundleIdentifierString.createCFString().get(), 0) == kCFCompareEqualTo; 52#else 53 UNUSED_PARAM(bundleIdentifierString); 54 return false; 55#endif 56} 57 58bool applicationIsSafari() 59{ 60 // FIXME: For the WebProcess case, ensure that this is Safari's WebProcess. 61 static bool isSafari = mainBundleIsEqualTo("com.apple.Safari") || mainBundleIsEqualTo("com.apple.WebProcess"); 62 return isSafari; 63} 64 65bool applicationIsAppleMail() 66{ 67 static bool isAppleMail = mainBundleIsEqualTo("com.apple.mail"); 68 return isAppleMail; 69} 70 71bool applicationIsITunes() 72{ 73 static bool isITunes = mainBundleIsEqualTo("com.apple.iTunes"); 74 return isITunes; 75} 76 77bool applicationIsMicrosoftMessenger() 78{ 79 static bool isMicrosoftMessenger = mainBundleIsEqualTo("com.microsoft.Messenger"); 80 return isMicrosoftMessenger; 81} 82 83bool applicationIsAdobeInstaller() 84{ 85 static bool isAdobeInstaller = mainBundleIsEqualTo("com.adobe.Installers.Setup"); 86 return isAdobeInstaller; 87} 88 89bool applicationIsAOLInstantMessenger() 90{ 91 static bool isAOLInstantMessenger = mainBundleIsEqualTo("com.aol.aim.desktop"); 92 return isAOLInstantMessenger; 93} 94 95bool applicationIsMicrosoftMyDay() 96{ 97 static bool isMicrosoftMyDay = mainBundleIsEqualTo("com.microsoft.myday"); 98 return isMicrosoftMyDay; 99} 100 101bool applicationIsMicrosoftOutlook() 102{ 103 static bool isMicrosoftOutlook = mainBundleIsEqualTo("com.microsoft.Outlook"); 104 return isMicrosoftOutlook; 105} 106 107bool applicationIsQuickenEssentials() 108{ 109 static bool isQuickenEssentials = mainBundleIsEqualTo("com.intuit.QuickenEssentials"); 110 return isQuickenEssentials; 111} 112 113bool applicationIsAperture() 114{ 115 static bool isAperture = mainBundleIsEqualTo("com.apple.Aperture"); 116 return isAperture; 117} 118 119bool applicationIsVersions() 120{ 121 static bool isVersions = mainBundleIsEqualTo("com.blackpixel.versions"); 122 return isVersions; 123} 124 125bool applicationIsHRBlock() 126{ 127 static bool isHRBlock = mainBundleIsEqualTo("com.hrblock.tax.2010"); 128 return isHRBlock; 129} 130 131bool applicationIsSolidStateNetworksDownloader() 132{ 133 static bool isSolidStateNetworksDownloader = mainBundleIsEqualTo("com.solidstatenetworks.awkhost"); 134 return isSolidStateNetworksDownloader; 135} 136 137} // namespace WebCore 138