f1862fb6faf2f84d78fbd04c49da1f9c07eeca18
[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 #include "InjectedBundlePageContextMenuClient.h"
36 #include "InjectedBundlePageEditorClient.h"
37 #include "InjectedBundlePageFormClient.h"
38 #include "InjectedBundlePageFullScreenClient.h"
39 #include "InjectedBundlePageLoaderClient.h"
40 #include "InjectedBundlePagePolicyClient.h"
41 #include "InjectedBundlePageResourceLoadClient.h"
42 #include "InjectedBundlePageUIClient.h"
43 #include "MessageSender.h"
44 #include "Plugin.h"
45 #include "SandboxExtension.h"
46 #include "ShareableBitmap.h"
47 #include "WebUndoStep.h"
48 #include <WebCore/DragData.h>
49 #include <WebCore/Editor.h>
50 #include <WebCore/FrameLoaderTypes.h>
51 #include <WebCore/IntRect.h>
52 #include <WebCore/PlatformScreen.h>
53 #include <WebCore/ScrollTypes.h>
54 #include <WebCore/WebCoreKeyboardUIMode.h>
55 #include <wtf/HashMap.h>
56 #include <wtf/OwnPtr.h>
57 #include <wtf/PassRefPtr.h>
58 #include <wtf/RefPtr.h>
59 #include <wtf/text/WTFString.h>
60
61 #if PLATFORM(QT)
62 #include "ArgumentCodersQt.h"
63 #endif
64
65 #if PLATFORM(GTK)
66 #include "ArgumentCodersGtk.h"
67 #endif
68
69 #if ENABLE(TOUCH_EVENTS)
70 #include <WebCore/PlatformTouchEvent.h>
71 #endif
72
73 #if PLATFORM(MAC)
74 #include "DictionaryPopupInfo.h"
75 #include <wtf/RetainPtr.h>
76 OBJC_CLASS NSDictionary;
77 OBJC_CLASS NSObject;
78 OBJC_CLASS WKAccessibilityWebPageObject;
79 #endif
80
81 namespace CoreIPC {
82     class ArgumentDecoder;
83     class Connection;
84     class MessageID;
85 }
86
87 namespace WebCore {
88     class GraphicsContext;
89     class Frame;
90     class FrameView;
91     class KeyboardEvent;
92     class Page;
93     class PrintContext;
94     class Range;
95     class ResourceRequest;
96     class SharedBuffer;
97     class VisibleSelection;
98     struct KeypressCommand;
99 }
100
101 namespace WebKit {
102
103 class DrawingArea;
104 class InjectedBundleBackForwardList;
105 class NotificationPermissionRequestManager;
106 class PageOverlay;
107 class PluginView;
108 class SessionState;
109 class WebContextMenu;
110 class WebContextMenuItemData;
111 class WebEvent;
112 class WebFrame;
113 class WebFullScreenManager;
114 class WebImage;
115 class WebInspector;
116 class WebKeyboardEvent;
117 class WebMouseEvent;
118 class WebNotificationClient;
119 class WebOpenPanelResultListener;
120 class WebPageGroupProxy;
121 class WebPopupMenu;
122 class WebWheelEvent;
123 struct AttributedString;
124 struct EditorState;
125 struct PrintInfo;
126 struct WebPageCreationParameters;
127 struct WebPreferencesStore;
128
129 #if ENABLE(GESTURE_EVENTS)
130 class WebGestureEvent;
131 #endif
132
133 #if ENABLE(TOUCH_EVENTS)
134 class WebTouchEvent;
135 #endif
136
137 class WebPage : public APIObject, public CoreIPC::MessageSender<WebPage> {
138 public:
139     static const Type APIType = TypeBundlePage;
140
141     static PassRefPtr<WebPage> create(uint64_t pageID, const WebPageCreationParameters&);
142     virtual ~WebPage();
143
144     // Used by MessageSender.
145     CoreIPC::Connection* connection() const;
146     uint64_t destinationID() const { return pageID(); }
147
148     void close();
149
150     WebCore::Page* corePage() const { return m_page.get(); }
151     uint64_t pageID() const { return m_pageID; }
152
153     void setSize(const WebCore::IntSize&);
154     const WebCore::IntSize& size() const { return m_viewSize; }
155     WebCore::IntRect bounds() const { return WebCore::IntRect(WebCore::IntPoint(), size()); }
156     
157     InjectedBundleBackForwardList* backForwardList();
158     DrawingArea* drawingArea() const { return m_drawingArea.get(); }
159
160     WebPageGroupProxy* pageGroup() const { return m_pageGroup.get(); }
161
162     void scrollMainFrameIfNotAtMaxScrollPosition(const WebCore::IntSize& scrollOffset);
163
164     void scrollBy(uint32_t scrollDirection, uint32_t scrollGranularity);
165
166     void centerSelectionInVisibleArea();
167
168 #if ENABLE(INSPECTOR)
169     WebInspector* inspector();
170 #endif
171
172 #if ENABLE(FULLSCREEN_API)
173     WebFullScreenManager* fullScreenManager();
174 #endif
175
176     // -- Called by the DrawingArea.
177     // FIXME: We could genericize these into a DrawingArea client interface. Would that be beneficial?
178     void drawRect(WebCore::GraphicsContext&, const WebCore::IntRect&);
179     void drawPageOverlay(WebCore::GraphicsContext&, const WebCore::IntRect&);
180     void layoutIfNeeded();
181
182     // -- Called from WebCore clients.
183 #if PLATFORM(MAC)
184     bool handleEditingKeyboardEvent(WebCore::KeyboardEvent*, bool saveCommands);
185 #elif !PLATFORM(GTK)
186     bool handleEditingKeyboardEvent(WebCore::KeyboardEvent*);
187 #endif
188
189     void show();
190     String userAgent() const { return m_userAgent; }
191     WebCore::IntRect windowResizerRect() const;
192     WebCore::KeyboardUIMode keyboardUIMode();
193
194     WebUndoStep* webUndoStep(uint64_t);
195     void addWebUndoStep(uint64_t, WebUndoStep*);
196     void removeWebEditCommand(uint64_t);
197     bool isInRedo() const { return m_isInRedo; }
198
199     void setActivePopupMenu(WebPopupMenu*);
200     
201     WebOpenPanelResultListener* activeOpenPanelResultListener() const { return m_activeOpenPanelResultListener.get(); }
202     void setActiveOpenPanelResultListener(PassRefPtr<WebOpenPanelResultListener>);
203
204     // -- Called from WebProcess.
205     void didReceiveMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*);
206     void didReceiveSyncMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*, OwnPtr<CoreIPC::ArgumentEncoder>&);
207
208     // -- InjectedBundle methods
209     void initializeInjectedBundleContextMenuClient(WKBundlePageContextMenuClient*);
210     void initializeInjectedBundleEditorClient(WKBundlePageEditorClient*);
211     void initializeInjectedBundleFormClient(WKBundlePageFormClient*);
212     void initializeInjectedBundleLoaderClient(WKBundlePageLoaderClient*);
213     void initializeInjectedBundlePolicyClient(WKBundlePagePolicyClient*);
214     void initializeInjectedBundleResourceLoadClient(WKBundlePageResourceLoadClient*);
215     void initializeInjectedBundleUIClient(WKBundlePageUIClient*);
216 #if ENABLE(FULLSCREEN_API)
217     void initializeInjectedBundleFullScreenClient(WKBundlePageFullScreenClient*);
218 #endif
219
220     InjectedBundlePageContextMenuClient& injectedBundleContextMenuClient() { return m_contextMenuClient; }
221     InjectedBundlePageEditorClient& injectedBundleEditorClient() { return m_editorClient; }
222     InjectedBundlePageFormClient& injectedBundleFormClient() { return m_formClient; }
223     InjectedBundlePageLoaderClient& injectedBundleLoaderClient() { return m_loaderClient; }
224     InjectedBundlePagePolicyClient& injectedBundlePolicyClient() { return m_policyClient; }
225     InjectedBundlePageResourceLoadClient& injectedBundleResourceLoadClient() { return m_resourceLoadClient; }
226     InjectedBundlePageUIClient& injectedBundleUIClient() { return m_uiClient; }
227 #if ENABLE(FULLSCREEN_API)
228     InjectedBundlePageFullScreenClient& injectedBundleFullScreenClient() { return m_fullScreenClient; }
229 #endif
230
231     void setUnderlayPage(PassRefPtr<WebPage> underlayPage) { m_underlayPage = underlayPage; }
232
233     bool findStringFromInjectedBundle(const String&, FindOptions);
234
235     WebFrame* mainWebFrame() const { return m_mainFrame.get(); }
236
237     WebCore::Frame* mainFrame() const; // May return 0.
238     WebCore::FrameView* mainFrameView() const; // May return 0.
239
240     PassRefPtr<Plugin> createPlugin(const Plugin::Parameters&);
241
242     EditorState editorState() const;
243
244     String renderTreeExternalRepresentation() const;
245     uint64_t renderTreeSize() const;
246
247     void setTracksRepaints(bool);
248     bool isTrackingRepaints() const;
249     void resetTrackedRepaints();
250     PassRefPtr<ImmutableArray> trackedRepaintRects();
251
252     void executeEditingCommand(const String& commandName, const String& argument);
253     bool isEditingCommandEnabled(const String& commandName);
254     void clearMainFrameName();
255     void sendClose();
256
257     double textZoomFactor() const;
258     void setTextZoomFactor(double);
259     double pageZoomFactor() const;
260     void setPageZoomFactor(double);
261     void setPageAndTextZoomFactors(double pageZoomFactor, double textZoomFactor);
262     void windowScreenDidChange(uint64_t);
263
264     void scalePage(double scale, const WebCore::IntPoint& origin);
265     double pageScaleFactor() const;
266
267     void setUseFixedLayout(bool);
268     bool useFixedLayout() const { return m_useFixedLayout; }
269     void setFixedLayoutSize(const WebCore::IntSize&);
270
271     void setPaginationMode(uint32_t /* WebCore::Page::Pagination::Mode */);
272     void setPageLength(double);
273     void setGapBetweenPages(double);
274
275     bool drawsBackground() const { return m_drawsBackground; }
276     bool drawsTransparentBackground() const { return m_drawsTransparentBackground; }
277
278     void stopLoading();
279     void stopLoadingFrame(uint64_t frameID);
280     void setDefersLoading(bool deferLoading);
281
282 #if USE(ACCELERATED_COMPOSITING)
283     void enterAcceleratedCompositingMode(WebCore::GraphicsLayer*);
284     void exitAcceleratedCompositingMode();
285 #endif
286
287 #if PLATFORM(MAC)
288     void addPluginView(PluginView*);
289     void removePluginView(PluginView*);
290
291     bool windowIsVisible() const { return m_windowIsVisible; }
292     const WebCore::IntRect& windowFrameInScreenCoordinates() const { return m_windowFrameInScreenCoordinates; }
293     const WebCore::IntRect& viewFrameInWindowCoordinates() const { return m_viewFrameInWindowCoordinates; }
294 #elif PLATFORM(WIN)
295     HWND nativeWindow() const { return m_nativeWindow; }
296 #endif
297
298     bool windowIsFocused() const;
299     void installPageOverlay(PassRefPtr<PageOverlay>);
300     void uninstallPageOverlay(PageOverlay*, bool fadeOut);
301     bool hasPageOverlay() const { return m_pageOverlay; }
302     WebCore::IntPoint screenToWindow(const WebCore::IntPoint&);
303     WebCore::IntRect windowToScreen(const WebCore::IntRect&);
304
305     PassRefPtr<WebImage> snapshotInViewCoordinates(const WebCore::IntRect&, ImageOptions);
306     PassRefPtr<WebImage> snapshotInDocumentCoordinates(const WebCore::IntRect&, ImageOptions);
307     PassRefPtr<WebImage> scaledSnapshotInDocumentCoordinates(const WebCore::IntRect&, double scaleFactor, ImageOptions);
308
309     static const WebEvent* currentEvent();
310
311     FindController& findController() { return m_findController; }
312     GeolocationPermissionRequestManager& geolocationPermissionRequestManager() { return m_geolocationPermissionRequestManager; }
313     NotificationPermissionRequestManager* notificationPermissionRequestManager();
314
315     void pageDidScroll();
316 #if USE(TILED_BACKING_STORE)
317     void pageDidRequestScroll(const WebCore::IntPoint&);
318     void setFixedVisibleContentRect(const WebCore::IntRect&);
319     void setResizesToContentsUsingLayoutSize(const WebCore::IntSize&);
320     void resizeToContentsIfNeeded();
321     void setViewportSize(const WebCore::IntSize&);
322     WebCore::IntSize viewportSize() const { return m_viewportSize; }
323 #endif
324
325     WebContextMenu* contextMenu();
326     
327     bool hasLocalDataForURL(const WebCore::KURL&);
328     String cachedResponseMIMETypeForURL(const WebCore::KURL&);
329     String cachedSuggestedFilenameForURL(const WebCore::KURL&);
330     PassRefPtr<WebCore::SharedBuffer> cachedResponseDataForURL(const WebCore::KURL&);
331
332     static bool canHandleRequest(const WebCore::ResourceRequest&);
333
334     class SandboxExtensionTracker {
335     public:
336         ~SandboxExtensionTracker();
337
338         void invalidate();
339
340         void beginLoad(WebFrame*, const SandboxExtension::Handle& handle);
341         void willPerformLoadDragDestinationAction(PassRefPtr<SandboxExtension> pendingDropSandboxExtension);
342         void didStartProvisionalLoad(WebFrame*);
343         void didCommitProvisionalLoad(WebFrame*);
344         void didFailProvisionalLoad(WebFrame*);
345
346     private:
347         void setPendingProvisionalSandboxExtension(PassRefPtr<SandboxExtension>);
348
349         RefPtr<SandboxExtension> m_pendingProvisionalSandboxExtension;
350         RefPtr<SandboxExtension> m_provisionalSandboxExtension;
351         RefPtr<SandboxExtension> m_committedSandboxExtension;
352     };
353
354     SandboxExtensionTracker& sandboxExtensionTracker() { return m_sandboxExtensionTracker; }
355
356 #if PLATFORM(QT)
357     void setComposition(const String& text, Vector<WebCore::CompositionUnderline> underlines, uint64_t selectionStart, uint64_t selectionEnd, uint64_t replacementRangeStart, uint64_t replacementRangeEnd);
358     void confirmComposition(const String& text, int64_t selectionStart, int64_t selectionLength);
359     void cancelComposition();
360 #endif
361
362 #if PLATFORM(MAC)
363     void registerUIProcessAccessibilityTokens(const CoreIPC::DataReference& elemenToken, const CoreIPC::DataReference& windowToken);
364     WKAccessibilityWebPageObject* accessibilityRemoteObject();
365     WebCore::IntPoint accessibilityPosition() const { return m_accessibilityPosition; }    
366     
367     void sendComplexTextInputToPlugin(uint64_t pluginComplexTextInputIdentifier, const String& textInput);
368
369     void setComposition(const String& text, Vector<WebCore::CompositionUnderline> underlines, uint64_t selectionStart, uint64_t selectionEnd, uint64_t replacementRangeStart, uint64_t replacementRangeEnd, EditorState& newState);
370     void confirmComposition(EditorState& newState);
371     void cancelComposition(EditorState& newState);
372     void insertText(const String& text, uint64_t replacementRangeStart, uint64_t replacementRangeEnd, bool& handled, EditorState& newState);
373     void getMarkedRange(uint64_t& location, uint64_t& length);
374     void getSelectedRange(uint64_t& location, uint64_t& length);
375     void getAttributedSubstringFromRange(uint64_t location, uint64_t length, AttributedString&);
376     void characterIndexForPoint(const WebCore::IntPoint point, uint64_t& result);
377     void firstRectForCharacterRange(uint64_t location, uint64_t length, WebCore::IntRect& resultRect);
378     void executeKeypressCommands(const Vector<WebCore::KeypressCommand>&, bool& handled, EditorState& newState);
379     void writeSelectionToPasteboard(const WTF::String& pasteboardName, const WTF::Vector<WTF::String>& pasteboardTypes, bool& result);
380     void readSelectionFromPasteboard(const WTF::String& pasteboardName, bool& result);
381     void shouldDelayWindowOrderingEvent(const WebKit::WebMouseEvent&, bool& result);
382     void acceptsFirstMouse(int eventNumber, const WebKit::WebMouseEvent&, bool& result);
383     bool performNonEditingBehaviorForSelector(const String&);
384
385 #elif PLATFORM(WIN)
386     void confirmComposition(const String& compositionString);
387     void setComposition(const WTF::String& compositionString, const WTF::Vector<WebCore::CompositionUnderline>& underlines, uint64_t cursorPosition);
388     void firstRectForCharacterInSelectedRange(const uint64_t characterPosition, WebCore::IntRect& resultRect);
389     void getSelectedText(WTF::String&);
390
391     void gestureWillBegin(const WebCore::IntPoint&, bool& canBeginPanning);
392     void gestureDidScroll(const WebCore::IntSize&);
393     void gestureDidEnd();
394 #endif
395
396     void setCompositionForTesting(const String& compositionString, uint64_t from, uint64_t length);
397     bool hasCompositionForTesting();
398     void confirmCompositionForTesting(const String& compositionString);
399
400     // FIXME: This a dummy message, to avoid breaking the build for platforms that don't require
401     // any synchronous messages, and should be removed when <rdar://problem/8775115> is fixed.
402     void dummy(bool&);
403
404 #if PLATFORM(MAC)
405     void performDictionaryLookupForSelection(DictionaryPopupInfo::Type, WebCore::Frame*, const WebCore::VisibleSelection&);
406
407     bool isSpeaking();
408     void speak(const String&);
409     void stopSpeaking();
410
411     bool isSmartInsertDeleteEnabled() const { return m_isSmartInsertDeleteEnabled; }
412 #endif
413
414     void replaceSelectionWithText(WebCore::Frame*, const String&);
415     void clearSelection();
416 #if PLATFORM(WIN)
417     void performDragControllerAction(uint64_t action, WebCore::IntPoint clientPosition, WebCore::IntPoint globalPosition, uint64_t draggingSourceOperationMask, const WebCore::DragDataMap&, uint32_t flags);
418 #elif PLATFORM(QT) || PLATFORM(GTK)
419     void performDragControllerAction(uint64_t action, WebCore::DragData);
420 #else
421     void performDragControllerAction(uint64_t action, WebCore::IntPoint clientPosition, WebCore::IntPoint globalPosition, uint64_t draggingSourceOperationMask, const WTF::String& dragStorageName, uint32_t flags, const SandboxExtension::Handle&);
422 #endif
423     void dragEnded(WebCore::IntPoint clientPosition, WebCore::IntPoint globalPosition, uint64_t operation);
424
425     void willPerformLoadDragDestinationAction();
426
427     void beginPrinting(uint64_t frameID, const PrintInfo&);
428     void endPrinting();
429     void computePagesForPrinting(uint64_t frameID, const PrintInfo&, uint64_t callbackID);
430 #if PLATFORM(MAC) || PLATFORM(WIN)
431     void drawRectToPDF(uint64_t frameID, const PrintInfo&, const WebCore::IntRect&, uint64_t callbackID);
432     void drawPagesToPDF(uint64_t frameID, const PrintInfo&, uint32_t first, uint32_t count, uint64_t callbackID);
433 #endif
434
435     bool mainFrameHasCustomRepresentation() const;
436
437     void didChangeScrollOffsetForMainFrame();
438
439     void mainFrameDidLayout();
440
441     bool canRunBeforeUnloadConfirmPanel() const { return m_canRunBeforeUnloadConfirmPanel; }
442     void setCanRunBeforeUnloadConfirmPanel(bool canRunBeforeUnloadConfirmPanel) { m_canRunBeforeUnloadConfirmPanel = canRunBeforeUnloadConfirmPanel; }
443
444     bool canRunModal() const { return m_canRunModal; }
445     void setCanRunModal(bool canRunModal) { m_canRunModal = canRunModal; }
446
447     void runModal();
448
449     void setDeviceScaleFactor(float);
450     float deviceScaleFactor() const;
451
452     void setMemoryCacheMessagesEnabled(bool);
453
454     void forceRepaintWithoutCallback();
455
456     void unmarkAllMisspellings();
457     void unmarkAllBadGrammar();
458
459 #if PLATFORM(MAC) && !defined(BUILDING_ON_SNOW_LEOPARD)
460     void handleCorrectionPanelResult(const String&);
461 #endif
462
463     // For testing purpose.
464     void simulateMouseDown(int button, WebCore::IntPoint, int clickCount, WKEventModifiers, double time);
465     void simulateMouseUp(int button, WebCore::IntPoint, int clickCount, WKEventModifiers, double time);
466     void simulateMouseMotion(WebCore::IntPoint, double time);
467     String viewportConfigurationAsText(int deviceDPI, int deviceWidth, int deviceHeight, int availableWidth, int availableHeight);
468
469     void contextMenuShowing() { m_isShowingContextMenu = true; }
470
471     void wheelEvent(const WebWheelEvent&);
472 #if ENABLE(GESTURE_EVENTS)
473     void gestureEvent(const WebGestureEvent&);
474 #endif
475
476 private:
477     WebPage(uint64_t pageID, const WebPageCreationParameters&);
478
479     virtual Type type() const { return APIType; }
480
481     void platformInitialize();
482
483     void didReceiveWebPageMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*);
484     void didReceiveSyncWebPageMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*, OwnPtr<CoreIPC::ArgumentEncoder>&);
485
486 #if !PLATFORM(MAC)
487     static const char* interpretKeyEvent(const WebCore::KeyboardEvent*);
488 #endif
489     bool performDefaultBehaviorForKeyEvent(const WebKeyboardEvent&);
490
491 #if PLATFORM(MAC)
492     bool executeKeypressCommandsInternal(const Vector<WebCore::KeypressCommand>&, WebCore::KeyboardEvent*);
493 #endif
494
495     String sourceForFrame(WebFrame*);
496
497     void loadData(PassRefPtr<WebCore::SharedBuffer>, const String& MIMEType, const String& encodingName, const WebCore::KURL& baseURL, const WebCore::KURL& failingURL);
498
499     bool platformHasLocalDataForURL(const WebCore::KURL&);
500
501     // Actions
502     void tryClose();
503     void loadURL(const String&, const SandboxExtension::Handle&);
504     void loadURLRequest(const WebCore::ResourceRequest&, const SandboxExtension::Handle&);
505     void loadHTMLString(const String& htmlString, const String& baseURL);
506     void loadAlternateHTMLString(const String& htmlString, const String& baseURL, const String& unreachableURL);
507     void loadPlainTextString(const String&);
508     void linkClicked(const String& url, const WebMouseEvent&);
509     void reload(bool reloadFromOrigin);
510     void goForward(uint64_t, const SandboxExtension::Handle&);
511     void goBack(uint64_t, const SandboxExtension::Handle&);
512     void goToBackForwardItem(uint64_t, const SandboxExtension::Handle&);
513     void tryRestoreScrollPosition();
514     void setActive(bool);
515     void setFocused(bool);
516     void setInitialFocus(bool forward, bool isKeyboardEventValid, const WebKeyboardEvent&);
517     void setWindowResizerSize(const WebCore::IntSize&);
518     void setIsInWindow(bool);
519     void validateCommand(const String&, uint64_t);
520     void executeEditCommand(const String&);
521
522     void mouseEvent(const WebMouseEvent&);
523     void mouseEventSyncForTesting(const WebMouseEvent&, bool&);
524     void wheelEventSyncForTesting(const WebWheelEvent&, bool&);
525     void keyEvent(const WebKeyboardEvent&);
526     void keyEventSyncForTesting(const WebKeyboardEvent&, bool&);
527 #if ENABLE(TOUCH_EVENTS)
528     void touchEvent(const WebTouchEvent&);
529     void touchEventSyncForTesting(const WebTouchEvent&, bool& handled);
530 #endif
531     void contextMenuHidden() { m_isShowingContextMenu = false; }
532
533     static void scroll(WebCore::Page*, WebCore::ScrollDirection, WebCore::ScrollGranularity);
534     static void logicalScroll(WebCore::Page*, WebCore::ScrollLogicalDirection, WebCore::ScrollGranularity);
535
536     uint64_t restoreSession(const SessionState&);
537     void restoreSessionAndNavigateToCurrentItem(const SessionState&, const SandboxExtension::Handle&);
538
539     void didRemoveBackForwardItem(uint64_t);
540
541     void setDrawsBackground(bool);
542     void setDrawsTransparentBackground(bool);
543
544     void viewWillStartLiveResize();
545     void viewWillEndLiveResize();
546
547     void getContentsAsString(uint64_t callbackID);
548     void getMainResourceDataOfFrame(uint64_t frameID, uint64_t callbackID);
549     void getResourceDataFromFrame(uint64_t frameID, const String& resourceURL, uint64_t callbackID);
550     void getRenderTreeExternalRepresentation(uint64_t callbackID);
551     void getSelectionOrContentsAsString(uint64_t callbackID);
552     void getSourceForFrame(uint64_t frameID, uint64_t callbackID);
553     void getWebArchiveOfFrame(uint64_t frameID, uint64_t callbackID);
554     void runJavaScriptInMainFrame(const String&, uint64_t callbackID);
555     void forceRepaint(uint64_t callbackID);
556
557     void preferencesDidChange(const WebPreferencesStore&);
558     void platformPreferencesDidChange(const WebPreferencesStore&);
559     void updatePreferences(const WebPreferencesStore&);
560
561     void didReceivePolicyDecision(uint64_t frameID, uint64_t listenerID, uint32_t policyAction, uint64_t downloadID);
562     void setUserAgent(const String&);
563     void setCustomTextEncodingName(const String&);
564
565 #if PLATFORM(MAC)
566     void performDictionaryLookupAtLocation(const WebCore::FloatPoint&);
567     void performDictionaryLookupForRange(DictionaryPopupInfo::Type, WebCore::Frame*, WebCore::Range*, NSDictionary *options);
568
569     void setWindowIsVisible(bool windowIsVisible);
570     void windowAndViewFramesChanged(const WebCore::IntRect& windowFrameInScreenCoordinates, const WebCore::IntRect& viewFrameInWindowCoordinates, const WebCore::IntPoint& accessibilityViewCoordinates);
571 #endif
572
573     void unapplyEditCommand(uint64_t commandID);
574     void reapplyEditCommand(uint64_t commandID);
575     void didRemoveEditCommand(uint64_t commandID);
576
577     void findString(const String&, uint32_t findOptions, uint32_t maxMatchCount);
578     void hideFindUI();
579     void countStringMatches(const String&, uint32_t findOptions, uint32_t maxMatchCount);
580
581 #if PLATFORM(QT)
582     void findZoomableAreaForPoint(const WebCore::IntPoint&);
583 #endif
584
585     void didChangeSelectedIndexForActivePopupMenu(int32_t newIndex);
586     void setTextForActivePopupMenu(int32_t index);
587
588 #if PLATFORM(GTK)    
589     void failedToShowPopupMenu();
590 #endif    
591
592     void didChooseFilesForOpenPanel(const Vector<String>&);
593     void didCancelForOpenPanel();
594 #if ENABLE(WEB_PROCESS_SANDBOX)
595     void extendSandboxForFileFromOpenPanel(const SandboxExtension::Handle&);
596 #endif
597
598     void didReceiveGeolocationPermissionDecision(uint64_t geolocationID, bool allowed);
599     void didReceiveNotificationPermissionDecision(uint64_t notificationID, bool allowed);
600
601     void advanceToNextMisspelling(bool startBeforeSelection);
602     void changeSpellingToWord(const String& word);
603 #if PLATFORM(MAC)
604     void uppercaseWord();
605     void lowercaseWord();
606     void capitalizeWord();
607
608     void setSmartInsertDeleteEnabled(bool isSmartInsertDeleteEnabled) { m_isSmartInsertDeleteEnabled = isSmartInsertDeleteEnabled; }
609 #endif
610
611 #if ENABLE(CONTEXT_MENUS)
612     void didSelectItemFromActiveContextMenu(const WebContextMenuItemData&);
613 #endif
614
615     void setCanStartMediaTimerFired();
616
617     static bool platformCanHandleRequest(const WebCore::ResourceRequest&);
618
619     OwnPtr<WebCore::Page> m_page;
620     RefPtr<WebFrame> m_mainFrame;
621     RefPtr<InjectedBundleBackForwardList> m_backForwardList;
622
623     RefPtr<WebPageGroupProxy> m_pageGroup;
624
625     String m_userAgent;
626
627     WebCore::IntSize m_viewSize;
628     OwnPtr<DrawingArea> m_drawingArea;
629     bool m_useFixedLayout;
630
631     bool m_drawsBackground;
632     bool m_drawsTransparentBackground;
633
634     bool m_isInRedo;
635     bool m_isClosed;
636
637     bool m_tabToLinks;
638
639 #if PLATFORM(MAC)
640     // Whether the containing window is visible or not.
641     bool m_windowIsVisible;
642
643     // Whether smart insert/delete is enabled or not.
644     bool m_isSmartInsertDeleteEnabled;
645
646     // The frame of the containing window in screen coordinates.
647     WebCore::IntRect m_windowFrameInScreenCoordinates;
648
649     // The frame of the view in window coordinates.
650     WebCore::IntRect m_viewFrameInWindowCoordinates;
651
652     // The accessibility position of the view.
653     WebCore::IntPoint m_accessibilityPosition;
654     
655     // All plug-in views on this web page.
656     HashSet<PluginView*> m_pluginViews;
657
658     RetainPtr<WKAccessibilityWebPageObject> m_mockAccessibilityElement;
659
660     WebCore::KeyboardEvent* m_keyboardEventBeingInterpreted;
661
662 #elif PLATFORM(WIN)
663     // Our view's window (in the UI process).
664     HWND m_nativeWindow;
665
666     RefPtr<WebCore::Node> m_gestureTargetNode;
667 #endif
668     
669     RunLoop::Timer<WebPage> m_setCanStartMediaTimer;
670
671     HashMap<uint64_t, RefPtr<WebUndoStep> > m_undoStepMap;
672
673     WebCore::IntSize m_windowResizerSize;
674
675     InjectedBundlePageContextMenuClient m_contextMenuClient;
676     InjectedBundlePageEditorClient m_editorClient;
677     InjectedBundlePageFormClient m_formClient;
678     InjectedBundlePageLoaderClient m_loaderClient;
679     InjectedBundlePagePolicyClient m_policyClient;
680     InjectedBundlePageResourceLoadClient m_resourceLoadClient;
681     InjectedBundlePageUIClient m_uiClient;
682 #if ENABLE(FULLSCREEN_API)
683     InjectedBundlePageFullScreenClient m_fullScreenClient;
684 #endif
685
686 #if USE(TILED_BACKING_STORE)
687     WebCore::IntSize m_resizesToContentsLayoutSize;
688     WebCore::IntSize m_viewportSize;
689 #endif
690
691     FindController m_findController;
692     RefPtr<PageOverlay> m_pageOverlay;
693
694     RefPtr<WebPage> m_underlayPage;
695
696 #if ENABLE(INSPECTOR)
697     RefPtr<WebInspector> m_inspector;
698 #endif
699 #if ENABLE(FULLSCREEN_API)
700     RefPtr<WebFullScreenManager> m_fullScreenManager;
701 #endif
702     RefPtr<WebPopupMenu> m_activePopupMenu;
703     RefPtr<WebContextMenu> m_contextMenu;
704     RefPtr<WebOpenPanelResultListener> m_activeOpenPanelResultListener;
705     GeolocationPermissionRequestManager m_geolocationPermissionRequestManager;
706     RefPtr<NotificationPermissionRequestManager> m_notificationPermissionRequestManager;
707
708     OwnPtr<WebCore::PrintContext> m_printContext;
709
710     SandboxExtensionTracker m_sandboxExtensionTracker;
711     uint64_t m_pageID;
712
713     RefPtr<SandboxExtension> m_pendingDropSandboxExtension;
714
715     bool m_canRunBeforeUnloadConfirmPanel;
716
717     bool m_canRunModal;
718     bool m_isRunningModal;
719
720     bool m_cachedMainFrameIsPinnedToLeftSide;
721     bool m_cachedMainFrameIsPinnedToRightSide;
722
723     unsigned m_cachedPageCount;
724
725     bool m_isShowingContextMenu;
726
727 #if PLATFORM(WIN)
728     bool m_gestureReachedScrollingLimit;
729 #endif
730 };
731
732 } // namespace WebKit
733
734 #endif // WebPage_h