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 typedef struct _GModule GModule;
47 class ArgumentDecoder;
55 typedef CFBundleRef PlatformBundle;
57 typedef HMODULE PlatformBundle;
59 typedef QLibrary PlatformBundle;
61 typedef ::GModule* PlatformBundle;
65 class InjectedBundleScriptWorld;
66 class WebCertificateInfo;
69 class WebPageGroupProxy;
71 class InjectedBundle : public APIObject {
73 static const Type APIType = TypeBundle;
75 static PassRefPtr<InjectedBundle> create(const String& path)
77 return adoptRef(new InjectedBundle(path));
81 bool load(APIObject* initializationUserData);
82 void setSandboxExtension(PassRefPtr<SandboxExtension> sandboxExtension) { m_sandboxExtension = sandboxExtension; }
85 void initializeClient(WKBundleClient*);
86 void postMessage(const String&, APIObject*);
87 void postSynchronousMessage(const String&, APIObject*, RefPtr<APIObject>& returnData);
89 void setHostAllowsAnyHTTPSCertificate(const String&);
90 void setClientCertificate(const String& host, const String& certificateSystemStoreName, const WebCertificateInfo*);
93 // TestRunner only SPI
94 void setShouldTrackVisitedLinks(bool);
95 void removeAllVisitedLinks();
96 void activateMacFontAscentHack();
97 void overrideXSSAuditorEnabledForTestRunner(WebPageGroupProxy* pageGroup, bool enabled);
98 void setAllowUniversalAccessFromFileURLs(WebPageGroupProxy*, bool);
99 void setAllowFileAccessFromFileURLs(WebPageGroupProxy*, bool);
100 void setFrameFlatteningEnabled(WebPageGroupProxy*, bool);
101 void setJavaScriptCanAccessClipboard(WebPageGroupProxy*, bool);
102 void setPrivateBrowsingEnabled(WebPageGroupProxy*, bool);
103 void switchNetworkLoaderToNewTestingSession();
104 void setAuthorAndUserStylesEnabled(WebPageGroupProxy*, bool);
105 void addOriginAccessWhitelistEntry(const String&, const String&, const String&, bool);
106 void removeOriginAccessWhitelistEntry(const String&, const String&, const String&, bool);
107 void resetOriginAccessWhitelists();
108 int numberOfPages(WebFrame*, double, double);
109 int pageNumberForElementById(WebFrame*, const String&, double, double);
110 String pageSizeAndMarginsInPixels(WebFrame*, int, int, int, int, int, int, int);
111 bool isPageBoxVisible(WebFrame*, int);
114 void addUserScript(WebPageGroupProxy*, InjectedBundleScriptWorld*, const String& source, const String& url, ImmutableArray* whitelist, ImmutableArray* blacklist, WebCore::UserScriptInjectionTime, WebCore::UserContentInjectedFrames);
115 void addUserStyleSheet(WebPageGroupProxy*, InjectedBundleScriptWorld*, const String& source, const String& url, ImmutableArray* whitelist, ImmutableArray* blacklist, WebCore::UserContentInjectedFrames);
116 void removeUserScript(WebPageGroupProxy*, InjectedBundleScriptWorld*, const String& url);
117 void removeUserStyleSheet(WebPageGroupProxy*, InjectedBundleScriptWorld*, const String& url);
118 void removeUserScripts(WebPageGroupProxy*, InjectedBundleScriptWorld*);
119 void removeUserStyleSheets(WebPageGroupProxy*, InjectedBundleScriptWorld*);
120 void removeAllUserContent(WebPageGroupProxy*);
123 void clearAllDatabases();
124 void setDatabaseQuota(uint64_t);
126 // Garbage collection API
127 void garbageCollectJavaScriptObjects();
128 void garbageCollectJavaScriptObjectsOnAlternateThreadForDebugging(bool waitUntilDone);
129 size_t javaScriptObjectsCount();
132 void didCreatePage(WebPage*);
133 void willDestroyPage(WebPage*);
134 void didInitializePageGroup(WebPageGroupProxy*);
135 void didReceiveMessage(const String&, APIObject*);
137 void didReceiveMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*);
139 static void reportException(JSContextRef, JSValueRef exception);
141 static bool isProcessingUserGesture();
144 InjectedBundle(const String&);
146 virtual Type type() const { return APIType; }
149 PlatformBundle m_platformBundle; // This is leaked right now, since we never unload the bundle/module.
151 RefPtr<SandboxExtension> m_sandboxExtension;
153 InjectedBundleClient m_client;
156 } // namespace WebKit
158 #endif // InjectedBundle_h