WebProcess should be terminated if invalid frameIDs are
[WebKit-https.git] / WebKit2 / UIProcess / WebPageProxy.cpp
1 /*
2  * Copyright (C) 2010 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 #include "WebPageProxy.h"
27
28 #include "AuthenticationChallengeProxy.h"
29 #include "AuthenticationDecisionListener.h"
30 #include "DataReference.h"
31 #include "DrawingAreaProxy.h"
32 #include "FindIndicator.h"
33 #include "MessageID.h"
34 #include "NativeWebKeyboardEvent.h"
35 #include "PageClient.h"
36 #include "StringPairVector.h"
37 #include "WKContextPrivate.h"
38 #include "WebBackForwardList.h"
39 #include "WebBackForwardListItem.h"
40 #include "WebCertificateInfo.h"
41 #include "WebContext.h"
42 #include "WebContextMenuProxy.h"
43 #include "WebContextUserMessageCoders.h"
44 #include "WebCoreArgumentCoders.h"
45 #include "WebData.h"
46 #include "WebEditCommandProxy.h"
47 #include "WebEvent.h"
48 #include "WebFormSubmissionListenerProxy.h"
49 #include "WebFramePolicyListenerProxy.h"
50 #include "WebOpenPanelResultListenerProxy.h"
51 #include "WebPageCreationParameters.h"
52 #include "WebPageGroup.h"
53 #include "WebPageGroupData.h"
54 #include "WebPageMessages.h"
55 #include "WebPopupItem.h"
56 #include "WebPopupMenuProxy.h"
57 #include "WebPreferences.h"
58 #include "WebProcessManager.h"
59 #include "WebProcessMessages.h"
60 #include "WebProcessProxy.h"
61 #include "WebProtectionSpace.h"
62 #include "WebSecurityOrigin.h"
63 #include "WebURLRequest.h"
64 #include <WebCore/FloatRect.h>
65 #include <WebCore/MIMETypeRegistry.h>
66 #include <WebCore/WindowFeatures.h>
67 #include <stdio.h>
68
69 #ifndef NDEBUG
70 #include <wtf/RefCountedLeakCounter.h>
71 #endif
72
73 // This controls what strategy we use for mouse wheel coalesing.
74 #define MERGE_WHEEL_EVENTS 0
75
76 #define MESSAGE_CHECK(assertion) MESSAGE_CHECK_BASE(assertion, process()->connection())
77
78 using namespace WebCore;
79
80 namespace WebKit {
81
82 #ifndef NDEBUG
83 static WTF::RefCountedLeakCounter webPageProxyCounter("WebPageProxy");
84 #endif
85
86 PassRefPtr<WebPageProxy> WebPageProxy::create(WebContext* context, WebPageGroup* pageGroup, uint64_t pageID)
87 {
88     return adoptRef(new WebPageProxy(context, pageGroup, pageID));
89 }
90
91 WebPageProxy::WebPageProxy(WebContext* context, WebPageGroup* pageGroup, uint64_t pageID)
92     : m_pageClient(0)
93     , m_context(context)
94     , m_pageGroup(pageGroup)
95     , m_mainFrame(0)
96     , m_userAgent(standardUserAgent())
97     , m_estimatedProgress(0.0)
98     , m_isInWindow(false)
99     , m_backForwardList(WebBackForwardList::create(this))
100     , m_textZoomFactor(1)
101     , m_pageZoomFactor(1)
102     , m_viewScaleFactor(1)
103     , m_drawsBackground(true)
104     , m_drawsTransparentBackground(false)
105     , m_isValid(true)
106     , m_isClosed(false)
107     , m_inDecidePolicyForMIMEType(false)
108     , m_syncMimeTypePolicyActionIsValid(false)
109     , m_syncMimeTypePolicyAction(PolicyUse)
110     , m_syncMimeTypePolicyDownloadID(0)
111     , m_processingWheelEvent(false)
112     , m_pageID(pageID)
113     , m_mainFrameHasCustomRepresentation(false)
114 {
115 #ifndef NDEBUG
116     webPageProxyCounter.increment();
117 #endif
118
119     WebContext::statistics().wkPageCount++;
120
121     m_pageGroup->addPage(this);
122 }
123
124 WebPageProxy::~WebPageProxy()
125 {
126     WebContext::statistics().wkPageCount--;
127
128     m_pageGroup->removePage(this);
129
130 #ifndef NDEBUG
131     webPageProxyCounter.decrement();
132 #endif
133 }
134
135 WebProcessProxy* WebPageProxy::process() const
136 {
137     return m_context->process();
138 }
139
140 bool WebPageProxy::isValid()
141 {
142     // A page that has been explicitly closed is never valid.
143     if (m_isClosed)
144         return false;
145
146     return m_isValid;
147 }
148
149 void WebPageProxy::setPageClient(PageClient* pageClient)
150 {
151     m_pageClient = pageClient;
152 }
153
154 void WebPageProxy::setDrawingArea(PassOwnPtr<DrawingAreaProxy> drawingArea)
155 {
156     if (drawingArea == m_drawingArea)
157         return;
158
159     m_drawingArea = drawingArea;
160 }
161
162 void WebPageProxy::initializeLoaderClient(const WKPageLoaderClient* loadClient)
163 {
164     m_loaderClient.initialize(loadClient);
165 }
166
167 void WebPageProxy::initializePolicyClient(const WKPagePolicyClient* policyClient)
168 {
169     m_policyClient.initialize(policyClient);
170 }
171
172 void WebPageProxy::initializeFormClient(const WKPageFormClient* formClient)
173 {
174     m_formClient.initialize(formClient);
175 }
176
177 void WebPageProxy::initializeResourceLoadClient(const WKPageResourceLoadClient* client)
178 {
179     m_resourceLoadClient.initialize(client);
180 }
181
182 void WebPageProxy::initializeUIClient(const WKPageUIClient* client)
183 {
184     m_uiClient.initialize(client);
185 }
186
187 void WebPageProxy::initializeFindClient(const WKPageFindClient* client)
188 {
189     m_findClient.initialize(client);
190 }
191
192 void WebPageProxy::initializeContextMenuClient(const WKPageContextMenuClient* client)
193 {
194     m_contextMenuClient.initialize(client);
195 }
196
197 void WebPageProxy::relaunch()
198 {
199     m_isValid = true;
200     context()->relaunchProcessIfNecessary();
201     process()->addExistingWebPage(this, m_pageID);
202
203     m_pageClient->didRelaunchProcess();
204 }
205
206 void WebPageProxy::initializeWebPage(const IntSize& size)
207 {
208     if (!isValid()) {
209         relaunch();
210         return;
211     }
212
213     ASSERT(m_drawingArea);
214     process()->send(Messages::WebProcess::CreateWebPage(m_pageID, creationParameters(size)), 0);
215 }
216
217 void WebPageProxy::reinitializeWebPage(const WebCore::IntSize& size)
218 {
219     if (!isValid())
220         return;
221
222     ASSERT(m_drawingArea);
223     process()->send(Messages::WebProcess::CreateWebPage(m_pageID, creationParameters(size)), 0);
224 }
225
226 void WebPageProxy::close()
227 {
228     if (!isValid())
229         return;
230
231     m_isClosed = true;
232
233     process()->disconnectFramesFromPage(this);
234     m_mainFrame = 0;
235
236 #if ENABLE(INSPECTOR)
237     if (m_inspector) {
238         m_inspector->invalidate();
239         m_inspector = 0;
240     }
241 #endif
242
243     if (m_openPanelResultListener) {
244         m_openPanelResultListener->invalidate();
245         m_openPanelResultListener = 0;
246     }
247
248     m_toolTip = String();
249
250     invalidateCallbackMap(m_dataCallbacks);
251     invalidateCallbackMap(m_stringCallbacks);
252
253     Vector<WebEditCommandProxy*> editCommandVector;
254     copyToVector(m_editCommandSet, editCommandVector);
255     m_editCommandSet.clear();
256     for (size_t i = 0, size = editCommandVector.size(); i < size; ++i)
257         editCommandVector[i]->invalidate();
258
259     m_activePopupMenu = 0;
260
261     m_estimatedProgress = 0.0;
262     
263     m_loaderClient.initialize(0);
264     m_policyClient.initialize(0);
265     m_uiClient.initialize(0);
266
267     m_drawingArea.clear();
268
269     process()->send(Messages::WebPage::Close(), m_pageID);
270     process()->removeWebPage(m_pageID);
271 }
272
273 bool WebPageProxy::tryClose()
274 {
275     if (!isValid())
276         return true;
277
278     process()->send(Messages::WebPage::TryClose(), m_pageID);
279     return false;
280 }
281
282 static void initializeSandboxExtensionHandle(const KURL& url, SandboxExtension::Handle& sandboxExtensionHandle)
283 {
284     if (!url.isLocalFile())
285         return;
286
287     SandboxExtension::createHandle("/", SandboxExtension::ReadOnly, sandboxExtensionHandle);
288 }
289
290 void WebPageProxy::loadURL(const String& url)
291 {
292     if (!isValid())
293         relaunch();
294
295     SandboxExtension::Handle sandboxExtensionHandle;
296     initializeSandboxExtensionHandle(KURL(KURL(), url), sandboxExtensionHandle);
297     process()->send(Messages::WebPage::LoadURL(url, sandboxExtensionHandle), m_pageID);
298 }
299
300 void WebPageProxy::loadURLRequest(WebURLRequest* urlRequest)
301 {
302     if (!isValid())
303         relaunch();
304
305     SandboxExtension::Handle sandboxExtensionHandle;
306     initializeSandboxExtensionHandle(urlRequest->resourceRequest().url(), sandboxExtensionHandle);
307     process()->send(Messages::WebPage::LoadURLRequest(urlRequest->resourceRequest(), sandboxExtensionHandle), m_pageID);
308 }
309
310 void WebPageProxy::loadHTMLString(const String& htmlString, const String& baseURL)
311 {
312     if (!isValid())
313         return;
314     process()->send(Messages::WebPage::LoadHTMLString(htmlString, baseURL), m_pageID);
315 }
316
317 void WebPageProxy::loadAlternateHTMLString(const String& htmlString, const String& baseURL, const String& unreachableURL)
318 {
319     if (!isValid())
320         return;
321
322     if (!m_mainFrame)
323         return;
324
325     m_mainFrame->setUnreachableURL(unreachableURL);
326     process()->send(Messages::WebPage::LoadAlternateHTMLString(htmlString, baseURL, unreachableURL), m_pageID);
327 }
328
329 void WebPageProxy::loadPlainTextString(const String& string)
330 {
331     if (!isValid())
332         return;
333     process()->send(Messages::WebPage::LoadPlainTextString(string), m_pageID);
334 }
335
336 void WebPageProxy::stopLoading()
337 {
338     if (!isValid())
339         return;
340     process()->send(Messages::WebPage::StopLoading(), m_pageID);
341 }
342
343 void WebPageProxy::reload(bool reloadFromOrigin)
344 {
345     if (!isValid())
346         return;
347     process()->send(Messages::WebPage::Reload(reloadFromOrigin), m_pageID);
348 }
349
350 void WebPageProxy::goForward()
351 {
352     if (!isValid())
353         return;
354
355     if (!canGoForward())
356         return;
357
358     process()->send(Messages::WebPage::GoForward(m_backForwardList->forwardItem()->itemID()), m_pageID);
359 }
360
361 bool WebPageProxy::canGoForward() const
362 {
363     return m_backForwardList->forwardItem();
364 }
365
366 void WebPageProxy::goBack()
367 {
368     if (!isValid())
369         return;
370
371     if (!canGoBack())
372         return;
373
374     process()->send(Messages::WebPage::GoBack(m_backForwardList->backItem()->itemID()), m_pageID);
375 }
376
377 bool WebPageProxy::canGoBack() const
378 {
379     return m_backForwardList->backItem();
380 }
381
382 void WebPageProxy::goToBackForwardItem(WebBackForwardListItem* item)
383 {
384     if (!isValid())
385         return;
386
387     process()->send(Messages::WebPage::GoToBackForwardItem(item->itemID()), m_pageID);
388 }
389
390 void WebPageProxy::didChangeBackForwardList()
391 {
392     m_loaderClient.didChangeBackForwardList(this);
393 }
394
395     
396 bool WebPageProxy::canShowMIMEType(const String& mimeType) const
397 {
398     if (MIMETypeRegistry::isSupportedNonImageMIMEType(mimeType))
399         return true;
400
401     if (MIMETypeRegistry::isSupportedImageMIMEType(mimeType))
402         return true;
403     
404     String newMimeType = mimeType;
405     PluginInfoStore::Plugin plugin = context()->pluginInfoStore()->findPlugin(newMimeType, KURL());
406     if (!plugin.path.isNull())
407         return true;
408
409     return false;
410 }
411
412 void WebPageProxy::setDrawsBackground(bool drawsBackground)
413 {
414     if (m_drawsBackground == drawsBackground)
415         return;
416
417     m_drawsBackground = drawsBackground;
418
419     if (isValid())
420         process()->send(Messages::WebPage::SetDrawsBackground(drawsBackground), m_pageID);
421 }
422
423 void WebPageProxy::setDrawsTransparentBackground(bool drawsTransparentBackground)
424 {
425     if (m_drawsTransparentBackground == drawsTransparentBackground)
426         return;
427
428     m_drawsTransparentBackground = drawsTransparentBackground;
429
430     if (isValid())
431         process()->send(Messages::WebPage::SetDrawsTransparentBackground(drawsTransparentBackground), m_pageID);
432 }
433
434 void WebPageProxy::setFocused(bool isFocused)
435 {
436     if (!isValid())
437         return;
438     process()->send(Messages::WebPage::SetFocused(isFocused), m_pageID);
439 }
440
441 void WebPageProxy::setInitialFocus(bool forward)
442 {
443     if (!isValid())
444         return;
445     process()->send(Messages::WebPage::SetInitialFocus(forward), m_pageID);
446 }
447
448 void WebPageProxy::setActive(bool active)
449 {
450     if (!isValid())
451         return;
452     process()->send(Messages::WebPage::SetActive(active), m_pageID);
453 }
454
455 void WebPageProxy::setWindowResizerSize(const IntSize& windowResizerSize)
456 {
457     if (!isValid())
458         return;
459     process()->send(Messages::WebPage::SetWindowResizerSize(windowResizerSize), m_pageID);
460 }
461
462 void WebPageProxy::validateMenuItem(const String& commandName)
463 {
464     if (!isValid())
465         return;
466     process()->send(Messages::WebPage::ValidateMenuItem(commandName), m_pageID);
467 }
468     
469 void WebPageProxy::executeEditCommand(const String& commandName)
470 {
471     if (!isValid())
472         return;
473
474     process()->send(Messages::WebPage::ExecuteEditCommand(commandName), m_pageID);
475 }
476     
477 void WebPageProxy::setIsInWindow(bool isInWindow)
478 {
479     if (m_isInWindow == isInWindow)
480         return;
481     
482     m_isInWindow = isInWindow;
483     if (!isValid())
484         return;
485     process()->send(Messages::WebPage::SetIsInWindow(isInWindow), m_pageID);
486 }
487
488 #if PLATFORM(MAC)
489 void WebPageProxy::updateWindowIsVisible(bool windowIsVisible)
490 {
491     if (!isValid())
492         return;
493     process()->send(Messages::WebPage::SetWindowIsVisible(windowIsVisible), m_pageID);
494 }
495
496 void WebPageProxy::windowAndViewFramesChanged(const IntRect& windowFrameInScreenCoordinates, const IntRect& viewFrameInWindowCoordinates)
497 {
498     if (!isValid())
499         return;
500
501     process()->send(Messages::WebPage::WindowAndViewFramesChanged(windowFrameInScreenCoordinates, viewFrameInWindowCoordinates), m_pageID);
502 }
503
504 void WebPageProxy::getMarkedRange(uint64_t& location, uint64_t& length)
505 {
506     process()->sendSync(Messages::WebPage::GetMarkedRange(), Messages::WebPage::GetMarkedRange::Reply(location, length), m_pageID);
507 }
508     
509 uint64_t WebPageProxy::characterIndexForPoint(const IntPoint point)
510 {
511     uint64_t result;
512     process()->sendSync(Messages::WebPage::CharacterIndexForPoint(point), Messages::WebPage::CharacterIndexForPoint::Reply(result), m_pageID);
513     return result;
514 }
515
516 WebCore::IntRect WebPageProxy::firstRectForCharacterRange(uint64_t location, uint64_t length)
517 {
518     IntRect resultRect;
519     process()->sendSync(Messages::WebPage::FirstRectForCharacterRange(location, length), Messages::WebPage::FirstRectForCharacterRange::Reply(resultRect), m_pageID);
520     return resultRect;
521 }
522 #elif PLATFORM(WIN)
523 WebCore::IntRect WebPageProxy::firstRectForCharacterInSelectedRange(int characterPosition)
524 {
525     IntRect resultRect;
526     process()->sendSync(Messages::WebPage::FirstRectForCharacterInSelectedRange(characterPosition), Messages::WebPage::FirstRectForCharacterInSelectedRange::Reply(resultRect), m_pageID);
527     return resultRect;
528 }
529
530 String WebPageProxy::getSelectedText()
531 {
532     String text;
533     process()->sendSync(Messages::WebPage::GetSelectedText(), Messages::WebPage::GetSelectedText::Reply(text), m_pageID);
534     return text;
535 }
536 #endif
537
538 #if ENABLE(TILED_BACKING_STORE)
539 void WebPageProxy::setActualVisibleContentRect(const IntRect& rect)
540 {
541     if (!isValid())
542         return;
543
544     process()->send(Messages::WebPage::SetActualVisibleContentRect(rect), m_pageID);
545 }
546 #endif
547
548 void WebPageProxy::handleMouseEvent(const WebMouseEvent& event)
549 {
550     if (!isValid())
551         return;
552
553     // NOTE: This does not start the responsiveness timer because mouse move should not indicate interaction.
554     if (event.type() != WebEvent::MouseMove)
555         process()->responsivenessTimer()->start();
556     process()->send(Messages::WebPage::MouseEvent(event), m_pageID);
557 }
558
559 static PassOwnPtr<WebWheelEvent> coalesceWheelEvents(WebWheelEvent* oldNextWheelEvent, const WebWheelEvent& newWheelEvent)
560 {
561 #if MERGE_WHEEL_EVENTS
562     // Merge model: Combine wheel event deltas (and wheel ticks) into a single wheel event.
563     if (!oldNextWheelEvent)
564         return adoptPtr(new WebWheelEvent(newWheelEvent));
565
566     if (oldNextWheelEvent->position() != newWheelEvent.position() || oldNextWheelEvent->modifiers() != newWheelEvent.modifiers() || oldNextWheelEvent->granularity() != newWheelEvent.granularity())
567         return adoptPtr(new WebWheelEvent(newWheelEvent));
568
569     FloatSize mergedDelta = oldNextWheelEvent->delta() + newWheelEvent.delta();
570     FloatSize mergedWheelTicks = oldNextWheelEvent->wheelTicks() + newWheelEvent.wheelTicks();
571
572     return adoptPtr(new WebWheelEvent(WebEvent::Wheel, newWheelEvent.position(), newWheelEvent.globalPosition(), mergedDelta, mergedWheelTicks, newWheelEvent.granularity(), newWheelEvent.modifiers(), newWheelEvent.timestamp()));
573 #else
574     // Simple model: Just keep the last event, dropping all interim events.
575     return adoptPtr(new WebWheelEvent(newWheelEvent));
576 #endif
577 }
578
579 void WebPageProxy::handleWheelEvent(const WebWheelEvent& event)
580 {
581     if (!isValid())
582         return;
583
584     if (m_processingWheelEvent) {
585         m_nextWheelEvent = coalesceWheelEvents(m_nextWheelEvent.get(), event);
586         return;
587     }
588
589     process()->responsivenessTimer()->start();
590     process()->send(Messages::WebPage::WheelEvent(event), m_pageID);
591     m_processingWheelEvent = true;
592 }
593
594 void WebPageProxy::handleKeyboardEvent(const NativeWebKeyboardEvent& event)
595 {
596     if (!isValid())
597         return;
598
599     m_keyEventQueue.append(event);
600
601     process()->responsivenessTimer()->start();
602     process()->send(Messages::WebPage::KeyEvent(event), m_pageID);
603 }
604
605 #if ENABLE(TOUCH_EVENTS)
606 void WebPageProxy::handleTouchEvent(const WebTouchEvent& event)
607 {
608     if (!isValid())
609         return;
610     process()->send(Messages::WebPage::TouchEvent(event), m_pageID); 
611 }
612 #endif
613
614 void WebPageProxy::receivedPolicyDecision(PolicyAction action, WebFrameProxy* frame, uint64_t listenerID)
615 {
616     if (!isValid())
617         return;
618
619     uint64_t downloadID = 0;
620     if (action == PolicyDownload) {
621         // Create a download proxy.
622         downloadID = context()->createDownloadProxy();
623     }
624
625     // If we received a policy decision while in decidePolicyForMIMEType the decision will 
626     // be sent back to the web process by decidePolicyForMIMEType. 
627     if (m_inDecidePolicyForMIMEType) {
628         m_syncMimeTypePolicyActionIsValid = true;
629         m_syncMimeTypePolicyAction = action;
630         m_syncMimeTypePolicyDownloadID = downloadID;
631         return;
632     }
633
634     process()->send(Messages::WebPage::DidReceivePolicyDecision(frame->frameID(), listenerID, action, downloadID), m_pageID);
635 }
636
637 String WebPageProxy::pageTitle() const
638 {
639     // Return the null string if there is no main frame (e.g. nothing has been loaded in the page yet, WebProcess has
640     // crashed, page has been closed).
641     if (!m_mainFrame)
642         return String();
643
644     return m_mainFrame->title();
645 }
646
647 void WebPageProxy::setUserAgent(const String& userAgent)
648 {
649     if (m_userAgent == userAgent)
650         return;
651     m_userAgent = userAgent;
652
653     if (!isValid())
654         return;
655     process()->send(Messages::WebPage::SetUserAgent(m_userAgent), m_pageID);
656 }
657
658 void WebPageProxy::setApplicationNameForUserAgent(const String& applicationName)
659 {
660     if (m_applicationNameForUserAgent == applicationName)
661         return;
662
663     m_applicationNameForUserAgent = applicationName;
664     if (!m_customUserAgent.isEmpty())
665         return;
666
667     setUserAgent(standardUserAgent(m_applicationNameForUserAgent));
668 }
669
670 void WebPageProxy::setCustomUserAgent(const String& customUserAgent)
671 {
672     if (m_customUserAgent == customUserAgent)
673         return;
674
675     m_customUserAgent = customUserAgent;
676
677     if (m_customUserAgent.isEmpty()) {
678         setUserAgent(standardUserAgent(m_applicationNameForUserAgent));
679         return;
680     }
681
682     setUserAgent(m_customUserAgent);
683 }
684
685 bool WebPageProxy::supportsTextEncoding() const
686 {
687     return !m_mainFrameHasCustomRepresentation && m_mainFrame && !m_mainFrame->isDisplayingStandaloneImageDocument();
688 }
689
690 void WebPageProxy::setCustomTextEncodingName(const String& encodingName)
691 {
692     if (m_customTextEncodingName == encodingName)
693         return;
694     m_customTextEncodingName = encodingName;
695
696     if (!isValid())
697         return;
698     process()->send(Messages::WebPage::SetCustomTextEncodingName(encodingName), m_pageID);
699 }
700
701 void WebPageProxy::terminateProcess()
702 {
703     if (!isValid())
704         return;
705
706     process()->terminate();
707 }
708
709 #if !PLATFORM(CF) || defined(BUILDING_QT__)
710 PassRefPtr<WebData> WebPageProxy::sessionStateData(WebPageProxySessionStateFilterCallback, void* context) const
711 {
712     // FIXME: Return session state data for saving Page state.
713     return 0;
714 }
715
716 void WebPageProxy::restoreFromSessionStateData(WebData*)
717 {
718     // FIXME: Restore the Page from the passed in session state data.
719 }
720 #endif
721
722 void WebPageProxy::setTextZoomFactor(double zoomFactor)
723 {
724     if (!isValid())
725         return;
726
727     if (m_textZoomFactor == zoomFactor)
728         return;
729
730     m_textZoomFactor = zoomFactor;
731     process()->send(Messages::WebPage::SetTextZoomFactor(m_textZoomFactor), m_pageID); 
732 }
733
734 void WebPageProxy::setPageZoomFactor(double zoomFactor)
735 {
736     if (!isValid())
737         return;
738
739     if (m_pageZoomFactor == zoomFactor)
740         return;
741
742     m_pageZoomFactor = zoomFactor;
743     process()->send(Messages::WebPage::SetPageZoomFactor(m_pageZoomFactor), m_pageID); 
744 }
745
746 void WebPageProxy::setPageAndTextZoomFactors(double pageZoomFactor, double textZoomFactor)
747 {
748     if (!isValid())
749         return;
750
751     if (m_pageZoomFactor == pageZoomFactor && m_textZoomFactor == textZoomFactor)
752         return;
753
754     m_pageZoomFactor = pageZoomFactor;
755     m_textZoomFactor = textZoomFactor;
756     process()->send(Messages::WebPage::SetPageAndTextZoomFactors(m_pageZoomFactor, m_textZoomFactor), m_pageID); 
757 }
758
759 void WebPageProxy::scaleWebView(double scale, const IntPoint& origin)
760 {
761     if (!isValid())
762         return;
763
764     if (m_viewScaleFactor == scale)
765         return;
766
767     m_viewScaleFactor = scale;
768     process()->send(Messages::WebPage::ScaleWebView(scale, origin), m_pageID);
769 }
770
771 void WebPageProxy::findString(const String& string, FindOptions options, unsigned maxMatchCount)
772 {
773     process()->send(Messages::WebPage::FindString(string, options, maxMatchCount), m_pageID);
774 }
775
776 void WebPageProxy::hideFindUI()
777 {
778     process()->send(Messages::WebPage::HideFindUI(), m_pageID);
779 }
780
781 void WebPageProxy::countStringMatches(const String& string, FindOptions options, unsigned maxMatchCount)
782 {
783     process()->send(Messages::WebPage::CountStringMatches(string, options, maxMatchCount), m_pageID);
784 }
785     
786 void WebPageProxy::runJavaScriptInMainFrame(const String& script, PassRefPtr<StringCallback> prpCallback)
787 {
788     RefPtr<StringCallback> callback = prpCallback;
789     uint64_t callbackID = callback->callbackID();
790     m_stringCallbacks.set(callbackID, callback.get());
791     process()->send(Messages::WebPage::RunJavaScriptInMainFrame(script, callbackID), m_pageID);
792 }
793
794 void WebPageProxy::getRenderTreeExternalRepresentation(PassRefPtr<StringCallback> prpCallback)
795 {
796     RefPtr<StringCallback> callback = prpCallback;
797     uint64_t callbackID = callback->callbackID();
798     m_stringCallbacks.set(callbackID, callback.get());
799     process()->send(Messages::WebPage::GetRenderTreeExternalRepresentation(callbackID), m_pageID);
800 }
801
802 void WebPageProxy::getSourceForFrame(WebFrameProxy* frame, PassRefPtr<StringCallback> prpCallback)
803 {
804     RefPtr<StringCallback> callback = prpCallback;
805     uint64_t callbackID = callback->callbackID();
806     m_stringCallbacks.set(callbackID, callback.get());
807     process()->send(Messages::WebPage::GetSourceForFrame(frame->frameID(), callbackID), m_pageID);
808 }
809
810 void WebPageProxy::getContentsAsString(PassRefPtr<StringCallback> prpCallback)
811 {
812     RefPtr<StringCallback> callback = prpCallback;
813     uint64_t callbackID = callback->callbackID();
814     m_stringCallbacks.set(callbackID, callback.get());
815     process()->send(Messages::WebPage::GetContentsAsString(callbackID), m_pageID);
816 }
817
818 void WebPageProxy::getSelectionOrContentsAsString(PassRefPtr<StringCallback> prpCallback)
819 {
820     RefPtr<StringCallback> callback = prpCallback;
821     uint64_t callbackID = callback->callbackID();
822     m_stringCallbacks.set(callbackID, callback.get());
823     process()->send(Messages::WebPage::GetSelectionOrContentsAsString(callbackID), m_pageID);
824 }
825
826 void WebPageProxy::getMainResourceDataOfFrame(WebFrameProxy* frame, PassRefPtr<DataCallback> prpCallback)
827 {
828     RefPtr<DataCallback> callback = prpCallback;
829     uint64_t callbackID = callback->callbackID();
830     m_dataCallbacks.set(callbackID, callback.get());
831     process()->send(Messages::WebPage::GetMainResourceDataOfFrame(frame->frameID(), callbackID), m_pageID);
832 }
833
834 void WebPageProxy::getWebArchiveOfFrame(WebFrameProxy* frame, PassRefPtr<DataCallback> prpCallback)
835 {
836     RefPtr<DataCallback> callback = prpCallback;
837     uint64_t callbackID = callback->callbackID();
838     m_dataCallbacks.set(callbackID, callback.get());
839     process()->send(Messages::WebPage::GetWebArchiveOfFrame(frame->frameID(), callbackID), m_pageID);
840 }
841
842 void WebPageProxy::preferencesDidChange()
843 {
844     if (!isValid())
845         return;
846
847     // FIXME: It probably makes more sense to send individual preference changes.
848     // However, WebKitTestRunner depends on getting a preference change notification
849     // even if nothing changed in UI process, so that overrides get removed.
850     process()->send(Messages::WebPage::PreferencesDidChange(pageGroup()->preferences()->store()), m_pageID);
851 }
852
853 #if ENABLE(TILED_BACKING_STORE)
854 void WebPageProxy::setResizesToContentsUsingLayoutSize(const WebCore::IntSize& targetLayoutSize)
855 {
856     process()->send(Messages::WebPage::SetResizesToContentsUsingLayoutSize(targetLayoutSize), m_pageID);
857 }
858 #endif
859
860 void WebPageProxy::didReceiveMessage(CoreIPC::Connection* connection, CoreIPC::MessageID messageID, CoreIPC::ArgumentDecoder* arguments)
861 {
862     if (messageID.is<CoreIPC::MessageClassDrawingAreaProxy>()) {
863         m_drawingArea->didReceiveMessage(connection, messageID, arguments);
864         return;
865     }
866
867 #if ENABLE(INSPECTOR)
868     if (messageID.is<CoreIPC::MessageClassWebInspectorProxy>()) {
869         if (WebInspectorProxy* inspector = this->inspector())
870             inspector->didReceiveWebInspectorProxyMessage(connection, messageID, arguments);
871         return;
872     }
873 #endif
874
875     didReceiveWebPageProxyMessage(connection, messageID, arguments);
876 }
877
878 void WebPageProxy::didReceiveSyncMessage(CoreIPC::Connection* connection, CoreIPC::MessageID messageID, CoreIPC::ArgumentDecoder* arguments, CoreIPC::ArgumentEncoder* reply)
879 {
880     if (messageID.is<CoreIPC::MessageClassDrawingAreaProxy>()) {
881         m_drawingArea->didReceiveSyncMessage(connection, messageID, arguments, reply);
882         return;
883     }
884
885 #if ENABLE(INSPECTOR)
886     if (messageID.is<CoreIPC::MessageClassWebInspectorProxy>()) {
887         if (WebInspectorProxy* inspector = this->inspector())
888             inspector->didReceiveSyncWebInspectorProxyMessage(connection, messageID, arguments, reply);
889         return;
890     }
891 #endif
892
893     // FIXME: Do something with reply.
894     didReceiveSyncWebPageProxyMessage(connection, messageID, arguments, reply);
895 }
896
897 #if PLATFORM(MAC)
898 void WebPageProxy::interpretKeyEvent(uint32_t type, Vector<KeypressCommand>& commandsList, uint32_t selectionStart, uint32_t selectionEnd, Vector<CompositionUnderline>& underlines)
899 {
900     m_pageClient->interceptKeyEvent(m_keyEventQueue.first(), commandsList, selectionStart, selectionEnd, underlines);
901 }
902 #endif
903
904 void WebPageProxy::didCreateMainFrame(uint64_t frameID)
905 {
906     MESSAGE_CHECK(!m_mainFrame);
907     MESSAGE_CHECK(process()->canCreateFrame(frameID));
908
909     m_mainFrame = WebFrameProxy::create(this, frameID);
910
911     // Add the frame to the process wide map.
912     process()->frameCreated(frameID, m_mainFrame.get());
913 }
914
915 void WebPageProxy::didCreateSubFrame(uint64_t frameID)
916 {
917     MESSAGE_CHECK(m_mainFrame);
918     MESSAGE_CHECK(process()->canCreateFrame(frameID));
919     
920     RefPtr<WebFrameProxy> subFrame = WebFrameProxy::create(this, frameID);
921
922     // Add the frame to the process wide map.
923     process()->frameCreated(frameID, subFrame.get());
924 }
925
926 void WebPageProxy::didStartProgress()
927 {
928     m_estimatedProgress = 0.0;
929     
930     m_loaderClient.didStartProgress(this);
931 }
932
933 void WebPageProxy::didChangeProgress(double value)
934 {
935     m_estimatedProgress = value;
936     
937     m_loaderClient.didChangeProgress(this);
938 }
939
940 void WebPageProxy::didFinishProgress()
941 {
942     m_estimatedProgress = 1.0;
943
944     m_loaderClient.didFinishProgress(this);
945 }
946
947 void WebPageProxy::didStartProvisionalLoadForFrame(uint64_t frameID, const String& url, bool loadingSubstituteDataForUnreachableURL, CoreIPC::ArgumentDecoder* arguments)
948 {
949     RefPtr<APIObject> userData;
950     WebContextUserMessageDecoder messageDecoder(userData, context());
951     if (!arguments->decode(messageDecoder))
952         return;
953
954     WebFrameProxy* frame = process()->webFrame(frameID);
955     MESSAGE_CHECK(frame);
956
957     if (!loadingSubstituteDataForUnreachableURL)
958         frame->setUnreachableURL(String());
959
960     frame->didStartProvisionalLoad(url);
961     m_loaderClient.didStartProvisionalLoadForFrame(this, frame, userData.get());
962 }
963
964 void WebPageProxy::didReceiveServerRedirectForProvisionalLoadForFrame(uint64_t frameID, const String& url, CoreIPC::ArgumentDecoder* arguments)
965 {
966     RefPtr<APIObject> userData;
967     WebContextUserMessageDecoder messageDecoder(userData, context());
968     if (!arguments->decode(messageDecoder))
969         return;
970
971     WebFrameProxy* frame = process()->webFrame(frameID);
972     MESSAGE_CHECK(frame);
973
974     frame->didReceiveServerRedirectForProvisionalLoad(url);
975
976     m_loaderClient.didReceiveServerRedirectForProvisionalLoadForFrame(this, frame, userData.get());
977 }
978
979 void WebPageProxy::didFailProvisionalLoadForFrame(uint64_t frameID, const ResourceError& error, CoreIPC::ArgumentDecoder* arguments)
980 {
981     RefPtr<APIObject> userData;
982     WebContextUserMessageDecoder messageDecoder(userData, context());
983     if (!arguments->decode(messageDecoder))
984         return;
985
986     WebFrameProxy* frame = process()->webFrame(frameID);
987     MESSAGE_CHECK(frame);
988
989     frame->didFailProvisionalLoad();
990
991     m_loaderClient.didFailProvisionalLoadWithErrorForFrame(this, frame, error, userData.get());
992 }
993
994 void WebPageProxy::didCommitLoadForFrame(uint64_t frameID, const String& mimeType, bool frameHasCustomRepresentation, const PlatformCertificateInfo& certificateInfo, CoreIPC::ArgumentDecoder* arguments)
995 {
996     RefPtr<APIObject> userData;
997     WebContextUserMessageDecoder messageDecoder(userData, context());
998     if (!arguments->decode(messageDecoder))
999         return;
1000
1001     WebFrameProxy* frame = process()->webFrame(frameID);
1002     MESSAGE_CHECK(frame);
1003
1004     frame->didCommitLoad(mimeType, certificateInfo);
1005
1006     if (frame->isMainFrame()) {
1007         m_mainFrameHasCustomRepresentation = frameHasCustomRepresentation;
1008         m_pageClient->didCommitLoadForMainFrame(frameHasCustomRepresentation);
1009     }
1010
1011     m_loaderClient.didCommitLoadForFrame(this, frame, userData.get());
1012 }
1013
1014 void WebPageProxy::didFinishDocumentLoadForFrame(uint64_t frameID, CoreIPC::ArgumentDecoder* arguments)
1015 {
1016     RefPtr<APIObject> userData;
1017     WebContextUserMessageDecoder messageDecoder(userData, context());
1018     if (!arguments->decode(messageDecoder))
1019         return;
1020
1021     WebFrameProxy* frame = process()->webFrame(frameID);
1022     MESSAGE_CHECK(frame);
1023
1024     m_loaderClient.didFinishDocumentLoadForFrame(this, frame, userData.get());
1025 }
1026
1027 void WebPageProxy::didFinishLoadForFrame(uint64_t frameID, CoreIPC::ArgumentDecoder* arguments)
1028 {
1029     RefPtr<APIObject> userData;
1030     WebContextUserMessageDecoder messageDecoder(userData, context());
1031     if (!arguments->decode(messageDecoder))
1032         return;
1033
1034     WebFrameProxy* frame = process()->webFrame(frameID);
1035     MESSAGE_CHECK(frame);
1036
1037     frame->didFinishLoad();
1038
1039     m_loaderClient.didFinishLoadForFrame(this, frame, userData.get());
1040 }
1041
1042 void WebPageProxy::didFailLoadForFrame(uint64_t frameID, const ResourceError& error, CoreIPC::ArgumentDecoder* arguments)
1043 {
1044     RefPtr<APIObject> userData;
1045     WebContextUserMessageDecoder messageDecoder(userData, context());
1046     if (!arguments->decode(messageDecoder))
1047         return;
1048
1049     WebFrameProxy* frame = process()->webFrame(frameID);
1050     MESSAGE_CHECK(frame);
1051
1052     frame->didFailLoad();
1053
1054     m_loaderClient.didFailLoadWithErrorForFrame(this, frame, error, userData.get());
1055 }
1056
1057 void WebPageProxy::didSameDocumentNavigationForFrame(uint64_t frameID, uint32_t opaqueSameDocumentNavigationType, const String& url, CoreIPC::ArgumentDecoder* arguments)
1058 {
1059     RefPtr<APIObject> userData;
1060     WebContextUserMessageDecoder messageDecoder(userData, context());
1061     if (!arguments->decode(messageDecoder))
1062         return;
1063
1064     WebFrameProxy* frame = process()->webFrame(frameID);
1065     MESSAGE_CHECK(frame);
1066
1067     frame->didSameDocumentNavigation(url);
1068
1069     m_loaderClient.didSameDocumentNavigationForFrame(this, frame, static_cast<SameDocumentNavigationType>(opaqueSameDocumentNavigationType), userData.get());
1070 }
1071
1072 void WebPageProxy::didReceiveTitleForFrame(uint64_t frameID, const String& title, CoreIPC::ArgumentDecoder* arguments)
1073 {
1074     RefPtr<APIObject> userData;
1075     WebContextUserMessageDecoder messageDecoder(userData, context());
1076     if (!arguments->decode(messageDecoder))
1077         return;
1078
1079     WebFrameProxy* frame = process()->webFrame(frameID);
1080     MESSAGE_CHECK(frame);
1081
1082     frame->didChangeTitle(title);
1083     
1084     m_loaderClient.didReceiveTitleForFrame(this, title, frame, userData.get());
1085 }
1086
1087 void WebPageProxy::didFirstLayoutForFrame(uint64_t frameID, CoreIPC::ArgumentDecoder* arguments)
1088 {
1089     RefPtr<APIObject> userData;
1090     WebContextUserMessageDecoder messageDecoder(userData, context());
1091     if (!arguments->decode(messageDecoder))
1092         return;
1093
1094     WebFrameProxy* frame = process()->webFrame(frameID);
1095     MESSAGE_CHECK(frame);
1096
1097     m_loaderClient.didFirstLayoutForFrame(this, frame, userData.get());
1098 }
1099
1100 void WebPageProxy::didFirstVisuallyNonEmptyLayoutForFrame(uint64_t frameID, CoreIPC::ArgumentDecoder* arguments)
1101 {
1102     RefPtr<APIObject> userData;
1103     WebContextUserMessageDecoder messageDecoder(userData, context());
1104     if (!arguments->decode(messageDecoder))
1105         return;
1106
1107     WebFrameProxy* frame = process()->webFrame(frameID);
1108     MESSAGE_CHECK(frame);
1109
1110     m_loaderClient.didFirstVisuallyNonEmptyLayoutForFrame(this, frame, userData.get());
1111 }
1112
1113 void WebPageProxy::didRemoveFrameFromHierarchy(uint64_t frameID, CoreIPC::ArgumentDecoder* arguments)
1114 {
1115     RefPtr<APIObject> userData;
1116     WebContextUserMessageDecoder messageDecoder(userData, context());
1117     if (!arguments->decode(messageDecoder))
1118         return;
1119
1120     WebFrameProxy* frame = process()->webFrame(frameID);
1121     MESSAGE_CHECK(frame);
1122
1123     m_loaderClient.didRemoveFrameFromHierarchy(this, frame, userData.get());
1124 }
1125
1126 void WebPageProxy::didDisplayInsecureContentForFrame(uint64_t frameID, CoreIPC::ArgumentDecoder* arguments)
1127 {
1128     RefPtr<APIObject> userData;
1129     WebContextUserMessageDecoder messageDecoder(userData, context());
1130     if (!arguments->decode(messageDecoder))
1131         return;
1132
1133     WebFrameProxy* frame = process()->webFrame(frameID);
1134     MESSAGE_CHECK(frame);
1135
1136     m_loaderClient.didDisplayInsecureContentForFrame(this, frame, userData.get());
1137 }
1138
1139 void WebPageProxy::didRunInsecureContentForFrame(uint64_t frameID, CoreIPC::ArgumentDecoder* arguments)
1140 {
1141     RefPtr<APIObject> userData;
1142     WebContextUserMessageDecoder messageDecoder(userData, context());
1143     if (!arguments->decode(messageDecoder))
1144         return;
1145
1146     WebFrameProxy* frame = process()->webFrame(frameID);
1147     MESSAGE_CHECK(frame);
1148
1149     m_loaderClient.didRunInsecureContentForFrame(this, frame, userData.get());
1150 }
1151
1152 void WebPageProxy::frameDidBecomeFrameSet(uint64_t frameID, bool value)
1153 {
1154     WebFrameProxy* frame = process()->webFrame(frameID);
1155     MESSAGE_CHECK(frame);
1156
1157     frame->setIsFrameSet(value);
1158 }
1159
1160 // PolicyClient
1161
1162 void WebPageProxy::decidePolicyForNavigationAction(uint64_t frameID, uint32_t opaqueNavigationType, uint32_t opaqueModifiers, int32_t opaqueMouseButton, const String& url, uint64_t listenerID)
1163 {
1164     WebFrameProxy* frame = process()->webFrame(frameID);
1165     MESSAGE_CHECK(frame);
1166
1167     NavigationType navigationType = static_cast<NavigationType>(opaqueNavigationType);
1168     WebEvent::Modifiers modifiers = static_cast<WebEvent::Modifiers>(opaqueModifiers);
1169     WebMouseEvent::Button mouseButton = static_cast<WebMouseEvent::Button>(opaqueMouseButton);
1170     
1171     RefPtr<WebFramePolicyListenerProxy> listener = frame->setUpPolicyListenerProxy(listenerID);
1172     if (!m_policyClient.decidePolicyForNavigationAction(this, navigationType, modifiers, mouseButton, url, frame, listener.get()))
1173         listener->use();
1174 }
1175
1176 void WebPageProxy::decidePolicyForNewWindowAction(uint64_t frameID, uint32_t opaqueNavigationType, uint32_t opaqueModifiers, int32_t opaqueMouseButton, const String& url, uint64_t listenerID)
1177 {
1178     WebFrameProxy* frame = process()->webFrame(frameID);
1179     MESSAGE_CHECK(frame);
1180
1181     NavigationType navigationType = static_cast<NavigationType>(opaqueNavigationType);
1182     WebEvent::Modifiers modifiers = static_cast<WebEvent::Modifiers>(opaqueModifiers);
1183     WebMouseEvent::Button mouseButton = static_cast<WebMouseEvent::Button>(opaqueMouseButton);
1184
1185     RefPtr<WebFramePolicyListenerProxy> listener = frame->setUpPolicyListenerProxy(listenerID);
1186     if (!m_policyClient.decidePolicyForNewWindowAction(this, navigationType, modifiers, mouseButton, url, frame, listener.get()))
1187         listener->use();
1188 }
1189
1190 void WebPageProxy::decidePolicyForMIMEType(uint64_t frameID, const String& MIMEType, const String& url, uint64_t listenerID, bool& receivedPolicyAction, uint64_t& policyAction, uint64_t& downloadID)
1191 {
1192     WebFrameProxy* frame = process()->webFrame(frameID);
1193     MESSAGE_CHECK(frame);
1194
1195     RefPtr<WebFramePolicyListenerProxy> listener = frame->setUpPolicyListenerProxy(listenerID);
1196
1197     ASSERT(!m_inDecidePolicyForMIMEType);
1198
1199     m_inDecidePolicyForMIMEType = true;
1200     m_syncMimeTypePolicyActionIsValid = false;
1201
1202     if (!m_policyClient.decidePolicyForMIMEType(this, MIMEType, url, frame, listener.get()))
1203         listener->use();
1204
1205     m_inDecidePolicyForMIMEType = false;
1206
1207     // Check if we received a policy decision already. If we did, we can just pass it back.
1208     if (m_syncMimeTypePolicyActionIsValid) {
1209         receivedPolicyAction = true;
1210         policyAction = m_syncMimeTypePolicyAction;
1211         downloadID = m_syncMimeTypePolicyDownloadID;
1212     }
1213 }
1214
1215 // FormClient
1216
1217 void WebPageProxy::willSubmitForm(uint64_t frameID, uint64_t sourceFrameID, const StringPairVector& textFieldValues, uint64_t listenerID, CoreIPC::ArgumentDecoder* arguments)
1218 {
1219     RefPtr<APIObject> userData;
1220     WebContextUserMessageDecoder messageDecoder(userData, context());
1221     if (!arguments->decode(messageDecoder))
1222         return;
1223
1224     WebFrameProxy* frame = process()->webFrame(frameID);
1225     MESSAGE_CHECK(frame);
1226
1227     WebFrameProxy* sourceFrame = process()->webFrame(sourceFrameID);
1228     MESSAGE_CHECK(sourceFrame);
1229
1230     RefPtr<WebFormSubmissionListenerProxy> listener = frame->setUpFormSubmissionListenerProxy(listenerID);
1231     if (!m_formClient.willSubmitForm(this, frame, sourceFrame, textFieldValues.stringPairVector(), userData.get(), listener.get()))
1232         listener->continueSubmission();
1233 }
1234
1235 // ResourceLoad Client
1236
1237 void WebPageProxy::didInitiateLoadForResource(uint64_t frameID, uint64_t resourceIdentifier, const ResourceRequest& request)
1238 {
1239     WebFrameProxy* frame = process()->webFrame(frameID);
1240     MESSAGE_CHECK(frame);
1241
1242     m_resourceLoadClient.didInitiateLoadForResource(this, frame, resourceIdentifier, request);
1243 }
1244
1245 void WebPageProxy::didSendRequestForResource(uint64_t frameID, uint64_t resourceIdentifier, const ResourceRequest& request, const ResourceResponse& redirectResponse)
1246 {
1247     WebFrameProxy* frame = process()->webFrame(frameID);
1248     MESSAGE_CHECK(frame);
1249
1250     m_resourceLoadClient.didSendRequestForResource(this, frame, resourceIdentifier, request, redirectResponse);
1251 }
1252
1253 void WebPageProxy::didReceiveResponseForResource(uint64_t frameID, uint64_t resourceIdentifier, const ResourceResponse& response)
1254 {
1255     WebFrameProxy* frame = process()->webFrame(frameID);
1256     MESSAGE_CHECK(frame);
1257
1258     m_resourceLoadClient.didReceiveResponseForResource(this, frame, resourceIdentifier, response);
1259 }
1260
1261 void WebPageProxy::didReceiveContentLengthForResource(uint64_t frameID, uint64_t resourceIdentifier, uint64_t contentLength)
1262 {
1263     WebFrameProxy* frame = process()->webFrame(frameID);
1264     MESSAGE_CHECK(frame);
1265
1266     m_resourceLoadClient.didReceiveContentLengthForResource(this, frame, resourceIdentifier, contentLength);
1267 }
1268
1269 void WebPageProxy::didFinishLoadForResource(uint64_t frameID, uint64_t resourceIdentifier)
1270 {
1271     WebFrameProxy* frame = process()->webFrame(frameID);
1272     MESSAGE_CHECK(frame);
1273
1274     m_resourceLoadClient.didFinishLoadForResource(this, frame, resourceIdentifier);
1275 }
1276
1277 void WebPageProxy::didFailLoadForResource(uint64_t frameID, uint64_t resourceIdentifier, const ResourceError& error)
1278 {
1279     WebFrameProxy* frame = process()->webFrame(frameID);
1280     MESSAGE_CHECK(frame);
1281
1282     m_resourceLoadClient.didFailLoadForResource(this, frame, resourceIdentifier, error);
1283 }
1284
1285 // UIClient
1286
1287 void WebPageProxy::createNewPage(const WindowFeatures& windowFeatures, uint32_t opaqueModifiers, int32_t opaqueMouseButton, uint64_t& newPageID, WebPageCreationParameters& newPageParameters)
1288 {
1289     RefPtr<WebPageProxy> newPage = m_uiClient.createNewPage(this, windowFeatures, static_cast<WebEvent::Modifiers>(opaqueModifiers), static_cast<WebMouseEvent::Button>(opaqueMouseButton));
1290     if (newPage) {
1291         // FIXME: Pass the real size.
1292         newPageID = newPage->pageID();
1293         newPageParameters = newPage->creationParameters(IntSize(100, 100));
1294     } else
1295         newPageID = 0;
1296 }
1297     
1298 void WebPageProxy::showPage()
1299 {
1300     m_uiClient.showPage(this);
1301 }
1302
1303 void WebPageProxy::closePage()
1304 {
1305     m_uiClient.close(this);
1306 }
1307
1308 void WebPageProxy::runJavaScriptAlert(uint64_t frameID, const String& message)
1309 {
1310     WebFrameProxy* frame = process()->webFrame(frameID);
1311     MESSAGE_CHECK(frame);
1312
1313     m_uiClient.runJavaScriptAlert(this, message, frame);
1314 }
1315
1316 void WebPageProxy::runJavaScriptConfirm(uint64_t frameID, const String& message, bool& result)
1317 {
1318     WebFrameProxy* frame = process()->webFrame(frameID);
1319     MESSAGE_CHECK(frame);
1320
1321     result = m_uiClient.runJavaScriptConfirm(this, message, frame);
1322 }
1323
1324 void WebPageProxy::runJavaScriptPrompt(uint64_t frameID, const String& message, const String& defaultValue, String& result)
1325 {
1326     WebFrameProxy* frame = process()->webFrame(frameID);
1327     MESSAGE_CHECK(frame);
1328
1329     result = m_uiClient.runJavaScriptPrompt(this, message, defaultValue, frame);
1330 }
1331
1332 void WebPageProxy::setStatusText(const String& text)
1333 {
1334     m_uiClient.setStatusText(this, text);
1335 }
1336
1337 void WebPageProxy::mouseDidMoveOverElement(uint32_t opaqueModifiers, CoreIPC::ArgumentDecoder* arguments)
1338 {
1339     RefPtr<APIObject> userData;
1340     WebContextUserMessageDecoder messageDecoder(userData, context());
1341     if (!arguments->decode(messageDecoder))
1342         return;
1343
1344     WebEvent::Modifiers modifiers = static_cast<WebEvent::Modifiers>(opaqueModifiers);
1345
1346     m_uiClient.mouseDidMoveOverElement(this, modifiers, userData.get());
1347 }
1348
1349 void WebPageProxy::missingPluginButtonClicked(const String& mimeType, const String& url)
1350 {
1351     m_uiClient.missingPluginButtonClicked(this, mimeType, url);
1352 }
1353
1354 void WebPageProxy::setToolbarsAreVisible(bool toolbarsAreVisible)
1355 {
1356     m_uiClient.setToolbarsAreVisible(this, toolbarsAreVisible);
1357 }
1358
1359 void WebPageProxy::getToolbarsAreVisible(bool& toolbarsAreVisible)
1360 {
1361     toolbarsAreVisible = m_uiClient.toolbarsAreVisible(this);
1362 }
1363
1364 void WebPageProxy::setMenuBarIsVisible(bool menuBarIsVisible)
1365 {
1366     m_uiClient.setMenuBarIsVisible(this, menuBarIsVisible);
1367 }
1368
1369 void WebPageProxy::getMenuBarIsVisible(bool& menuBarIsVisible)
1370 {
1371     menuBarIsVisible = m_uiClient.menuBarIsVisible(this);
1372 }
1373
1374 void WebPageProxy::setStatusBarIsVisible(bool statusBarIsVisible)
1375 {
1376     m_uiClient.setStatusBarIsVisible(this, statusBarIsVisible);
1377 }
1378
1379 void WebPageProxy::getStatusBarIsVisible(bool& statusBarIsVisible)
1380 {
1381     statusBarIsVisible = m_uiClient.statusBarIsVisible(this);
1382 }
1383
1384 void WebPageProxy::setIsResizable(bool isResizable)
1385 {
1386     m_uiClient.setIsResizable(this, isResizable);
1387 }
1388
1389 void WebPageProxy::getIsResizable(bool& isResizable)
1390 {
1391     isResizable = m_uiClient.isResizable(this);
1392 }
1393
1394 void WebPageProxy::setWindowFrame(const FloatRect& newWindowFrame)
1395 {
1396     m_uiClient.setWindowFrame(this, m_pageClient->convertToDeviceSpace(newWindowFrame));
1397 }
1398
1399 void WebPageProxy::getWindowFrame(FloatRect& newWindowFrame)
1400 {
1401     newWindowFrame = m_pageClient->convertToUserSpace(m_uiClient.windowFrame(this));
1402 }
1403
1404 void WebPageProxy::canRunBeforeUnloadConfirmPanel(bool& canRun)
1405 {
1406     canRun = m_uiClient.canRunBeforeUnloadConfirmPanel();
1407 }
1408
1409 void WebPageProxy::runBeforeUnloadConfirmPanel(const String& message, uint64_t frameID, bool& shouldClose)
1410 {
1411     WebFrameProxy* frame = process()->webFrame(frameID);
1412     MESSAGE_CHECK(frame);
1413
1414     shouldClose = m_uiClient.runBeforeUnloadConfirmPanel(this, message, frame);
1415 }
1416
1417 #if ENABLE(TILED_BACKING_STORE)
1418 void WebPageProxy::pageDidRequestScroll(const IntSize& delta)
1419 {
1420     m_pageClient->pageDidRequestScroll(delta);
1421 }
1422 #endif
1423
1424 void WebPageProxy::didChangeViewportData(const ViewportArguments& args)
1425 {
1426     m_pageClient->setViewportArguments(args);
1427 }
1428
1429 void WebPageProxy::pageDidScroll()
1430 {
1431     m_uiClient.pageDidScroll(this);
1432 }
1433
1434 void WebPageProxy::runOpenPanel(uint64_t frameID, const WebOpenPanelParameters::Data& data)
1435 {
1436     if (m_openPanelResultListener) {
1437         m_openPanelResultListener->invalidate();
1438         m_openPanelResultListener = 0;
1439     }
1440
1441     WebFrameProxy* frame = process()->webFrame(frameID);
1442     MESSAGE_CHECK(frame);
1443
1444     m_openPanelResultListener = WebOpenPanelResultListenerProxy::create(this);
1445
1446     if (!m_uiClient.runOpenPanel(this, frame, data, m_openPanelResultListener.get()))
1447         didCancelForOpenPanel();
1448 }
1449
1450 #if PLATFORM(QT)
1451 void WebPageProxy::didChangeContentsSize(const WebCore::IntSize& size)
1452 {
1453     m_pageClient->didChangeContentsSize(size);
1454 }
1455
1456 void WebPageProxy::didFindZoomableArea(const WebCore::IntRect& area)
1457 {
1458     m_pageClient->didFindZoomableArea(area);
1459 }
1460
1461 void WebPageProxy::findZoomableAreaForPoint(const WebCore::IntPoint& point)
1462 {
1463     if (!isValid())
1464         return;
1465
1466     process()->send(Messages::WebPage::FindZoomableAreaForPoint(point), m_pageID);
1467 }
1468 #endif
1469
1470 void WebPageProxy::didDraw()
1471 {
1472     m_uiClient.didDraw(this);
1473 }
1474
1475 // Inspector
1476
1477 #if ENABLE(INSPECTOR)
1478
1479 WebInspectorProxy* WebPageProxy::inspector()
1480 {
1481     if (isClosed() || !isValid())
1482         return 0;
1483     if (!m_inspector)
1484         m_inspector = WebInspectorProxy::create(this);
1485     return m_inspector.get();
1486 }
1487
1488 #endif
1489
1490 // BackForwardList
1491
1492 void WebPageProxy::backForwardAddItem(uint64_t itemID)
1493 {
1494     m_backForwardList->addItem(process()->webBackForwardItem(itemID));
1495 }
1496
1497 void WebPageProxy::backForwardGoToItem(uint64_t itemID)
1498 {
1499     m_backForwardList->goToItem(process()->webBackForwardItem(itemID));
1500 }
1501
1502 void WebPageProxy::backForwardItemAtIndex(int32_t index, uint64_t& itemID)
1503 {
1504     WebBackForwardListItem* item = m_backForwardList->itemAtIndex(index);
1505     itemID = item ? item->itemID() : 0;
1506 }
1507
1508 void WebPageProxy::backForwardBackListCount(int32_t& count)
1509 {
1510     count = m_backForwardList->backListCount();
1511 }
1512
1513 void WebPageProxy::backForwardForwardListCount(int32_t& count)
1514 {
1515     count = m_backForwardList->forwardListCount();
1516 }
1517
1518 #if PLATFORM(MAC)
1519 // Selection change support
1520 void WebPageProxy::didSelectionChange(bool isNone, bool isContentEditable, bool isPasswordField, bool hasComposition, uint64_t location, uint64_t length)
1521 {
1522     m_pageClient->selectionChanged(isNone, isContentEditable, isPasswordField, hasComposition, location, length);
1523 }
1524
1525 // Complex text input support for plug-ins.
1526 void WebPageProxy::sendComplexTextInputToPlugin(uint64_t pluginComplexTextInputIdentifier, const String& textInput)
1527 {
1528     if (!isValid())
1529         return;
1530     
1531     process()->send(Messages::WebPage::SendComplexTextInputToPlugin(pluginComplexTextInputIdentifier, textInput), m_pageID);
1532 }
1533     
1534 #else    
1535 void WebPageProxy::didChangeSelection(bool isNone, bool isContentEditable, bool isPasswordField, bool hasComposition)
1536 {
1537     m_pageClient->selectionChanged(isNone, isContentEditable, isPasswordField, hasComposition);
1538 }
1539 #endif
1540
1541 #if PLATFORM(WIN)
1542 void WebPageProxy::didChangeCompositionSelection(bool hasComposition)
1543 {
1544     m_pageClient->compositionSelectionChanged(hasComposition);
1545 }
1546
1547 void WebPageProxy::confirmComposition(const String& compositionString)
1548 {
1549     process()->send(Messages::WebPage::ConfirmComposition(compositionString), m_pageID);
1550 }
1551
1552 void WebPageProxy::setComposition(const String& compositionString, Vector<WebCore::CompositionUnderline>& underlines, int cursorPosition)
1553 {
1554     process()->send(Messages::WebPage::SetComposition(compositionString, underlines, cursorPosition), m_pageID);
1555 }
1556 #endif
1557     
1558 // Undo management
1559
1560 void WebPageProxy::registerEditCommandForUndo(uint64_t commandID, uint32_t editAction)
1561 {
1562     registerEditCommand(WebEditCommandProxy::create(commandID, static_cast<EditAction>(editAction), this), Undo);
1563 }
1564
1565 void WebPageProxy::clearAllEditCommands()
1566 {
1567     m_pageClient->clearAllEditCommands();
1568 }
1569
1570 void WebPageProxy::didCountStringMatches(const String& string, uint32_t matchCount)
1571 {
1572     m_findClient.didCountStringMatches(this, string, matchCount);
1573 }
1574
1575 void WebPageProxy::setFindIndicator(const FloatRect& selectionRect, const Vector<FloatRect>& textRects, const SharedMemory::Handle& contentImageHandle, bool fadeOut)
1576 {
1577     RefPtr<FindIndicator> findIndicator = FindIndicator::create(selectionRect, textRects, contentImageHandle);
1578     m_pageClient->setFindIndicator(findIndicator.release(), fadeOut);
1579 }
1580
1581 void WebPageProxy::didFindString(const String& string, uint32_t matchCount)
1582 {
1583     m_findClient.didFindString(this, string, matchCount);
1584 }
1585
1586 void WebPageProxy::didFailToFindString(const String& string)
1587 {
1588     m_findClient.didFailToFindString(this, string);
1589 }
1590
1591 void WebPageProxy::valueChangedForPopupMenu(WebPopupMenuProxy*, int32_t newSelectedIndex)
1592 {
1593     process()->send(Messages::WebPage::DidChangeSelectedIndexForActivePopupMenu(newSelectedIndex), m_pageID);
1594 }
1595
1596 void WebPageProxy::setTextFromItemForPopupMenu(WebPopupMenuProxy*, int32_t index)
1597 {
1598     process()->send(Messages::WebPage::SetTextForActivePopupMenu(index), m_pageID);
1599 }
1600
1601 void WebPageProxy::showPopupMenu(const IntRect& rect, const Vector<WebPopupItem>& items, int32_t selectedIndex, const PlatformPopupMenuData& data)
1602 {
1603     if (m_activePopupMenu)
1604         m_activePopupMenu->hidePopupMenu();
1605     else
1606         m_activePopupMenu = m_pageClient->createPopupMenuProxy(this);
1607
1608     m_activePopupMenu->showPopupMenu(rect, items, data, selectedIndex);
1609     m_activePopupMenu = 0;
1610 }
1611
1612 void WebPageProxy::hidePopupMenu()
1613 {
1614     if (!m_activePopupMenu)
1615         return;
1616
1617     m_activePopupMenu->hidePopupMenu();
1618     m_activePopupMenu = 0;
1619 }
1620
1621 void WebPageProxy::showContextMenu(const WebCore::IntPoint& menuLocation, const Vector<WebContextMenuItemData>& proposedItems, CoreIPC::ArgumentDecoder* arguments)
1622 {
1623     RefPtr<APIObject> userData;
1624     WebContextUserMessageDecoder messageDecoder(userData, context());
1625     if (!arguments->decode(messageDecoder))
1626         return;
1627
1628     if (m_activeContextMenu)
1629         m_activeContextMenu->hideContextMenu();
1630     else
1631         m_activeContextMenu = m_pageClient->createContextMenuProxy(this);
1632
1633     // Give the PageContextMenuClient one last swipe at changing the menu.
1634     Vector<WebContextMenuItemData> items;
1635         
1636     if (!m_contextMenuClient.getContextMenuFromProposedMenu(this, proposedItems, items, userData.get())) {
1637         m_activeContextMenu->showContextMenu(menuLocation, proposedItems);
1638         return;
1639     }
1640     
1641     if (items.size())
1642         m_activeContextMenu->showContextMenu(menuLocation, items);
1643 }
1644
1645 void WebPageProxy::contextMenuItemSelected(const WebContextMenuItemData& item)
1646 {
1647     // Application custom items don't need to round-trip through to WebCore in the WebProcess.
1648     if (item.action() >= ContextMenuItemBaseApplicationTag) {
1649         m_contextMenuClient.customContextMenuItemSelected(this, item);
1650         return;
1651     }
1652     
1653     process()->send(Messages::WebPage::DidSelectItemFromActiveContextMenu(item), m_pageID);
1654 }
1655
1656 void WebPageProxy::didChooseFilesForOpenPanel(const Vector<String>& fileURLs)
1657 {
1658     if (!isValid())
1659         return;
1660
1661     // FIXME: This also needs to send a sandbox extension for these paths.
1662     process()->send(Messages::WebPage::DidChooseFilesForOpenPanel(fileURLs), m_pageID);
1663
1664     m_openPanelResultListener->invalidate();
1665     m_openPanelResultListener = 0;
1666 }
1667
1668 void WebPageProxy::didCancelForOpenPanel()
1669 {
1670     if (!isValid())
1671         return;
1672
1673     process()->send(Messages::WebPage::DidCancelForOpenPanel(), m_pageID);
1674     
1675     m_openPanelResultListener->invalidate();
1676     m_openPanelResultListener = 0;
1677 }
1678
1679 void WebPageProxy::unmarkAllMisspellings()
1680 {
1681     process()->send(Messages::WebPage::UnmarkAllMisspellings(), m_pageID);
1682 }
1683
1684 void WebPageProxy::unmarkAllBadGrammar()
1685 {
1686     process()->send(Messages::WebPage::UnmarkAllBadGrammar(), m_pageID);
1687 }
1688
1689 void WebPageProxy::registerEditCommand(PassRefPtr<WebEditCommandProxy> commandProxy, UndoOrRedo undoOrRedo)
1690 {
1691     m_pageClient->registerEditCommand(commandProxy, undoOrRedo);
1692 }
1693
1694 void WebPageProxy::addEditCommand(WebEditCommandProxy* command)
1695 {
1696     m_editCommandSet.add(command);
1697 }
1698
1699 void WebPageProxy::removeEditCommand(WebEditCommandProxy* command)
1700 {
1701     m_editCommandSet.remove(command);
1702
1703     if (!isValid())
1704         return;
1705     process()->send(Messages::WebPage::DidRemoveEditCommand(command->commandID()), m_pageID);
1706 }
1707
1708 // Other
1709
1710 void WebPageProxy::takeFocus(bool direction)
1711 {
1712     m_pageClient->takeFocus(direction);
1713 }
1714
1715 void WebPageProxy::setToolTip(const String& toolTip)
1716 {
1717     String oldToolTip = m_toolTip;
1718     m_toolTip = toolTip;
1719     m_pageClient->toolTipChanged(oldToolTip, m_toolTip);
1720 }
1721
1722 void WebPageProxy::setCursor(const WebCore::Cursor& cursor)
1723 {
1724     m_pageClient->setCursor(cursor);
1725 }
1726
1727 void WebPageProxy::didValidateMenuItem(const String& commandName, bool isEnabled, int32_t state)
1728 {
1729     m_pageClient->setEditCommandState(commandName, isEnabled, state);
1730 }
1731
1732 void WebPageProxy::didReceiveEvent(uint32_t opaqueType, bool handled)
1733 {
1734     WebEvent::Type type = static_cast<WebEvent::Type>(opaqueType);
1735
1736     switch (type) {
1737     case WebEvent::MouseMove:
1738         break;
1739
1740     case WebEvent::MouseDown:
1741     case WebEvent::MouseUp:
1742     case WebEvent::Wheel:
1743     case WebEvent::KeyDown:
1744     case WebEvent::KeyUp:
1745     case WebEvent::RawKeyDown:
1746     case WebEvent::Char:
1747         process()->responsivenessTimer()->stop();
1748         break;
1749     }
1750
1751     switch (type) {
1752     case WebEvent::MouseMove:
1753     case WebEvent::MouseDown:
1754     case WebEvent::MouseUp:
1755         break;
1756
1757     case WebEvent::Wheel: {
1758         m_processingWheelEvent = false;
1759         if (m_nextWheelEvent) {
1760             handleWheelEvent(*m_nextWheelEvent);
1761             m_nextWheelEvent.clear();
1762         }
1763         break;
1764     }
1765
1766     case WebEvent::KeyDown:
1767     case WebEvent::KeyUp:
1768     case WebEvent::RawKeyDown:
1769     case WebEvent::Char: {
1770         NativeWebKeyboardEvent event = m_keyEventQueue.first();
1771         MESSAGE_CHECK(type == event.type());
1772
1773         m_keyEventQueue.removeFirst();
1774
1775         if (handled)
1776             break;
1777
1778         m_pageClient->didNotHandleKeyEvent(event);
1779         m_uiClient.didNotHandleKeyEvent(this, event);
1780         break;
1781     }
1782     }
1783 }
1784
1785 void WebPageProxy::dataCallback(const CoreIPC::DataReference& dataReference, uint64_t callbackID)
1786 {
1787     RefPtr<DataCallback> callback = m_dataCallbacks.take(callbackID);
1788     if (!callback) {
1789         // FIXME: Log error or assert.
1790         return;
1791     }
1792
1793     RefPtr<WebData> data;
1794     if (size_t size = dataReference.size())
1795         data = WebData::create(dataReference.data(), size);
1796
1797     callback->performCallbackWithReturnValue(data.get());
1798 }
1799
1800 void WebPageProxy::stringCallback(const String& resultString, uint64_t callbackID)
1801 {
1802     RefPtr<StringCallback> callback = m_stringCallbacks.take(callbackID);
1803     if (!callback) {
1804         // FIXME: Log error or assert.
1805         return;
1806     }
1807
1808     callback->performCallbackWithReturnValue(resultString.impl());
1809 }
1810
1811 void WebPageProxy::focusedFrameChanged(uint64_t frameID)
1812 {
1813     if (!frameID) {
1814         m_focusedFrame = 0;
1815         return;
1816     }
1817
1818     WebFrameProxy* frame = process()->webFrame(frameID);
1819     MESSAGE_CHECK(frame);
1820
1821     m_focusedFrame = frame;
1822 }
1823
1824 #if USE(ACCELERATED_COMPOSITING)
1825 void WebPageProxy::didChangeAcceleratedCompositing(bool compositing, DrawingAreaInfo& drawingAreaInfo)
1826 {
1827     if (compositing)
1828         didEnterAcceleratedCompositing();
1829     else
1830         didLeaveAcceleratedCompositing();
1831
1832     drawingAreaInfo = drawingArea()->info();
1833 }
1834 #endif
1835
1836 void WebPageProxy::processDidBecomeUnresponsive()
1837 {
1838     m_loaderClient.processDidBecomeUnresponsive(this);
1839 }
1840
1841 void WebPageProxy::processDidBecomeResponsive()
1842 {
1843     m_loaderClient.processDidBecomeResponsive(this);
1844 }
1845
1846 void WebPageProxy::processDidCrash()
1847 {
1848     ASSERT(m_pageClient);
1849
1850     m_isValid = false;
1851
1852     if (m_mainFrame)
1853         m_urlAtProcessExit = m_mainFrame->url();
1854
1855     m_mainFrame = 0;
1856
1857 #if ENABLE(INSPECTOR)
1858     if (m_inspector) {
1859         m_inspector->invalidate();
1860         m_inspector = 0;
1861     }
1862 #endif
1863
1864     if (m_openPanelResultListener) {
1865         m_openPanelResultListener->invalidate();
1866         m_openPanelResultListener = 0;
1867     }
1868
1869     m_toolTip = String();
1870
1871     invalidateCallbackMap(m_dataCallbacks);
1872     invalidateCallbackMap(m_stringCallbacks);
1873
1874     Vector<WebEditCommandProxy*> editCommandVector;
1875     copyToVector(m_editCommandSet, editCommandVector);
1876     m_editCommandSet.clear();
1877     for (size_t i = 0, size = editCommandVector.size(); i < size; ++i)
1878         editCommandVector[i]->invalidate();
1879     m_pageClient->clearAllEditCommands();
1880
1881     m_activePopupMenu = 0;
1882
1883     m_estimatedProgress = 0.0;
1884
1885     m_pageClient->processDidCrash();
1886     m_loaderClient.processDidCrash(this);
1887 }
1888
1889 WebPageCreationParameters WebPageProxy::creationParameters(const IntSize& size) const
1890 {
1891     WebPageCreationParameters parameters;
1892     parameters.viewSize = size;
1893     parameters.drawingAreaInfo = m_drawingArea->info();
1894     parameters.store = m_pageGroup->preferences()->store();
1895     parameters.pageGroupData = m_pageGroup->data();
1896     parameters.drawsBackground = m_drawsBackground;
1897     parameters.drawsTransparentBackground = m_drawsTransparentBackground;
1898     parameters.userAgent = userAgent();
1899
1900 #if PLATFORM(WIN)
1901     parameters.nativeWindow = m_pageClient->nativeWindow();
1902 #endif
1903
1904     return parameters;
1905 }
1906
1907 #if USE(ACCELERATED_COMPOSITING)
1908 void WebPageProxy::didEnterAcceleratedCompositing()
1909 {
1910     m_pageClient->pageDidEnterAcceleratedCompositing();
1911 }
1912
1913 void WebPageProxy::didLeaveAcceleratedCompositing()
1914 {
1915     m_pageClient->pageDidLeaveAcceleratedCompositing();
1916 }
1917 #endif // USE(ACCELERATED_COMPOSITING)
1918
1919 void WebPageProxy::backForwardClear()
1920 {
1921     m_backForwardList->clear();
1922 }
1923
1924 void WebPageProxy::canAuthenticateAgainstProtectionSpaceInFrame(uint64_t frameID, const WebCore::ProtectionSpace& coreProtectionSpace, bool& canAuthenticate)
1925 {
1926     WebFrameProxy* frame = process()->webFrame(frameID);
1927     MESSAGE_CHECK(frame);
1928
1929     RefPtr<WebProtectionSpace> protectionSpace = WebProtectionSpace::create(coreProtectionSpace);
1930     
1931     canAuthenticate = m_loaderClient.canAuthenticateAgainstProtectionSpaceInFrame(this, frame, protectionSpace.get());
1932 }
1933
1934 void WebPageProxy::didReceiveAuthenticationChallenge(uint64_t frameID, const WebCore::AuthenticationChallenge& coreChallenge, uint64_t challengeID)
1935 {
1936     WebFrameProxy* frame = process()->webFrame(frameID);
1937     MESSAGE_CHECK(frame);
1938
1939     RefPtr<AuthenticationChallengeProxy> authenticationChallenge = AuthenticationChallengeProxy::create(coreChallenge, challengeID, this);
1940     
1941     m_loaderClient.didReceiveAuthenticationChallengeInFrame(this, frame, authenticationChallenge.get());
1942 }
1943
1944 void WebPageProxy::exceededDatabaseQuota(uint64_t frameID, const String& originIdentifier, const String& databaseName, const String& displayName, uint64_t currentQuota, uint64_t currentUsage, uint64_t expectedUsage, uint64_t& newQuota)
1945 {
1946     WebFrameProxy* frame = process()->webFrame(frameID);
1947     MESSAGE_CHECK(frame);
1948
1949     RefPtr<WebSecurityOrigin> origin = WebSecurityOrigin::create(originIdentifier);
1950
1951     newQuota = m_uiClient.exceededDatabaseQuota(this, frame, origin.get(), databaseName, displayName, currentQuota, currentUsage, expectedUsage);
1952 }
1953
1954 void WebPageProxy::didFinishLoadingDataForCustomRepresentation(const CoreIPC::DataReference& dataReference)
1955 {
1956     m_pageClient->didFinishLoadingDataForCustomRepresentation(dataReference);
1957 }
1958
1959 #if PLATFORM(MAC)
1960 void WebPageProxy::setComplexTextInputEnabled(uint64_t pluginComplexTextInputIdentifier, bool complexTextInputEnabled)
1961 {
1962     m_pageClient->setComplexTextInputEnabled(pluginComplexTextInputIdentifier, complexTextInputEnabled);
1963 }
1964 #endif
1965
1966 } // namespace WebKit