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