Remove deprecated old Reader code
[framework/web/webkit-efl.git] / Source / WebKit2 / UIProcess / WebPageProxy.cpp
1 /*
2  * Copyright (C) 2010, 2011 Apple Inc. All rights reserved.
3  * Copyright (C) 2012 Intel Corporation. All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  * 1. Redistributions of source code must retain the above copyright
9  *    notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  *    notice, this list of conditions and the following disclaimer in the
12  *    documentation and/or other materials provided with the distribution.
13  *
14  * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
15  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
16  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
17  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
18  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
19  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
20  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
21  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
22  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
23  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
24  * THE POSSIBILITY OF SUCH DAMAGE.
25  */
26
27 #include "config.h"
28 #include "WebPageProxy.h"
29
30 #include "AuthenticationChallengeProxy.h"
31 #include "AuthenticationDecisionListener.h"
32 #include "DataReference.h"
33 #include "DownloadProxy.h"
34 #include "DrawingAreaProxy.h"
35 #include "EventDispatcherMessages.h"
36 #include "FindIndicator.h"
37 #include "Logging.h"
38 #include "MessageID.h"
39 #include "NativeWebKeyboardEvent.h"
40 #include "NativeWebMouseEvent.h"
41 #include "NativeWebWheelEvent.h"
42 #include "NotificationPermissionRequest.h"
43 #include "NotificationPermissionRequestManager.h"
44 #include "PageClient.h"
45 #include "PrintInfo.h"
46 #include "SessionState.h"
47 #include "StringPairVector.h"
48 #include "TextChecker.h"
49 #include "TextCheckerState.h"
50 #include "WKContextPrivate.h"
51 #include "WebBackForwardList.h"
52 #include "WebBackForwardListItem.h"
53 #include "WebCertificateInfo.h"
54 #include "WebContext.h"
55 #include "WebContextMenuProxy.h"
56 #include "WebContextUserMessageCoders.h"
57 #include "WebCoreArgumentCoders.h"
58 #include "WebData.h"
59 #include "WebEditCommandProxy.h"
60 #include "WebEvent.h"
61 #include "WebFormSubmissionListenerProxy.h"
62 #include "WebFramePolicyListenerProxy.h"
63 #include "WebFullScreenManagerProxy.h"
64 #include "WebInspectorProxy.h"
65 #include "WebNotificationManagerProxy.h"
66 #include "WebOpenPanelResultListenerProxy.h"
67 #include "WebPageCreationParameters.h"
68 #include "WebPageGroup.h"
69 #include "WebPageGroupData.h"
70 #include "WebPageMessages.h"
71 #include "WebPopupItem.h"
72 #include "WebPopupMenuProxy.h"
73 #include "WebPreferences.h"
74 #include "WebProcessMessages.h"
75 #include "WebProcessProxy.h"
76 #include "WebProtectionSpace.h"
77 #include "WebSecurityOrigin.h"
78 #include "WebURLRequest.h"
79 #include <WebCore/DragController.h>
80 #include <WebCore/DragData.h>
81 #include <WebCore/DragSession.h>
82 #include <WebCore/FloatRect.h>
83 #include <WebCore/FocusDirection.h>
84 #include <WebCore/MIMETypeRegistry.h>
85 #include <WebCore/TextCheckerClient.h>
86 #include <WebCore/WindowFeatures.h>
87 #include <stdio.h>
88
89 #if USE(UI_SIDE_COMPOSITING)
90 #include "LayerTreeHostProxyMessages.h"
91 #endif
92
93 #if PLATFORM(QT)
94 #include "ArgumentCodersQt.h"
95 #endif
96
97 #if PLATFORM(GTK)
98 #include "ArgumentCodersGtk.h"
99 #endif
100
101 #ifndef NDEBUG
102 #include <wtf/RefCountedLeakCounter.h>
103 #endif
104
105 #if ENABLE(TIZEN_ISF_PORT)
106 #include <WebCore/Logging.h>
107 #endif
108
109 // This controls what strategy we use for mouse wheel coalescing.
110 #define MERGE_WHEEL_EVENTS 1
111
112 #define MESSAGE_CHECK(assertion) MESSAGE_CHECK_BASE(assertion, m_process->connection())
113 #define MESSAGE_CHECK_URL(url) MESSAGE_CHECK_BASE(m_process->checkURLReceivedFromWebProcess(url), m_process->connection())
114
115 using namespace WebCore;
116
117 // Represents the number of wheel events we can hold in the queue before we start pushing them preemptively.
118 static const unsigned wheelEventQueueSizeThreshold = 10;
119
120 namespace WebKit {
121
122 WKPageDebugPaintFlags WebPageProxy::s_debugPaintFlags = 0;
123
124 DEFINE_DEBUG_ONLY_GLOBAL(WTF::RefCountedLeakCounter, webPageProxyCounter, ("WebPageProxy"));
125
126 #if !LOG_DISABLED
127 static const char* webKeyboardEventTypeString(WebEvent::Type type)
128 {
129     switch (type) {
130     case WebEvent::KeyDown:
131         return "KeyDown";
132     
133     case WebEvent::KeyUp:
134         return "KeyUp";
135     
136     case WebEvent::RawKeyDown:
137         return "RawKeyDown";
138     
139     case WebEvent::Char:
140         return "Char";
141     
142     default:
143         ASSERT_NOT_REACHED();
144         return "<unknown>";
145     }
146 }
147 #endif // !LOG_DISABLED
148
149 PassRefPtr<WebPageProxy> WebPageProxy::create(PageClient* pageClient, PassRefPtr<WebProcessProxy> process, WebPageGroup* pageGroup, uint64_t pageID)
150 {
151     return adoptRef(new WebPageProxy(pageClient, process, pageGroup, pageID));
152 }
153
154 WebPageProxy::WebPageProxy(PageClient* pageClient, PassRefPtr<WebProcessProxy> process, WebPageGroup* pageGroup, uint64_t pageID)
155     : m_pageClient(pageClient)
156     , m_process(process)
157     , m_pageGroup(pageGroup)
158     , m_mainFrame(0)
159     , m_userAgent(standardUserAgent())
160     , m_geolocationPermissionRequestManager(this)
161     , m_notificationPermissionRequestManager(this)
162 #if ENABLE(TIZEN_MEDIA_STREAM)
163     , m_userMediaPermissionRequestManager(this)
164 #endif
165     , m_estimatedProgress(0)
166     , m_isInWindow(m_pageClient->isViewInWindow())
167     , m_isVisible(m_pageClient->isViewVisible())
168     , m_backForwardList(WebBackForwardList::create(this))
169     , m_loadStateAtProcessExit(WebFrameProxy::LoadStateFinished)
170     , m_textZoomFactor(1)
171     , m_pageZoomFactor(1)
172     , m_pageScaleFactor(1)
173     , m_intrinsicDeviceScaleFactor(1)
174     , m_customDeviceScaleFactor(0)
175 #if HAVE(LAYER_HOSTING_IN_WINDOW_SERVER)
176     , m_layerHostingMode(LayerHostingModeInWindowServer)
177 #else
178     , m_layerHostingMode(LayerHostingModeDefault)
179 #endif
180     , m_drawsBackground(true)
181     , m_drawsTransparentBackground(false)
182     , m_areMemoryCacheClientCallsEnabled(true)
183     , m_useFixedLayout(false)
184     , m_paginationMode(Page::Pagination::Unpaginated)
185     , m_paginationBehavesLikeColumns(false)
186     , m_pageLength(0)
187     , m_gapBetweenPages(0)
188     , m_isValid(true)
189     , m_isClosed(false)
190     , m_isInPrintingMode(false)
191     , m_isPerformingDOMPrintOperation(false)
192     , m_inDecidePolicyForResponse(false)
193     , m_syncMimeTypePolicyActionIsValid(false)
194     , m_syncMimeTypePolicyAction(PolicyUse)
195     , m_syncMimeTypePolicyDownloadID(0)
196     , m_inDecidePolicyForNavigationAction(false)
197     , m_syncNavigationActionPolicyActionIsValid(false)
198     , m_syncNavigationActionPolicyAction(PolicyUse)
199     , m_syncNavigationActionPolicyDownloadID(0)
200     , m_processingMouseMoveEvent(false)
201 #if ENABLE(TOUCH_EVENTS)
202     , m_needTouchEvents(false)
203 #endif
204     , m_pageID(pageID)
205     , m_isPageSuspended(false)
206 #if PLATFORM(MAC)
207     , m_isSmartInsertDeleteEnabled(TextChecker::isSmartInsertDeleteEnabled())
208 #endif
209     , m_spellDocumentTag(0)
210     , m_hasSpellDocumentTag(false)
211     , m_pendingLearnOrIgnoreWordMessageCount(0)
212     , m_mainFrameHasCustomRepresentation(false)
213     , m_mainFrameHasHorizontalScrollbar(false)
214     , m_mainFrameHasVerticalScrollbar(false)
215     , m_canShortCircuitHorizontalWheelEvents(true)
216     , m_mainFrameIsPinnedToLeftSide(false)
217     , m_mainFrameIsPinnedToRightSide(false)
218     , m_pageCount(0)
219     , m_renderTreeSize(0)
220     , m_shouldSendEventsSynchronously(false)
221     , m_mediaVolume(1)
222 #if ENABLE(PAGE_VISIBILITY_API)
223     , m_visibilityState(PageVisibilityStateVisible)
224 #endif
225 {
226 #ifndef NDEBUG
227     webPageProxyCounter.increment();
228 #endif
229
230     WebContext::statistics().wkPageCount++;
231
232     m_pageGroup->addPage(this);
233 }
234
235 WebPageProxy::~WebPageProxy()
236 {
237     if (!m_isClosed)
238         close();
239
240     WebContext::statistics().wkPageCount--;
241
242     if (m_hasSpellDocumentTag)
243         TextChecker::closeSpellDocumentWithTag(m_spellDocumentTag);
244
245     m_pageGroup->removePage(this);
246
247 #ifndef NDEBUG
248     webPageProxyCounter.decrement();
249 #endif
250 }
251
252 WebProcessProxy* WebPageProxy::process() const
253 {
254     return m_process.get();
255 }
256
257 PlatformProcessIdentifier WebPageProxy::processIdentifier() const
258 {
259     if (!m_process)
260         return 0;
261
262     return m_process->processIdentifier();
263 }
264
265 bool WebPageProxy::isValid()
266 {
267     // A page that has been explicitly closed is never valid.
268     if (m_isClosed)
269         return false;
270
271     return m_isValid;
272 }
273
274 void WebPageProxy::initializeLoaderClient(const WKPageLoaderClient* loadClient)
275 {
276     m_loaderClient.initialize(loadClient);
277     
278     if (!loadClient)
279         return;
280
281     process()->send(Messages::WebPage::SetWillGoToBackForwardItemCallbackEnabled(loadClient->version > 0), m_pageID);
282 }
283
284 void WebPageProxy::initializePolicyClient(const WKPagePolicyClient* policyClient)
285 {
286     m_policyClient.initialize(policyClient);
287 }
288
289 void WebPageProxy::initializeFormClient(const WKPageFormClient* formClient)
290 {
291     m_formClient.initialize(formClient);
292 }
293
294 void WebPageProxy::initializeResourceLoadClient(const WKPageResourceLoadClient* client)
295 {
296     m_resourceLoadClient.initialize(client);
297 }
298
299 void WebPageProxy::initializeUIClient(const WKPageUIClient* client)
300 {
301     if (!isValid())
302         return;
303
304     m_uiClient.initialize(client);
305
306     process()->send(Messages::WebPage::SetCanRunBeforeUnloadConfirmPanel(m_uiClient.canRunBeforeUnloadConfirmPanel()), m_pageID);
307     process()->send(Messages::WebPage::SetCanRunModal(m_uiClient.canRunModal()), m_pageID);
308 }
309
310 void WebPageProxy::initializeFindClient(const WKPageFindClient* client)
311 {
312     m_findClient.initialize(client);
313 }
314
315 #if ENABLE(CONTEXT_MENUS)
316 void WebPageProxy::initializeContextMenuClient(const WKPageContextMenuClient* client)
317 {
318     m_contextMenuClient.initialize(client);
319 }
320 #endif
321
322 void WebPageProxy::reattachToWebProcess()
323 {
324     ASSERT(!isValid());
325
326     m_isValid = true;
327
328     m_process = m_process->context()->relaunchProcessIfNecessary();
329     process()->addExistingWebPage(this, m_pageID);
330
331     initializeWebPage();
332
333     m_pageClient->didRelaunchProcess();
334     m_drawingArea->waitForBackingStoreUpdateOnNextPaint();
335 }
336
337 void WebPageProxy::reattachToWebProcessWithItem(WebBackForwardListItem* item)
338 {
339     if (item && item != m_backForwardList->currentItem())
340         m_backForwardList->goToItem(item);
341     
342     reattachToWebProcess();
343
344     if (!item)
345         return;
346
347     process()->send(Messages::WebPage::GoToBackForwardItem(item->itemID()), m_pageID);
348     process()->responsivenessTimer()->start();
349 }
350
351 void WebPageProxy::initializeWebPage()
352 {
353     ASSERT(isValid());
354
355     BackForwardListItemVector items = m_backForwardList->entries();
356     for (size_t i = 0; i < items.size(); ++i)
357         process()->registerNewWebBackForwardListItem(items[i].get());
358
359     m_drawingArea = m_pageClient->createDrawingAreaProxy();
360     ASSERT(m_drawingArea);
361
362 #if ENABLE(INSPECTOR_SERVER)
363     if (m_pageGroup->preferences()->developerExtrasEnabled())
364         inspector()->enableRemoteInspection();
365 #endif
366
367     process()->send(Messages::WebProcess::CreateWebPage(m_pageID, creationParameters()), 0);
368
369 #if ENABLE(PAGE_VISIBILITY_API)
370     process()->send(Messages::WebPage::SetVisibilityState(m_visibilityState, /* isInitialState */ true), m_pageID);
371 #endif
372 }
373
374 void WebPageProxy::close()
375 {
376     if (!isValid())
377         return;
378
379     m_isClosed = true;
380
381     m_backForwardList->pageClosed();
382     m_pageClient->pageClosed();
383
384     process()->disconnectFramesFromPage(this);
385     m_mainFrame = 0;
386
387 #if ENABLE(INSPECTOR)
388     if (m_inspector) {
389         m_inspector->invalidate();
390         m_inspector = 0;
391     }
392 #endif
393
394 #if ENABLE(FULLSCREEN_API)
395     if (m_fullScreenManager) {
396         m_fullScreenManager->invalidate();
397         m_fullScreenManager = 0;
398     }
399 #endif
400
401     if (m_openPanelResultListener) {
402         m_openPanelResultListener->invalidate();
403         m_openPanelResultListener = 0;
404     }
405
406 #if ENABLE(INPUT_TYPE_COLOR)
407     if (m_colorChooser) {
408         m_colorChooser->invalidate();
409         m_colorChooser = nullptr;
410     }
411 #endif
412
413 #if ENABLE(GEOLOCATION)
414     m_geolocationPermissionRequestManager.invalidateRequests();
415 #endif
416
417     m_notificationPermissionRequestManager.invalidateRequests();
418 #if ENABLE(TIZEN_MEDIA_STREAM)
419     m_userMediaPermissionRequestManager.invalidateRequests();
420 #endif
421
422     m_toolTip = String();
423
424     m_mainFrameHasHorizontalScrollbar = false;
425     m_mainFrameHasVerticalScrollbar = false;
426
427     m_mainFrameIsPinnedToLeftSide = false;
428     m_mainFrameIsPinnedToRightSide = false;
429
430     m_visibleScrollerThumbRect = IntRect();
431
432 #if ENABLE(TIZEN_SUPPORT_WEBAPP_META_TAG)
433     invalidateCallbackMap(m_booleanCallbacks);
434 #endif
435     invalidateCallbackMap(m_voidCallbacks);
436     invalidateCallbackMap(m_dataCallbacks);
437     invalidateCallbackMap(m_stringCallbacks);
438     m_loadDependentStringCallbackIDs.clear();
439     invalidateCallbackMap(m_scriptValueCallbacks);
440     invalidateCallbackMap(m_computedPagesCallbacks);
441 #if PLATFORM(GTK)
442     invalidateCallbackMap(m_printFinishedCallbacks);
443 #endif
444
445     Vector<WebEditCommandProxy*> editCommandVector;
446     copyToVector(m_editCommandSet, editCommandVector);
447     m_editCommandSet.clear();
448     for (size_t i = 0, size = editCommandVector.size(); i < size; ++i)
449         editCommandVector[i]->invalidate();
450
451     m_activePopupMenu = 0;
452
453     m_estimatedProgress = 0.0;
454     
455     m_loaderClient.initialize(0);
456     m_policyClient.initialize(0);
457     m_uiClient.initialize(0);
458
459     m_drawingArea = nullptr;
460
461     process()->send(Messages::WebPage::Close(), m_pageID);
462     process()->removeWebPage(m_pageID);
463 }
464
465 bool WebPageProxy::tryClose()
466 {
467     if (!isValid())
468         return true;
469
470     process()->send(Messages::WebPage::TryClose(), m_pageID);
471     process()->responsivenessTimer()->start();
472     return false;
473 }
474
475 bool WebPageProxy::maybeInitializeSandboxExtensionHandle(const KURL& url, SandboxExtension::Handle& sandboxExtensionHandle)
476 {
477     if (!url.isLocalFile())
478         return false;
479
480 #if ENABLE(INSPECTOR)
481     // Don't give the inspector full access to the file system.
482     if (WebInspectorProxy::isInspectorPage(this))
483         return false;
484 #endif
485
486     SandboxExtension::createHandle("/", SandboxExtension::ReadOnly, sandboxExtensionHandle);
487     return true;
488 }
489
490 void WebPageProxy::loadURL(const String& url)
491 {
492     setPendingAPIRequestURL(url);
493
494     if (!isValid())
495         reattachToWebProcess();
496
497     SandboxExtension::Handle sandboxExtensionHandle;
498     bool createdExtension = maybeInitializeSandboxExtensionHandle(KURL(KURL(), url), sandboxExtensionHandle);
499     if (createdExtension)
500         process()->willAcquireUniversalFileReadSandboxExtension();
501     process()->send(Messages::WebPage::LoadURL(url, sandboxExtensionHandle), m_pageID);
502     process()->responsivenessTimer()->start();
503 }
504
505 void WebPageProxy::loadURLRequest(WebURLRequest* urlRequest)
506 {
507     setPendingAPIRequestURL(urlRequest->resourceRequest().url());
508
509     if (!isValid())
510         reattachToWebProcess();
511
512     SandboxExtension::Handle sandboxExtensionHandle;
513     bool createdExtension = maybeInitializeSandboxExtensionHandle(urlRequest->resourceRequest().url(), sandboxExtensionHandle);
514     if (createdExtension)
515         process()->willAcquireUniversalFileReadSandboxExtension();
516     process()->send(Messages::WebPage::LoadURLRequest(urlRequest->resourceRequest(), sandboxExtensionHandle), m_pageID);
517     process()->responsivenessTimer()->start();
518 }
519
520 void WebPageProxy::loadHTMLString(const String& htmlString, const String& baseURL)
521 {
522     if (!isValid())
523         reattachToWebProcess();
524
525     process()->assumeReadAccessToBaseURL(baseURL);
526     process()->send(Messages::WebPage::LoadHTMLString(htmlString, baseURL), m_pageID);
527     process()->responsivenessTimer()->start();
528 }
529
530 void WebPageProxy::loadAlternateHTMLString(const String& htmlString, const String& baseURL, const String& unreachableURL)
531 {
532     if (!isValid())
533         reattachToWebProcess();
534
535     if (m_mainFrame)
536         m_mainFrame->setUnreachableURL(unreachableURL);
537
538     process()->assumeReadAccessToBaseURL(baseURL);
539     process()->send(Messages::WebPage::LoadAlternateHTMLString(htmlString, baseURL, unreachableURL), m_pageID);
540     process()->responsivenessTimer()->start();
541 }
542
543 void WebPageProxy::loadPlainTextString(const String& string)
544 {
545     if (!isValid())
546         reattachToWebProcess();
547
548     process()->send(Messages::WebPage::LoadPlainTextString(string), m_pageID);
549     process()->responsivenessTimer()->start();
550 }
551
552 void WebPageProxy::loadWebArchiveData(const WebData* webArchiveData)
553 {
554     if (!isValid())
555         reattachToWebProcess();
556
557     process()->send(Messages::WebPage::LoadWebArchiveData(webArchiveData->dataReference()), m_pageID);
558     process()->responsivenessTimer()->start();
559 }
560
561 #if OS(TIZEN)
562 void WebPageProxy::loadContentsbyMimeType(const WebData* contents, const String& mimeType, const String& encoding, const String& baseURL)
563 {
564     if (!isValid())
565         reattachToWebProcess();
566
567     process()->assumeReadAccessToBaseURL(baseURL);
568     process()->send(Messages::WebPage::LoadContentsbyMimeType(contents->dataReference(), mimeType, encoding, baseURL), m_pageID);
569     process()->responsivenessTimer()->start();
570 }
571 #endif
572
573 void WebPageProxy::stopLoading()
574 {
575     if (!isValid())
576         return;
577
578     process()->send(Messages::WebPage::StopLoading(), m_pageID);
579     process()->responsivenessTimer()->start();
580 }
581
582 void WebPageProxy::reload(bool reloadFromOrigin)
583 {
584     SandboxExtension::Handle sandboxExtensionHandle;
585
586     if (m_backForwardList->currentItem()) {
587         String url = m_backForwardList->currentItem()->url();
588         setPendingAPIRequestURL(url);
589
590         // We may not have an extension yet if back/forward list was reinstated after a WebProcess crash or a browser relaunch
591         bool createdExtension = maybeInitializeSandboxExtensionHandle(KURL(KURL(), url), sandboxExtensionHandle);
592         if (createdExtension)
593             process()->willAcquireUniversalFileReadSandboxExtension();
594     }
595
596     if (!isValid()) {
597         reattachToWebProcessWithItem(m_backForwardList->currentItem());
598         return;
599     }
600
601     process()->send(Messages::WebPage::Reload(reloadFromOrigin, sandboxExtensionHandle), m_pageID);
602     process()->responsivenessTimer()->start();
603 }
604
605 void WebPageProxy::goForward()
606 {
607     if (isValid() && !canGoForward())
608         return;
609
610     WebBackForwardListItem* forwardItem = m_backForwardList->forwardItem();
611     if (!forwardItem)
612         return;
613
614     setPendingAPIRequestURL(forwardItem->url());
615
616     if (!isValid()) {
617         reattachToWebProcessWithItem(forwardItem);
618         return;
619     }
620
621     process()->send(Messages::WebPage::GoForward(forwardItem->itemID()), m_pageID);
622     process()->responsivenessTimer()->start();
623 }
624
625 bool WebPageProxy::canGoForward() const
626 {
627     return m_backForwardList->forwardItem();
628 }
629
630 void WebPageProxy::goBack()
631 {
632     if (isValid() && !canGoBack())
633         return;
634
635     WebBackForwardListItem* backItem = m_backForwardList->backItem();
636     if (!backItem)
637         return;
638
639     setPendingAPIRequestURL(backItem->url());
640
641     if (!isValid()) {
642         reattachToWebProcessWithItem(backItem);
643         return;
644     }
645
646     process()->send(Messages::WebPage::GoBack(backItem->itemID()), m_pageID);
647     process()->responsivenessTimer()->start();
648 }
649
650 bool WebPageProxy::canGoBack() const
651 {
652     return m_backForwardList->backItem();
653 }
654
655 void WebPageProxy::goToBackForwardItem(WebBackForwardListItem* item)
656 {
657     if (!isValid()) {
658         reattachToWebProcessWithItem(item);
659         return;
660     }
661     
662     setPendingAPIRequestURL(item->url());
663
664     process()->send(Messages::WebPage::GoToBackForwardItem(item->itemID()), m_pageID);
665     process()->responsivenessTimer()->start();
666 }
667
668 void WebPageProxy::tryRestoreScrollPosition()
669 {
670     if (!isValid())
671         return;
672
673     process()->send(Messages::WebPage::TryRestoreScrollPosition(), m_pageID);
674 }
675
676 void WebPageProxy::didChangeBackForwardList(WebBackForwardListItem* added, Vector<RefPtr<APIObject> >* removed)
677 {
678     m_loaderClient.didChangeBackForwardList(this, added, removed);
679 }
680
681 void WebPageProxy::shouldGoToBackForwardListItem(uint64_t itemID, bool& shouldGoToBackForwardItem)
682 {
683     WebBackForwardListItem* item = process()->webBackForwardItem(itemID);
684     shouldGoToBackForwardItem = item && m_loaderClient.shouldGoToBackForwardListItem(this, item);
685 }
686
687 void WebPageProxy::willGoToBackForwardListItem(uint64_t itemID, CoreIPC::ArgumentDecoder* arguments)
688 {
689     RefPtr<APIObject> userData;
690     WebContextUserMessageDecoder messageDecoder(userData, m_process->context());
691     if (!arguments->decode(messageDecoder))
692         return;
693
694     if (WebBackForwardListItem* item = process()->webBackForwardItem(itemID))
695         m_loaderClient.willGoToBackForwardListItem(this, item, userData.get());
696 }
697
698 String WebPageProxy::activeURL() const
699 {
700     // If there is a currently pending url, it is the active URL,
701     // even when there's no main frame yet, as it might be the
702     // first API request.
703     if (!m_pendingAPIRequestURL.isNull())
704         return m_pendingAPIRequestURL;
705
706     if (!m_mainFrame)
707         return String();
708
709     if (!m_mainFrame->unreachableURL().isEmpty())
710         return m_mainFrame->unreachableURL();
711
712     switch (m_mainFrame->loadState()) {
713     case WebFrameProxy::LoadStateProvisional:
714         return m_mainFrame->provisionalURL();
715     case WebFrameProxy::LoadStateCommitted:
716     case WebFrameProxy::LoadStateFinished:
717         return m_mainFrame->url();
718     }
719
720     ASSERT_NOT_REACHED();
721     return String();
722 }
723
724 String WebPageProxy::provisionalURL() const
725 {
726     if (!m_mainFrame)
727         return String();
728     return m_mainFrame->provisionalURL();
729 }
730
731 String WebPageProxy::committedURL() const
732 {
733     if (!m_mainFrame)
734         return String();
735
736     return m_mainFrame->url();
737 }
738
739 bool WebPageProxy::canShowMIMEType(const String& mimeType) const
740 {
741     if (MIMETypeRegistry::isSupportedNonImageMIMEType(mimeType))
742         return true;
743
744     if (MIMETypeRegistry::isSupportedImageMIMEType(mimeType))
745         return true;
746
747     if (mimeType.startsWith("text/", false))
748         return !MIMETypeRegistry::isUnsupportedTextMIMEType(mimeType);
749
750 #if ENABLE(TIZEN_FIX_PLUGIN_DOWNLOAD)
751     // check plugin mime types if the plugin option is enabled
752     if (arePluginsEnabled()) {
753         String newMimeType = mimeType;
754         PluginModuleInfo plugin = m_process->context()->pluginInfoStore().findPlugin(newMimeType, KURL());
755         if (!plugin.path.isNull())
756             return true;
757     }
758 #else // ENABLE(TIZEN_FIX_PLUGIN_DOWNLOAD)
759     String newMimeType = mimeType;
760     PluginModuleInfo plugin = m_process->context()->pluginInfoStore().findPlugin(newMimeType, KURL());
761     if (!plugin.path.isNull())
762         return true;
763 #endif // ENABLE(TIZEN_FIX_PLUGIN_DOWNLOAD)
764
765     return false;
766 }
767
768 void WebPageProxy::setDrawsBackground(bool drawsBackground)
769 {
770     if (m_drawsBackground == drawsBackground)
771         return;
772
773     m_drawsBackground = drawsBackground;
774
775     if (isValid())
776         process()->send(Messages::WebPage::SetDrawsBackground(drawsBackground), m_pageID);
777 }
778
779 void WebPageProxy::setDrawsTransparentBackground(bool drawsTransparentBackground)
780 {
781     if (m_drawsTransparentBackground == drawsTransparentBackground)
782         return;
783
784     m_drawsTransparentBackground = drawsTransparentBackground;
785
786     if (isValid())
787         process()->send(Messages::WebPage::SetDrawsTransparentBackground(drawsTransparentBackground), m_pageID);
788 }
789
790 void WebPageProxy::viewWillStartLiveResize()
791 {
792     if (!isValid())
793         return;
794     process()->send(Messages::WebPage::ViewWillStartLiveResize(), m_pageID);
795 }
796
797 void WebPageProxy::viewWillEndLiveResize()
798 {
799     if (!isValid())
800         return;
801     process()->send(Messages::WebPage::ViewWillEndLiveResize(), m_pageID);
802 }
803
804 void WebPageProxy::setViewNeedsDisplay(const IntRect& rect)
805 {
806     m_pageClient->setViewNeedsDisplay(rect);
807 }
808
809 void WebPageProxy::displayView()
810 {
811     m_pageClient->displayView();
812 }
813
814 void WebPageProxy::scrollView(const IntRect& scrollRect, const IntSize& scrollOffset)
815 {
816     m_pageClient->scrollView(scrollRect, scrollOffset);
817 }
818
819 void WebPageProxy::viewStateDidChange(ViewStateFlags flags)
820 {
821     if (!isValid())
822         return;
823
824     if (flags & ViewIsFocused)
825         process()->send(Messages::WebPage::SetFocused(m_pageClient->isViewFocused()), m_pageID);
826
827     if (flags & ViewWindowIsActive)
828         process()->send(Messages::WebPage::SetActive(m_pageClient->isViewWindowActive()), m_pageID);
829
830     if (flags & ViewIsVisible) {
831         bool isVisible = m_pageClient->isViewVisible();
832         if (isVisible != m_isVisible) {
833             m_isVisible = isVisible;
834             m_drawingArea->visibilityDidChange();
835
836             if (!m_isVisible) {
837                 // If we've started the responsiveness timer as part of telling the web process to update the backing store
838                 // state, it might not send back a reply (since it won't paint anything if the web page is hidden) so we
839                 // stop the unresponsiveness timer here.
840                 process()->responsivenessTimer()->stop();
841             }
842         }
843     }
844
845     if (flags & ViewIsInWindow) {
846         bool isInWindow = m_pageClient->isViewInWindow();
847         if (m_isInWindow != isInWindow) {
848             m_isInWindow = isInWindow;
849             process()->send(Messages::WebPage::SetIsInWindow(isInWindow), m_pageID);
850         }
851
852         if (isInWindow) {
853             LayerHostingMode layerHostingMode = m_pageClient->viewLayerHostingMode();
854             if (m_layerHostingMode != layerHostingMode) {
855                 m_layerHostingMode = layerHostingMode;
856                 m_drawingArea->layerHostingModeDidChange();
857             }
858         }
859     }
860
861 #if ENABLE(PAGE_VISIBILITY_API)
862     PageVisibilityState visibilityState = PageVisibilityStateHidden;
863
864     if (m_pageClient->isViewVisible())
865         visibilityState = PageVisibilityStateVisible;
866
867     if (visibilityState != m_visibilityState) {
868         m_visibilityState = visibilityState;
869         process()->send(Messages::WebPage::SetVisibilityState(visibilityState, false), m_pageID);
870     }
871 #endif
872
873     updateBackingStoreDiscardableState();
874 }
875
876 IntSize WebPageProxy::viewSize() const
877 {
878     return m_pageClient->viewSize();
879 }
880
881 void WebPageProxy::setInitialFocus(bool forward, bool isKeyboardEventValid, const WebKeyboardEvent& keyboardEvent)
882 {
883     if (!isValid())
884         return;
885     process()->send(Messages::WebPage::SetInitialFocus(forward, isKeyboardEventValid, keyboardEvent), m_pageID);
886 }
887
888 void WebPageProxy::setWindowResizerSize(const IntSize& windowResizerSize)
889 {
890     if (!isValid())
891         return;
892     process()->send(Messages::WebPage::SetWindowResizerSize(windowResizerSize), m_pageID);
893 }
894     
895 void WebPageProxy::clearSelection()
896 {
897     if (!isValid())
898         return;
899     process()->send(Messages::WebPage::ClearSelection(), m_pageID);
900 }
901
902 void WebPageProxy::validateCommand(const String& commandName, PassRefPtr<ValidateCommandCallback> callback)
903 {
904     if (!isValid()) {
905         callback->invalidate();
906         return;
907     }
908
909     uint64_t callbackID = callback->callbackID();
910     m_validateCommandCallbacks.set(callbackID, callback.get());
911     process()->send(Messages::WebPage::ValidateCommand(commandName, callbackID), m_pageID);
912 }
913
914 void WebPageProxy::setMaintainsInactiveSelection(bool newValue)
915 {
916     m_maintainsInactiveSelection = newValue;
917 }
918     
919 void WebPageProxy::executeEditCommand(const String& commandName)
920 {
921     if (!isValid())
922         return;
923
924     DEFINE_STATIC_LOCAL(String, ignoreSpellingCommandName, ("ignoreSpelling"));
925     if (commandName == ignoreSpellingCommandName)
926         ++m_pendingLearnOrIgnoreWordMessageCount;
927
928     process()->send(Messages::WebPage::ExecuteEditCommand(commandName), m_pageID);
929 }
930     
931 #if USE(TILED_BACKING_STORE)
932 void WebPageProxy::setViewportSize(const IntSize& size)
933 {
934     if (!isValid())
935         return;
936
937     process()->send(Messages::WebPage::SetViewportSize(size), m_pageID);
938 }
939 #endif
940
941 #if ENABLE(DRAG_SUPPORT)
942 void WebPageProxy::dragEntered(DragData* dragData, const String& dragStorageName)
943 {
944     SandboxExtension::Handle sandboxExtensionHandle;
945     SandboxExtension::HandleArray sandboxExtensionHandleEmptyArray;
946     performDragControllerAction(DragControllerActionEntered, dragData, dragStorageName, sandboxExtensionHandle, sandboxExtensionHandleEmptyArray);
947 }
948
949 void WebPageProxy::dragUpdated(DragData* dragData, const String& dragStorageName)
950 {
951     SandboxExtension::Handle sandboxExtensionHandle;
952     SandboxExtension::HandleArray sandboxExtensionHandleEmptyArray;
953     performDragControllerAction(DragControllerActionUpdated, dragData, dragStorageName, sandboxExtensionHandle, sandboxExtensionHandleEmptyArray);
954 }
955
956 void WebPageProxy::dragExited(DragData* dragData, const String& dragStorageName)
957 {
958     SandboxExtension::Handle sandboxExtensionHandle;
959     SandboxExtension::HandleArray sandboxExtensionHandleEmptyArray;
960     performDragControllerAction(DragControllerActionExited, dragData, dragStorageName, sandboxExtensionHandle, sandboxExtensionHandleEmptyArray);
961 }
962
963 void WebPageProxy::performDrag(DragData* dragData, const String& dragStorageName, const SandboxExtension::Handle& sandboxExtensionHandle, const SandboxExtension::HandleArray& sandboxExtensionsForUpload)
964 {
965     performDragControllerAction(DragControllerActionPerformDrag, dragData, dragStorageName, sandboxExtensionHandle, sandboxExtensionsForUpload);
966 }
967
968 void WebPageProxy::performDragControllerAction(DragControllerAction action, DragData* dragData, const String& dragStorageName, const SandboxExtension::Handle& sandboxExtensionHandle, const SandboxExtension::HandleArray& sandboxExtensionsForUpload)
969 {
970     if (!isValid())
971         return;
972 #if PLATFORM(WIN)
973     // FIXME: We should pass the drag data map only on DragEnter.
974     process()->send(Messages::WebPage::PerformDragControllerAction(action, dragData->clientPosition(), dragData->globalPosition(),
975         dragData->draggingSourceOperationMask(), dragData->dragDataMap(), dragData->flags()), m_pageID);
976 #elif PLATFORM(QT) || PLATFORM(GTK)
977     process()->send(Messages::WebPage::PerformDragControllerAction(action, *dragData), m_pageID);
978 #else
979     process()->send(Messages::WebPage::PerformDragControllerAction(action, dragData->clientPosition(), dragData->globalPosition(), dragData->draggingSourceOperationMask(), dragStorageName, dragData->flags(), sandboxExtensionHandle, sandboxExtensionsForUpload), m_pageID);
980 #endif
981 }
982
983 void WebPageProxy::didPerformDragControllerAction(WebCore::DragSession dragSession)
984 {
985     m_currentDragSession = dragSession;
986 }
987
988 #if PLATFORM(QT) || PLATFORM(GTK)
989 void WebPageProxy::startDrag(const DragData& dragData, const ShareableBitmap::Handle& dragImageHandle)
990 {
991     RefPtr<ShareableBitmap> dragImage = 0;
992     if (!dragImageHandle.isNull()) {
993         dragImage = ShareableBitmap::create(dragImageHandle);
994     if (!dragImage)
995         return;
996     }
997
998     m_pageClient->startDrag(dragData, dragImage.release());
999 }
1000 #endif
1001
1002 void WebPageProxy::dragEnded(const IntPoint& clientPosition, const IntPoint& globalPosition, uint64_t operation)
1003 {
1004     if (!isValid())
1005         return;
1006     process()->send(Messages::WebPage::DragEnded(clientPosition, globalPosition, operation), m_pageID);
1007 }
1008 #endif // ENABLE(DRAG_SUPPORT)
1009
1010 void WebPageProxy::handleMouseEvent(const NativeWebMouseEvent& event)
1011 {
1012     if (!isValid())
1013         return;
1014
1015     // NOTE: This does not start the responsiveness timer because mouse move should not indicate interaction.
1016     if (event.type() != WebEvent::MouseMove)
1017         process()->responsivenessTimer()->start();
1018     else {
1019         if (m_processingMouseMoveEvent) {
1020             m_nextMouseMoveEvent = adoptPtr(new NativeWebMouseEvent(event));
1021             return;
1022         }
1023
1024         m_processingMouseMoveEvent = true;
1025     }
1026
1027     // <https://bugs.webkit.org/show_bug.cgi?id=57904> We need to keep track of the mouse down event in the case where we
1028     // display a popup menu for select elements. When the user changes the selected item,
1029     // we fake a mouse up event by using this stored down event. This event gets cleared
1030     // when the mouse up message is received from WebProcess.
1031     if (event.type() == WebEvent::MouseDown)
1032         m_currentlyProcessedMouseDownEvent = adoptPtr(new NativeWebMouseEvent(event));
1033
1034 #if ENABLE(TIZEN_CONTEXT_MENU_WEBKIT_2)
1035     // We have to hide text-selection's context menu when other area is clicked.
1036     // In case of normal context menu, it is hided by elm_ctxpopup's logic.
1037     if (event.type() == WebEvent::MouseDown)
1038         hideContextMenu();
1039 #endif
1040
1041 #if ENABLE(TIZEN_ISF_PORT)
1042     if (event.type() == WebEvent::MouseDown)
1043         m_pageClient->handleInputMethodMousePress();
1044 #endif
1045
1046     if (m_shouldSendEventsSynchronously) {
1047         bool handled = false;
1048         process()->sendSync(Messages::WebPage::MouseEventSyncForTesting(event), Messages::WebPage::MouseEventSyncForTesting::Reply(handled), m_pageID);
1049         didReceiveEvent(event.type(), handled);
1050     } else
1051         process()->send(Messages::WebPage::MouseEvent(event), m_pageID);
1052 }
1053
1054 #if MERGE_WHEEL_EVENTS
1055 static bool canCoalesce(const WebWheelEvent& a, const WebWheelEvent& b)
1056 {
1057     if (a.position() != b.position())
1058         return false;
1059     if (a.globalPosition() != b.globalPosition())
1060         return false;
1061     if (a.modifiers() != b.modifiers())
1062         return false;
1063     if (a.granularity() != b.granularity())
1064         return false;
1065 #if PLATFORM(MAC)
1066     if (a.phase() != b.phase())
1067         return false;
1068     if (a.momentumPhase() != b.momentumPhase())
1069         return false;
1070     if (a.hasPreciseScrollingDeltas() != b.hasPreciseScrollingDeltas())
1071         return false;
1072 #endif
1073
1074     return true;
1075 }
1076
1077 static WebWheelEvent coalesce(const WebWheelEvent& a, const WebWheelEvent& b)
1078 {
1079     ASSERT(canCoalesce(a, b));
1080
1081     FloatSize mergedDelta = a.delta() + b.delta();
1082     FloatSize mergedWheelTicks = a.wheelTicks() + b.wheelTicks();
1083
1084 #if PLATFORM(MAC)
1085     FloatSize mergedUnacceleratedScrollingDelta = a.unacceleratedScrollingDelta() + b.unacceleratedScrollingDelta();
1086
1087     return WebWheelEvent(WebEvent::Wheel, b.position(), b.globalPosition(), mergedDelta, mergedWheelTicks, b.granularity(), b.directionInvertedFromDevice(), b.phase(), b.momentumPhase(), b.hasPreciseScrollingDeltas(), b.scrollCount(), mergedUnacceleratedScrollingDelta, b.modifiers(), b.timestamp());
1088 #else
1089     return WebWheelEvent(WebEvent::Wheel, b.position(), b.globalPosition(), mergedDelta, mergedWheelTicks, b.granularity(), b.modifiers(), b.timestamp());
1090 #endif
1091 }
1092 #endif // MERGE_WHEEL_EVENTS
1093
1094 static WebWheelEvent coalescedWheelEvent(Deque<NativeWebWheelEvent>& queue, Vector<NativeWebWheelEvent>& coalescedEvents)
1095 {
1096     ASSERT(!queue.isEmpty());
1097     ASSERT(coalescedEvents.isEmpty());
1098
1099 #if MERGE_WHEEL_EVENTS
1100     NativeWebWheelEvent firstEvent = queue.takeFirst();
1101     coalescedEvents.append(firstEvent);
1102
1103     WebWheelEvent event = firstEvent;
1104     while (!queue.isEmpty() && canCoalesce(event, queue.first())) {
1105         NativeWebWheelEvent firstEvent = queue.takeFirst();
1106         coalescedEvents.append(firstEvent);
1107         event = coalesce(event, firstEvent);
1108     }
1109
1110     return event;
1111 #else
1112     while (!queue.isEmpty())
1113         coalescedEvents.append(queue.takeFirst());
1114     return coalescedEvents.last();
1115 #endif
1116 }
1117
1118 void WebPageProxy::handleWheelEvent(const NativeWebWheelEvent& event)
1119 {
1120     if (!isValid())
1121         return;
1122
1123     if (!m_currentlyProcessedWheelEvents.isEmpty()) {
1124         m_wheelEventQueue.append(event);
1125         if (m_wheelEventQueue.size() < wheelEventQueueSizeThreshold)
1126             return;
1127         // The queue has too many wheel events, so push a new event.
1128     }
1129
1130     if (!m_wheelEventQueue.isEmpty()) {
1131         processNextQueuedWheelEvent();
1132         return;
1133     }
1134
1135     OwnPtr<Vector<NativeWebWheelEvent> > coalescedWheelEvent = adoptPtr(new Vector<NativeWebWheelEvent>);
1136     coalescedWheelEvent->append(event);
1137     m_currentlyProcessedWheelEvents.append(coalescedWheelEvent.release());
1138     sendWheelEvent(event);
1139 }
1140
1141 void WebPageProxy::processNextQueuedWheelEvent()
1142 {
1143     OwnPtr<Vector<NativeWebWheelEvent> > nextCoalescedEvent = adoptPtr(new Vector<NativeWebWheelEvent>);
1144     WebWheelEvent nextWheelEvent = coalescedWheelEvent(m_wheelEventQueue, *nextCoalescedEvent.get());
1145     m_currentlyProcessedWheelEvents.append(nextCoalescedEvent.release());
1146     sendWheelEvent(nextWheelEvent);
1147 }
1148
1149 void WebPageProxy::sendWheelEvent(const WebWheelEvent& event)
1150 {
1151     process()->responsivenessTimer()->start();
1152
1153     if (m_shouldSendEventsSynchronously) {
1154         bool handled = false;
1155         process()->sendSync(Messages::WebPage::WheelEventSyncForTesting(event), Messages::WebPage::WheelEventSyncForTesting::Reply(handled), m_pageID);
1156         didReceiveEvent(event.type(), handled);
1157         return;
1158     }
1159
1160     process()->send(Messages::EventDispatcher::WheelEvent(m_pageID, event, canGoBack(), canGoForward()), 0);
1161 }
1162
1163 void WebPageProxy::handleKeyboardEvent(const NativeWebKeyboardEvent& event)
1164 {
1165     if (!isValid())
1166         return;
1167     
1168     LOG(KeyHandling, "WebPageProxy::handleKeyboardEvent: %s", webKeyboardEventTypeString(event.type()));
1169
1170     m_keyEventQueue.append(event);
1171
1172     process()->responsivenessTimer()->start();
1173     if (m_shouldSendEventsSynchronously) {
1174         bool handled = false;
1175         process()->sendSync(Messages::WebPage::KeyEventSyncForTesting(event), Messages::WebPage::KeyEventSyncForTesting::Reply(handled), m_pageID);
1176         didReceiveEvent(event.type(), handled);
1177     } else
1178         process()->send(Messages::WebPage::KeyEvent(event), m_pageID);
1179 }
1180
1181 #if ENABLE(GESTURE_EVENTS)
1182 void WebPageProxy::handleGestureEvent(const WebGestureEvent& event)
1183 {
1184     if (!isValid())
1185         return;
1186
1187     m_gestureEventQueue.append(event);
1188
1189     process()->responsivenessTimer()->start();
1190     process()->send(Messages::EventDispatcher::GestureEvent(m_pageID, event), 0);
1191 }
1192 #endif
1193
1194 #if ENABLE(TOUCH_EVENTS)
1195 #if PLATFORM(QT)
1196 void WebPageProxy::handlePotentialActivation(const IntPoint& touchPoint, const IntSize& touchArea)
1197 {
1198     process()->send(Messages::WebPage::HighlightPotentialActivation(touchPoint, touchArea), m_pageID);
1199 }
1200 #endif
1201
1202 void WebPageProxy::handleTouchEvent(const NativeWebTouchEvent& event)
1203 {
1204     if (!isValid())
1205         return;
1206
1207     // If the page is suspended, which should be the case during panning, pinching
1208     // and animation on the page itself (kinetic scrolling, tap to zoom) etc, then
1209     // we do not send any of the events to the page even if is has listeners.
1210     if (m_needTouchEvents && !m_isPageSuspended) {
1211 #if OS(TIZEN)
1212         // Do not send the TouchMove event if last TouchMove is not processed yet.
1213         // TouchMove event will be sent too many times without below codes,
1214         // and it will affect Web Applications' performance.
1215         if (event.type() == WebEvent::TouchMove
1216             && !m_touchEventQueue.isEmpty()
1217             && m_touchEventQueue.last().forwardedEvent.type() == event.type())
1218             return;
1219 #endif
1220         m_touchEventQueue.append(event);
1221         process()->responsivenessTimer()->start();
1222         if (m_shouldSendEventsSynchronously) {
1223             bool handled = false;
1224             process()->sendSync(Messages::WebPage::TouchEventSyncForTesting(event), Messages::WebPage::TouchEventSyncForTesting::Reply(handled), m_pageID);
1225             didReceiveEvent(event.type(), handled);
1226         } else
1227             process()->send(Messages::WebPage::TouchEvent(event), m_pageID);
1228     } else {
1229         if (m_touchEventQueue.isEmpty()) {
1230             bool isEventHandled = false;
1231             m_pageClient->doneWithTouchEvent(event, isEventHandled);
1232         } else {
1233             // We attach the incoming events to the newest queued event so that all
1234             // the events are delivered in the correct order when the event is dequed.
1235             QueuedTouchEvents& lastEvent = m_touchEventQueue.last();
1236             lastEvent.deferredTouchEvents.append(event);
1237         }
1238     }
1239 }
1240 #endif
1241
1242 #if ENABLE(TIZEN_VIBRATION)
1243 void WebPageProxy::vibrate(uint64_t time)
1244 {
1245     m_pageClient->vibrate(time);
1246 }
1247
1248 void WebPageProxy::cancelVibration()
1249 {
1250     m_pageClient->cancelVibration();
1251 }
1252 #endif
1253
1254 #if ENABLE(SCREEN_ORIENTATION_SUPPORT) && ENABLE(TIZEN_SCREEN_ORIENTATION_SUPPORT)
1255 void WebPageProxy::lockOrientation(int willLockOrientation, bool& result)
1256 {
1257     result = m_pageClient->lockOrientation(willLockOrientation);
1258 }
1259 void WebPageProxy::unlockOrientation()
1260 {
1261     m_pageClient->unlockOrientation();
1262 }
1263 #endif
1264
1265 void WebPageProxy::scrollBy(ScrollDirection direction, ScrollGranularity granularity)
1266 {
1267     if (!isValid())
1268         return;
1269
1270     process()->send(Messages::WebPage::ScrollBy(direction, granularity), m_pageID);
1271 }
1272
1273 void WebPageProxy::centerSelectionInVisibleArea()
1274 {
1275     if (!isValid())
1276         return;
1277
1278     process()->send(Messages::WebPage::CenterSelectionInVisibleArea(), m_pageID);
1279 }
1280
1281 void WebPageProxy::receivedPolicyDecision(PolicyAction action, WebFrameProxy* frame, uint64_t listenerID)
1282 {
1283     if (!isValid())
1284         return;
1285
1286     if (action == PolicyIgnore)
1287         clearPendingAPIRequestURL();
1288
1289     uint64_t downloadID = 0;
1290     if (action == PolicyDownload) {
1291         // Create a download proxy.
1292         DownloadProxy* download = m_process->context()->createDownloadProxy();
1293         downloadID = download->downloadID();
1294 #if PLATFORM(QT)
1295         // Our design does not suppport downloads without a WebPage.
1296         handleDownloadRequest(download);
1297 #endif
1298     }
1299
1300     // If we received a policy decision while in decidePolicyForResponse the decision will
1301     // be sent back to the web process by decidePolicyForResponse.
1302     if (m_inDecidePolicyForResponse) {
1303         m_syncMimeTypePolicyActionIsValid = true;
1304         m_syncMimeTypePolicyAction = action;
1305         m_syncMimeTypePolicyDownloadID = downloadID;
1306         return;
1307     }
1308
1309     // If we received a policy decision while in decidePolicyForNavigationAction the decision will 
1310     // be sent back to the web process by decidePolicyForNavigationAction. 
1311     if (m_inDecidePolicyForNavigationAction) {
1312         m_syncNavigationActionPolicyActionIsValid = true;
1313         m_syncNavigationActionPolicyAction = action;
1314         m_syncNavigationActionPolicyDownloadID = downloadID;
1315         return;
1316     }
1317     
1318     process()->send(Messages::WebPage::DidReceivePolicyDecision(frame->frameID(), listenerID, action, downloadID), m_pageID);
1319 }
1320
1321 String WebPageProxy::pageTitle() const
1322 {
1323     // Return the null string if there is no main frame (e.g. nothing has been loaded in the page yet, WebProcess has
1324     // crashed, page has been closed).
1325     if (!m_mainFrame)
1326         return String();
1327
1328     return m_mainFrame->title();
1329 }
1330
1331 void WebPageProxy::setUserAgent(const String& userAgent)
1332 {
1333     if (m_userAgent == userAgent)
1334         return;
1335     m_userAgent = userAgent;
1336
1337     if (!isValid())
1338         return;
1339     process()->send(Messages::WebPage::SetUserAgent(m_userAgent), m_pageID);
1340 }
1341
1342 void WebPageProxy::setApplicationNameForUserAgent(const String& applicationName)
1343 {
1344     if (m_applicationNameForUserAgent == applicationName)
1345         return;
1346
1347     m_applicationNameForUserAgent = applicationName;
1348     if (!m_customUserAgent.isEmpty())
1349         return;
1350
1351     setUserAgent(standardUserAgent(m_applicationNameForUserAgent));
1352 }
1353
1354 void WebPageProxy::setCustomUserAgent(const String& customUserAgent)
1355 {
1356     if (m_customUserAgent == customUserAgent)
1357         return;
1358
1359     m_customUserAgent = customUserAgent;
1360
1361     if (m_customUserAgent.isEmpty()) {
1362         setUserAgent(standardUserAgent(m_applicationNameForUserAgent));
1363         return;
1364     }
1365
1366     setUserAgent(m_customUserAgent);
1367 }
1368
1369 void WebPageProxy::resumeActiveDOMObjectsAndAnimations()
1370 {
1371     if (!isValid() || !m_isPageSuspended)
1372         return;
1373
1374     m_isPageSuspended = false;
1375
1376     process()->send(Messages::WebPage::ResumeActiveDOMObjectsAndAnimations(), m_pageID);
1377 }
1378
1379 void WebPageProxy::suspendActiveDOMObjectsAndAnimations()
1380 {
1381     if (!isValid() || m_isPageSuspended)
1382         return;
1383
1384     m_isPageSuspended = true;
1385
1386     process()->send(Messages::WebPage::SuspendActiveDOMObjectsAndAnimations(), m_pageID);
1387 }
1388
1389 bool WebPageProxy::supportsTextEncoding() const
1390 {
1391     return !m_mainFrameHasCustomRepresentation && m_mainFrame && !m_mainFrame->isDisplayingStandaloneImageDocument();
1392 }
1393
1394 void WebPageProxy::setCustomTextEncodingName(const String& encodingName)
1395 {
1396     if (m_customTextEncodingName == encodingName)
1397         return;
1398     m_customTextEncodingName = encodingName;
1399
1400     if (!isValid())
1401         return;
1402     process()->send(Messages::WebPage::SetCustomTextEncodingName(encodingName), m_pageID);
1403 }
1404
1405 void WebPageProxy::terminateProcess()
1406 {
1407     // NOTE: This uses a check of m_isValid rather than calling isValid() since
1408     // we want this to run even for pages being closed or that already closed.
1409     if (!m_isValid)
1410         return;
1411
1412     process()->terminate();
1413 }
1414
1415 #if !USE(CF) || defined(BUILDING_QT__)
1416 PassRefPtr<WebData> WebPageProxy::sessionStateData(WebPageProxySessionStateFilterCallback, void* context) const
1417 {
1418     // FIXME: Return session state data for saving Page state.
1419     return 0;
1420 }
1421
1422 void WebPageProxy::restoreFromSessionStateData(WebData*)
1423 {
1424     // FIXME: Restore the Page from the passed in session state data.
1425 }
1426 #endif
1427
1428 bool WebPageProxy::supportsTextZoom() const
1429 {
1430     if (m_mainFrameHasCustomRepresentation)
1431         return false;
1432
1433     // FIXME: This should also return false for standalone media and plug-in documents.
1434     if (!m_mainFrame || m_mainFrame->isDisplayingStandaloneImageDocument())
1435         return false;
1436
1437     return true;
1438 }
1439  
1440 void WebPageProxy::setTextZoomFactor(double zoomFactor)
1441 {
1442     if (!isValid())
1443         return;
1444
1445     if (m_mainFrameHasCustomRepresentation)
1446         return;
1447
1448     if (m_textZoomFactor == zoomFactor)
1449         return;
1450
1451     m_textZoomFactor = zoomFactor;
1452     process()->send(Messages::WebPage::SetTextZoomFactor(m_textZoomFactor), m_pageID); 
1453 }
1454
1455 double WebPageProxy::pageZoomFactor() const
1456 {
1457     return m_mainFrameHasCustomRepresentation ? m_pageClient->customRepresentationZoomFactor() : m_pageZoomFactor;
1458 }
1459
1460 void WebPageProxy::setPageZoomFactor(double zoomFactor)
1461 {
1462     if (!isValid())
1463         return;
1464
1465     if (m_mainFrameHasCustomRepresentation) {
1466         m_pageClient->setCustomRepresentationZoomFactor(zoomFactor);
1467         return;
1468     }
1469
1470     if (m_pageZoomFactor == zoomFactor)
1471         return;
1472
1473     m_pageZoomFactor = zoomFactor;
1474     process()->send(Messages::WebPage::SetPageZoomFactor(m_pageZoomFactor), m_pageID); 
1475 }
1476
1477 void WebPageProxy::setPageAndTextZoomFactors(double pageZoomFactor, double textZoomFactor)
1478 {
1479     if (!isValid())
1480         return;
1481
1482     if (m_mainFrameHasCustomRepresentation) {
1483         m_pageClient->setCustomRepresentationZoomFactor(pageZoomFactor);
1484         return;
1485     }
1486
1487     if (m_pageZoomFactor == pageZoomFactor && m_textZoomFactor == textZoomFactor)
1488         return;
1489
1490     m_pageZoomFactor = pageZoomFactor;
1491     m_textZoomFactor = textZoomFactor;
1492     process()->send(Messages::WebPage::SetPageAndTextZoomFactors(m_pageZoomFactor, m_textZoomFactor), m_pageID); 
1493 }
1494
1495 void WebPageProxy::scalePage(double scale, const IntPoint& origin)
1496 {
1497     if (!isValid())
1498         return;
1499
1500     process()->send(Messages::WebPage::ScalePage(scale, origin), m_pageID);
1501 #if OS(TIZEN)
1502     m_pageClient->setRequestedScaleFactor(scale);
1503 #endif
1504 }
1505
1506 void WebPageProxy::setIntrinsicDeviceScaleFactor(float scaleFactor)
1507 {
1508     if (m_intrinsicDeviceScaleFactor == scaleFactor)
1509         return;
1510
1511     m_intrinsicDeviceScaleFactor = scaleFactor;
1512
1513     if (m_drawingArea)
1514         m_drawingArea->deviceScaleFactorDidChange();
1515 }
1516
1517 void WebPageProxy::windowScreenDidChange(PlatformDisplayID displayID)
1518 {
1519     if (!isValid())
1520         return;
1521
1522     process()->send(Messages::WebPage::WindowScreenDidChange(displayID), m_pageID);
1523 }
1524
1525 float WebPageProxy::deviceScaleFactor() const
1526 {
1527     if (m_customDeviceScaleFactor)
1528         return m_customDeviceScaleFactor;
1529     return m_intrinsicDeviceScaleFactor;
1530 }
1531
1532 void WebPageProxy::setCustomDeviceScaleFactor(float customScaleFactor)
1533 {
1534     if (!isValid())
1535         return;
1536
1537     if (m_customDeviceScaleFactor == customScaleFactor)
1538         return;
1539
1540     float oldScaleFactor = deviceScaleFactor();
1541
1542     m_customDeviceScaleFactor = customScaleFactor;
1543
1544     if (deviceScaleFactor() != oldScaleFactor)
1545         m_drawingArea->deviceScaleFactorDidChange();
1546 }
1547
1548 void WebPageProxy::setUseFixedLayout(bool fixed)
1549 {
1550     if (!isValid())
1551         return;
1552
1553     // This check is fine as the value is initialized in the web
1554     // process as part of the creation parameters.
1555     if (fixed == m_useFixedLayout)
1556         return;
1557
1558     m_useFixedLayout = fixed;
1559     if (!fixed)
1560         m_fixedLayoutSize = IntSize();
1561     process()->send(Messages::WebPage::SetUseFixedLayout(fixed), m_pageID);
1562 }
1563
1564 void WebPageProxy::setFixedLayoutSize(const IntSize& size)
1565 {
1566     if (!isValid())
1567         return;
1568
1569     if (size == m_fixedLayoutSize)
1570         return;
1571
1572     m_fixedLayoutSize = size;
1573     process()->send(Messages::WebPage::SetFixedLayoutSize(size), m_pageID);
1574 }
1575
1576 void WebPageProxy::setPaginationMode(WebCore::Page::Pagination::Mode mode)
1577 {
1578     if (mode == m_paginationMode)
1579         return;
1580
1581     m_paginationMode = mode;
1582
1583     if (!isValid())
1584         return;
1585     process()->send(Messages::WebPage::SetPaginationMode(mode), m_pageID);
1586 }
1587
1588 void WebPageProxy::setPaginationBehavesLikeColumns(bool behavesLikeColumns)
1589 {
1590     if (behavesLikeColumns == m_paginationBehavesLikeColumns)
1591         return;
1592
1593     m_paginationBehavesLikeColumns = behavesLikeColumns;
1594
1595     if (!isValid())
1596         return;
1597     process()->send(Messages::WebPage::SetPaginationBehavesLikeColumns(behavesLikeColumns), m_pageID);
1598 }
1599
1600 void WebPageProxy::setPageLength(double pageLength)
1601 {
1602     if (pageLength == m_pageLength)
1603         return;
1604
1605     m_pageLength = pageLength;
1606
1607     if (!isValid())
1608         return;
1609     process()->send(Messages::WebPage::SetPageLength(pageLength), m_pageID);
1610 }
1611
1612 void WebPageProxy::setGapBetweenPages(double gap)
1613 {
1614     if (gap == m_gapBetweenPages)
1615         return;
1616
1617     m_gapBetweenPages = gap;
1618
1619     if (!isValid())
1620         return;
1621     process()->send(Messages::WebPage::SetGapBetweenPages(gap), m_pageID);
1622 }
1623
1624 void WebPageProxy::pageScaleFactorDidChange(double scaleFactor)
1625 {
1626     m_pageScaleFactor = scaleFactor;
1627     m_pageClient->pageScaleFactorDidChange();
1628 }
1629
1630 void WebPageProxy::setMemoryCacheClientCallsEnabled(bool memoryCacheClientCallsEnabled)
1631 {
1632     if (!isValid())
1633         return;
1634
1635     if (m_areMemoryCacheClientCallsEnabled == memoryCacheClientCallsEnabled)
1636         return;
1637
1638     m_areMemoryCacheClientCallsEnabled = memoryCacheClientCallsEnabled;
1639     process()->send(Messages::WebPage::SetMemoryCacheMessagesEnabled(memoryCacheClientCallsEnabled), m_pageID);
1640 }
1641
1642 void WebPageProxy::findString(const String& string, FindOptions options, unsigned maxMatchCount)
1643 {
1644     if (m_mainFrameHasCustomRepresentation)
1645         m_pageClient->findStringInCustomRepresentation(string, options, maxMatchCount);
1646     else
1647         process()->send(Messages::WebPage::FindString(string, options, maxMatchCount), m_pageID);
1648 }
1649
1650 void WebPageProxy::hideFindUI()
1651 {
1652     process()->send(Messages::WebPage::HideFindUI(), m_pageID);
1653 }
1654
1655 void WebPageProxy::countStringMatches(const String& string, FindOptions options, unsigned maxMatchCount)
1656 {
1657     if (m_mainFrameHasCustomRepresentation) {
1658         m_pageClient->countStringMatchesInCustomRepresentation(string, options, maxMatchCount);
1659         return;
1660     }
1661
1662     if (!isValid())
1663         return;
1664
1665     process()->send(Messages::WebPage::CountStringMatches(string, options, maxMatchCount), m_pageID);
1666 }
1667
1668 void WebPageProxy::runJavaScriptInMainFrame(const String& script, PassRefPtr<ScriptValueCallback> prpCallback)
1669 {
1670     RefPtr<ScriptValueCallback> callback = prpCallback;
1671     if (!isValid()) {
1672         callback->invalidate();
1673         return;
1674     }
1675
1676     uint64_t callbackID = callback->callbackID();
1677     m_scriptValueCallbacks.set(callbackID, callback.get());
1678     process()->send(Messages::WebPage::RunJavaScriptInMainFrame(script, callbackID), m_pageID);
1679 }
1680
1681 void WebPageProxy::getRenderTreeExternalRepresentation(PassRefPtr<StringCallback> prpCallback)
1682 {
1683     RefPtr<StringCallback> callback = prpCallback;
1684     if (!isValid()) {
1685         callback->invalidate();
1686         return;
1687     }
1688     
1689     uint64_t callbackID = callback->callbackID();
1690     m_stringCallbacks.set(callbackID, callback.get());
1691     process()->send(Messages::WebPage::GetRenderTreeExternalRepresentation(callbackID), m_pageID);
1692 }
1693
1694 void WebPageProxy::getSourceForFrame(WebFrameProxy* frame, PassRefPtr<StringCallback> prpCallback)
1695 {
1696     RefPtr<StringCallback> callback = prpCallback;
1697     if (!isValid()) {
1698         callback->invalidate();
1699         return;
1700     }
1701     
1702     uint64_t callbackID = callback->callbackID();
1703     m_loadDependentStringCallbackIDs.add(callbackID);
1704     m_stringCallbacks.set(callbackID, callback.get());
1705     process()->send(Messages::WebPage::GetSourceForFrame(frame->frameID(), callbackID), m_pageID);
1706 }
1707
1708 void WebPageProxy::getContentsAsString(PassRefPtr<StringCallback> prpCallback)
1709 {
1710     RefPtr<StringCallback> callback = prpCallback;
1711     if (!isValid()) {
1712         callback->invalidate();
1713         return;
1714     }
1715     
1716     uint64_t callbackID = callback->callbackID();
1717     m_loadDependentStringCallbackIDs.add(callbackID);
1718     m_stringCallbacks.set(callbackID, callback.get());
1719     process()->send(Messages::WebPage::GetContentsAsString(callbackID), m_pageID);
1720 }
1721
1722 void WebPageProxy::getSelectionOrContentsAsString(PassRefPtr<StringCallback> prpCallback)
1723 {
1724     RefPtr<StringCallback> callback = prpCallback;
1725     if (!isValid()) {
1726         callback->invalidate();
1727         return;
1728     }
1729     
1730     uint64_t callbackID = callback->callbackID();
1731     m_stringCallbacks.set(callbackID, callback.get());
1732     process()->send(Messages::WebPage::GetSelectionOrContentsAsString(callbackID), m_pageID);
1733 }
1734
1735 void WebPageProxy::getMainResourceDataOfFrame(WebFrameProxy* frame, PassRefPtr<DataCallback> prpCallback)
1736 {
1737     RefPtr<DataCallback> callback = prpCallback;
1738     if (!isValid()) {
1739         callback->invalidate();
1740         return;
1741     }
1742     
1743     uint64_t callbackID = callback->callbackID();
1744     m_dataCallbacks.set(callbackID, callback.get());
1745     process()->send(Messages::WebPage::GetMainResourceDataOfFrame(frame->frameID(), callbackID), m_pageID);
1746 }
1747
1748 void WebPageProxy::getResourceDataFromFrame(WebFrameProxy* frame, WebURL* resourceURL, PassRefPtr<DataCallback> prpCallback)
1749 {
1750     RefPtr<DataCallback> callback = prpCallback;
1751     if (!isValid()) {
1752         callback->invalidate();
1753         return;
1754     }
1755     
1756     uint64_t callbackID = callback->callbackID();
1757     m_dataCallbacks.set(callbackID, callback.get());
1758     process()->send(Messages::WebPage::GetResourceDataFromFrame(frame->frameID(), resourceURL->string(), callbackID), m_pageID);
1759 }
1760
1761 void WebPageProxy::getWebArchiveOfFrame(WebFrameProxy* frame, PassRefPtr<DataCallback> prpCallback)
1762 {
1763     RefPtr<DataCallback> callback = prpCallback;
1764     if (!isValid()) {
1765         callback->invalidate();
1766         return;
1767     }
1768     
1769     uint64_t callbackID = callback->callbackID();
1770     m_dataCallbacks.set(callbackID, callback.get());
1771     process()->send(Messages::WebPage::GetWebArchiveOfFrame(frame->frameID(), callbackID), m_pageID);
1772 }
1773
1774 void WebPageProxy::forceRepaint(PassRefPtr<VoidCallback> prpCallback)
1775 {
1776     RefPtr<VoidCallback> callback = prpCallback;
1777     if (!isValid()) {
1778         callback->invalidate();
1779         return;
1780     }
1781
1782     uint64_t callbackID = callback->callbackID();
1783     m_voidCallbacks.set(callbackID, callback.get());
1784     m_drawingArea->waitForBackingStoreUpdateOnNextPaint();
1785     process()->send(Messages::WebPage::ForceRepaint(callbackID), m_pageID); 
1786 }
1787
1788 void WebPageProxy::preferencesDidChange()
1789 {
1790     if (!isValid())
1791         return;
1792
1793 #if ENABLE(INSPECTOR_SERVER)
1794     if (m_pageGroup->preferences()->developerExtrasEnabled())
1795         inspector()->enableRemoteInspection();
1796 #endif
1797
1798     // FIXME: It probably makes more sense to send individual preference changes.
1799     // However, WebKitTestRunner depends on getting a preference change notification
1800     // even if nothing changed in UI process, so that overrides get removed.
1801
1802     // Preferences need to be updated during synchronous printing to make "print backgrounds" preference work when toggled from a print dialog checkbox.
1803     process()->send(Messages::WebPage::PreferencesDidChange(pageGroup()->preferences()->store()), m_pageID, m_isPerformingDOMPrintOperation ? CoreIPC::DispatchMessageEvenWhenWaitingForSyncReply : 0);
1804 }
1805
1806 void WebPageProxy::didReceiveMessage(CoreIPC::Connection* connection, CoreIPC::MessageID messageID, CoreIPC::ArgumentDecoder* arguments)
1807 {
1808     if (messageID.is<CoreIPC::MessageClassDrawingAreaProxy>()) {
1809         m_drawingArea->didReceiveDrawingAreaProxyMessage(connection, messageID, arguments);
1810         return;
1811     }
1812
1813 #if USE(UI_SIDE_COMPOSITING)
1814     if (messageID.is<CoreIPC::MessageClassLayerTreeHostProxy>()) {
1815         m_drawingArea->didReceiveLayerTreeHostProxyMessage(connection, messageID, arguments);
1816         return;
1817     }
1818 #endif
1819
1820 #if ENABLE(INSPECTOR)
1821     if (messageID.is<CoreIPC::MessageClassWebInspectorProxy>()) {
1822         if (WebInspectorProxy* inspector = this->inspector())
1823             inspector->didReceiveWebInspectorProxyMessage(connection, messageID, arguments);
1824         return;
1825     }
1826 #endif
1827
1828 #if ENABLE(FULLSCREEN_API)
1829     if (messageID.is<CoreIPC::MessageClassWebFullScreenManagerProxy>()) {
1830         fullScreenManager()->didReceiveMessage(connection, messageID, arguments);
1831         return;
1832     }
1833 #endif
1834
1835     didReceiveWebPageProxyMessage(connection, messageID, arguments);
1836 }
1837
1838 void WebPageProxy::didReceiveSyncMessage(CoreIPC::Connection* connection, CoreIPC::MessageID messageID, CoreIPC::ArgumentDecoder* arguments, OwnPtr<CoreIPC::ArgumentEncoder>& reply)
1839 {
1840 #if ENABLE(INSPECTOR)
1841     if (messageID.is<CoreIPC::MessageClassWebInspectorProxy>()) {
1842         if (WebInspectorProxy* inspector = this->inspector())
1843             inspector->didReceiveSyncWebInspectorProxyMessage(connection, messageID, arguments, reply);
1844         return;
1845     }
1846 #endif
1847
1848 #if ENABLE(FULLSCREEN_API)
1849     if (messageID.is<CoreIPC::MessageClassWebFullScreenManagerProxy>()) {
1850         fullScreenManager()->didReceiveSyncMessage(connection, messageID, arguments, reply);
1851         return;
1852     }
1853 #endif
1854
1855     // FIXME: Do something with reply.
1856     didReceiveSyncWebPageProxyMessage(connection, messageID, arguments, reply);
1857 }
1858
1859 void WebPageProxy::didCreateMainFrame(uint64_t frameID)
1860 {
1861     MESSAGE_CHECK(!m_mainFrame);
1862     MESSAGE_CHECK(process()->canCreateFrame(frameID));
1863
1864     m_mainFrame = WebFrameProxy::create(this, frameID);
1865
1866     // Add the frame to the process wide map.
1867     process()->frameCreated(frameID, m_mainFrame.get());
1868 }
1869
1870 void WebPageProxy::didCreateSubframe(uint64_t frameID, uint64_t parentFrameID)
1871 {
1872     MESSAGE_CHECK(m_mainFrame);
1873
1874     WebFrameProxy* parentFrame = process()->webFrame(parentFrameID);
1875     MESSAGE_CHECK(parentFrame);
1876     MESSAGE_CHECK(parentFrame->isDescendantOf(m_mainFrame.get()));
1877
1878     MESSAGE_CHECK(process()->canCreateFrame(frameID));
1879     
1880     RefPtr<WebFrameProxy> subFrame = WebFrameProxy::create(this, frameID);
1881
1882     // Add the frame to the process wide map.
1883     process()->frameCreated(frameID, subFrame.get());
1884
1885     // Insert the frame into the frame hierarchy.
1886     parentFrame->appendChild(subFrame.get());
1887 }
1888
1889 static bool isDisconnectedFrame(WebFrameProxy* frame)
1890 {
1891     return !frame->page() || !frame->page()->mainFrame() || !frame->isDescendantOf(frame->page()->mainFrame());
1892 }
1893
1894 void WebPageProxy::didSaveFrameToPageCache(uint64_t frameID)
1895 {
1896     MESSAGE_CHECK(m_mainFrame);
1897
1898     WebFrameProxy* subframe = process()->webFrame(frameID);
1899     MESSAGE_CHECK(subframe);
1900
1901     if (isDisconnectedFrame(subframe))
1902         return;
1903
1904     MESSAGE_CHECK(subframe->isDescendantOf(m_mainFrame.get()));
1905
1906     subframe->didRemoveFromHierarchy();
1907 }
1908
1909 void WebPageProxy::didRestoreFrameFromPageCache(uint64_t frameID, uint64_t parentFrameID)
1910 {
1911     MESSAGE_CHECK(m_mainFrame);
1912
1913     WebFrameProxy* subframe = process()->webFrame(frameID);
1914     MESSAGE_CHECK(subframe);
1915     MESSAGE_CHECK(!subframe->parentFrame());
1916     MESSAGE_CHECK(subframe->page() == m_mainFrame->page());
1917
1918     WebFrameProxy* parentFrame = process()->webFrame(parentFrameID);
1919     MESSAGE_CHECK(parentFrame);
1920     MESSAGE_CHECK(parentFrame->isDescendantOf(m_mainFrame.get()));
1921
1922     // Insert the frame into the frame hierarchy.
1923     parentFrame->appendChild(subframe);
1924 }
1925
1926
1927 // Always start progress at initialProgressValue. This helps provide feedback as
1928 // soon as a load starts.
1929
1930 static const double initialProgressValue = 0.1;
1931
1932 double WebPageProxy::estimatedProgress() const
1933 {
1934     if (!pendingAPIRequestURL().isNull())
1935         return initialProgressValue;
1936     return m_estimatedProgress; 
1937 }
1938
1939 void WebPageProxy::didStartProgress()
1940 {
1941     m_estimatedProgress = initialProgressValue;
1942
1943 #if OS(TIZEN)
1944     //FIXME: After ewk_view_loader_client is implemented,
1945     // consider this line to move to loaderClient.
1946     m_pageClient->didStartProgress();
1947 #endif
1948
1949     m_loaderClient.didStartProgress(this);
1950 }
1951
1952 void WebPageProxy::didChangeProgress(double value)
1953 {
1954     m_estimatedProgress = value;
1955
1956     m_loaderClient.didChangeProgress(this);
1957 }
1958
1959 void WebPageProxy::didFinishProgress()
1960 {
1961     m_estimatedProgress = 1.0;
1962
1963 #if OS(TIZEN)
1964     //FIXME: consider to move this to loaderClient.
1965     m_pageClient->didFinishProgress();
1966 #endif
1967
1968     m_loaderClient.didFinishProgress(this);
1969 }
1970
1971 void WebPageProxy::didStartProvisionalLoadForFrame(uint64_t frameID, const String& url, const String& unreachableURL, CoreIPC::ArgumentDecoder* arguments)
1972 {
1973     clearPendingAPIRequestURL();
1974
1975     RefPtr<APIObject> userData;
1976     WebContextUserMessageDecoder messageDecoder(userData, m_process->context());
1977     if (!arguments->decode(messageDecoder))
1978         return;
1979
1980     WebFrameProxy* frame = process()->webFrame(frameID);
1981     MESSAGE_CHECK(frame);
1982     MESSAGE_CHECK_URL(url);
1983
1984     frame->setUnreachableURL(unreachableURL);
1985
1986     frame->didStartProvisionalLoad(url);
1987     m_loaderClient.didStartProvisionalLoadForFrame(this, frame, userData.get());
1988 }
1989
1990 void WebPageProxy::didReceiveServerRedirectForProvisionalLoadForFrame(uint64_t frameID, const String& url, CoreIPC::ArgumentDecoder* arguments)
1991 {
1992     RefPtr<APIObject> userData;
1993     WebContextUserMessageDecoder messageDecoder(userData, m_process->context());
1994     if (!arguments->decode(messageDecoder))
1995         return;
1996
1997     WebFrameProxy* frame = process()->webFrame(frameID);
1998     MESSAGE_CHECK(frame);
1999     MESSAGE_CHECK_URL(url);
2000
2001     frame->didReceiveServerRedirectForProvisionalLoad(url);
2002
2003     m_loaderClient.didReceiveServerRedirectForProvisionalLoadForFrame(this, frame, userData.get());
2004 }
2005
2006 void WebPageProxy::didFailProvisionalLoadForFrame(uint64_t frameID, const ResourceError& error, CoreIPC::ArgumentDecoder* arguments)
2007 {
2008     RefPtr<APIObject> userData;
2009     WebContextUserMessageDecoder messageDecoder(userData, m_process->context());
2010     if (!arguments->decode(messageDecoder))
2011         return;
2012
2013     WebFrameProxy* frame = process()->webFrame(frameID);
2014     MESSAGE_CHECK(frame);
2015
2016     frame->didFailProvisionalLoad();
2017
2018     m_loaderClient.didFailProvisionalLoadWithErrorForFrame(this, frame, error, userData.get());
2019 }
2020
2021 void WebPageProxy::clearLoadDependentCallbacks()
2022 {
2023     Vector<uint64_t> callbackIDsCopy;
2024     copyToVector(m_loadDependentStringCallbackIDs, callbackIDsCopy);
2025     m_loadDependentStringCallbackIDs.clear();
2026
2027     for (size_t i = 0; i < callbackIDsCopy.size(); ++i) {
2028         RefPtr<StringCallback> callback = m_stringCallbacks.take(callbackIDsCopy[i]);
2029         if (callback)
2030             callback->invalidate();
2031     }
2032 }
2033
2034 void WebPageProxy::didCommitLoadForFrame(uint64_t frameID, const String& mimeType, bool frameHasCustomRepresentation, const PlatformCertificateInfo& certificateInfo, CoreIPC::ArgumentDecoder* arguments)
2035 {
2036     RefPtr<APIObject> userData;
2037     WebContextUserMessageDecoder messageDecoder(userData, m_process->context());
2038     if (!arguments->decode(messageDecoder))
2039         return;
2040
2041     WebFrameProxy* frame = process()->webFrame(frameID);
2042     MESSAGE_CHECK(frame);
2043
2044 #if PLATFORM(MAC)
2045     // FIXME (bug 59111): didCommitLoadForFrame comes too late when restoring a page from b/f cache, making us disable secure event mode in password fields.
2046     // FIXME (bug 59121): A load going on in one frame shouldn't affect typing in sibling frames.
2047     m_pageClient->resetTextInputState();
2048 #if !defined(BUILDING_ON_SNOW_LEOPARD)
2049     // FIXME: Should this be moved inside resetTextInputState()?
2050     dismissCorrectionPanel(ReasonForDismissingAlternativeTextIgnored);
2051     m_pageClient->dismissDictionaryLookupPanel();
2052 #endif
2053 #endif
2054
2055     clearLoadDependentCallbacks();
2056
2057     frame->didCommitLoad(mimeType, certificateInfo);
2058
2059     if (frame->isMainFrame()) {
2060         m_mainFrameHasCustomRepresentation = frameHasCustomRepresentation;
2061
2062         if (m_mainFrameHasCustomRepresentation) {
2063             // Always assume that the main frame is pinned here, since the custom representation view will handle
2064             // any wheel events and dispatch them to the WKView when necessary.
2065             m_mainFrameIsPinnedToLeftSide = true;
2066             m_mainFrameIsPinnedToRightSide = true;
2067         }
2068         m_pageClient->didCommitLoadForMainFrame(frameHasCustomRepresentation);
2069     }
2070
2071     m_loaderClient.didCommitLoadForFrame(this, frame, userData.get());
2072 }
2073
2074 void WebPageProxy::didFinishDocumentLoadForFrame(uint64_t frameID, CoreIPC::ArgumentDecoder* arguments)
2075 {
2076     RefPtr<APIObject> userData;
2077     WebContextUserMessageDecoder messageDecoder(userData, m_process->context());
2078     if (!arguments->decode(messageDecoder))
2079         return;
2080
2081     WebFrameProxy* frame = process()->webFrame(frameID);
2082     MESSAGE_CHECK(frame);
2083
2084     m_loaderClient.didFinishDocumentLoadForFrame(this, frame, userData.get());
2085 }
2086
2087 void WebPageProxy::didFinishLoadForFrame(uint64_t frameID, CoreIPC::ArgumentDecoder* arguments)
2088 {
2089     RefPtr<APIObject> userData;
2090     WebContextUserMessageDecoder messageDecoder(userData, m_process->context());
2091     if (!arguments->decode(messageDecoder))
2092         return;
2093
2094     WebFrameProxy* frame = process()->webFrame(frameID);
2095     MESSAGE_CHECK(frame);
2096
2097     frame->didFinishLoad();
2098
2099 #if OS(TIZEN)
2100     if (frame->isMainFrame())
2101         m_pageClient->didFinishLoadForMainFrame();
2102 #endif
2103
2104     m_loaderClient.didFinishLoadForFrame(this, frame, userData.get());
2105 }
2106
2107 void WebPageProxy::didFailLoadForFrame(uint64_t frameID, const ResourceError& error, CoreIPC::ArgumentDecoder* arguments)
2108 {
2109     RefPtr<APIObject> userData;
2110     WebContextUserMessageDecoder messageDecoder(userData, m_process->context());
2111     if (!arguments->decode(messageDecoder))
2112         return;
2113
2114     WebFrameProxy* frame = process()->webFrame(frameID);
2115     MESSAGE_CHECK(frame);
2116
2117     clearLoadDependentCallbacks();
2118
2119     frame->didFailLoad();
2120
2121     m_loaderClient.didFailLoadWithErrorForFrame(this, frame, error, userData.get());
2122 }
2123
2124 void WebPageProxy::didSameDocumentNavigationForFrame(uint64_t frameID, uint32_t opaqueSameDocumentNavigationType, const String& url, CoreIPC::ArgumentDecoder* arguments)
2125 {
2126     RefPtr<APIObject> userData;
2127     WebContextUserMessageDecoder messageDecoder(userData, m_process->context());
2128     if (!arguments->decode(messageDecoder))
2129         return;
2130
2131     WebFrameProxy* frame = process()->webFrame(frameID);
2132     MESSAGE_CHECK(frame);
2133     MESSAGE_CHECK_URL(url);
2134
2135     clearPendingAPIRequestURL();
2136     frame->didSameDocumentNavigation(url);
2137
2138 #if ENABLE(TIZEN_ISF_PORT)
2139     if (m_pageClient->getInputMethodState()) {
2140         LOG(ISF, "%s\n", __func__);
2141         setInputMethodState(false, String(), String());
2142     }
2143 #endif
2144
2145     m_loaderClient.didSameDocumentNavigationForFrame(this, frame, static_cast<SameDocumentNavigationType>(opaqueSameDocumentNavigationType), userData.get());
2146 }
2147
2148 void WebPageProxy::didReceiveTitleForFrame(uint64_t frameID, const String& title, CoreIPC::ArgumentDecoder* arguments)
2149 {
2150     RefPtr<APIObject> userData;
2151     WebContextUserMessageDecoder messageDecoder(userData, m_process->context());
2152     if (!arguments->decode(messageDecoder))
2153         return;
2154
2155     WebFrameProxy* frame = process()->webFrame(frameID);
2156     MESSAGE_CHECK(frame);
2157
2158     frame->didChangeTitle(title);
2159     
2160     m_loaderClient.didReceiveTitleForFrame(this, title, frame, userData.get());
2161 }
2162
2163 void WebPageProxy::didFirstLayoutForFrame(uint64_t frameID, CoreIPC::ArgumentDecoder* arguments)
2164 {
2165     RefPtr<APIObject> userData;
2166     WebContextUserMessageDecoder messageDecoder(userData, m_process->context());
2167     if (!arguments->decode(messageDecoder))
2168         return;
2169
2170     WebFrameProxy* frame = process()->webFrame(frameID);
2171     MESSAGE_CHECK(frame);
2172
2173     m_loaderClient.didFirstLayoutForFrame(this, frame, userData.get());
2174 }
2175
2176 void WebPageProxy::didFirstVisuallyNonEmptyLayoutForFrame(uint64_t frameID, CoreIPC::ArgumentDecoder* arguments)
2177 {
2178     RefPtr<APIObject> userData;
2179     WebContextUserMessageDecoder messageDecoder(userData, m_process->context());
2180     if (!arguments->decode(messageDecoder))
2181         return;
2182
2183     WebFrameProxy* frame = process()->webFrame(frameID);
2184     MESSAGE_CHECK(frame);
2185
2186 #if OS(TIZEN)
2187     if (frame->isMainFrame())
2188         m_pageClient->didFirstVisuallyNonEmptyLayoutForMainFrame();
2189 #endif
2190
2191     m_loaderClient.didFirstVisuallyNonEmptyLayoutForFrame(this, frame, userData.get());
2192 }
2193
2194 void WebPageProxy::didNewFirstVisuallyNonEmptyLayout(CoreIPC::ArgumentDecoder* arguments)
2195 {
2196     RefPtr<APIObject> userData;
2197     WebContextUserMessageDecoder messageDecoder(userData, m_process->context());
2198     if (!arguments->decode(messageDecoder))
2199         return;
2200
2201     m_loaderClient.didNewFirstVisuallyNonEmptyLayout(this, userData.get());
2202 }
2203
2204 void WebPageProxy::didRemoveFrameFromHierarchy(uint64_t frameID, CoreIPC::ArgumentDecoder* arguments)
2205 {
2206     RefPtr<APIObject> userData;
2207     WebContextUserMessageDecoder messageDecoder(userData, m_process->context());
2208     if (!arguments->decode(messageDecoder))
2209         return;
2210
2211     WebFrameProxy* frame = process()->webFrame(frameID);
2212     MESSAGE_CHECK(frame);
2213
2214     frame->didRemoveFromHierarchy();
2215
2216     m_loaderClient.didRemoveFrameFromHierarchy(this, frame, userData.get());
2217 }
2218
2219 void WebPageProxy::didDisplayInsecureContentForFrame(uint64_t frameID, CoreIPC::ArgumentDecoder* arguments)
2220 {
2221     RefPtr<APIObject> userData;
2222     WebContextUserMessageDecoder messageDecoder(userData, m_process->context());
2223     if (!arguments->decode(messageDecoder))
2224         return;
2225
2226     WebFrameProxy* frame = process()->webFrame(frameID);
2227     MESSAGE_CHECK(frame);
2228
2229     m_loaderClient.didDisplayInsecureContentForFrame(this, frame, userData.get());
2230 }
2231
2232 void WebPageProxy::didRunInsecureContentForFrame(uint64_t frameID, CoreIPC::ArgumentDecoder* arguments)
2233 {
2234     RefPtr<APIObject> userData;
2235     WebContextUserMessageDecoder messageDecoder(userData, m_process->context());
2236     if (!arguments->decode(messageDecoder))
2237         return;
2238
2239     WebFrameProxy* frame = process()->webFrame(frameID);
2240     MESSAGE_CHECK(frame);
2241
2242     m_loaderClient.didRunInsecureContentForFrame(this, frame, userData.get());
2243 }
2244
2245 void WebPageProxy::didDetectXSSForFrame(uint64_t frameID, CoreIPC::ArgumentDecoder* arguments)
2246 {
2247     RefPtr<APIObject> userData;
2248     WebContextUserMessageDecoder messageDecoder(userData, m_process->context());
2249     if (!arguments->decode(messageDecoder))
2250         return;
2251
2252     WebFrameProxy* frame = process()->webFrame(frameID);
2253     MESSAGE_CHECK(frame);
2254
2255     m_loaderClient.didDetectXSSForFrame(this, frame, userData.get());
2256 }
2257
2258 void WebPageProxy::frameDidBecomeFrameSet(uint64_t frameID, bool value)
2259 {
2260     WebFrameProxy* frame = process()->webFrame(frameID);
2261     MESSAGE_CHECK(frame);
2262
2263     frame->setIsFrameSet(value);
2264     if (frame->isMainFrame())
2265         m_frameSetLargestFrame = value ? m_mainFrame : 0;
2266 }
2267
2268 // PolicyClient
2269 void WebPageProxy::decidePolicyForNavigationAction(uint64_t frameID, uint32_t opaqueNavigationType, uint32_t opaqueModifiers, int32_t opaqueMouseButton, const ResourceRequest& request, uint64_t listenerID, CoreIPC::ArgumentDecoder* arguments, bool& receivedPolicyAction, uint64_t& policyAction, uint64_t& downloadID)
2270 {
2271     RefPtr<APIObject> userData;
2272     WebContextUserMessageDecoder messageDecoder(userData, m_process->context());
2273     if (!arguments->decode(messageDecoder))
2274         return;
2275
2276     if (request.url() != pendingAPIRequestURL())
2277         clearPendingAPIRequestURL();
2278
2279     WebFrameProxy* frame = process()->webFrame(frameID);
2280     MESSAGE_CHECK(frame);
2281     MESSAGE_CHECK_URL(request.url());
2282
2283     NavigationType navigationType = static_cast<NavigationType>(opaqueNavigationType);
2284     WebEvent::Modifiers modifiers = static_cast<WebEvent::Modifiers>(opaqueModifiers);
2285     WebMouseEvent::Button mouseButton = static_cast<WebMouseEvent::Button>(opaqueMouseButton);
2286     
2287     RefPtr<WebFramePolicyListenerProxy> listener = frame->setUpPolicyListenerProxy(listenerID);
2288
2289     ASSERT(!m_inDecidePolicyForNavigationAction);
2290
2291     m_inDecidePolicyForNavigationAction = true;
2292     m_syncNavigationActionPolicyActionIsValid = false;
2293     
2294     if (!m_policyClient.decidePolicyForNavigationAction(this, frame, navigationType, modifiers, mouseButton, request, listener.get(), userData.get()))
2295         listener->use();
2296
2297     m_inDecidePolicyForNavigationAction = false;
2298
2299     // Check if we received a policy decision already. If we did, we can just pass it back.
2300     receivedPolicyAction = m_syncNavigationActionPolicyActionIsValid;
2301     if (m_syncNavigationActionPolicyActionIsValid) {
2302         policyAction = m_syncNavigationActionPolicyAction;
2303         downloadID = m_syncNavigationActionPolicyDownloadID;
2304     }
2305 }
2306
2307 void WebPageProxy::decidePolicyForNewWindowAction(uint64_t frameID, uint32_t opaqueNavigationType, uint32_t opaqueModifiers, int32_t opaqueMouseButton, const ResourceRequest& request, const String& frameName, uint64_t listenerID, CoreIPC::ArgumentDecoder* arguments)
2308 {
2309     RefPtr<APIObject> userData;
2310     WebContextUserMessageDecoder messageDecoder(userData, m_process->context());
2311     if (!arguments->decode(messageDecoder))
2312         return;
2313
2314     WebFrameProxy* frame = process()->webFrame(frameID);
2315     MESSAGE_CHECK(frame);
2316     MESSAGE_CHECK_URL(request.url());
2317
2318     NavigationType navigationType = static_cast<NavigationType>(opaqueNavigationType);
2319     WebEvent::Modifiers modifiers = static_cast<WebEvent::Modifiers>(opaqueModifiers);
2320     WebMouseEvent::Button mouseButton = static_cast<WebMouseEvent::Button>(opaqueMouseButton);
2321
2322     RefPtr<WebFramePolicyListenerProxy> listener = frame->setUpPolicyListenerProxy(listenerID);
2323     if (!m_policyClient.decidePolicyForNewWindowAction(this, frame, navigationType, modifiers, mouseButton, request, frameName, listener.get(), userData.get()))
2324         listener->use();
2325 }
2326
2327 void WebPageProxy::decidePolicyForResponse(uint64_t frameID, const ResourceResponse& response, const ResourceRequest& request, uint64_t listenerID, CoreIPC::ArgumentDecoder* arguments, bool& receivedPolicyAction, uint64_t& policyAction, uint64_t& downloadID)
2328 {
2329     RefPtr<APIObject> userData;
2330     WebContextUserMessageDecoder messageDecoder(userData, m_process->context());
2331     if (!arguments->decode(messageDecoder))
2332         return;
2333
2334     WebFrameProxy* frame = process()->webFrame(frameID);
2335     MESSAGE_CHECK(frame);
2336     MESSAGE_CHECK_URL(request.url());
2337     MESSAGE_CHECK_URL(response.url());
2338     
2339     RefPtr<WebFramePolicyListenerProxy> listener = frame->setUpPolicyListenerProxy(listenerID);
2340
2341     ASSERT(!m_inDecidePolicyForResponse);
2342
2343     m_inDecidePolicyForResponse = true;
2344     m_syncMimeTypePolicyActionIsValid = false;
2345
2346     if (!m_policyClient.decidePolicyForResponse(this, frame, response, request, listener.get(), userData.get()))
2347         listener->use();
2348
2349     m_inDecidePolicyForResponse = false;
2350
2351     // Check if we received a policy decision already. If we did, we can just pass it back.
2352     receivedPolicyAction = m_syncMimeTypePolicyActionIsValid;
2353     if (m_syncMimeTypePolicyActionIsValid) {
2354         policyAction = m_syncMimeTypePolicyAction;
2355         downloadID = m_syncMimeTypePolicyDownloadID;
2356     }
2357 }
2358
2359 void WebPageProxy::unableToImplementPolicy(uint64_t frameID, const ResourceError& error, CoreIPC::ArgumentDecoder* arguments)
2360 {
2361     RefPtr<APIObject> userData;
2362     WebContextUserMessageDecoder messageDecoder(userData, m_process->context());
2363     if (!arguments->decode(messageDecoder))
2364         return;
2365     
2366     WebFrameProxy* frame = process()->webFrame(frameID);
2367     MESSAGE_CHECK(frame);
2368
2369     m_policyClient.unableToImplementPolicy(this, frame, error, userData.get());
2370 }
2371
2372 // FormClient
2373
2374 void WebPageProxy::willSubmitForm(uint64_t frameID, uint64_t sourceFrameID, const StringPairVector& textFieldValues, uint64_t listenerID, CoreIPC::ArgumentDecoder* arguments)
2375 {
2376     RefPtr<APIObject> userData;
2377     WebContextUserMessageDecoder messageDecoder(userData, m_process->context());
2378     if (!arguments->decode(messageDecoder))
2379         return;
2380
2381     WebFrameProxy* frame = process()->webFrame(frameID);
2382     MESSAGE_CHECK(frame);
2383
2384     WebFrameProxy* sourceFrame = process()->webFrame(sourceFrameID);
2385     MESSAGE_CHECK(sourceFrame);
2386
2387     RefPtr<WebFormSubmissionListenerProxy> listener = frame->setUpFormSubmissionListenerProxy(listenerID);
2388     if (!m_formClient.willSubmitForm(this, frame, sourceFrame, textFieldValues.stringPairVector(), userData.get(), listener.get()))
2389         listener->continueSubmission();
2390 }
2391
2392 // ResourceLoad Client
2393
2394 void WebPageProxy::didInitiateLoadForResource(uint64_t frameID, uint64_t resourceIdentifier, const ResourceRequest& request, bool pageIsProvisionallyLoading)
2395 {
2396     WebFrameProxy* frame = process()->webFrame(frameID);
2397     MESSAGE_CHECK(frame);
2398     MESSAGE_CHECK_URL(request.url());
2399
2400     m_resourceLoadClient.didInitiateLoadForResource(this, frame, resourceIdentifier, request, pageIsProvisionallyLoading);
2401 }
2402
2403 void WebPageProxy::didSendRequestForResource(uint64_t frameID, uint64_t resourceIdentifier, const ResourceRequest& request, const ResourceResponse& redirectResponse)
2404 {
2405     WebFrameProxy* frame = process()->webFrame(frameID);
2406     MESSAGE_CHECK(frame);
2407     MESSAGE_CHECK_URL(request.url());
2408
2409     m_resourceLoadClient.didSendRequestForResource(this, frame, resourceIdentifier, request, redirectResponse);
2410 }
2411
2412 void WebPageProxy::didReceiveResponseForResource(uint64_t frameID, uint64_t resourceIdentifier, const ResourceResponse& response)
2413 {
2414     WebFrameProxy* frame = process()->webFrame(frameID);
2415     MESSAGE_CHECK(frame);
2416     MESSAGE_CHECK_URL(response.url());
2417
2418     m_resourceLoadClient.didReceiveResponseForResource(this, frame, resourceIdentifier, response);
2419 }
2420
2421 void WebPageProxy::didReceiveContentLengthForResource(uint64_t frameID, uint64_t resourceIdentifier, uint64_t contentLength)
2422 {
2423     WebFrameProxy* frame = process()->webFrame(frameID);
2424     MESSAGE_CHECK(frame);
2425
2426     m_resourceLoadClient.didReceiveContentLengthForResource(this, frame, resourceIdentifier, contentLength);
2427 }
2428
2429 void WebPageProxy::didFinishLoadForResource(uint64_t frameID, uint64_t resourceIdentifier)
2430 {
2431     WebFrameProxy* frame = process()->webFrame(frameID);
2432     MESSAGE_CHECK(frame);
2433
2434     m_resourceLoadClient.didFinishLoadForResource(this, frame, resourceIdentifier);
2435 }
2436
2437 void WebPageProxy::didFailLoadForResource(uint64_t frameID, uint64_t resourceIdentifier, const ResourceError& error)
2438 {
2439     WebFrameProxy* frame = process()->webFrame(frameID);
2440     MESSAGE_CHECK(frame);
2441
2442     m_resourceLoadClient.didFailLoadForResource(this, frame, resourceIdentifier, error);
2443 }
2444
2445 // UIClient
2446
2447 void WebPageProxy::createNewPage(const ResourceRequest& request, const WindowFeatures& windowFeatures, uint32_t opaqueModifiers, int32_t opaqueMouseButton, uint64_t& newPageID, WebPageCreationParameters& newPageParameters)
2448 {
2449     RefPtr<WebPageProxy> newPage = m_uiClient.createNewPage(this, request, windowFeatures, static_cast<WebEvent::Modifiers>(opaqueModifiers), static_cast<WebMouseEvent::Button>(opaqueMouseButton));
2450     if (newPage) {
2451         newPageID = newPage->pageID();
2452         newPageParameters = newPage->creationParameters();
2453     } else
2454         newPageID = 0;
2455 }
2456     
2457 void WebPageProxy::showPage()
2458 {
2459     m_uiClient.showPage(this);
2460 }
2461
2462 void WebPageProxy::closePage(bool stopResponsivenessTimer)
2463 {
2464     if (stopResponsivenessTimer)
2465         process()->responsivenessTimer()->stop();
2466
2467     m_pageClient->clearAllEditCommands();
2468     m_uiClient.close(this);
2469 }
2470
2471 #if OS(TIZEN)
2472 void WebPageProxy::runJavaScriptAlert(uint64_t frameID, const String& message, PassRefPtr<Messages::WebPageProxy::RunJavaScriptAlert::DelayedReply> reply)
2473 {
2474     WebFrameProxy* frame = process()->webFrame(frameID);
2475     MESSAGE_CHECK(frame);
2476
2477     // Since runJavaScriptAlert() can spin a nested run loop we need to turn off the responsiveness timer.
2478     process()->responsivenessTimer()->stop();
2479
2480     m_alertReply = reply;
2481     if (!m_uiClient.runJavaScriptAlert(this, message, frame))
2482         replyJavaScriptAlert();
2483 }
2484
2485 void WebPageProxy::runJavaScriptConfirm(uint64_t frameID, const String& message, PassRefPtr<Messages::WebPageProxy::RunJavaScriptConfirm::DelayedReply> reply)
2486 {
2487     WebFrameProxy* frame = process()->webFrame(frameID);
2488     MESSAGE_CHECK(frame);
2489
2490     // Since runJavaScriptConfirm() can spin a nested run loop we need to turn off the responsiveness timer.
2491     process()->responsivenessTimer()->stop();
2492
2493     m_confirmReply = reply;
2494     if (!m_uiClient.runJavaScriptConfirm(this, message, frame))
2495         replyJavaScriptConfirm(false);
2496 }
2497
2498 void WebPageProxy::runJavaScriptPrompt(uint64_t frameID, const String& message, const String& defaultValue, PassRefPtr<Messages::WebPageProxy::RunJavaScriptPrompt::DelayedReply> reply)
2499 {
2500     WebFrameProxy* frame = process()->webFrame(frameID);
2501     MESSAGE_CHECK(frame);
2502
2503     // Since runJavaScriptPrompt() can spin a nested run loop we need to turn off the responsiveness timer.
2504     process()->responsivenessTimer()->stop();
2505
2506     m_promptReply = reply;
2507     if (!m_uiClient.runJavaScriptPrompt(this, message, defaultValue, frame))
2508         replyJavaScriptPrompt(String());
2509 }
2510 #else
2511 void WebPageProxy::runJavaScriptAlert(uint64_t frameID, const String& message)
2512 {
2513     WebFrameProxy* frame = process()->webFrame(frameID);
2514     MESSAGE_CHECK(frame);
2515
2516     // Since runJavaScriptAlert() can spin a nested run loop we need to turn off the responsiveness timer.
2517     process()->responsivenessTimer()->stop();
2518
2519     m_uiClient.runJavaScriptAlert(this, message, frame);
2520 }
2521
2522 void WebPageProxy::runJavaScriptConfirm(uint64_t frameID, const String& message, bool& result)
2523 {
2524     WebFrameProxy* frame = process()->webFrame(frameID);
2525     MESSAGE_CHECK(frame);
2526
2527     // Since runJavaScriptConfirm() can spin a nested run loop we need to turn off the responsiveness timer.
2528     process()->responsivenessTimer()->stop();
2529
2530     result = m_uiClient.runJavaScriptConfirm(this, message, frame);
2531 }
2532
2533 void WebPageProxy::runJavaScriptPrompt(uint64_t frameID, const String& message, const String& defaultValue, String& result)
2534 {
2535     WebFrameProxy* frame = process()->webFrame(frameID);
2536     MESSAGE_CHECK(frame);
2537
2538     // Since runJavaScriptPrompt() can spin a nested run loop we need to turn off the responsiveness timer.
2539     process()->responsivenessTimer()->stop();
2540
2541     result = m_uiClient.runJavaScriptPrompt(this, message, defaultValue, frame);
2542 }
2543 #endif
2544
2545 void WebPageProxy::shouldInterruptJavaScript(bool& result)
2546 {
2547     // Since shouldInterruptJavaScript() can spin a nested run loop we need to turn off the responsiveness timer.
2548     process()->responsivenessTimer()->stop();
2549
2550     result = m_uiClient.shouldInterruptJavaScript(this);
2551 }
2552
2553 void WebPageProxy::setStatusText(const String& text)
2554 {
2555     m_uiClient.setStatusText(this, text);
2556 }
2557
2558 void WebPageProxy::mouseDidMoveOverElement(const WebHitTestResult::Data& hitTestResultData, uint32_t opaqueModifiers, CoreIPC::ArgumentDecoder* arguments)
2559 {
2560     RefPtr<APIObject> userData;
2561     WebContextUserMessageDecoder messageDecoder(userData, m_process->context());
2562     if (!arguments->decode(messageDecoder))
2563         return;
2564
2565     WebEvent::Modifiers modifiers = static_cast<WebEvent::Modifiers>(opaqueModifiers);
2566
2567     m_uiClient.mouseDidMoveOverElement(this, hitTestResultData, modifiers, userData.get());
2568 }
2569
2570 void WebPageProxy::unavailablePluginButtonClicked(uint32_t opaquePluginUnavailabilityReason, const String& mimeType, const String& url, const String& pluginsPageURL)
2571 {
2572     MESSAGE_CHECK_URL(url);
2573     MESSAGE_CHECK_URL(pluginsPageURL);
2574
2575     WKPluginUnavailabilityReason pluginUnavailabilityReason = static_cast<WKPluginUnavailabilityReason>(opaquePluginUnavailabilityReason);
2576     m_uiClient.unavailablePluginButtonClicked(this, pluginUnavailabilityReason, mimeType, url, pluginsPageURL);
2577 }
2578
2579 void WebPageProxy::setToolbarsAreVisible(bool toolbarsAreVisible)
2580 {
2581     m_uiClient.setToolbarsAreVisible(this, toolbarsAreVisible);
2582 }
2583
2584 void WebPageProxy::getToolbarsAreVisible(bool& toolbarsAreVisible)
2585 {
2586     toolbarsAreVisible = m_uiClient.toolbarsAreVisible(this);
2587 }
2588
2589 void WebPageProxy::setMenuBarIsVisible(bool menuBarIsVisible)
2590 {
2591     m_uiClient.setMenuBarIsVisible(this, menuBarIsVisible);
2592 }
2593
2594 void WebPageProxy::getMenuBarIsVisible(bool& menuBarIsVisible)
2595 {
2596     menuBarIsVisible = m_uiClient.menuBarIsVisible(this);
2597 }
2598
2599 void WebPageProxy::setStatusBarIsVisible(bool statusBarIsVisible)
2600 {
2601     m_uiClient.setStatusBarIsVisible(this, statusBarIsVisible);
2602 }
2603
2604 void WebPageProxy::getStatusBarIsVisible(bool& statusBarIsVisible)
2605 {
2606     statusBarIsVisible = m_uiClient.statusBarIsVisible(this);
2607 }
2608
2609 void WebPageProxy::setIsResizable(bool isResizable)
2610 {
2611     m_uiClient.setIsResizable(this, isResizable);
2612 }
2613
2614 void WebPageProxy::getIsResizable(bool& isResizable)
2615 {
2616     isResizable = m_uiClient.isResizable(this);
2617 }
2618
2619 void WebPageProxy::setWindowFrame(const FloatRect& newWindowFrame)
2620 {
2621     m_uiClient.setWindowFrame(this, m_pageClient->convertToDeviceSpace(newWindowFrame));
2622 }
2623
2624 void WebPageProxy::getWindowFrame(FloatRect& newWindowFrame)
2625 {
2626     newWindowFrame = m_pageClient->convertToUserSpace(m_uiClient.windowFrame(this));
2627 }
2628     
2629 void WebPageProxy::screenToWindow(const IntPoint& screenPoint, IntPoint& windowPoint)
2630 {
2631     windowPoint = m_pageClient->screenToWindow(screenPoint);
2632 }
2633     
2634 void WebPageProxy::windowToScreen(const IntRect& viewRect, IntRect& result)
2635 {
2636     result = m_pageClient->windowToScreen(viewRect);
2637 }
2638     
2639 void WebPageProxy::runBeforeUnloadConfirmPanel(const String& message, uint64_t frameID, bool& shouldClose)
2640 {
2641     WebFrameProxy* frame = process()->webFrame(frameID);
2642     MESSAGE_CHECK(frame);
2643
2644     // Since runBeforeUnloadConfirmPanel() can spin a nested run loop we need to turn off the responsiveness timer.
2645     process()->responsivenessTimer()->stop();
2646
2647     shouldClose = m_uiClient.runBeforeUnloadConfirmPanel(this, message, frame);
2648 }
2649
2650 #if USE(TILED_BACKING_STORE)
2651 void WebPageProxy::pageDidRequestScroll(const IntPoint& point)
2652 {
2653     m_pageClient->pageDidRequestScroll(point);
2654 }
2655 #endif
2656
2657 void WebPageProxy::didChangeViewportProperties(const ViewportAttributes& attr)
2658 {
2659     m_pageClient->didChangeViewportProperties(attr);
2660 }
2661
2662 void WebPageProxy::pageDidScroll()
2663 {
2664     m_uiClient.pageDidScroll(this);
2665 #if PLATFORM(MAC) && !defined(BUILDING_ON_SNOW_LEOPARD)
2666     dismissCorrectionPanel(ReasonForDismissingAlternativeTextIgnored);
2667 #endif
2668 }
2669
2670 void WebPageProxy::runOpenPanel(uint64_t frameID, const FileChooserSettings& settings)
2671 {
2672     if (m_openPanelResultListener) {
2673         m_openPanelResultListener->invalidate();
2674         m_openPanelResultListener = 0;
2675     }
2676
2677     WebFrameProxy* frame = process()->webFrame(frameID);
2678     MESSAGE_CHECK(frame);
2679
2680     RefPtr<WebOpenPanelParameters> parameters = WebOpenPanelParameters::create(settings);
2681     m_openPanelResultListener = WebOpenPanelResultListenerProxy::create(this);
2682
2683     // Since runOpenPanel() can spin a nested run loop we need to turn off the responsiveness timer.
2684     process()->responsivenessTimer()->stop();
2685
2686     if (!m_uiClient.runOpenPanel(this, frame, parameters.get(), m_openPanelResultListener.get()))
2687         didCancelForOpenPanel();
2688 }
2689
2690 void WebPageProxy::printFrame(uint64_t frameID)
2691 {
2692     ASSERT(!m_isPerformingDOMPrintOperation);
2693     m_isPerformingDOMPrintOperation = true;
2694
2695     WebFrameProxy* frame = process()->webFrame(frameID);
2696     MESSAGE_CHECK(frame);
2697
2698     m_uiClient.printFrame(this, frame);
2699
2700     endPrinting(); // Send a message synchronously while m_isPerformingDOMPrintOperation is still true.
2701     m_isPerformingDOMPrintOperation = false;
2702 }
2703
2704 void WebPageProxy::printMainFrame()
2705 {
2706     printFrame(m_mainFrame->frameID());
2707 }
2708
2709 #if ENABLE(TIZEN_REGISTER_PROTOCOL_HANDLER)
2710 void WebPageProxy::registerProtocolHandler(const String& scheme, const String& baseURL, const String& url, const String& title)
2711 {
2712     m_pageClient->registerProtocolHandler(scheme, baseURL, url, title);
2713 }
2714 #endif
2715
2716 #if ENABLE(TIZEN_REGISTER_CONTENT_HANDLER)
2717 void WebPageProxy::registerContentHandler(const String& mimeType, const String& baseURL, const String& url, const String& title)
2718 {
2719     m_pageClient->registerContentHandler(mimeType, baseURL, url, title);
2720 }
2721 #endif
2722
2723 #if ENABLE(TIZEN_SUPPORT_WEBAPP_META_TAG)
2724 void WebPageProxy::getStandaloneStatus(bool& standalone)
2725 {
2726     standalone = m_pageClient->getStandaloneStatus();
2727 }
2728
2729 void WebPageProxy::getWebAppCapable(PassRefPtr<BooleanCallback> prpCallback)
2730 {
2731     RefPtr<BooleanCallback> callback = prpCallback;
2732     if (!isValid()) {
2733         callback->invalidate();
2734         return;
2735     }
2736
2737     uint64_t callbackID = callback->callbackID();
2738     m_booleanCallbacks.set(callbackID, callback.get());
2739     process()->send(Messages::WebPage::GetWebAppCapable(callbackID), m_pageID);
2740 }
2741
2742 void WebPageProxy::didGetWebAppCapable(const bool capable, uint64_t callbackID)
2743 {
2744     RefPtr<BooleanCallback> callback = m_booleanCallbacks.take(callbackID);
2745     if (!callback) {
2746         // FIXME: Log error or assert.
2747         // this can validly happen if a load invalidated the callback, though
2748         return;
2749     }
2750
2751     m_booleanCallbacks.remove(callbackID);
2752     callback->performCallbackWithReturnValue(WebBoolean::create(capable).leakRef());
2753 }
2754
2755 void WebPageProxy::getWebAppIconURL(PassRefPtr<StringCallback> prpCallback)
2756 {
2757     RefPtr<StringCallback> callback = prpCallback;
2758     if (!isValid()) {
2759         callback->invalidate();
2760         return;
2761     }
2762
2763     uint64_t callbackID = callback->callbackID();
2764     m_stringCallbacks.set(callbackID, callback.get());
2765     process()->send(Messages::WebPage::GetWebAppIconURL(callbackID), m_pageID);
2766 }
2767
2768 void WebPageProxy::didGetWebAppIconURL(const String& iconURL, uint64_t callbackID)
2769 {
2770     RefPtr<StringCallback> callback = m_stringCallbacks.take(callbackID);
2771     if (!callback) {
2772         // FIXME: Log error or assert.
2773         // this can validly happen if a load invalidated the callback, though
2774         return;
2775     }
2776
2777     m_stringCallbacks.remove(callbackID);
2778     callback->performCallbackWithReturnValue(iconURL.impl());
2779 }
2780 #endif
2781
2782 void WebPageProxy::setMediaVolume(float volume)
2783 {
2784     if (volume == m_mediaVolume)
2785         return;
2786     
2787     m_mediaVolume = volume;
2788     
2789     if (!isValid())
2790         return;
2791     
2792     process()->send(Messages::WebPage::SetMediaVolume(volume), m_pageID);    
2793 }
2794
2795 #if PLATFORM(QT)
2796 void WebPageProxy::didChangeContentsSize(const IntSize& size)
2797 {
2798     m_pageClient->didChangeContentsSize(size);
2799 }
2800
2801 void WebPageProxy::didFindZoomableArea(const IntPoint& target, const IntRect& area)
2802 {
2803     m_pageClient->didFindZoomableArea(target, area);
2804 }
2805
2806 void WebPageProxy::findZoomableAreaForPoint(const IntPoint& point, const IntSize& area)
2807 {
2808     if (!isValid())
2809         return;
2810
2811     process()->send(Messages::WebPage::FindZoomableAreaForPoint(point, area), m_pageID);
2812 }
2813
2814 void WebPageProxy::didReceiveMessageFromNavigatorQtObject(const String& contents)
2815 {
2816     m_pageClient->didReceiveMessageFromNavigatorQtObject(contents);
2817 }
2818
2819 void WebPageProxy::handleDownloadRequest(DownloadProxy* download)
2820 {
2821     m_pageClient->handleDownloadRequest(download);
2822 }
2823
2824 void WebPageProxy::authenticationRequiredRequest(const String& hostname, const String& realm, const String& prefilledUsername, String& username, String& password)
2825 {
2826     m_pageClient->handleAuthenticationRequiredRequest(hostname, realm, prefilledUsername, username, password);
2827 }
2828
2829 void WebPageProxy::proxyAuthenticationRequiredRequest(const String& hostname, uint16_t port, const String& prefilledUsername, String& username, String& password)
2830 {
2831     m_pageClient->handleProxyAuthenticationRequiredRequest(hostname, port, prefilledUsername, username, password);
2832 }
2833
2834 void WebPageProxy::certificateVerificationRequest(const String& hostname, bool& ignoreErrors)
2835 {
2836     m_pageClient->handleCertificateVerificationRequest(hostname, ignoreErrors);
2837 }
2838 #endif // PLATFORM(QT).
2839
2840 #if ENABLE(TOUCH_EVENTS)
2841 void WebPageProxy::needTouchEvents(bool needTouchEvents)
2842 {
2843     m_needTouchEvents = needTouchEvents;
2844 }
2845 #endif
2846
2847 #if ENABLE(INPUT_TYPE_COLOR)
2848 void WebPageProxy::showColorChooser(const WebCore::Color& initialColor)
2849 {
2850     ASSERT(!m_colorChooser);
2851
2852     m_colorChooser = m_pageClient->createColorChooserProxy(this, initialColor);
2853 }
2854
2855 void WebPageProxy::setColorChooserColor(const WebCore::Color& color)
2856 {
2857     ASSERT(m_colorChooser);
2858
2859     m_colorChooser->setSelectedColor(color);
2860 }
2861
2862 void WebPageProxy::endColorChooser()
2863 {
2864     ASSERT(m_colorChooser);
2865
2866     m_colorChooser->endChooser();
2867 }
2868
2869 void WebPageProxy::didChooseColor(const WebCore::Color& color)
2870 {
2871     if (!isValid())
2872         return;
2873
2874     process()->send(Messages::WebPage::DidChooseColor(color), m_pageID);
2875 }
2876
2877 void WebPageProxy::didEndColorChooser()
2878 {
2879     if (!isValid())
2880         return;
2881
2882     ASSERT(m_colorChooser);
2883
2884 #if !ENABLE(TIZEN_INPUT_COLOR_PICKER) // prevent crash when the color chooser closed
2885     m_colorChooser->invalidate();
2886 #endif
2887     m_colorChooser = nullptr;
2888
2889     process()->send(Messages::WebPage::DidEndColorChooser(), m_pageID);
2890 }
2891 #endif
2892
2893 void WebPageProxy::didDraw()
2894 {
2895     m_uiClient.didDraw(this);
2896 }
2897
2898 // Inspector
2899
2900 #if ENABLE(INSPECTOR)
2901
2902 WebInspectorProxy* WebPageProxy::inspector()
2903 {
2904     if (isClosed() || !isValid())
2905         return 0;
2906     if (!m_inspector)
2907         m_inspector = WebInspectorProxy::create(this);
2908     return m_inspector.get();
2909 }
2910
2911 #endif
2912
2913 #if ENABLE(FULLSCREEN_API)
2914 WebFullScreenManagerProxy* WebPageProxy::fullScreenManager()
2915 {
2916     if (!m_fullScreenManager)
2917         m_fullScreenManager = WebFullScreenManagerProxy::create(this);
2918     return m_fullScreenManager.get();
2919 }
2920 #endif
2921
2922 // BackForwardList
2923
2924 void WebPageProxy::backForwardAddItem(uint64_t itemID)
2925 {
2926     m_backForwardList->addItem(process()->webBackForwardItem(itemID));
2927 }
2928
2929 void WebPageProxy::backForwardGoToItem(uint64_t itemID, SandboxExtension::Handle& sandboxExtensionHandle)
2930 {
2931     WebBackForwardListItem* item = process()->webBackForwardItem(itemID);
2932     if (!item)
2933         return;
2934
2935     bool createdExtension = maybeInitializeSandboxExtensionHandle(KURL(KURL(), item->url()), sandboxExtensionHandle);
2936     if (createdExtension)
2937         process()->willAcquireUniversalFileReadSandboxExtension();
2938     m_backForwardList->goToItem(item);
2939 }
2940
2941 void WebPageProxy::backForwardItemAtIndex(int32_t index, uint64_t& itemID)
2942 {
2943     WebBackForwardListItem* item = m_backForwardList->itemAtIndex(index);
2944     itemID = item ? item->itemID() : 0;
2945 }
2946
2947 void WebPageProxy::backForwardBackListCount(int32_t& count)
2948 {
2949     count = m_backForwardList->backListCount();
2950 }
2951
2952 void WebPageProxy::backForwardForwardListCount(int32_t& count)
2953 {
2954     count = m_backForwardList->forwardListCount();
2955 }
2956
2957 void WebPageProxy::editorStateChanged(const EditorState& editorState)
2958 {
2959 #if PLATFORM(MAC)
2960     bool couldChangeSecureInputState = m_editorState.isInPasswordField != editorState.isInPasswordField || m_editorState.selectionIsNone;
2961 #endif
2962
2963     m_editorState = editorState;
2964
2965 #if PLATFORM(MAC)
2966     m_pageClient->updateTextInputState(couldChangeSecureInputState);
2967 #elif PLATFORM(QT)
2968     m_pageClient->updateTextInputState();
2969 #endif
2970
2971 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
2972     m_pageClient->updateTextSelection();
2973 #endif
2974 }
2975
2976 // Undo management
2977
2978 void WebPageProxy::registerEditCommandForUndo(uint64_t commandID, uint32_t editAction)
2979 {
2980     registerEditCommand(WebEditCommandProxy::create(commandID, static_cast<EditAction>(editAction), this), Undo);
2981 }
2982
2983 void WebPageProxy::canUndoRedo(uint32_t action, bool& result)
2984 {
2985     result = m_pageClient->canUndoRedo(static_cast<UndoOrRedo>(action));
2986 }
2987
2988 void WebPageProxy::executeUndoRedo(uint32_t action, bool& result)
2989 {
2990     m_pageClient->executeUndoRedo(static_cast<UndoOrRedo>(action));
2991     result = true;
2992 }
2993
2994 void WebPageProxy::clearAllEditCommands()
2995 {
2996     m_pageClient->clearAllEditCommands();
2997 }
2998
2999 void WebPageProxy::didCountStringMatches(const String& string, uint32_t matchCount)
3000 {
3001     m_findClient.didCountStringMatches(this, string, matchCount);
3002 }
3003
3004 void WebPageProxy::setFindIndicator(const FloatRect& selectionRectInWindowCoordinates, const Vector<FloatRect>& textRectsInSelectionRectCoordinates, float contentImageScaleFactor, const ShareableBitmap::Handle& contentImageHandle, bool fadeOut, bool animate)
3005 {
3006     RefPtr<FindIndicator> findIndicator = FindIndicator::create(selectionRectInWindowCoordinates, textRectsInSelectionRectCoordinates, contentImageScaleFactor, contentImageHandle);
3007     m_pageClient->setFindIndicator(findIndicator.release(), fadeOut, animate);
3008 }
3009
3010 void WebPageProxy::didFindString(const String& string, uint32_t matchCount)
3011 {
3012     m_findClient.didFindString(this, string, matchCount);
3013 }
3014
3015 void WebPageProxy::didFailToFindString(const String& string)
3016 {
3017     m_findClient.didFailToFindString(this, string);
3018 }
3019
3020 void WebPageProxy::valueChangedForPopupMenu(WebPopupMenuProxy*, int32_t newSelectedIndex)
3021 {
3022     process()->send(Messages::WebPage::DidChangeSelectedIndexForActivePopupMenu(newSelectedIndex), m_pageID);
3023 }
3024
3025 void WebPageProxy::setTextFromItemForPopupMenu(WebPopupMenuProxy*, int32_t index)
3026 {
3027     process()->send(Messages::WebPage::SetTextForActivePopupMenu(index), m_pageID);
3028 }
3029
3030 NativeWebMouseEvent* WebPageProxy::currentlyProcessedMouseDownEvent()
3031 {
3032     return m_currentlyProcessedMouseDownEvent.get();
3033 }
3034
3035 #if PLATFORM(GTK)
3036 void WebPageProxy::failedToShowPopupMenu()
3037 {
3038     process()->send(Messages::WebPage::FailedToShowPopupMenu(), m_pageID);
3039 }
3040 #endif
3041
3042 void WebPageProxy::showPopupMenu(const IntRect& rect, uint64_t textDirection, const Vector<WebPopupItem>& items, int32_t selectedIndex, const PlatformPopupMenuData& data)
3043 {
3044     if (m_activePopupMenu) {
3045         m_activePopupMenu->hidePopupMenu();
3046         m_activePopupMenu->invalidate();
3047         m_activePopupMenu = 0;
3048     }
3049
3050     m_activePopupMenu = m_pageClient->createPopupMenuProxy(this);
3051
3052     // Since showPopupMenu() can spin a nested run loop we need to turn off the responsiveness timer.
3053     process()->responsivenessTimer()->stop();
3054
3055     RefPtr<WebPopupMenuProxy> protectedActivePopupMenu = m_activePopupMenu;
3056
3057     protectedActivePopupMenu->showPopupMenu(rect, static_cast<TextDirection>(textDirection), m_pageScaleFactor, items, data, selectedIndex);
3058 #if !PLATFORM(EFL)
3059     protectedActivePopupMenu->invalidate();
3060 #endif
3061     protectedActivePopupMenu = 0;
3062 }
3063
3064 void WebPageProxy::hidePopupMenu()
3065 {
3066     if (!m_activePopupMenu)
3067         return;
3068
3069     m_activePopupMenu->hidePopupMenu();
3070     m_activePopupMenu->invalidate();
3071     m_activePopupMenu = 0;
3072 }
3073
3074 #if ENABLE(CONTEXT_MENUS)
3075 void WebPageProxy::showContextMenu(const IntPoint& menuLocation, const WebHitTestResult::Data& hitTestResultData, const Vector<WebContextMenuItemData>& proposedItems, CoreIPC::ArgumentDecoder* arguments)
3076 {
3077     internalShowContextMenu(menuLocation, hitTestResultData, proposedItems, arguments);
3078     
3079     // No matter the result of internalShowContextMenu, always notify the WebProcess that the menu is hidden so it starts handling mouse events again.
3080     process()->send(Messages::WebPage::ContextMenuHidden(), m_pageID);
3081 #if ENABLE(TOUCH_EVENTS) && ENABLE(TIZEN_CONTEXT_MENU_WEBKIT_2)
3082     // Cancel touch event when ContextMenu is shown.
3083     m_pageClient->cancelTouchEvent();
3084 #endif
3085 }
3086
3087 void WebPageProxy::internalShowContextMenu(const IntPoint& menuLocation, const WebHitTestResult::Data& hitTestResultData, const Vector<WebContextMenuItemData>& proposedItems, CoreIPC::ArgumentDecoder* arguments)
3088 {
3089     RefPtr<APIObject> userData;
3090     WebContextUserMessageDecoder messageDecoder(userData, m_process->context());
3091     if (!arguments->decode(messageDecoder))
3092         return;
3093
3094     m_activeContextMenuHitTestResultData = hitTestResultData;
3095
3096     if (m_activeContextMenu) {
3097         m_activeContextMenu->hideContextMenu();
3098         m_activeContextMenu = 0;
3099     }
3100
3101     m_activeContextMenu = m_pageClient->createContextMenuProxy(this);
3102
3103     // Since showContextMenu() can spin a nested run loop we need to turn off the responsiveness timer.
3104     process()->responsivenessTimer()->stop();
3105
3106     // Give the PageContextMenuClient one last swipe at changing the menu.
3107     Vector<WebContextMenuItemData> items;
3108     if (!m_contextMenuClient.getContextMenuFromProposedMenu(this, proposedItems, items, hitTestResultData, userData.get()))
3109         m_activeContextMenu->showContextMenu(menuLocation, proposedItems);
3110     else
3111         m_activeContextMenu->showContextMenu(menuLocation, items);
3112     
3113     m_contextMenuClient.contextMenuDismissed(this);
3114 }
3115
3116 void WebPageProxy::contextMenuItemSelected(const WebContextMenuItemData& item)
3117 {
3118     // Application custom items don't need to round-trip through to WebCore in the WebProcess.
3119     if (item.action() >= ContextMenuItemBaseApplicationTag) {
3120         m_contextMenuClient.customContextMenuItemSelected(this, item);
3121 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
3122         m_pageClient->setIsTextSelectionMode(false);
3123 #endif
3124         return;
3125     }
3126
3127 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
3128     if (item.action() == ContextMenuItemTagPaste)
3129         m_pageClient->setIsTextSelectionMode(false);
3130 #endif
3131
3132 #if PLATFORM(MAC)
3133     if (item.action() == ContextMenuItemTagSmartCopyPaste) {
3134         setSmartInsertDeleteEnabled(!isSmartInsertDeleteEnabled());
3135         return;
3136     }
3137     if (item.action() == ContextMenuItemTagSmartQuotes) {
3138         TextChecker::setAutomaticQuoteSubstitutionEnabled(!TextChecker::state().isAutomaticQuoteSubstitutionEnabled);
3139         process()->updateTextCheckerState();
3140         return;
3141     }
3142     if (item.action() == ContextMenuItemTagSmartDashes) {
3143         TextChecker::setAutomaticDashSubstitutionEnabled(!TextChecker::state().isAutomaticDashSubstitutionEnabled);
3144         process()->updateTextCheckerState();
3145         return;
3146     }
3147     if (item.action() == ContextMenuItemTagSmartLinks) {
3148         TextChecker::setAutomaticLinkDetectionEnabled(!TextChecker::state().isAutomaticLinkDetectionEnabled);
3149         process()->updateTextCheckerState();
3150         return;
3151     }
3152     if (item.action() == ContextMenuItemTagTextReplacement) {
3153         TextChecker::setAutomaticTextReplacementEnabled(!TextChecker::state().isAutomaticTextReplacementEnabled);
3154         process()->updateTextCheckerState();
3155         return;
3156     }
3157     if (item.action() == ContextMenuItemTagCorrectSpellingAutomatically) {
3158         TextChecker::setAutomaticSpellingCorrectionEnabled(!TextChecker::state().isAutomaticSpellingCorrectionEnabled);
3159         process()->updateTextCheckerState();
3160         return;        
3161     }
3162     if (item.action() == ContextMenuItemTagShowSubstitutions) {
3163         TextChecker::toggleSubstitutionsPanelIsShowing();
3164         return;
3165     }
3166 #endif
3167     if (item.action() == ContextMenuItemTagDownloadImageToDisk) {
3168         m_process->context()->download(this, KURL(KURL(), m_activeContextMenuHitTestResultData.absoluteImageURL));
3169         return;    
3170     }
3171     if (item.action() == ContextMenuItemTagDownloadLinkToDisk) {
3172         m_process->context()->download(this, KURL(KURL(), m_activeContextMenuHitTestResultData.absoluteLinkURL));
3173         return;
3174     }
3175     if (item.action() == ContextMenuItemTagCheckSpellingWhileTyping) {
3176         TextChecker::setContinuousSpellCheckingEnabled(!TextChecker::state().isContinuousSpellCheckingEnabled);
3177         process()->updateTextCheckerState();
3178         return;
3179     }
3180     if (item.action() == ContextMenuItemTagCheckGrammarWithSpelling) {
3181         TextChecker::setGrammarCheckingEnabled(!TextChecker::state().isGrammarCheckingEnabled);
3182         process()->updateTextCheckerState();
3183         return;
3184     }
3185     if (item.action() == ContextMenuItemTagShowSpellingPanel) {
3186         if (!TextChecker::spellingUIIsShowing())
3187             advanceToNextMisspelling(true);
3188         TextChecker::toggleSpellingUIIsShowing();
3189         return;
3190     }
3191     if (item.action() == ContextMenuItemTagLearnSpelling || item.action() == ContextMenuItemTagIgnoreSpelling)
3192         ++m_pendingLearnOrIgnoreWordMessageCount;
3193
3194 #if ENABLE(TIZEN_WEBKIT_PASTEBOARD)
3195     if (item.action() == ContextMenuItemTagPaste) {
3196         // process paste after getting data from clipboard.
3197         pasteWithClipboard();
3198         return;
3199     }
3200 #endif
3201
3202 #if ENABLE(CONTEXT_MENUS)
3203     process()->send(Messages::WebPage::DidSelectItemFromActiveContextMenu(item), m_pageID);
3204 #endif
3205 }
3206 #endif // ENABLE(CONTEXT_MENUS)
3207
3208 void WebPageProxy::didChooseFilesForOpenPanel(const Vector<String>& fileURLs)
3209 {
3210     if (!isValid())
3211         return;
3212
3213 #if ENABLE(WEB_PROCESS_SANDBOX)
3214     // FIXME: The sandbox extensions should be sent with the DidChooseFilesForOpenPanel message. This
3215     // is gated on a way of passing SandboxExtension::Handles in a Vector.
3216     for (size_t i = 0; i < fileURLs.size(); ++i) {
3217         SandboxExtension::Handle sandboxExtensionHandle;
3218         SandboxExtension::createHandle(fileURLs[i], SandboxExtension::ReadOnly, sandboxExtensionHandle);
3219         process()->send(Messages::WebPage::ExtendSandboxForFileFromOpenPanel(sandboxExtensionHandle), m_pageID);
3220     }
3221 #endif
3222
3223     process()->send(Messages::WebPage::DidChooseFilesForOpenPanel(fileURLs), m_pageID);
3224
3225     m_openPanelResultListener->invalidate();
3226     m_openPanelResultListener = 0;
3227 }
3228
3229 void WebPageProxy::didCancelForOpenPanel()
3230 {
3231     if (!isValid())
3232         return;
3233
3234     process()->send(Messages::WebPage::DidCancelForOpenPanel(), m_pageID);
3235     
3236     m_openPanelResultListener->invalidate();
3237     m_openPanelResultListener = 0;
3238 }
3239
3240 void WebPageProxy::advanceToNextMisspelling(bool startBeforeSelection) const
3241 {
3242     process()->send(Messages::WebPage::AdvanceToNextMisspelling(startBeforeSelection), m_pageID);
3243 }
3244
3245 void WebPageProxy::changeSpellingToWord(const String& word) const
3246 {
3247     if (word.isEmpty())
3248         return;
3249
3250     process()->send(Messages::WebPage::ChangeSpellingToWord(word), m_pageID);
3251 }
3252
3253 void WebPageProxy::registerEditCommand(PassRefPtr<WebEditCommandProxy> commandProxy, UndoOrRedo undoOrRedo)
3254 {
3255     m_pageClient->registerEditCommand(commandProxy, undoOrRedo);
3256 }
3257
3258 void WebPageProxy::addEditCommand(WebEditCommandProxy* command)
3259 {
3260     m_editCommandSet.add(command);
3261 }
3262
3263 void WebPageProxy::removeEditCommand(WebEditCommandProxy* command)
3264 {
3265     m_editCommandSet.remove(command);
3266
3267     if (!isValid())
3268         return;
3269     process()->send(Messages::WebPage::DidRemoveEditCommand(command->commandID()), m_pageID);
3270 }
3271
3272 bool WebPageProxy::isValidEditCommand(WebEditCommandProxy* command)
3273 {
3274     return m_editCommandSet.find(command) != m_editCommandSet.end();
3275 }
3276
3277 int64_t WebPageProxy::spellDocumentTag()
3278 {
3279     if (!m_hasSpellDocumentTag) {
3280         m_spellDocumentTag = TextChecker::uniqueSpellDocumentTag(this);
3281         m_hasSpellDocumentTag = true;
3282     }
3283
3284     return m_spellDocumentTag;
3285 }
3286
3287 #if USE(UNIFIED_TEXT_CHECKING)
3288 void WebPageProxy::checkTextOfParagraph(const String& text, uint64_t checkingTypes, Vector<TextCheckingResult>& results)
3289 {
3290     results = TextChecker::checkTextOfParagraph(spellDocumentTag(), text.characters(), text.length(), checkingTypes);
3291 }
3292 #endif
3293
3294 void WebPageProxy::checkSpellingOfString(const String& text, int32_t& misspellingLocation, int32_t& misspellingLength)
3295 {
3296     TextChecker::checkSpellingOfString(spellDocumentTag(), text.characters(), text.length(), misspellingLocation, misspellingLength);
3297 }
3298
3299 void WebPageProxy::checkGrammarOfString(const String& text, Vector<GrammarDetail>& grammarDetails, int32_t& badGrammarLocation, int32_t& badGrammarLength)
3300 {
3301     TextChecker::checkGrammarOfString(spellDocumentTag(), text.characters(), text.length(), grammarDetails, badGrammarLocation, badGrammarLength);
3302 }
3303
3304 void WebPageProxy::spellingUIIsShowing(bool& isShowing)
3305 {
3306     isShowing = TextChecker::spellingUIIsShowing();
3307 }
3308
3309 void WebPageProxy::updateSpellingUIWithMisspelledWord(const String& misspelledWord)
3310 {
3311     TextChecker::updateSpellingUIWithMisspelledWord(spellDocumentTag(), misspelledWord);
3312 }
3313
3314 void WebPageProxy::updateSpellingUIWithGrammarString(const String& badGrammarPhrase, const GrammarDetail& grammarDetail)
3315 {
3316     TextChecker::updateSpellingUIWithGrammarString(spellDocumentTag(), badGrammarPhrase, grammarDetail);
3317 }
3318
3319 void WebPageProxy::getGuessesForWord(const String& word, const String& context, Vector<String>& guesses)
3320 {
3321     TextChecker::getGuessesForWord(spellDocumentTag(), word, context, guesses);
3322 }
3323
3324 void WebPageProxy::learnWord(const String& word)
3325 {
3326     MESSAGE_CHECK(m_pendingLearnOrIgnoreWordMessageCount);
3327     --m_pendingLearnOrIgnoreWordMessageCount;
3328
3329     TextChecker::learnWord(spellDocumentTag(), word);
3330 }
3331
3332 void WebPageProxy::ignoreWord(const String& word)
3333 {
3334     MESSAGE_CHECK(m_pendingLearnOrIgnoreWordMessageCount);
3335     --m_pendingLearnOrIgnoreWordMessageCount;
3336
3337     TextChecker::ignoreWord(spellDocumentTag(), word);
3338 }
3339
3340 // Other
3341
3342 void WebPageProxy::setFocus(bool focused)
3343 {
3344     if (focused)
3345         m_uiClient.focus(this);
3346     else
3347         m_uiClient.unfocus(this);
3348 }
3349
3350 void WebPageProxy::takeFocus(uint32_t direction)
3351 {
3352     m_uiClient.takeFocus(this, (static_cast<FocusDirection>(direction) == FocusDirectionForward) ? kWKFocusDirectionForward : kWKFocusDirectionBackward);
3353 }
3354
3355 void WebPageProxy::setToolTip(const String& toolTip)
3356 {
3357     String oldToolTip = m_toolTip;
3358     m_toolTip = toolTip;
3359     m_pageClient->toolTipChanged(oldToolTip, m_toolTip);
3360 }
3361
3362 void WebPageProxy::setCursor(const WebCore::Cursor& cursor)
3363 {
3364     m_pageClient->setCursor(cursor);
3365 }
3366
3367 void WebPageProxy::setCursorHiddenUntilMouseMoves(bool hiddenUntilMouseMoves)
3368 {
3369     m_pageClient->setCursorHiddenUntilMouseMoves(hiddenUntilMouseMoves);
3370 }
3371
3372 void WebPageProxy::didReceiveEvent(uint32_t opaqueType, bool handled)
3373 {
3374     WebEvent::Type type = static_cast<WebEvent::Type>(opaqueType);
3375
3376     switch (type) {
3377     case WebEvent::NoType:
3378     case WebEvent::MouseMove:
3379         break;
3380
3381     case WebEvent::MouseDown:
3382     case WebEvent::MouseUp:
3383     case WebEvent::Wheel:
3384     case WebEvent::KeyDown:
3385     case WebEvent::KeyUp:
3386     case WebEvent::RawKeyDown:
3387     case WebEvent::Char:
3388 #if ENABLE(GESTURE_EVENTS)
3389     case WebEvent::GestureScrollBegin:
3390     case WebEvent::GestureScrollEnd:
3391     case WebEvent::GestureSingleTap:
3392 #endif
3393 #if ENABLE(TOUCH_EVENTS)
3394     case WebEvent::TouchStart:
3395     case WebEvent::TouchMove:
3396     case WebEvent::TouchEnd:
3397     case WebEvent::TouchCancel:
3398 #endif
3399         process()->responsivenessTimer()->stop();
3400         break;
3401     }
3402
3403     switch (type) {
3404     case WebEvent::NoType:
3405         break;
3406     case WebEvent::MouseMove:
3407         m_processingMouseMoveEvent = false;
3408         if (m_nextMouseMoveEvent) {
3409             handleMouseEvent(*m_nextMouseMoveEvent);
3410             m_nextMouseMoveEvent = nullptr;
3411         }
3412         break;
3413     case WebEvent::MouseDown:
3414         break;
3415 #if ENABLE(GESTURE_EVENTS)
3416     case WebEvent::GestureScrollBegin:
3417     case WebEvent::GestureScrollEnd:
3418     case WebEvent::GestureSingleTap: {
3419         WebGestureEvent event = m_gestureEventQueue.first();
3420         MESSAGE_CHECK(type == event.type());
3421
3422         m_gestureEventQueue.removeFirst();
3423         m_pageClient->doneWithGestureEvent(event, handled);
3424         break;
3425     }
3426 #endif
3427     case WebEvent::MouseUp:
3428         m_currentlyProcessedMouseDownEvent = nullptr;
3429         break;
3430
3431     case WebEvent::Wheel: {
3432         ASSERT(!m_currentlyProcessedWheelEvents.isEmpty());
3433
3434         OwnPtr<Vector<NativeWebWheelEvent> > oldestCoalescedEvent = m_currentlyProcessedWheelEvents.takeFirst();
3435
3436         // FIXME: Dispatch additional events to the didNotHandleWheelEvent client function.
3437         if (!handled && m_uiClient.implementsDidNotHandleWheelEvent())
3438             m_uiClient.didNotHandleWheelEvent(this, oldestCoalescedEvent->last());
3439
3440         if (!m_wheelEventQueue.isEmpty())
3441             processNextQueuedWheelEvent();
3442         break;
3443     }
3444
3445     case WebEvent::KeyDown:
3446     case WebEvent::KeyUp:
3447     case WebEvent::RawKeyDown:
3448     case WebEvent::Char: {
3449         LOG(KeyHandling, "WebPageProxy::didReceiveEvent: %s", webKeyboardEventTypeString(type));
3450
3451         NativeWebKeyboardEvent event = m_keyEventQueue.first();
3452         MESSAGE_CHECK(type == event.type());
3453
3454         m_keyEventQueue.removeFirst();
3455
3456         m_pageClient->doneWithKeyEvent(event, handled);
3457
3458         if (handled)
3459             break;
3460
3461         if (m_uiClient.implementsDidNotHandleKeyEvent())
3462             m_uiClient.didNotHandleKeyEvent(this, event);
3463 #if PLATFORM(WIN)
3464         else
3465             ::TranslateMessage(event.nativeEvent());
3466 #endif
3467         break;
3468     }
3469 #if ENABLE(TOUCH_EVENTS)
3470     case WebEvent::TouchStart:
3471     case WebEvent::TouchMove:
3472     case WebEvent::TouchEnd:
3473     case WebEvent::TouchCancel: {
3474         QueuedTouchEvents queuedEvents = m_touchEventQueue.first();
3475         MESSAGE_CHECK(type == queuedEvents.forwardedEvent.type());
3476         m_touchEventQueue.removeFirst();
3477
3478         m_pageClient->doneWithTouchEvent(queuedEvents.forwardedEvent, handled);
3479         for (size_t i = 0; i < queuedEvents.deferredTouchEvents.size(); ++i) {
3480             bool isEventHandled = false;
3481             m_pageClient->doneWithTouchEvent(queuedEvents.deferredTouchEvents.at(i), isEventHandled);
3482         }
3483         break;
3484     }
3485 #endif
3486     }
3487 }
3488
3489 void WebPageProxy::stopResponsivenessTimer()
3490 {
3491     process()->responsivenessTimer()->stop();
3492 }
3493
3494 void WebPageProxy::voidCallback(uint64_t callbackID)
3495 {
3496     RefPtr<VoidCallback> callback = m_voidCallbacks.take(callbackID);
3497     if (!callback) {
3498         // FIXME: Log error or assert.
3499         return;
3500     }
3501
3502     callback->performCallback();
3503 }
3504
3505 void WebPageProxy::dataCallback(const CoreIPC::DataReference& dataReference, uint64_t callbackID)
3506 {
3507     RefPtr<DataCallback> callback = m_dataCallbacks.take(callbackID);
3508     if (!callback) {
3509         // FIXME: Log error or assert.
3510         return;
3511     }
3512
3513     callback->performCallbackWithReturnValue(WebData::create(dataReference.data(), dataReference.size()).get());
3514 }
3515
3516 void WebPageProxy::stringCallback(const String& resultString, uint64_t callbackID)
3517 {
3518     RefPtr<StringCallback> callback = m_stringCallbacks.take(callbackID);
3519     if (!callback) {
3520         // FIXME: Log error or assert.
3521         // this can validly happen if a load invalidated the callback, though
3522         return;
3523     }
3524
3525     m_loadDependentStringCallbackIDs.remove(callbackID);
3526
3527     callback->performCallbackWithReturnValue(resultString.impl());
3528 }
3529
3530 void WebPageProxy::scriptValueCallback(const CoreIPC::DataReference& dataReference, uint64_t callbackID)
3531 {
3532     RefPtr<ScriptValueCallback> callback = m_scriptValueCallbacks.take(callbackID);
3533     if (!callback) {
3534         // FIXME: Log error or assert.
3535         return;
3536     }
3537
3538     Vector<uint8_t> data;
3539     data.reserveInitialCapacity(dataReference.size());
3540     data.append(dataReference.data(), dataReference.size());
3541
3542     callback->performCallbackWithReturnValue(data.size() ? WebSerializedScriptValue::adopt(data).get() : 0);
3543 }
3544
3545 void WebPageProxy::computedPagesCallback(const Vector<IntRect>& pageRects, double totalScaleFactorForPrinting, uint64_t callbackID)
3546 {
3547     RefPtr<ComputedPagesCallback> callback = m_computedPagesCallbacks.take(callbackID);
3548     if (!callback) {
3549         // FIXME: Log error or assert.
3550         return;
3551     }
3552
3553     callback->performCallbackWithReturnValue(pageRects, totalScaleFactorForPrinting);
3554 }
3555
3556 void WebPageProxy::validateCommandCallback(const String& commandName, bool isEnabled, int state, uint64_t callbackID)
3557 {
3558     RefPtr<ValidateCommandCallback> callback = m_validateCommandCallbacks.take(callbackID);
3559     if (!callback) {
3560         // FIXME: Log error or assert.
3561         return;
3562     }
3563
3564     callback->performCallbackWithReturnValue(commandName.impl(), isEnabled, state);
3565 }
3566
3567 #if PLATFORM(GTK)
3568 void WebPageProxy::printFinishedCallback(const ResourceError& printError, uint64_t callbackID)
3569 {
3570     RefPtr<PrintFinishedCallback> callback = m_printFinishedCallbacks.take(callbackID);
3571     if (!callback) {
3572         // FIXME: Log error or assert.
3573         return;
3574     }
3575
3576     RefPtr<WebError> error = WebError::create(printError);
3577     callback->performCallbackWithReturnValue(error.get());
3578 }
3579 #endif
3580
3581 void WebPageProxy::focusedFrameChanged(uint64_t frameID)
3582 {
3583     if (!frameID) {
3584         m_focusedFrame = 0;
3585         return;
3586     }
3587
3588     WebFrameProxy* frame = process()->webFrame(frameID);
3589     MESSAGE_CHECK(frame);
3590
3591     m_focusedFrame = frame;
3592 }
3593
3594 void WebPageProxy::frameSetLargestFrameChanged(uint64_t frameID)
3595 {
3596     if (!frameID) {
3597         m_frameSetLargestFrame = 0;
3598         return;
3599     }
3600
3601     WebFrameProxy* frame = process()->webFrame(frameID);
3602     MESSAGE_CHECK(frame);
3603
3604     m_frameSetLargestFrame = frame;
3605 }
3606
3607 void WebPageProxy::processDidBecomeUnresponsive()
3608 {
3609     if (!isValid())
3610         return;
3611
3612     updateBackingStoreDiscardableState();
3613
3614     m_loaderClient.processDidBecomeUnresponsive(this);
3615 }
3616
3617 void WebPageProxy::interactionOccurredWhileProcessUnresponsive()
3618 {
3619     if (!isValid())
3620         return;
3621
3622     m_loaderClient.interactionOccurredWhileProcessUnresponsive(this);
3623 }
3624
3625 void WebPageProxy::processDidBecomeResponsive()
3626 {
3627     if (!isValid())
3628         return;
3629     
3630     updateBackingStoreDiscardableState();
3631
3632     m_loaderClient.processDidBecomeResponsive(this);
3633 }
3634
3635 void WebPageProxy::processDidCrash()
3636 {
3637     ASSERT(m_pageClient);
3638
3639     m_isValid = false;
3640     m_isPageSuspended = false;
3641
3642     if (m_mainFrame) {
3643         m_urlAtProcessExit = m_mainFrame->url();
3644         m_loadStateAtProcessExit = m_mainFrame->loadState();
3645     }
3646
3647     m_mainFrame = nullptr;
3648     m_drawingArea = nullptr;
3649
3650 #if ENABLE(INSPECTOR)
3651     if (m_inspector) {
3652         m_inspector->invalidate();
3653         m_inspector = nullptr;
3654     }
3655 #endif
3656
3657 #if ENABLE(FULLSCREEN_API)
3658     if (m_fullScreenManager) {
3659         m_fullScreenManager->invalidate();
3660         m_fullScreenManager = nullptr;
3661     }
3662 #endif
3663
3664     if (m_openPanelResultListener) {
3665         m_openPanelResultListener->invalidate();
3666         m_openPanelResultListener = nullptr;
3667     }
3668
3669 #if ENABLE(INPUT_TYPE_COLOR)
3670     if (m_colorChooser) {
3671         m_colorChooser->invalidate();
3672         m_colorChooser = nullptr;
3673     }
3674 #endif
3675
3676 #if ENABLE(GEOLOCATION)
3677     m_geolocationPermissionRequestManager.invalidateRequests();
3678 #endif
3679
3680     m_notificationPermissionRequestManager.invalidateRequests();
3681
3682     m_toolTip = String();
3683
3684     m_mainFrameHasHorizontalScrollbar = false;
3685     m_mainFrameHasVerticalScrollbar = false;
3686
3687     m_mainFrameIsPinnedToLeftSide = false;
3688     m_mainFrameIsPinnedToRightSide = false;
3689
3690     m_visibleScrollerThumbRect = IntRect();
3691
3692 #if ENABLE(TIZEN_SUPPORT_WEBAPP_META_TAG)
3693     invalidateCallbackMap(m_booleanCallbacks);
3694 #endif
3695     invalidateCallbackMap(m_voidCallbacks);
3696     invalidateCallbackMap(m_dataCallbacks);
3697     invalidateCallbackMap(m_stringCallbacks);
3698     m_loadDependentStringCallbackIDs.clear();
3699     invalidateCallbackMap(m_scriptValueCallbacks);
3700     invalidateCallbackMap(m_computedPagesCallbacks);
3701     invalidateCallbackMap(m_validateCommandCallbacks);
3702 #if PLATFORM(GTK)
3703     invalidateCallbackMap(m_printFinishedCallbacks);
3704 #endif
3705
3706     Vector<WebEditCommandProxy*> editCommandVector;
3707     copyToVector(m_editCommandSet, editCommandVector);
3708     m_editCommandSet.clear();
3709     for (size_t i = 0, size = editCommandVector.size(); i < size; ++i)
3710         editCommandVector[i]->invalidate();
3711     m_pageClient->clearAllEditCommands();
3712
3713     m_activePopupMenu = 0;
3714
3715     m_estimatedProgress = 0.0;
3716
3717     m_pendingLearnOrIgnoreWordMessageCount = 0;
3718
3719     m_pageClient->processDidCrash();
3720     m_loaderClient.processDidCrash(this);
3721
3722     if (!m_isValid) {
3723         // If the call out to the loader client didn't cause the web process to be relaunched, 
3724         // we'll call setNeedsDisplay on the view so that we won't have the old contents showing.
3725         // If the call did cause the web process to be relaunched, we'll keep the old page contents showing
3726         // until the new web process has painted its contents.
3727         setViewNeedsDisplay(IntRect(IntPoint(), viewSize()));
3728     }
3729
3730     // Can't expect DidReceiveEvent notifications from a crashed web process.
3731     m_keyEventQueue.clear();
3732     
3733     m_wheelEventQueue.clear();
3734     m_currentlyProcessedWheelEvents.clear();
3735
3736     m_nextMouseMoveEvent = nullptr;
3737     m_currentlyProcessedMouseDownEvent = nullptr;
3738
3739     m_processingMouseMoveEvent = false;
3740
3741 #if ENABLE(TOUCH_EVENTS)
3742     m_needTouchEvents = false;
3743     m_touchEventQueue.clear();
3744 #endif
3745
3746 #if PLATFORM(MAC) && !defined(BUILDING_ON_SNOW_LEOPARD)
3747     dismissCorrectionPanel(ReasonForDismissingAlternativeTextIgnored);
3748     m_pageClient->dismissDictionaryLookupPanel();
3749 #endif
3750 }
3751
3752 WebPageCreationParameters WebPageProxy::creationParameters() const
3753 {
3754     WebPageCreationParameters parameters;
3755
3756     parameters.viewSize = m_pageClient->viewSize();
3757     parameters.isActive = m_pageClient->isViewWindowActive();
3758     parameters.isFocused = m_pageClient->isViewFocused();
3759     parameters.isVisible = m_pageClient->isViewVisible();
3760     parameters.isInWindow = m_pageClient->isViewInWindow();
3761     parameters.drawingAreaType = m_drawingArea->type();
3762     parameters.store = m_pageGroup->preferences()->store();
3763     parameters.pageGroupData = m_pageGroup->data();
3764     parameters.drawsBackground = m_drawsBackground;
3765     parameters.drawsTransparentBackground = m_drawsTransparentBackground;
3766     parameters.areMemoryCacheClientCallsEnabled = m_areMemoryCacheClientCallsEnabled;
3767     parameters.useFixedLayout = m_useFixedLayout;
3768     parameters.fixedLayoutSize = m_fixedLayoutSize;
3769     parameters.paginationMode = m_paginationMode;
3770     parameters.paginationBehavesLikeColumns = m_paginationBehavesLikeColumns;
3771     parameters.pageLength = m_pageLength;
3772     parameters.gapBetweenPages = m_gapBetweenPages;
3773     parameters.userAgent = userAgent();
3774     parameters.sessionState = SessionState(m_backForwardList->entries(), m_backForwardList->currentIndex());
3775     parameters.highestUsedBackForwardItemID = WebBackForwardListItem::highedUsedItemID();
3776     parameters.canRunBeforeUnloadConfirmPanel = m_uiClient.canRunBeforeUnloadConfirmPanel();
3777     parameters.canRunModal = m_uiClient.canRunModal();
3778     parameters.deviceScaleFactor = m_intrinsicDeviceScaleFactor;
3779     parameters.mediaVolume = m_mediaVolume;
3780
3781 #if PLATFORM(MAC)
3782     parameters.isSmartInsertDeleteEnabled = m_isSmartInsertDeleteEnabled;
3783     parameters.layerHostingMode = m_layerHostingMode;
3784 #endif
3785
3786 #if PLATFORM(WIN)
3787     parameters.nativeWindow = m_pageClient->nativeWindow();
3788 #endif
3789     return parameters;
3790 }
3791
3792 #if USE(ACCELERATED_COMPOSITING)
3793 void WebPageProxy::enterAcceleratedCompositingMode(const LayerTreeContext& layerTreeContext)
3794 {
3795     m_pageClient->enterAcceleratedCompositingMode(layerTreeContext);
3796 }
3797
3798 void WebPageProxy::exitAcceleratedCompositingMode()
3799 {
3800     m_pageClient->exitAcceleratedCompositingMode();
3801 }
3802
3803 void WebPageProxy::updateAcceleratedCompositingMode(const LayerTreeContext& layerTreeContext)
3804 {
3805     m_pageClient->updateAcceleratedCompositingMode(layerTreeContext);
3806 }
3807 #endif // USE(ACCELERATED_COMPOSITING)
3808
3809 void WebPageProxy::backForwardClear()
3810 {
3811     m_backForwardList->clear();
3812 }
3813
3814 void WebPageProxy::canAuthenticateAgainstProtectionSpaceInFrame(uint64_t frameID, const ProtectionSpace& coreProtectionSpace, bool& canAuthenticate)
3815 {
3816     WebFrameProxy* frame = process()->webFrame(frameID);
3817     MESSAGE_CHECK(frame);
3818
3819     RefPtr<WebProtectionSpace> protectionSpace = WebProtectionSpace::create(coreProtectionSpace);
3820     
3821     canAuthenticate = m_loaderClient.canAuthenticateAgainstProtectionSpaceInFrame(this, frame, protectionSpace.get());
3822 }
3823
3824 void WebPageProxy::didReceiveAuthenticationChallenge(uint64_t frameID, const AuthenticationChallenge& coreChallenge, uint64_t challengeID)
3825 {
3826     WebFrameProxy* frame = process()->webFrame(frameID);
3827     MESSAGE_CHECK(frame);
3828
3829     RefPtr<AuthenticationChallengeProxy> authenticationChallenge = AuthenticationChallengeProxy::create(coreChallenge, challengeID, process());
3830     
3831     m_loaderClient.didReceiveAuthenticationChallengeInFrame(this, frame, authenticationChallenge.get());
3832 }
3833
3834 void WebPageProxy::exceededDatabaseQuota(uint64_t frameID, const String& originIdentifier, const String& databaseName, const String& displayName, uint64_t currentQuota, uint64_t currentOriginUsage, uint64_t currentDatabaseUsage, uint64_t expectedUsage, uint64_t& newQuota)
3835 {
3836     WebFrameProxy* frame = process()->webFrame(frameID);
3837     MESSAGE_CHECK(frame);
3838
3839     RefPtr<WebSecurityOrigin> origin = WebSecurityOrigin::createFromDatabaseIdentifier(originIdentifier);
3840
3841     newQuota = m_uiClient.exceededDatabaseQuota(this, frame, origin.get(), databaseName, displayName, currentQuota, currentOriginUsage, currentDatabaseUsage, expectedUsage);
3842 }
3843
3844 void WebPageProxy::requestGeolocationPermissionForFrame(uint64_t geolocationID, uint64_t frameID, String originIdentifier)
3845 {
3846     WebFrameProxy* frame = process()->webFrame(frameID);
3847     MESSAGE_CHECK(frame);
3848
3849     // FIXME: Geolocation should probably be using toString() as its string representation instead of databaseIdentifier().
3850     RefPtr<WebSecurityOrigin> origin = WebSecurityOrigin::createFromDatabaseIdentifier(originIdentifier);
3851     RefPtr<GeolocationPermissionRequestProxy> request = m_geolocationPermissionRequestManager.createRequest(geolocationID);
3852
3853     if (!m_uiClient.decidePolicyForGeolocationPermissionRequest(this, frame, origin.get(), request.get()))
3854         request->deny();
3855 }
3856
3857 void WebPageProxy::requestNotificationPermission(uint64_t requestID, const String& originString)
3858 {
3859     if (!isRequestIDValid(requestID))
3860         return;
3861
3862     RefPtr<WebSecurityOrigin> origin = WebSecurityOrigin::createFromString(originString);
3863     RefPtr<NotificationPermissionRequest> request = m_notificationPermissionRequestManager.createRequest(requestID);
3864     
3865     if (!m_uiClient.decidePolicyForNotificationPermissionRequest(this, origin.get(), request.get()))
3866         request->deny();
3867 }
3868
3869 void WebPageProxy::showNotification(const String& title, const String& body, const String& iconURL, const String& tag, const String& originString, uint64_t notificationID)
3870 {
3871     m_process->context()->notificationManagerProxy()->show(this, title, body, iconURL, tag, originString, notificationID);
3872 }
3873
3874 #if ENABLE(TIZEN_MEDIA_STREAM)
3875 void WebPageProxy::requestUserMediaPermission(uint64_t requestID)
3876 {
3877     if (!isRequestIDValid(requestID))
3878         return;
3879
3880     RefPtr<UserMediaPermissionRequest> request = m_userMediaPermissionRequestManager.createRequest(requestID);
3881
3882     if (!m_tizenClient.decidePolicyForUserMediaPermissionRequest(this, request.get()))
3883         request->deny();
3884 }
3885 #endif
3886
3887 float WebPageProxy::headerHeight(WebFrameProxy* frame)
3888 {
3889     if (frame->isDisplayingPDFDocument())
3890         return 0;
3891     return m_uiClient.headerHeight(this, frame);
3892 }
3893
3894 float WebPageProxy::footerHeight(WebFrameProxy* frame)
3895 {
3896     if (frame->isDisplayingPDFDocument())
3897         return 0;
3898     return m_uiClient.footerHeight(this, frame);
3899 }
3900
3901 void WebPageProxy::drawHeader(WebFrameProxy* frame, const FloatRect& rect)
3902 {
3903     if (frame->isDisplayingPDFDocument())
3904         return;
3905     m_uiClient.drawHeader(this, frame, rect);
3906 }
3907
3908 void WebPageProxy::drawFooter(WebFrameProxy* frame, const FloatRect& rect)
3909 {
3910     if (frame->isDisplayingPDFDocument())
3911         return;
3912     m_uiClient.drawFooter(this, frame, rect);
3913 }
3914
3915 void WebPageProxy::runModal()
3916 {
3917     // Since runModal() can (and probably will) spin a nested run loop we need to turn off the responsiveness timer.
3918     process()->responsivenessTimer()->stop();
3919
3920     m_uiClient.runModal(this);
3921 }
3922
3923 void WebPageProxy::notifyScrollerThumbIsVisibleInRect(const IntRect& scrollerThumb)
3924 {
3925     m_visibleScrollerThumbRect = scrollerThumb;
3926 }
3927
3928 void WebPageProxy::recommendedScrollbarStyleDidChange(int32_t newStyle)
3929 {
3930 #if PLATFORM(MAC)
3931     m_pageClient->recommendedScrollbarStyleDidChange(newStyle);
3932 #endif
3933 }
3934
3935 void WebPageProxy::didChangeScrollbarsForMainFrame(bool hasHorizontalScrollbar, bool hasVerticalScrollbar)
3936 {
3937     m_mainFrameHasHorizontalScrollbar = hasHorizontalScrollbar;
3938     m_mainFrameHasVerticalScrollbar = hasVerticalScrollbar;
3939
3940     m_pageClient->didChangeScrollbarsForMainFrame();
3941 }
3942
3943 void WebPageProxy::didChangeScrollOffsetPinningForMainFrame(bool pinnedToLeftSide, bool pinnedToRightSide)
3944 {
3945     m_mainFrameIsPinnedToLeftSide = pinnedToLeftSide;
3946     m_mainFrameIsPinnedToRightSide = pinnedToRightSide;
3947 }
3948
3949 void WebPageProxy::didChangePageCount(unsigned pageCount)
3950 {
3951     m_pageCount = pageCount;
3952 }
3953
3954 void WebPageProxy::didFailToInitializePlugin(const String& mimeType)
3955 {
3956     m_loaderClient.didFailToInitializePlugin(this, mimeType);
3957 }
3958
3959 void WebPageProxy::didBlockInsecurePluginVersion(const String& mimeType, const String& urlString)
3960 {
3961     String pluginIdentifier;
3962     String pluginVersion;
3963     String newMimeType = mimeType;
3964
3965 #if PLATFORM(MAC)
3966     PluginModuleInfo plugin = m_process->context()->pluginInfoStore().findPlugin(newMimeType, KURL(KURL(), urlString));
3967
3968     pluginIdentifier = plugin.bundleIdentifier;
3969     pluginVersion = plugin.versionString;
3970 #endif
3971
3972     m_loaderClient.didBlockInsecurePluginVersion(this, newMimeType, pluginIdentifier, pluginVersion);
3973 }
3974
3975 bool WebPageProxy::willHandleHorizontalScrollEvents() const
3976 {
3977     return !m_canShortCircuitHorizontalWheelEvents;
3978 }
3979
3980 void WebPageProxy::didFinishLoadingDataForCustomRepresentation(const String& suggestedFilename, const CoreIPC::DataReference& dataReference)
3981 {
3982     m_pageClient->didFinishLoadingDataForCustomRepresentation(suggestedFilename, dataReference);
3983 }
3984
3985 void WebPageProxy::backForwardRemovedItem(uint64_t itemID)
3986 {
3987     process()->send(Messages::WebPage::DidRemoveBackForwardItem(itemID), m_pageID);
3988 }
3989
3990 void WebPageProxy::beginPrinting(WebFrameProxy* frame, const PrintInfo& printInfo)
3991 {
3992     if (m_isInPrintingMode)
3993         return;
3994
3995     m_isInPrintingMode = true;
3996     process()->send(Messages::WebPage::BeginPrinting(frame->frameID(), printInfo), m_pageID, m_isPerformingDOMPrintOperation ? CoreIPC::DispatchMessageEvenWhenWaitingForSyncReply : 0);
3997 }
3998
3999 void WebPageProxy::endPrinting()
4000 {
4001     if (!m_isInPrintingMode)
4002         return;
4003
4004     m_isInPrintingMode = false;
4005     process()->send(Messages::WebPage::EndPrinting(), m_pageID, m_isPerformingDOMPrintOperation ? CoreIPC::DispatchMessageEvenWhenWaitingForSyncReply : 0);
4006 }
4007
4008 void WebPageProxy::computePagesForPrinting(WebFrameProxy* frame, const PrintInfo& printInfo, PassRefPtr<ComputedPagesCallback> prpCallback)
4009 {
4010     RefPtr<ComputedPagesCallback> callback = prpCallback;
4011     if (!isValid()) {
4012         callback->invalidate();
4013         return;
4014     }
4015
4016     uint64_t callbackID = callback->callbackID();
4017     m_computedPagesCallbacks.set(callbackID, callback.get());
4018     m_isInPrintingMode = true;
4019     process()->send(Messages::WebPage::ComputePagesForPrinting(frame->frameID(), printInfo, callbackID), m_pageID, m_isPerformingDOMPrintOperation ? CoreIPC::DispatchMessageEvenWhenWaitingForSyncReply : 0);
4020 }
4021
4022 #if PLATFORM(MAC) || PLATFORM(WIN)
4023 void WebPageProxy::drawRectToPDF(WebFrameProxy* frame, const PrintInfo& printInfo, const IntRect& rect, PassRefPtr<DataCallback> prpCallback)
4024 {
4025     RefPtr<DataCallback> callback = prpCallback;
4026     if (!isValid()) {
4027         callback->invalidate();
4028         return;
4029     }
4030     
4031     uint64_t callbackID = callback->callbackID();
4032     m_dataCallbacks.set(callbackID, callback.get());
4033     process()->send(Messages::WebPage::DrawRectToPDF(frame->frameID(), printInfo, rect, callbackID), m_pageID, m_isPerformingDOMPrintOperation ? CoreIPC::DispatchMessageEvenWhenWaitingForSyncReply : 0);
4034 }
4035
4036 void WebPageProxy::drawPagesToPDF(WebFrameProxy* frame, const PrintInfo& printInfo, uint32_t first, uint32_t count, PassRefPtr<DataCallback> prpCallback)
4037 {
4038     RefPtr<DataCallback> callback = prpCallback;
4039     if (!isValid()) {
4040         callback->invalidate();
4041         return;
4042     }
4043     
4044     uint64_t callbackID = callback->callbackID();
4045     m_dataCallbacks.set(callbackID, callback.get());
4046     process()->send(Messages::WebPage::DrawPagesToPDF(frame->frameID(), printInfo, first, count, callbackID), m_pageID, m_isPerformingDOMPrintOperation ? CoreIPC::DispatchMessageEvenWhenWaitingForSyncReply : 0);
4047 }
4048 #elif PLATFORM(GTK)
4049 void WebPageProxy::drawPagesForPrinting(WebFrameProxy* frame, const PrintInfo& printInfo, PassRefPtr<PrintFinishedCallback> didPrintCallback)
4050 {
4051     RefPtr<PrintFinishedCallback> callback = didPrintCallback;
4052     if (!isValid()) {
4053         callback->invalidate();
4054         return;
4055     }
4056
4057     uint64_t callbackID = callback->callbackID();
4058     m_printFinishedCallbacks.set(callbackID, callback.get());
4059     m_isInPrintingMode = true;
4060     process()->send(Messages::WebPage::DrawPagesForPrinting(frame->frameID(), printInfo, callbackID), m_pageID, m_isPerformingDOMPrintOperation ? CoreIPC::DispatchMessageEvenWhenWaitingForSyncReply : 0);
4061 }
4062 #endif
4063
4064 void WebPageProxy::flashBackingStoreUpdates(const Vector<IntRect>& updateRects)
4065 {
4066     m_pageClient->flashBackingStoreUpdates(updateRects);
4067 }
4068
4069 void WebPageProxy::updateBackingStoreDiscardableState()
4070 {
4071     ASSERT(isValid());
4072
4073     bool isDiscardable;
4074
4075     if (!process()->responsivenessTimer()->isResponsive())
4076         isDiscardable = false;
4077     else
4078         isDiscardable = !m_pageClient->isViewWindowActive() || !isViewVisible();
4079
4080     m_drawingArea->setBackingStoreIsDiscardable(isDiscardable);
4081 }
4082
4083 Color WebPageProxy::viewUpdatesFlashColor()
4084 {
4085     return Color(0, 200, 255);
4086 }
4087
4088 Color WebPageProxy::backingStoreUpdatesFlashColor()
4089 {
4090     return Color(200, 0, 255);
4091 }
4092
4093 void WebPageProxy::saveDataToFileInDownloadsFolder(const String& suggestedFilename, const String& mimeType, const String& originatingURLString, WebData* data)
4094 {
4095     m_uiClient.saveDataToFileInDownloadsFolder(this, suggestedFilename, mimeType, originatingURLString, data);
4096 }
4097
4098 void WebPageProxy::linkClicked(const String& url, const WebMouseEvent& event)
4099 {
4100     process()->send(Messages::WebPage::LinkClicked(url, event), m_pageID, 0);
4101 }
4102
4103 #if PLATFORM(MAC)
4104
4105 void WebPageProxy::substitutionsPanelIsShowing(bool& isShowing)
4106 {
4107     isShowing = TextChecker::substitutionsPanelIsShowing();
4108 }
4109
4110 #if !defined(BUILDING_ON_SNOW_LEOPARD)
4111 void WebPageProxy::showCorrectionPanel(int32_t panelType, const FloatRect& boundingBoxOfReplacedString, const String& replacedString, const String& replacementString, const Vector<String>& alternativeReplacementStrings)
4112 {
4113     m_pageClient->showCorrectionPanel((AlternativeTextType)panelType, boundingBoxOfReplacedString, replacedString, replacementString, alternativeReplacementStrings);
4114 }
4115
4116 void WebPageProxy::dismissCorrectionPanel(int32_t reason)
4117 {
4118     m_pageClient->dismissCorrectionPanel((ReasonForDismissingAlternativeText)reason);
4119 }
4120
4121 void WebPageProxy::dismissCorrectionPanelSoon(int32_t reason, String& result)
4122 {
4123     result = m_pageClient->dismissCorrectionPanelSoon((ReasonForDismissingAlternativeText)reason);
4124 }
4125
4126 void WebPageProxy::recordAutocorrectionResponse(int32_t responseType, const String& replacedString, const String& replacementString)
4127 {
4128     m_pageClient->recordAutocorrectionResponse((AutocorrectionResponseType)responseType, replacedString, replacementString);
4129 }
4130 #endif // !defined(BUILDING_ON_SNOW_LEOPARD)
4131
4132 void WebPageProxy::handleAlternativeTextUIResult(const String& result)
4133 {
4134 #if !defined(BUILDING_ON_SNOW_LEOPARD)
4135     if (!isClosed())
4136         process()->send(Messages::WebPage::HandleAlternativeTextUIResult(result), m_pageID, 0);
4137 #endif
4138 }
4139 #endif // PLATFORM(MAC)
4140
4141 #if ENABLE(TIZEN_PAGE_VISIBILITY_API)
4142 void WebPageProxy::setPageVisibility(WebCore::PageVisibilityState pageVisibilityState, bool isInitialState)
4143 {
4144     process()->send(Messages::WebPage::SetVisibilityState(static_cast<uint32_t>(pageVisibilityState), isInitialState), m_pageID);
4145 }
4146 #endif
4147
4148 #if ENABLE(TIZEN_WEBKIT2_TILED_AC)
4149 void WebPageProxy::updateLayoutAndScaleIfNeeded()
4150 {
4151     m_pageClient->updateLayoutAndScaleIfNeeded();
4152 }
4153 #endif
4154
4155 #if ENABLE(TIZEN_CERTIFICATE_HANDLING)
4156 void WebPageProxy::decidePolicyForCertificateError(bool isTrusted, const String& url, const String& certificate, int error, bool& canContinue)
4157 {
4158     canContinue = m_tizenClient.decidePolicyForCertificateError(this, isTrusted, url, certificate, error);
4159 }
4160 #endif
4161
4162 } // namespace WebKit