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