1/* 2 * Copyright (C) 2013 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 "PluginInformation.h" 28 29#include "PluginInfoStore.h" 30#include "PluginModuleInfo.h" 31#include "WKAPICast.h" 32#include "WebNumber.h" 33#include "WebString.h" 34#include "WebURL.h" 35#include <wtf/text/WTFString.h> 36 37namespace WebKit { 38 39String pluginInformationBundleIdentifierKey() 40{ 41 return ASCIILiteral("PluginInformationBundleIdentifier"); 42} 43 44String pluginInformationBundleVersionKey() 45{ 46 return ASCIILiteral("PluginInformationBundleVersion"); 47} 48 49String pluginInformationBundleShortVersionKey() 50{ 51 return ASCIILiteral("PluginInformationBundleShortVersion"); 52} 53 54String pluginInformationPathKey() 55{ 56 return ASCIILiteral("PluginInformationPath"); 57} 58 59String pluginInformationDisplayNameKey() 60{ 61 return ASCIILiteral("PluginInformationDisplayName"); 62} 63 64String pluginInformationDefaultLoadPolicyKey() 65{ 66 return ASCIILiteral("PluginInformationDefaultLoadPolicy"); 67} 68 69String pluginInformationUpdatePastLastBlockedVersionIsKnownAvailableKey() 70{ 71 return ASCIILiteral("PluginInformationUpdatePastLastBlockedVersionIsKnownAvailable"); 72} 73 74String pluginInformationHasSandboxProfileKey() 75{ 76 return ASCIILiteral("PluginInformationHasSandboxProfile"); 77} 78 79String pluginInformationFrameURLKey() 80{ 81 return ASCIILiteral("PluginInformationFrameURL"); 82} 83 84String pluginInformationMIMETypeKey() 85{ 86 return ASCIILiteral("PluginInformationMIMEType"); 87} 88 89String pluginInformationPageURLKey() 90{ 91 return ASCIILiteral("PluginInformationPageURL"); 92} 93 94String pluginInformationPluginspageAttributeURLKey() 95{ 96 return ASCIILiteral("PluginInformationPluginspageAttributeURL"); 97} 98 99String pluginInformationPluginURLKey() 100{ 101 return ASCIILiteral("PluginInformationPluginURL"); 102} 103 104String plugInInformationReplacementObscuredKey() 105{ 106 return ASCIILiteral("PlugInInformationReplacementObscured"); 107} 108 109void getPluginModuleInformation(const PluginModuleInfo& plugin, ImmutableDictionary::MapType& map) 110{ 111#if ENABLE(NETSCAPE_PLUGIN_API) 112 map.set(pluginInformationPathKey(), WebString::create(plugin.path)); 113 map.set(pluginInformationDisplayNameKey(), WebString::create(plugin.info.name)); 114 map.set(pluginInformationDefaultLoadPolicyKey(), WebUInt64::create(toWKPluginLoadPolicy(PluginInfoStore::defaultLoadPolicyForPlugin(plugin)))); 115 116 getPlatformPluginModuleInformation(plugin, map); 117#endif 118} 119 120PassRefPtr<ImmutableDictionary> createPluginInformationDictionary(const PluginModuleInfo& plugin) 121{ 122 ImmutableDictionary::MapType map; 123 getPluginModuleInformation(plugin, map); 124 125 return ImmutableDictionary::adopt(map); 126} 127 128PassRefPtr<ImmutableDictionary> createPluginInformationDictionary(const PluginModuleInfo& plugin, const String& frameURLString, const String& mimeType, const String& pageURLString, const String& pluginspageAttributeURLString, const String& pluginURLString, bool replacementObscured) 129{ 130 ImmutableDictionary::MapType map; 131 getPluginModuleInformation(plugin, map); 132 133 if (!frameURLString.isEmpty()) 134 map.set(pluginInformationFrameURLKey(), WebURL::create(frameURLString)); 135 if (!mimeType.isEmpty()) 136 map.set(pluginInformationMIMETypeKey(), WebString::create(mimeType)); 137 if (!pageURLString.isEmpty()) 138 map.set(pluginInformationPageURLKey(), WebURL::create(pageURLString)); 139 if (!pluginspageAttributeURLString.isEmpty()) 140 map.set(pluginInformationPluginspageAttributeURLKey(), WebURL::create(pluginspageAttributeURLString)); 141 if (!pluginURLString.isEmpty()) 142 map.set(pluginInformationPluginURLKey(), WebURL::create(pluginURLString)); 143 map.set(plugInInformationReplacementObscuredKey(), WebBoolean::create(replacementObscured)); 144 145 return ImmutableDictionary::adopt(map); 146} 147 148PassRefPtr<ImmutableDictionary> createPluginInformationDictionary(const String& mimeType, const String& frameURLString, const String& pageURLString) 149{ 150 ImmutableDictionary::MapType map; 151 152 if (!frameURLString.isEmpty()) 153 map.set(pluginInformationFrameURLKey(), WebURL::create(frameURLString)); 154 if (!mimeType.isEmpty()) 155 map.set(pluginInformationMIMETypeKey(), WebString::create(mimeType)); 156 if (!pageURLString.isEmpty()) 157 map.set(pluginInformationPageURLKey(), WebURL::create(pageURLString)); 158 159 return ImmutableDictionary::adopt(map); 160} 161 162#if !PLATFORM(MAC) 163void getPlatformPluginModuleInformation(const PluginModuleInfo&, ImmutableDictionary::MapType&) 164{ 165} 166#endif 167 168} // namespace WebKit 169