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