Add WKPageLoadData and WKPageLoadDataWithUserData SPI to support loading arbitrary...
[WebKit-https.git] / Source / WebKit2 / WebProcess / WebPage / WebPage.h
1 /*
2  * Copyright (C) 2010, 2011, 2013 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 WebPage_h
27 #define WebPage_h
28
29 #include "APIObject.h"
30 #include "DrawingArea.h"
31 #include "FindController.h"
32 #include "GeolocationPermissionRequestManager.h"
33 #include "ImageOptions.h"
34 #include "ImmutableArray.h"
35 #if ENABLE(CONTEXT_MENUS)
36 #include "InjectedBundlePageContextMenuClient.h"
37 #endif
38 #include "InjectedBundlePageDiagnosticLoggingClient.h"
39 #include "InjectedBundlePageEditorClient.h"
40 #include "InjectedBundlePageFormClient.h"
41 #include "InjectedBundlePageFullScreenClient.h"
42 #include "InjectedBundlePageLoaderClient.h"
43 #include "InjectedBundlePagePolicyClient.h"
44 #include "InjectedBundlePageResourceLoadClient.h"
45 #include "InjectedBundlePageUIClient.h"
46 #include "MessageReceiver.h"
47 #include "MessageSender.h"
48 #include "TapHighlightController.h"
49 #include "Plugin.h"
50 #include "SandboxExtension.h"
51 #include "ShareableBitmap.h"
52 #include "WebUndoStep.h"
53 #include <WebCore/DictationAlternative.h>
54 #include <WebCore/DragData.h>
55 #include <WebCore/Editor.h>
56 #include <WebCore/FrameLoaderTypes.h>
57 #include <WebCore/IntRect.h>
58 #include <WebCore/Page.h>
59 #include <WebCore/PageVisibilityState.h>
60 #include <WebCore/PlatformScreen.h>
61 #include <WebCore/ScrollTypes.h>
62 #include <WebCore/TextChecking.h>
63 #include <WebCore/WebCoreKeyboardUIMode.h>
64 #include <wtf/HashMap.h>
65 #include <wtf/OwnPtr.h>
66 #include <wtf/PassRefPtr.h>
67 #include <wtf/RefPtr.h>
68 #include <wtf/text/WTFString.h>
69
70 #if PLATFORM(QT)
71 #include "ArgumentCodersQt.h"
72 #include "QtNetworkAccessManager.h"
73 #include "QtNetworkReply.h"
74 #include "QtNetworkReplyData.h"
75 #include "QtNetworkRequestData.h"
76 #include <QNetworkReply>
77 #include <QNetworkRequest>
78 #endif
79
80 #if HAVE(ACCESSIBILITY) && (PLATFORM(GTK) || PLATFORM(EFL))
81 #include "WebPageAccessibilityObject.h"
82 #include <wtf/gobject/GRefPtr.h>
83 #endif
84
85 #if PLATFORM(GTK)
86 #include "ArgumentCodersGtk.h"
87 #include "WebPrintOperationGtk.h"
88 #endif
89
90 #if ENABLE(TOUCH_EVENTS)
91 #include <WebCore/PlatformTouchEvent.h>
92 #endif
93
94 #if PLATFORM(MAC)
95 #include "DictionaryPopupInfo.h"
96 #include "LayerHostingContext.h"
97 #include <wtf/RetainPtr.h>
98 OBJC_CLASS CALayer;
99 OBJC_CLASS NSDictionary;
100 OBJC_CLASS NSObject;
101 OBJC_CLASS WKAccessibilityWebPageObject;
102
103 #define ENABLE_PRIMARY_SNAPSHOTTED_PLUGIN_HEURISTIC 1
104 #endif
105
106 namespace CoreIPC {
107     class ArgumentDecoder;
108     class Connection;
109 }
110
111 namespace WebCore {
112     class GraphicsContext;
113     class Frame;
114     class FrameView;
115     class HTMLPlugInElement;
116     class KeyboardEvent;
117     class Page;
118     class PrintContext;
119     class Range;
120     class ResourceResponse;
121     class ResourceRequest;
122     class SharedBuffer;
123     class TextCheckingRequest;
124     class VisibleSelection;
125     struct KeypressCommand;
126     struct TextCheckingResult;
127 }
128
129 namespace WebKit {
130
131 class DrawingArea;
132 class InjectedBundleBackForwardList;
133 class NotificationPermissionRequestManager;
134 class PageBanner;
135 class PageOverlay;
136 class PluginView;
137 class SessionState;
138 class WebColorChooser;
139 class WebContextMenu;
140 class WebContextMenuItemData;
141 class WebEvent;
142 class WebFrame;
143 class WebFullScreenManager;
144 class WebImage;
145 class WebInspector;
146 class WebInspectorClient;
147 class WebKeyboardEvent;
148 class WebMouseEvent;
149 class WebNotificationClient;
150 class WebOpenPanelResultListener;
151 class WebPageGroupProxy;
152 class WebPopupMenu;
153 class WebWheelEvent;
154 struct AttributedString;
155 struct EditorState;
156 struct PrintInfo;
157 struct WebPageCreationParameters;
158 struct WebPreferencesStore;
159
160 #if ENABLE(GESTURE_EVENTS)
161 class WebGestureEvent;
162 #endif
163
164 #if ENABLE(TOUCH_EVENTS)
165 class WebTouchEvent;
166 #endif
167
168 typedef Vector<RefPtr<PageOverlay>> PageOverlayList;
169
170 class WebPage : public TypedAPIObject<APIObject::TypeBundlePage>, public CoreIPC::MessageReceiver, public CoreIPC::MessageSender<WebPage> {
171 public:
172     static PassRefPtr<WebPage> create(uint64_t pageID, const WebPageCreationParameters&);
173     virtual ~WebPage();
174
175     // Used by MessageSender.
176     CoreIPC::Connection* connection() const;
177     uint64_t destinationID() const { return pageID(); }
178
179     void close();
180
181     static WebPage* fromCorePage(WebCore::Page*);
182
183     WebCore::Page* corePage() const { return m_page.get(); }
184     uint64_t pageID() const { return m_pageID; }
185
186     void setSize(const WebCore::IntSize&);
187     const WebCore::IntSize& size() const { return m_viewSize; }
188     WebCore::IntRect bounds() const { return WebCore::IntRect(WebCore::IntPoint(), size()); }
189     
190     InjectedBundleBackForwardList* backForwardList();
191     DrawingArea* drawingArea() const { return m_drawingArea.get(); }
192
193     WebPageGroupProxy* pageGroup() const { return m_pageGroup.get(); }
194
195     void scrollMainFrameIfNotAtMaxScrollPosition(const WebCore::IntSize& scrollOffset);
196
197     void scrollBy(uint32_t scrollDirection, uint32_t scrollGranularity);
198
199     void centerSelectionInVisibleArea();
200
201 #if ENABLE(INSPECTOR)
202     WebInspector* inspector();
203 #endif
204
205 #if ENABLE(FULLSCREEN_API)
206     WebFullScreenManager* fullScreenManager();
207 #endif
208
209     // -- Called by the DrawingArea.
210     // FIXME: We could genericize these into a DrawingArea client interface. Would that be beneficial?
211     void drawRect(WebCore::GraphicsContext&, const WebCore::IntRect&);
212     void drawPageOverlay(PageOverlay*, WebCore::GraphicsContext&, const WebCore::IntRect&);
213     void layoutIfNeeded();
214
215     // -- Called from WebCore clients.
216 #if PLATFORM(MAC)
217     bool handleEditingKeyboardEvent(WebCore::KeyboardEvent*, bool saveCommands);
218 #elif !PLATFORM(GTK)
219     bool handleEditingKeyboardEvent(WebCore::KeyboardEvent*);
220 #endif
221
222     void didStartPageTransition();
223     void didCompletePageTransition();
224     void didCommitLoad(WebFrame*);
225     void didFinishLoad(WebFrame*);
226     void show();
227     String userAgent() const { return m_userAgent; }
228     WebCore::IntRect windowResizerRect() const;
229     WebCore::KeyboardUIMode keyboardUIMode();
230
231     WebUndoStep* webUndoStep(uint64_t);
232     void addWebUndoStep(uint64_t, WebUndoStep*);
233     void removeWebEditCommand(uint64_t);
234     bool isInRedo() const { return m_isInRedo; }
235
236     void setActivePopupMenu(WebPopupMenu*);
237
238 #if ENABLE(INPUT_TYPE_COLOR)
239     WebColorChooser* activeColorChooser() const { return m_activeColorChooser; }
240     void setActiveColorChooser(WebColorChooser*);
241     void didChooseColor(const WebCore::Color&);
242     void didEndColorChooser();
243 #endif
244
245     WebOpenPanelResultListener* activeOpenPanelResultListener() const { return m_activeOpenPanelResultListener.get(); }
246     void setActiveOpenPanelResultListener(PassRefPtr<WebOpenPanelResultListener>);
247
248     void didReceiveMessage(CoreIPC::Connection*, CoreIPC::MessageDecoder&) OVERRIDE;
249     void didReceiveSyncMessage(CoreIPC::Connection*, CoreIPC::MessageDecoder&, OwnPtr<CoreIPC::MessageEncoder>&) OVERRIDE;
250
251     // -- InjectedBundle methods
252 #if ENABLE(CONTEXT_MENUS)
253     void initializeInjectedBundleContextMenuClient(WKBundlePageContextMenuClient*);
254 #endif
255     void initializeInjectedBundleEditorClient(WKBundlePageEditorClient*);
256     void initializeInjectedBundleFormClient(WKBundlePageFormClient*);
257     void initializeInjectedBundleLoaderClient(WKBundlePageLoaderClient*);
258     void initializeInjectedBundlePolicyClient(WKBundlePagePolicyClient*);
259     void initializeInjectedBundleResourceLoadClient(WKBundlePageResourceLoadClient*);
260     void initializeInjectedBundleUIClient(WKBundlePageUIClient*);
261 #if ENABLE(FULLSCREEN_API)
262     void initializeInjectedBundleFullScreenClient(WKBundlePageFullScreenClient*);
263 #endif
264     void initializeInjectedBundleDiagnosticLoggingClient(WKBundlePageDiagnosticLoggingClient*);
265
266 #if ENABLE(CONTEXT_MENUS)
267     InjectedBundlePageContextMenuClient& injectedBundleContextMenuClient() { return m_contextMenuClient; }
268 #endif
269     InjectedBundlePageEditorClient& injectedBundleEditorClient() { return m_editorClient; }
270     InjectedBundlePageFormClient& injectedBundleFormClient() { return m_formClient; }
271     InjectedBundlePageLoaderClient& injectedBundleLoaderClient() { return m_loaderClient; }
272     InjectedBundlePagePolicyClient& injectedBundlePolicyClient() { return m_policyClient; }
273     InjectedBundlePageResourceLoadClient& injectedBundleResourceLoadClient() { return m_resourceLoadClient; }
274     InjectedBundlePageUIClient& injectedBundleUIClient() { return m_uiClient; }
275     InjectedBundlePageDiagnosticLoggingClient& injectedBundleDiagnosticLoggingClient() { return m_logDiagnosticMessageClient; }
276 #if ENABLE(FULLSCREEN_API)
277     InjectedBundlePageFullScreenClient& injectedBundleFullScreenClient() { return m_fullScreenClient; }
278 #endif
279
280     void setUnderlayPage(PassRefPtr<WebPage> underlayPage) { m_underlayPage = underlayPage; }
281
282     bool findStringFromInjectedBundle(const String&, FindOptions);
283
284     WebFrame* mainWebFrame() const { return m_mainFrame.get(); }
285
286     WebCore::Frame* mainFrame() const; // May return 0.
287     WebCore::FrameView* mainFrameView() const; // May return 0.
288
289     PassRefPtr<WebCore::Range> currentSelectionAsRange();
290
291 #if ENABLE(NETSCAPE_PLUGIN_API)
292     PassRefPtr<Plugin> createPlugin(WebFrame*, WebCore::HTMLPlugInElement*, const Plugin::Parameters&, String& newMIMEType);
293 #endif
294
295     EditorState editorState() const;
296
297     String renderTreeExternalRepresentation() const;
298     String renderTreeExternalRepresentationForPrinting() const;
299     uint64_t renderTreeSize() const;
300
301     void setTracksRepaints(bool);
302     bool isTrackingRepaints() const;
303     void resetTrackedRepaints();
304     PassRefPtr<ImmutableArray> trackedRepaintRects();
305
306     void executeEditingCommand(const String& commandName, const String& argument);
307     bool isEditingCommandEnabled(const String& commandName);
308     void clearMainFrameName();
309     void sendClose();
310
311     void sendSetWindowFrame(const WebCore::FloatRect&);
312
313     double textZoomFactor() const;
314     void setTextZoomFactor(double);
315     double pageZoomFactor() const;
316     void setPageZoomFactor(double);
317     void setPageAndTextZoomFactors(double pageZoomFactor, double textZoomFactor);
318     void windowScreenDidChange(uint64_t);
319
320     void scalePage(double scale, const WebCore::IntPoint& origin);
321     double pageScaleFactor() const;
322
323     void setUseFixedLayout(bool);
324     bool useFixedLayout() const { return m_useFixedLayout; }
325     void setFixedLayoutSize(const WebCore::IntSize&);
326
327     void listenForLayoutMilestones(uint32_t /* LayoutMilestones */);
328
329     void setSuppressScrollbarAnimations(bool);
330
331     void setRubberBandsAtBottom(bool);
332     void setRubberBandsAtTop(bool);
333
334     void setPaginationMode(uint32_t /* WebCore::Pagination::Mode */);
335     void setPaginationBehavesLikeColumns(bool);
336     void setPageLength(double);
337     void setGapBetweenPages(double);
338
339     void postInjectedBundleMessage(const String& messageName, CoreIPC::MessageDecoder&);
340
341     bool drawsBackground() const { return m_drawsBackground; }
342     bool drawsTransparentBackground() const { return m_drawsTransparentBackground; }
343
344     void setUnderlayColor(const WebCore::Color& color) { m_underlayColor = color; }
345     WebCore::Color underlayColor() const { return m_underlayColor; }
346
347     void stopLoading();
348     void stopLoadingFrame(uint64_t frameID);
349     void setDefersLoading(bool deferLoading);
350
351 #if USE(ACCELERATED_COMPOSITING)
352     void enterAcceleratedCompositingMode(WebCore::GraphicsLayer*);
353     void exitAcceleratedCompositingMode();
354 #endif
355
356     void addPluginView(PluginView*);
357     void removePluginView(PluginView*);
358
359 #if PLATFORM(MAC)
360     LayerHostingMode layerHostingMode() const { return m_layerHostingMode; }
361     void setLayerHostingMode(LayerHostingMode);
362
363     bool windowIsVisible() const { return m_windowIsVisible; }
364     void updatePluginsActiveAndFocusedState();
365     const WebCore::FloatRect& windowFrameInScreenCoordinates() const { return m_windowFrameInScreenCoordinates; }
366     const WebCore::FloatRect& windowFrameInUnflippedScreenCoordinates() const { return m_windowFrameInUnflippedScreenCoordinates; }
367     const WebCore::FloatRect& viewFrameInWindowCoordinates() const { return m_viewFrameInWindowCoordinates; }
368
369     bool hasCachedWindowFrame() const { return m_hasCachedWindowFrame; }
370
371     void setTopOverhangImage(PassRefPtr<WebImage>);
372     void setBottomOverhangImage(PassRefPtr<WebImage>);
373
374     void updateHeaderAndFooterLayersForDeviceScaleChange(float scaleFactor);
375 #endif
376
377     bool windowIsFocused() const;
378     bool windowAndWebPageAreFocused() const;
379     void installPageOverlay(PassRefPtr<PageOverlay>, bool shouldFadeIn = false);
380     void uninstallPageOverlay(PageOverlay*, bool shouldFadeOut = false);
381     bool hasPageOverlay() const { return m_pageOverlays.size(); }
382     PageOverlayList& pageOverlays() { return m_pageOverlays; }
383
384     void setHeaderPageBanner(PassRefPtr<PageBanner>);
385     PageBanner* headerPageBanner();
386     void setFooterPageBanner(PassRefPtr<PageBanner>);
387     PageBanner* footerPageBanner();
388
389
390     WebCore::IntPoint screenToWindow(const WebCore::IntPoint&);
391     WebCore::IntRect windowToScreen(const WebCore::IntRect&);
392
393     PassRefPtr<WebImage> scaledSnapshotWithOptions(const WebCore::IntRect&, double scaleFactor, SnapshotOptions);
394
395     static const WebEvent* currentEvent();
396
397     FindController& findController() { return m_findController; }
398 #if ENABLE(TOUCH_EVENTS) && PLATFORM(QT)
399     TapHighlightController& tapHighlightController() { return m_tapHighlightController; }
400 #endif
401
402 #if ENABLE(GEOLOCATION)
403     GeolocationPermissionRequestManager& geolocationPermissionRequestManager() { return m_geolocationPermissionRequestManager; }
404 #endif
405
406     NotificationPermissionRequestManager* notificationPermissionRequestManager();
407
408     void pageDidScroll();
409 #if USE(TILED_BACKING_STORE)
410     void pageDidRequestScroll(const WebCore::IntPoint&);
411     void setFixedVisibleContentRect(const WebCore::IntRect&);
412     void sendViewportAttributesChanged();
413 #endif
414
415 #if ENABLE(CONTEXT_MENUS)
416     WebContextMenu* contextMenu();
417     WebContextMenu* contextMenuAtPointInWindow(const WebCore::IntPoint&);
418 #endif
419     
420     bool hasLocalDataForURL(const WebCore::KURL&);
421     String cachedResponseMIMETypeForURL(const WebCore::KURL&);
422     String cachedSuggestedFilenameForURL(const WebCore::KURL&);
423     PassRefPtr<WebCore::SharedBuffer> cachedResponseDataForURL(const WebCore::KURL&);
424
425     static bool canHandleRequest(const WebCore::ResourceRequest&);
426
427     class SandboxExtensionTracker {
428     public:
429         ~SandboxExtensionTracker();
430
431         void invalidate();
432
433         void beginLoad(WebFrame*, const SandboxExtension::Handle& handle);
434         void willPerformLoadDragDestinationAction(PassRefPtr<SandboxExtension> pendingDropSandboxExtension);
435         void didStartProvisionalLoad(WebFrame*);
436         void didCommitProvisionalLoad(WebFrame*);
437         void didFailProvisionalLoad(WebFrame*);
438
439     private:
440         void setPendingProvisionalSandboxExtension(PassRefPtr<SandboxExtension>);
441
442         RefPtr<SandboxExtension> m_pendingProvisionalSandboxExtension;
443         RefPtr<SandboxExtension> m_provisionalSandboxExtension;
444         RefPtr<SandboxExtension> m_committedSandboxExtension;
445     };
446
447     SandboxExtensionTracker& sandboxExtensionTracker() { return m_sandboxExtensionTracker; }
448
449 #if PLATFORM(EFL)
450     void setThemePath(const String&);
451 #endif
452
453 #if USE(TILED_BACKING_STORE)
454     void commitPageTransitionViewport();
455 #endif
456
457 #if PLATFORM(QT) || PLATFORM(GTK)
458     void setComposition(const String& text, Vector<WebCore::CompositionUnderline> underlines, uint64_t selectionStart, uint64_t selectionEnd, uint64_t replacementRangeStart, uint64_t replacementRangeEnd);
459     void confirmComposition(const String& text, int64_t selectionStart, int64_t selectionLength);
460     void cancelComposition();
461 #endif
462
463     void didChangeSelection();
464
465 #if PLATFORM(MAC)
466     void registerUIProcessAccessibilityTokens(const CoreIPC::DataReference& elemenToken, const CoreIPC::DataReference& windowToken);
467     WKAccessibilityWebPageObject* accessibilityRemoteObject();
468     const WebCore::FloatPoint& accessibilityPosition() const { return m_accessibilityPosition; }
469     
470     void sendComplexTextInputToPlugin(uint64_t pluginComplexTextInputIdentifier, const String& textInput);
471
472     void setComposition(const String& text, Vector<WebCore::CompositionUnderline> underlines, uint64_t selectionStart, uint64_t selectionEnd, uint64_t replacementRangeStart, uint64_t replacementRangeEnd, EditorState& newState);
473     void confirmComposition(EditorState& newState);
474     void cancelComposition(EditorState& newState);
475     void insertText(const String& text, uint64_t replacementRangeStart, uint64_t replacementRangeEnd, bool& handled, EditorState& newState);
476     void getMarkedRange(uint64_t& location, uint64_t& length);
477     void getSelectedRange(uint64_t& location, uint64_t& length);
478     void getAttributedSubstringFromRange(uint64_t location, uint64_t length, AttributedString&);
479     void characterIndexForPoint(const WebCore::IntPoint point, uint64_t& result);
480     void firstRectForCharacterRange(uint64_t location, uint64_t length, WebCore::IntRect& resultRect);
481     void executeKeypressCommands(const Vector<WebCore::KeypressCommand>&, bool& handled, EditorState& newState);
482     void readSelectionFromPasteboard(const WTF::String& pasteboardName, bool& result);
483     void getStringSelectionForPasteboard(WTF::String& stringValue);
484     void getDataSelectionForPasteboard(const WTF::String pasteboardType, SharedMemory::Handle& handle, uint64_t& size);
485     void shouldDelayWindowOrderingEvent(const WebKit::WebMouseEvent&, bool& result);
486     void acceptsFirstMouse(int eventNumber, const WebKit::WebMouseEvent&, bool& result);
487     bool performNonEditingBehaviorForSelector(const String&);
488     void insertDictatedText(const String& text, uint64_t replacementRangeStart, uint64_t replacementRangeEnd, const Vector<WebCore::DictationAlternative>& dictationAlternativeLocations, bool& handled, EditorState& newState);
489 #elif PLATFORM(EFL)
490     void confirmComposition(const String& compositionString);
491     void setComposition(const WTF::String& compositionString, const WTF::Vector<WebCore::CompositionUnderline>& underlines, uint64_t cursorPosition);
492     void cancelComposition();
493 #elif PLATFORM(GTK)
494 #if USE(TEXTURE_MAPPER_GL)
495     void setAcceleratedCompositingWindowId(int64_t nativeWindowHandle);
496 #endif
497 #endif
498
499 #if HAVE(ACCESSIBILITY) && (PLATFORM(GTK) || PLATFORM(EFL))
500     void updateAccessibilityTree();
501 #endif
502
503     void setCompositionForTesting(const String& compositionString, uint64_t from, uint64_t length);
504     bool hasCompositionForTesting();
505     void confirmCompositionForTesting(const String& compositionString);
506
507     // FIXME: This a dummy message, to avoid breaking the build for platforms that don't require
508     // any synchronous messages, and should be removed when <rdar://problem/8775115> is fixed.
509     void dummy(bool&);
510
511 #if PLATFORM(MAC)
512     void performDictionaryLookupForSelection(WebCore::Frame*, const WebCore::VisibleSelection&);
513
514     bool isSpeaking();
515     void speak(const String&);
516     void stopSpeaking();
517
518 #endif
519
520     bool isSmartInsertDeleteEnabled();
521     void setSmartInsertDeleteEnabled(bool);
522
523     void replaceSelectionWithText(WebCore::Frame*, const String&);
524     void clearSelection();
525
526 #if ENABLE(DRAG_SUPPORT)
527 #if PLATFORM(QT) || PLATFORM(GTK)
528     void performDragControllerAction(uint64_t action, WebCore::DragData);
529 #else
530     void performDragControllerAction(uint64_t action, WebCore::IntPoint clientPosition, WebCore::IntPoint globalPosition, uint64_t draggingSourceOperationMask, const WTF::String& dragStorageName, uint32_t flags, const SandboxExtension::Handle&, const SandboxExtension::HandleArray&);
531 #endif
532     void dragEnded(WebCore::IntPoint clientPosition, WebCore::IntPoint globalPosition, uint64_t operation);
533
534     void willPerformLoadDragDestinationAction();
535     void mayPerformUploadDragDestinationAction();
536 #endif // ENABLE(DRAG_SUPPORT)
537
538     void beginPrinting(uint64_t frameID, const PrintInfo&);
539     void endPrinting();
540     void computePagesForPrinting(uint64_t frameID, const PrintInfo&, uint64_t callbackID);
541 #if PLATFORM(MAC)
542     void drawRectToImage(uint64_t frameID, const PrintInfo&, const WebCore::IntRect&, const WebCore::IntSize&, uint64_t callbackID);
543     void drawPagesToPDF(uint64_t frameID, const PrintInfo&, uint32_t first, uint32_t count, uint64_t callbackID);
544 #elif PLATFORM(GTK)
545     void drawPagesForPrinting(uint64_t frameID, const PrintInfo&, uint64_t callbackID);
546 #endif
547
548     void setMediaVolume(float);
549     void setMayStartMediaWhenInWindow(bool);
550
551     bool mainFrameHasCustomRepresentation() const;
552
553     void didChangeScrollOffsetForMainFrame();
554
555     void mainFrameDidLayout();
556
557     bool canRunBeforeUnloadConfirmPanel() const { return m_canRunBeforeUnloadConfirmPanel; }
558     void setCanRunBeforeUnloadConfirmPanel(bool canRunBeforeUnloadConfirmPanel) { m_canRunBeforeUnloadConfirmPanel = canRunBeforeUnloadConfirmPanel; }
559
560     bool canRunModal() const { return m_canRunModal; }
561     void setCanRunModal(bool canRunModal) { m_canRunModal = canRunModal; }
562
563     void runModal();
564
565     void setDeviceScaleFactor(float);
566     float deviceScaleFactor() const;
567
568     void setMemoryCacheMessagesEnabled(bool);
569
570     void forceRepaintWithoutCallback();
571
572     void unmarkAllMisspellings();
573     void unmarkAllBadGrammar();
574 #if PLATFORM(MAC)
575     void handleAlternativeTextUIResult(const String&);
576 #endif
577
578     // For testing purpose.
579     void simulateMouseDown(int button, WebCore::IntPoint, int clickCount, WKEventModifiers, double time);
580     void simulateMouseUp(int button, WebCore::IntPoint, int clickCount, WKEventModifiers, double time);
581     void simulateMouseMotion(WebCore::IntPoint, double time);
582
583 #if ENABLE(CONTEXT_MENUS)
584     void contextMenuShowing() { m_isShowingContextMenu = true; }
585 #endif
586
587 #if PLATFORM(QT)
588     void registerApplicationScheme(const String& scheme);
589     void applicationSchemeReply(const QtNetworkReplyData&);
590     void receivedApplicationSchemeRequest(const QNetworkRequest&, QtNetworkReply*);
591     void setUserScripts(const Vector<String>&);
592 #endif
593     void wheelEvent(const WebWheelEvent&);
594 #if ENABLE(GESTURE_EVENTS)
595     void gestureEvent(const WebGestureEvent&);
596 #endif
597
598     void numWheelEventHandlersChanged(unsigned);
599     void recomputeShortCircuitHorizontalWheelEventsState();
600
601     bool willGoToBackForwardItemCallbackEnabled() const { return m_willGoToBackForwardItemCallbackEnabled; }
602
603 #if ENABLE(PAGE_VISIBILITY_API) || ENABLE(HIDDEN_PAGE_DOM_TIMER_THROTTLING)
604     void setVisibilityState(uint32_t /* WebCore::PageVisibilityState */, bool isInitialState);
605 #endif
606     void setThrottled(bool isThrottled);
607
608 #if PLATFORM(GTK) && USE(TEXTURE_MAPPER_GL)
609     uint64_t nativeWindowHandle() { return m_nativeWindowHandle; }
610 #endif
611
612     bool shouldUseCustomRepresentationForResponse(const WebCore::ResourceResponse&);
613     bool canPluginHandleResponse(const WebCore::ResourceResponse& response);
614
615     bool asynchronousPluginInitializationEnabled() const { return m_asynchronousPluginInitializationEnabled; }
616     void setAsynchronousPluginInitializationEnabled(bool enabled) { m_asynchronousPluginInitializationEnabled = enabled; }
617     bool asynchronousPluginInitializationEnabledForAllPlugins() const { return m_asynchronousPluginInitializationEnabledForAllPlugins; }
618     void setAsynchronousPluginInitializationEnabledForAllPlugins(bool enabled) { m_asynchronousPluginInitializationEnabledForAllPlugins = enabled; }
619     bool artificialPluginInitializationDelayEnabled() const { return m_artificialPluginInitializationDelayEnabled; }
620     void setArtificialPluginInitializationDelayEnabled(bool enabled) { m_artificialPluginInitializationDelayEnabled = enabled; }
621     void setTabToLinksEnabled(bool enabled) { m_tabToLinks = enabled; }
622     bool tabToLinksEnabled() const { return m_tabToLinks; }
623
624     bool scrollingPerformanceLoggingEnabled() const { return m_scrollingPerformanceLoggingEnabled; }
625     void setScrollingPerformanceLoggingEnabled(bool);
626
627 #if PLATFORM(MAC)
628     bool shouldUsePDFPlugin() const;
629     bool pdfPluginEnabled() const { return m_pdfPluginEnabled; }
630     void setPDFPluginEnabled(bool enabled) { m_pdfPluginEnabled = enabled; }
631 #endif
632
633     void savePDFToFileInDownloadsFolder(const String& suggestedFilename, const String& originatingURLString, const uint8_t* data, unsigned long size);
634 #if PLATFORM(MAC)
635     void savePDFToTemporaryFolderAndOpenWithNativeApplication(const String& suggestedFilename, const String& originatingURLString, const uint8_t* data, unsigned long size, const String& pdfUUID);
636 #endif
637
638     bool mainFrameIsScrollable() const { return m_mainFrameIsScrollable; }
639
640     void setMinimumLayoutWidth(double);
641     double minimumLayoutWidth() const { return m_minimumLayoutWidth; }
642
643     bool canShowMIMEType(const String& MIMEType) const;
644
645     void addTextCheckingRequest(uint64_t requestID, PassRefPtr<WebCore::TextCheckingRequest>);
646     void didFinishCheckingText(uint64_t requestID, const Vector<WebCore::TextCheckingResult>&);
647     void didCancelCheckingText(uint64_t requestID);
648
649 #if ENABLE(PRIMARY_SNAPSHOTTED_PLUGIN_HEURISTIC)
650     void determinePrimarySnapshottedPlugIn();
651     void determinePrimarySnapshottedPlugInTimerFired();
652     void resetPrimarySnapshottedPlugIn();
653     bool matchesPrimaryPlugIn(const String& pageOrigin, const String& pluginOrigin, const String& mimeType) const;
654 #endif
655
656 private:
657     WebPage(uint64_t pageID, const WebPageCreationParameters&);
658
659     void platformInitialize();
660
661     void didReceiveWebPageMessage(CoreIPC::Connection*, CoreIPC::MessageDecoder&);
662     void didReceiveSyncWebPageMessage(CoreIPC::Connection*, CoreIPC::MessageDecoder&, OwnPtr<CoreIPC::MessageEncoder>&);
663
664 #if !PLATFORM(MAC)
665     static const char* interpretKeyEvent(const WebCore::KeyboardEvent*);
666 #endif
667     bool performDefaultBehaviorForKeyEvent(const WebKeyboardEvent&);
668
669 #if PLATFORM(MAC)
670     bool executeKeypressCommandsInternal(const Vector<WebCore::KeypressCommand>&, WebCore::KeyboardEvent*);
671 #endif
672
673     String sourceForFrame(WebFrame*);
674
675     void loadDataImpl(PassRefPtr<WebCore::SharedBuffer>, const String& MIMEType, const String& encodingName, const WebCore::KURL& baseURL, const WebCore::KURL& failingURL, CoreIPC::MessageDecoder&);
676
677     bool platformHasLocalDataForURL(const WebCore::KURL&);
678
679     // Actions
680     void tryClose();
681     void loadURL(const String&, const SandboxExtension::Handle&, CoreIPC::MessageDecoder&);
682     void loadURLRequest(const WebCore::ResourceRequest&, const SandboxExtension::Handle&, CoreIPC::MessageDecoder&);
683     void loadData(const CoreIPC::DataReference&, const String& MIMEType, const String& encodingName, const String& baseURL, CoreIPC::MessageDecoder&);
684     void loadHTMLString(const String& htmlString, const String& baseURL, CoreIPC::MessageDecoder&);
685     void loadAlternateHTMLString(const String& htmlString, const String& baseURL, const String& unreachableURL, CoreIPC::MessageDecoder&);
686     void loadPlainTextString(const String&, CoreIPC::MessageDecoder&);
687     void loadWebArchiveData(const CoreIPC::DataReference&, CoreIPC::MessageDecoder&);
688     void linkClicked(const String& url, const WebMouseEvent&);
689     void reload(bool reloadFromOrigin, const SandboxExtension::Handle&);
690     void goForward(uint64_t);
691     void goBack(uint64_t);
692     void goToBackForwardItem(uint64_t);
693     void tryRestoreScrollPosition();
694     void setActive(bool);
695     void setFocused(bool);
696     void setInitialFocus(bool forward, bool isKeyboardEventValid, const WebKeyboardEvent&);
697     void setWindowResizerSize(const WebCore::IntSize&);
698     void setIsInWindow(bool);
699     void validateCommand(const String&, uint64_t);
700     void executeEditCommand(const String&);
701
702     void mouseEvent(const WebMouseEvent&);
703     void mouseEventSyncForTesting(const WebMouseEvent&, bool&);
704     void wheelEventSyncForTesting(const WebWheelEvent&, bool&);
705     void keyEvent(const WebKeyboardEvent&);
706     void keyEventSyncForTesting(const WebKeyboardEvent&, bool&);
707 #if ENABLE(TOUCH_EVENTS)
708     void touchEvent(const WebTouchEvent&);
709     void touchEventSyncForTesting(const WebTouchEvent&, bool& handled);
710 #if PLATFORM(QT)
711     void highlightPotentialActivation(const WebCore::IntPoint&, const WebCore::IntSize& area);
712 #endif
713 #endif
714 #if ENABLE(CONTEXT_MENUS)
715     void contextMenuHidden() { m_isShowingContextMenu = false; }
716 #endif
717
718     static void scroll(WebCore::Page*, WebCore::ScrollDirection, WebCore::ScrollGranularity);
719     static void logicalScroll(WebCore::Page*, WebCore::ScrollLogicalDirection, WebCore::ScrollGranularity);
720
721     uint64_t restoreSession(const SessionState&);
722     void restoreSessionAndNavigateToCurrentItem(const SessionState&);
723
724     void didRemoveBackForwardItem(uint64_t);
725
726     void setWillGoToBackForwardItemCallbackEnabled(bool enabled) { m_willGoToBackForwardItemCallbackEnabled = enabled; }
727     
728     void setDrawsBackground(bool);
729     void setDrawsTransparentBackground(bool);
730
731     void viewWillStartLiveResize();
732     void viewWillEndLiveResize();
733
734     void getContentsAsString(uint64_t callbackID);
735 #if ENABLE(MHTML)
736     void getContentsAsMHTMLData(uint64_t callbackID, bool useBinaryEncoding);
737 #endif
738     void getMainResourceDataOfFrame(uint64_t frameID, uint64_t callbackID);
739     void getResourceDataFromFrame(uint64_t frameID, const String& resourceURL, uint64_t callbackID);
740     void getRenderTreeExternalRepresentation(uint64_t callbackID);
741     void getSelectionOrContentsAsString(uint64_t callbackID);
742     void getSelectionAsWebArchiveData(uint64_t callbackID);
743     void getSourceForFrame(uint64_t frameID, uint64_t callbackID);
744     void getWebArchiveOfFrame(uint64_t frameID, uint64_t callbackID);
745     void runJavaScriptInMainFrame(const String&, uint64_t callbackID);
746     void forceRepaint(uint64_t callbackID);
747
748     void preferencesDidChange(const WebPreferencesStore&);
749     void platformPreferencesDidChange(const WebPreferencesStore&);
750     void updatePreferences(const WebPreferencesStore&);
751
752     void didReceivePolicyDecision(uint64_t frameID, uint64_t listenerID, uint32_t policyAction, uint64_t downloadID);
753     void setUserAgent(const String&);
754     void setCustomTextEncodingName(const String&);
755     void suspendActiveDOMObjectsAndAnimations();
756     void resumeActiveDOMObjectsAndAnimations();
757
758 #if PLATFORM(MAC)
759     void performDictionaryLookupAtLocation(const WebCore::FloatPoint&);
760     void performDictionaryLookupForRange(WebCore::Frame*, WebCore::Range*, NSDictionary *options);
761
762     void setWindowIsVisible(bool windowIsVisible);
763     void windowAndViewFramesChanged(const WebCore::FloatRect& windowFrameInScreenCoordinates, const WebCore::FloatRect& windowFrameInUnflippedScreenCoordinates, const WebCore::FloatRect& viewFrameInWindowCoordinates, const WebCore::FloatPoint& accessibilityViewCoordinates);
764
765     RetainPtr<PDFDocument> pdfDocumentForPrintingFrame(WebCore::Frame*);
766     void computePagesForPrintingPDFDocument(uint64_t frameID, const PrintInfo&, Vector<WebCore::IntRect>& resultPageRects);
767     void drawPDFDocument(CGContextRef, PDFDocument *, const PrintInfo&, const WebCore::IntRect&);
768     void drawPagesToPDFFromPDFDocument(CGContextRef, PDFDocument *, const PrintInfo&, uint32_t first, uint32_t count);
769 #endif
770
771     void viewExposedRectChanged(const WebCore::FloatRect& exposedRect);
772     void setMainFrameIsScrollable(bool);
773
774     void unapplyEditCommand(uint64_t commandID);
775     void reapplyEditCommand(uint64_t commandID);
776     void didRemoveEditCommand(uint64_t commandID);
777
778     void findString(const String&, uint32_t findOptions, uint32_t maxMatchCount);
779     void findStringMatches(const String&, uint32_t findOptions, uint32_t maxMatchCount);
780     void getImageForFindMatch(uint32_t matchIndex);
781     void selectFindMatch(uint32_t matchIndex);
782     void hideFindUI();
783     void countStringMatches(const String&, uint32_t findOptions, uint32_t maxMatchCount);
784
785 #if PLATFORM(QT)
786     void findZoomableAreaForPoint(const WebCore::IntPoint&, const WebCore::IntSize& area);
787 #endif
788
789     void didChangeSelectedIndexForActivePopupMenu(int32_t newIndex);
790     void setTextForActivePopupMenu(int32_t index);
791
792 #if PLATFORM(GTK)
793     void failedToShowPopupMenu();
794 #endif
795 #if PLATFORM(QT)
796     void hidePopupMenu();
797     void selectedIndex(int32_t newIndex);
798 #endif
799
800     void didChooseFilesForOpenPanel(const Vector<String>&);
801     void didCancelForOpenPanel();
802 #if ENABLE(WEB_PROCESS_SANDBOX)
803     void extendSandboxForFileFromOpenPanel(const SandboxExtension::Handle&);
804 #endif
805
806     void didReceiveGeolocationPermissionDecision(uint64_t geolocationID, bool allowed);
807
808     void didReceiveNotificationPermissionDecision(uint64_t notificationID, bool allowed);
809
810     void advanceToNextMisspelling(bool startBeforeSelection);
811     void changeSpellingToWord(const String& word);
812 #if USE(APPKIT)
813     void uppercaseWord();
814     void lowercaseWord();
815     void capitalizeWord();
816 #endif
817
818 #if ENABLE(CONTEXT_MENUS)
819     void didSelectItemFromActiveContextMenu(const WebContextMenuItemData&);
820 #endif
821
822     void changeSelectedIndex(int32_t index);
823     void setCanStartMediaTimerFired();
824     void didUpdateInWindowStateTimerFired();
825
826     bool canHandleUserEvents() const;
827
828     void setMainFrameInViewSourceMode(bool);
829     void setOverridePrivateBrowsingEnabled(bool);
830
831     static bool platformCanHandleRequest(const WebCore::ResourceRequest&);
832
833     static PluginView* focusedPluginViewForFrame(WebCore::Frame*);
834     static PluginView* pluginViewForFrame(WebCore::Frame*);
835
836     void reportUsedFeatures();
837
838     OwnPtr<WebCore::Page> m_page;
839     RefPtr<WebFrame> m_mainFrame;
840     RefPtr<InjectedBundleBackForwardList> m_backForwardList;
841
842     RefPtr<WebPageGroupProxy> m_pageGroup;
843
844     String m_userAgent;
845
846     WebCore::IntSize m_viewSize;
847     OwnPtr<DrawingArea> m_drawingArea;
848
849     HashSet<PluginView*> m_pluginViews;
850
851     HashMap<uint64_t, RefPtr<WebCore::TextCheckingRequest>> m_pendingTextCheckingRequestMap;
852
853     bool m_useFixedLayout;
854
855     bool m_drawsBackground;
856     bool m_drawsTransparentBackground;
857
858     WebCore::Color m_underlayColor;
859
860     bool m_isInRedo;
861     bool m_isClosed;
862
863     bool m_tabToLinks;
864     
865     bool m_asynchronousPluginInitializationEnabled;
866     bool m_asynchronousPluginInitializationEnabledForAllPlugins;
867     bool m_artificialPluginInitializationDelayEnabled;
868
869     bool m_scrollingPerformanceLoggingEnabled;
870
871     bool m_mainFrameIsScrollable;
872
873 #if ENABLE(PRIMARY_SNAPSHOTTED_PLUGIN_HEURISTIC)
874     bool m_readyToFindPrimarySnapshottedPlugin;
875     bool m_didFindPrimarySnapshottedPlugin;
876     String m_primaryPlugInPageOrigin;
877     String m_primaryPlugInOrigin;
878     String m_primaryPlugInMimeType;
879     WebCore::RunLoop::Timer<WebPage> m_determinePrimarySnapshottedPlugInTimer;
880 #endif
881
882 #if PLATFORM(MAC)
883     bool m_pdfPluginEnabled;
884
885     bool m_hasCachedWindowFrame;
886
887     // Whether the containing window is visible or not.
888     bool m_windowIsVisible;
889
890     // The frame of the containing window in screen coordinates.
891     WebCore::FloatRect m_windowFrameInScreenCoordinates;
892
893     // The frame of the containing window in unflipped screen coordinates.
894     WebCore::FloatRect m_windowFrameInUnflippedScreenCoordinates;
895
896     // The frame of the view in window coordinates.
897     WebCore::FloatRect m_viewFrameInWindowCoordinates;
898
899     // The accessibility position of the view.
900     WebCore::FloatPoint m_accessibilityPosition;
901     
902     // The layer hosting mode.
903     LayerHostingMode m_layerHostingMode;
904
905     RetainPtr<WKAccessibilityWebPageObject> m_mockAccessibilityElement;
906
907     WebCore::KeyboardEvent* m_keyboardEventBeingInterpreted;
908
909 #elif HAVE(ACCESSIBILITY) && (PLATFORM(GTK) || PLATFORM(EFL))
910     GRefPtr<WebPageAccessibilityObject> m_accessibilityObject;
911
912 #if USE(TEXTURE_MAPPER_GL)
913     // Our view's window in the UI process.
914     uint64_t m_nativeWindowHandle;
915 #endif
916 #endif
917
918     RefPtr<PageBanner> m_headerBanner;
919     RefPtr<PageBanner> m_footerBanner;
920
921     WebCore::RunLoop::Timer<WebPage> m_setCanStartMediaTimer;
922     WebCore::RunLoop::Timer<WebPage> m_sendDidUpdateInWindowStateTimer;
923     bool m_mayStartMediaWhenInWindow;
924
925     HashMap<uint64_t, RefPtr<WebUndoStep>> m_undoStepMap;
926
927     WebCore::IntSize m_windowResizerSize;
928
929 #if ENABLE(CONTEXT_MENUS)
930     InjectedBundlePageContextMenuClient m_contextMenuClient;
931 #endif
932     InjectedBundlePageEditorClient m_editorClient;
933     InjectedBundlePageFormClient m_formClient;
934     InjectedBundlePageLoaderClient m_loaderClient;
935     InjectedBundlePagePolicyClient m_policyClient;
936     InjectedBundlePageResourceLoadClient m_resourceLoadClient;
937     InjectedBundlePageUIClient m_uiClient;
938 #if ENABLE(FULLSCREEN_API)
939     InjectedBundlePageFullScreenClient m_fullScreenClient;
940 #endif
941     InjectedBundlePageDiagnosticLoggingClient m_logDiagnosticMessageClient;
942
943     FindController m_findController;
944 #if ENABLE(TOUCH_EVENTS) && PLATFORM(QT)
945     TapHighlightController m_tapHighlightController;
946 #endif
947     PageOverlayList m_pageOverlays;
948
949     RefPtr<WebPage> m_underlayPage;
950
951 #if ENABLE(INSPECTOR)
952     RefPtr<WebInspector> m_inspector;
953 #endif
954 #if ENABLE(FULLSCREEN_API)
955     RefPtr<WebFullScreenManager> m_fullScreenManager;
956 #endif
957     RefPtr<WebPopupMenu> m_activePopupMenu;
958 #if ENABLE(CONTEXT_MENUS)
959     RefPtr<WebContextMenu> m_contextMenu;
960 #endif
961 #if ENABLE(INPUT_TYPE_COLOR)
962     WebColorChooser* m_activeColorChooser;
963 #endif
964     RefPtr<WebOpenPanelResultListener> m_activeOpenPanelResultListener;
965     RefPtr<NotificationPermissionRequestManager> m_notificationPermissionRequestManager;
966
967 #if ENABLE(GEOLOCATION)
968     GeolocationPermissionRequestManager m_geolocationPermissionRequestManager;
969 #endif
970
971     OwnPtr<WebCore::PrintContext> m_printContext;
972 #if PLATFORM(GTK)
973     RefPtr<WebPrintOperationGtk> m_printOperation;
974 #endif
975
976     SandboxExtensionTracker m_sandboxExtensionTracker;
977     uint64_t m_pageID;
978
979     RefPtr<SandboxExtension> m_pendingDropSandboxExtension;
980     Vector<RefPtr<SandboxExtension>> m_pendingDropExtensionsForFileUpload;
981
982     bool m_canRunBeforeUnloadConfirmPanel;
983
984     bool m_canRunModal;
985     bool m_isRunningModal;
986
987     bool m_cachedMainFrameIsPinnedToLeftSide;
988     bool m_cachedMainFrameIsPinnedToRightSide;
989     bool m_cachedMainFrameIsPinnedToTopSide;
990     bool m_cachedMainFrameIsPinnedToBottomSide;
991     bool m_canShortCircuitHorizontalWheelEvents;
992     unsigned m_numWheelEventHandlers;
993
994     unsigned m_cachedPageCount;
995
996     double m_minimumLayoutWidth;
997
998 #if ENABLE(CONTEXT_MENUS)
999     bool m_isShowingContextMenu;
1000 #endif
1001     
1002     bool m_willGoToBackForwardItemCallbackEnabled;
1003     bool m_overridePrivateBrowsingEnabled;
1004     
1005 #if PLATFORM(QT)
1006     HashMap<String, QtNetworkReply*> m_applicationSchemeReplies;
1007 #endif
1008 #if ENABLE(PAGE_VISIBILITY_API)
1009     WebCore::PageVisibilityState m_visibilityState;
1010 #endif
1011     WebInspectorClient* m_inspectorClient;
1012
1013     HashSet<String, CaseFoldingHash> m_mimeTypesWithCustomRepresentations;
1014     WebCore::Color m_backgroundColor;
1015 };
1016
1017 } // namespace WebKit
1018
1019 #endif // WebPage_h