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