1/* 2 * Copyright (C) 2010 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 "Plugin.h" 28 29#include "WebCoreArgumentCoders.h" 30#include <WebCore/IntPoint.h> 31 32using namespace WebCore; 33 34namespace WebKit { 35 36void Plugin::Parameters::encode(IPC::ArgumentEncoder& encoder) const 37{ 38 encoder << url.string(); 39 encoder << names; 40 encoder << values; 41 encoder << mimeType; 42 encoder << isFullFramePlugin; 43 encoder << shouldUseManualLoader; 44#if PLATFORM(COCOA) 45 encoder.encodeEnum(layerHostingMode); 46#endif 47} 48 49bool Plugin::Parameters::decode(IPC::ArgumentDecoder& decoder, Parameters& parameters) 50{ 51 String urlString; 52 if (!decoder.decode(urlString)) 53 return false; 54 // FIXME: We can't assume that the url passed in here is valid. 55 parameters.url = URL(ParsedURLString, urlString); 56 57 if (!decoder.decode(parameters.names)) 58 return false; 59 if (!decoder.decode(parameters.values)) 60 return false; 61 if (!decoder.decode(parameters.mimeType)) 62 return false; 63 if (!decoder.decode(parameters.isFullFramePlugin)) 64 return false; 65 if (!decoder.decode(parameters.shouldUseManualLoader)) 66 return false; 67#if PLATFORM(COCOA) 68 if (!decoder.decodeEnum(parameters.layerHostingMode)) 69 return false; 70#endif 71 if (parameters.names.size() != parameters.values.size()) { 72 decoder.markInvalid(); 73 return false; 74 } 75 76 return true; 77} 78 79Plugin::Plugin() 80 : m_pluginController(0) 81{ 82} 83 84Plugin::~Plugin() 85{ 86} 87 88bool Plugin::initialize(PluginController* pluginController, const Parameters& parameters) 89{ 90 ASSERT(!m_pluginController); 91 ASSERT(pluginController); 92 93 m_pluginController = pluginController; 94 95 return initialize(parameters); 96} 97 98void Plugin::destroyPlugin() 99{ 100 destroy(); 101 102 m_pluginController = 0; 103} 104 105void Plugin::updateControlTints(GraphicsContext*) 106{ 107} 108 109IntPoint Plugin::convertToRootView(const IntPoint&) const 110{ 111 ASSERT_NOT_REACHED(); 112 return IntPoint(); 113} 114 115} // namespace WebKit 116