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