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