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