2 * Copyright (C) 2010 Apple Inc. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
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.
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.
26 #ifndef InjectedBundle_h
27 #define InjectedBundle_h
29 #include "APIObject.h"
30 #include "InjectedBundleClient.h"
31 #include "SandboxExtension.h"
33 #include <WebCore/UserContentTypes.h>
34 #include <WebCore/UserScriptTypes.h>
35 #include <wtf/PassRefPtr.h>
36 #include <wtf/text/WTFString.h>
43 class ArgumentDecoder;
51 typedef CFBundleRef PlatformBundle;
53 typedef HMODULE PlatformBundle;
55 typedef QLibrary PlatformBundle;
57 typedef void* PlatformBundle;
61 class InjectedBundleScriptWorld;
62 class WebCertificateInfo;
65 class WebPageGroupProxy;
67 class InjectedBundle : public APIObject {
69 static const Type APIType = TypeBundle;
71 static PassRefPtr<InjectedBundle> create(const String& path)
73 return adoptRef(new InjectedBundle(path));
77 bool load(APIObject* initializationUserData);
78 void setSandboxExtension(PassRefPtr<SandboxExtension> sandboxExtension) { m_sandboxExtension = sandboxExtension; }
81 void initializeClient(WKBundleClient*);
82 void postMessage(const String&, APIObject*);
83 void postSynchronousMessage(const String&, APIObject*, RefPtr<APIObject>& returnData);
85 void setHostAllowsAnyHTTPSCertificate(const String&);
86 void setClientCertificate(const String& host, const String& certificateSystemStoreName, const WebCertificateInfo*);
89 // TestRunner only SPI
90 void setShouldTrackVisitedLinks(bool);
91 void removeAllVisitedLinks();
92 void activateMacFontAscentHack();
93 void overrideXSSAuditorEnabledForTestRunner(WebPageGroupProxy* pageGroup, bool enabled);
94 void overrideAllowUniversalAccessFromFileURLsForTestRunner(WebPageGroupProxy*, bool);
95 void setAllowFileAccessFromFileURLs(WebPageGroupProxy*, bool);
96 int numberOfPages(WebFrame*, double, double);
97 int pageNumberForElementById(WebFrame*, const String&, double, double);
100 void addUserScript(WebPageGroupProxy*, InjectedBundleScriptWorld*, const String& source, const String& url, ImmutableArray* whitelist, ImmutableArray* blacklist, WebCore::UserScriptInjectionTime, WebCore::UserContentInjectedFrames);
101 void addUserStyleSheet(WebPageGroupProxy*, InjectedBundleScriptWorld*, const String& source, const String& url, ImmutableArray* whitelist, ImmutableArray* blacklist, WebCore::UserContentInjectedFrames);
102 void removeUserScript(WebPageGroupProxy*, InjectedBundleScriptWorld*, const String& url);
103 void removeUserStyleSheet(WebPageGroupProxy*, InjectedBundleScriptWorld*, const String& url);
104 void removeUserScripts(WebPageGroupProxy*, InjectedBundleScriptWorld*);
105 void removeUserStyleSheets(WebPageGroupProxy*, InjectedBundleScriptWorld*);
106 void removeAllUserContent(WebPageGroupProxy*);
109 void clearAllDatabases();
110 void setDatabaseQuota(uint64_t);
112 // Garbage collection API
113 void garbageCollectJavaScriptObjects();
114 void garbageCollectJavaScriptObjectsOnAlternateThreadForDebugging(bool waitUntilDone);
115 size_t javaScriptObjectsCount();
118 void didCreatePage(WebPage*);
119 void willDestroyPage(WebPage*);
120 void didInitializePageGroup(WebPageGroupProxy*);
121 void didReceiveMessage(const String&, APIObject*);
123 void didReceiveMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*);
125 static void reportException(JSContextRef, JSValueRef exception);
128 InjectedBundle(const String&);
130 virtual Type type() const { return APIType; }
133 PlatformBundle m_platformBundle; // This is leaked right now, since we never unload the bundle/module.
135 RefPtr<SandboxExtension> m_sandboxExtension;
137 InjectedBundleClient m_client;
140 } // namespace WebKit
142 #endif // InjectedBundle_h