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