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#ifndef PluginProcess_h 27#define PluginProcess_h 28 29#if ENABLE(PLUGIN_PROCESS) 30 31#include "ChildProcess.h" 32#include <wtf/Forward.h> 33#include <wtf/text/WTFString.h> 34 35namespace WebKit { 36 37class NetscapePluginModule; 38class WebProcessConnection; 39struct PluginProcessCreationParameters; 40 41class PluginProcess : public ChildProcess { 42 WTF_MAKE_NONCOPYABLE(PluginProcess); 43public: 44 static PluginProcess& shared(); 45 46 void removeWebProcessConnection(WebProcessConnection*); 47 48 NetscapePluginModule* netscapePluginModule(); 49 50 const String& pluginPath() const { return m_pluginPath; } 51 52#if PLATFORM(MAC) 53 void setModalWindowIsShowing(bool); 54 void setFullscreenWindowIsShowing(bool); 55 56#if USE(ACCELERATED_COMPOSITING) 57 mach_port_t compositingRenderServerPort() const { return m_compositingRenderServerPort; } 58#endif 59 60 bool launchProcess(const String& launchPath, const Vector<String>& arguments); 61 bool launchApplicationAtURL(const String& urlString, const Vector<String>& arguments); 62 bool openURL(const String& urlString, int32_t& status, String& launchedURLString); 63 bool openFile(const String& urlString); 64#endif 65 66private: 67 PluginProcess(); 68 ~PluginProcess(); 69 70 // ChildProcess 71 virtual void initializeProcess(const ChildProcessInitializationParameters&) OVERRIDE; 72 virtual void initializeProcessName(const ChildProcessInitializationParameters&) OVERRIDE; 73 virtual void initializeSandbox(const ChildProcessInitializationParameters&, SandboxInitializationParameters&) OVERRIDE; 74 virtual bool shouldTerminate() OVERRIDE; 75 void platformInitializeProcess(const ChildProcessInitializationParameters&); 76 77#if PLATFORM(MAC) 78 virtual void stopRunLoop() OVERRIDE; 79#endif 80 81 // CoreIPC::Connection::Client 82 virtual void didReceiveMessage(CoreIPC::Connection*, CoreIPC::MessageDecoder&) OVERRIDE; 83 virtual void didClose(CoreIPC::Connection*) OVERRIDE; 84 virtual void didReceiveInvalidMessage(CoreIPC::Connection*, CoreIPC::StringReference messageReceiverName, CoreIPC::StringReference messageName) OVERRIDE; 85 86 // Message handlers. 87 void didReceivePluginProcessMessage(CoreIPC::Connection*, CoreIPC::MessageDecoder&); 88 void initializePluginProcess(const PluginProcessCreationParameters&); 89 void createWebProcessConnection(); 90 void getSitesWithData(uint64_t callbackID); 91 void clearSiteData(const Vector<String>& sites, uint64_t flags, uint64_t maxAgeInSeconds, uint64_t callbackID); 92 93 void platformInitializePluginProcess(const PluginProcessCreationParameters&); 94 95 void setMinimumLifetime(double); 96 void minimumLifetimeTimerFired(); 97 // Our web process connections. 98 Vector<RefPtr<WebProcessConnection>> m_webProcessConnections; 99 100 // The plug-in path. 101 String m_pluginPath; 102 103#if PLATFORM(MAC) 104 String m_pluginBundleIdentifier; 105#endif 106 107 // The plug-in module. 108 RefPtr<NetscapePluginModule> m_pluginModule; 109 110 bool m_supportsAsynchronousPluginInitialization; 111 112 WebCore::RunLoop::Timer<PluginProcess> m_minimumLifetimeTimer; 113 114#if USE(ACCELERATED_COMPOSITING) && PLATFORM(MAC) 115 // The Mach port used for accelerated compositing. 116 mach_port_t m_compositingRenderServerPort; 117#endif 118 119 static void lowMemoryHandler(bool critical); 120}; 121 122} // namespace WebKit 123 124#endif // ENABLE(PLUGIN_PROCESS) 125 126#endif // PluginProcess_h 127