2
* Copyright (C) 2010, 2011, 2012 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 "AccessibilityController.h"
30
#include "EventSendingController.h"
31
#include "GCController.h"
32
#include "TestRunner.h"
33
#include "TextInputController.h"
34
#include <WebKit2/WKBase.h>
35
#include <WebKit2/WKRetainPtr.h>
36
#include <wtf/OwnPtr.h>
37
#include <wtf/RefPtr.h>
38
#include <wtf/Vector.h>
48
class InjectedBundlePage;
50
class InjectedBundle {
52
static InjectedBundle& shared();
54
// Initialize the InjectedBundle.
55
void initialize(WKBundleRef, WKTypeRef initializationUserData);
57
WKBundleRef bundle() const { return m_bundle; }
58
WKBundlePageGroupRef pageGroup() const { return m_pageGroup; }
60
TestRunner* testRunner() { return m_testRunner.get(); }
61
GCController* gcController() { return m_gcController.get(); }
62
EventSendingController* eventSendingController() { return m_eventSendingController.get(); }
63
TextInputController* textInputController() { return m_textInputController.get(); }
64
AccessibilityController* accessibilityController() { return m_accessibilityController.get(); }
66
InjectedBundlePage* page() const;
67
size_t pageCount() const { return m_pages.size(); }
68
void closeOtherPages();
70
void dumpBackForwardListsForAllPages();
73
WTF::StringBuilder* stringBuilder() { return m_stringBuilder.get(); }
74
void setPixelResult(WKImageRef image) { m_pixelResult = image; }
75
void setRepaintRects(WKArrayRef rects) { m_repaintRects = rects; }
77
bool isTestRunning() { return m_state == Testing; }
79
WKBundleFrameRef topLoadingFrame() { return m_topLoadingFrame; }
80
void setTopLoadingFrame(WKBundleFrameRef frame) { m_topLoadingFrame = frame; }
82
bool shouldDumpPixels() const { return m_dumpPixels; }
83
bool useWaitToDumpWatchdogTimer() const { return m_useWaitToDumpWatchdogTimer; }
85
void postNewBeforeUnloadReturnValue(bool);
86
void postAddChromeInputField();
87
void postRemoveChromeInputField();
88
void postFocusWebView();
89
void postSetBackingScaleFactor(double);
90
void postSetWindowIsKey(bool);
91
void postSimulateWebNotificationClick(uint64_t notificationID);
94
void setGeolocationPermission(bool);
95
void setMockGeolocationPosition(double latitude, double longitude, double accuracy, bool providesAltitude, double altitude, bool providesAltitudeAccuracy, double altitudeAccuracy, bool providesHeading, double heading, bool providesSpeed, double speed);
96
void setMockGeolocationPositionUnavailableError(WKStringRef errorMessage);
99
void setCustomPolicyDelegate(bool enabled, bool permissive);
102
bool shouldProcessWorkQueue() const;
103
void processWorkQueue();
104
void queueBackNavigation(unsigned howFarBackward);
105
void queueForwardNavigation(unsigned howFarForward);
106
void queueLoad(WKStringRef url, WKStringRef target);
107
void queueLoadHTMLString(WKStringRef content, WKStringRef baseURL = 0, WKStringRef unreachableURL = 0);
109
void queueLoadingScript(WKStringRef script);
110
void queueNonLoadingScript(WKStringRef script);
116
static void didCreatePage(WKBundleRef, WKBundlePageRef, const void* clientInfo);
117
static void willDestroyPage(WKBundleRef, WKBundlePageRef, const void* clientInfo);
118
static void didInitializePageGroup(WKBundleRef, WKBundlePageGroupRef, const void* clientInfo);
119
static void didReceiveMessage(WKBundleRef, WKStringRef messageName, WKTypeRef messageBody, const void* clientInfo);
120
static void didReceiveMessageToPage(WKBundleRef, WKBundlePageRef, WKStringRef messageName, WKTypeRef messageBody, const void* clientInfo);
122
void didCreatePage(WKBundlePageRef);
123
void willDestroyPage(WKBundlePageRef);
124
void didInitializePageGroup(WKBundlePageGroupRef);
125
void didReceiveMessage(WKStringRef messageName, WKTypeRef messageBody);
126
void didReceiveMessageToPage(WKBundlePageRef, WKStringRef messageName, WKTypeRef messageBody);
128
void platformInitialize(WKTypeRef initializationUserData);
129
void resetLocalSettings();
131
void beginTesting(WKDictionaryRef initialSettings);
133
bool booleanForKey(WKDictionaryRef, const char* key);
135
WKBundleRef m_bundle;
136
WKBundlePageGroupRef m_pageGroup;
137
Vector<OwnPtr<InjectedBundlePage> > m_pages;
139
RefPtr<AccessibilityController> m_accessibilityController;
140
RefPtr<TestRunner> m_testRunner;
141
RefPtr<GCController> m_gcController;
142
RefPtr<EventSendingController> m_eventSendingController;
143
RefPtr<TextInputController> m_textInputController;
145
WKBundleFrameRef m_topLoadingFrame;
147
OwnPtr<WTF::StringBuilder> m_stringBuilder;
157
bool m_useWaitToDumpWatchdogTimer;
160
WKRetainPtr<WKImageRef> m_pixelResult;
161
WKRetainPtr<WKArrayRef> m_repaintRects;
166
#endif // InjectedBundle_h