Fix keypad of previous tap issue
[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)
1263     if (event.type() == WebEvent::GestureSingleTap) {
1264         InputMethodContextEfl* inputMethodContext = static_cast<PageClientImpl*>(m_pageClient)->viewImpl()->inputMethodContext();
1265         if (inputMethodContext)
1266             inputMethodContext->resetIMFContext();
1267     }
1268 #endif
1269
1270 #if ENABLE(TIZEN_WEBKIT2_ROTATION_WHILE_JAVASCRIPT_POPUP)
1271     if (!isWaitingForJavaScriptPopupReply()) {
1272         m_gestureEventQueue.append(event);
1273
1274         process()->responsivenessTimer()->start();
1275         process()->send(Messages::EventDispatcher::GestureEvent(m_pageID, event), 0);
1276     } else {
1277         if (m_gestureEventQueue.isEmpty()) {
1278             bool isEventHandled = false;
1279             m_pageClient->doneWithGestureEvent(event, isEventHandled);
1280         } else {
1281             QueuedUIEvents<WebGestureEvent>& lastEvent = m_gestureEventQueue.last();
1282             lastEvent.deferredEvents.append(event);
1283         }
1284     }
1285 #else
1286     m_gestureEventQueue.append(event);
1287
1288     process()->responsivenessTimer()->start();
1289     process()->send(Messages::EventDispatcher::GestureEvent(m_pageID, event), 0);
1290 #endif
1291 }
1292 #endif
1293
1294 #if ENABLE(TOUCH_EVENTS)
1295 #if PLATFORM(QT)
1296 void WebPageProxy::handlePotentialActivation(const IntPoint& touchPoint, const IntSize& touchArea)
1297 {
1298     process()->send(Messages::WebPage::HighlightPotentialActivation(touchPoint, touchArea), m_pageID);
1299 }
1300 #endif
1301
1302 void WebPageProxy::handleTouchEvent(const NativeWebTouchEvent& event)
1303 {
1304 #if ENABLE(TIZEN_WEBKIT2_NOTIFY_SUSPEND_BY_REMOTE_WEB_INSPECTOR)
1305     if (!isValid() || isContentSuspendedByInspector())
1306 #else
1307     if (!isValid())
1308 #endif
1309         return;
1310
1311     // If the page is suspended, which should be the case during panning, pinching
1312     // and animation on the page itself (kinetic scrolling, tap to zoom) etc, then
1313     // we do not send any of the events to the page even if is has listeners.
1314 #if ENABLE(TIZEN_WEBKIT2_ROTATION_WHILE_JAVASCRIPT_POPUP)
1315     if (m_needTouchEvents && !m_isPageSuspended && !isWaitingForJavaScriptPopupReply()) {
1316 #else
1317     if (m_needTouchEvents && !m_isPageSuspended) {
1318 #endif
1319 #if OS(TIZEN)
1320         // Do not send the TouchMove event if last TouchMove is not processed yet.
1321         // TouchMove event will be sent too many times without below codes,
1322         // and it will affect Web Applications' performance.
1323         if (event.type() == WebEvent::TouchMove
1324             && !m_touchEventQueue.isEmpty()
1325             && m_touchEventQueue.last().forwardedEvent.type() == event.type())
1326             return;
1327 #endif
1328         m_touchEventQueue.append(event);
1329         process()->responsivenessTimer()->start();
1330         if (m_shouldSendEventsSynchronously) {
1331             bool handled = false;
1332             process()->sendSync(Messages::WebPage::TouchEventSyncForTesting(event), Messages::WebPage::TouchEventSyncForTesting::Reply(handled), m_pageID);
1333             didReceiveEvent(event.type(), handled);
1334         } else
1335             process()->send(Messages::WebPage::TouchEvent(event), m_pageID);
1336     } else {
1337         if (m_touchEventQueue.isEmpty()) {
1338             bool isEventHandled = false;
1339             m_pageClient->doneWithTouchEvent(event, isEventHandled);
1340         } else {
1341             // We attach the incoming events to the newest queued event so that all
1342             // the events are delivered in the correct order when the event is dequed.
1343 #if ENABLE(TIZEN_WEBKIT2_ROTATION_WHILE_JAVASCRIPT_POPUP)
1344             QueuedUIEvents<NativeWebTouchEvent>& lastEvent = m_touchEventQueue.last();
1345             lastEvent.deferredEvents.append(event);
1346 #else
1347             QueuedTouchEvents& lastEvent = m_touchEventQueue.last();
1348             lastEvent.deferredTouchEvents.append(event);
1349 #endif
1350         }
1351     }
1352 }
1353 #endif
1354
1355 #if ENABLE(SCREEN_ORIENTATION_SUPPORT) && ENABLE(TIZEN_SCREEN_ORIENTATION_SUPPORT)
1356 void WebPageProxy::lockOrientation(int willLockOrientation, bool& result)
1357 {
1358     result = m_pageClient->lockOrientation(willLockOrientation);
1359 }
1360 void WebPageProxy::unlockOrientation()
1361 {
1362     m_pageClient->unlockOrientation();
1363 }
1364 #endif
1365
1366 void WebPageProxy::scrollBy(ScrollDirection direction, ScrollGranularity granularity)
1367 {
1368     if (!isValid())
1369         return;
1370
1371     process()->send(Messages::WebPage::ScrollBy(direction, granularity), m_pageID);
1372 }
1373
1374 void WebPageProxy::centerSelectionInVisibleArea()
1375 {
1376     if (!isValid())
1377         return;
1378
1379     process()->send(Messages::WebPage::CenterSelectionInVisibleArea(), m_pageID);
1380 }
1381
1382 #if ENABLE(TIZEN_DOWNLOAD_ATTRIBUTE)
1383 void WebPageProxy::startDownload(const ResourceRequest& request, const String& /*suggestedName*/)
1384 {
1385     // FIXME: suggestedName need to be passed to provide a suggested destination file name
1386     m_process->context()->download(this, request);
1387 }
1388 #endif
1389
1390 void WebPageProxy::receivedPolicyDecision(PolicyAction action, WebFrameProxy* frame, uint64_t listenerID)
1391 {
1392     if (!isValid())
1393         return;
1394
1395     if (action == PolicyIgnore)
1396         clearPendingAPIRequestURL();
1397
1398     uint64_t downloadID = 0;
1399     if (action == PolicyDownload) {
1400         // Create a download proxy.
1401         DownloadProxy* download = m_process->context()->createDownloadProxy();
1402         downloadID = download->downloadID();
1403 #if PLATFORM(QT) || PLATFORM(EFL)
1404         // Our design does not suppport downloads without a WebPage.
1405         handleDownloadRequest(download);
1406 #endif
1407     }
1408
1409     // If we received a policy decision while in decidePolicyForResponse the decision will
1410     // be sent back to the web process by decidePolicyForResponse.
1411     if (m_inDecidePolicyForResponse) {
1412         m_syncMimeTypePolicyActionIsValid = true;
1413         m_syncMimeTypePolicyAction = action;
1414         m_syncMimeTypePolicyDownloadID = downloadID;
1415         return;
1416     }
1417
1418     // If we received a policy decision while in decidePolicyForNavigationAction the decision will 
1419     // be sent back to the web process by decidePolicyForNavigationAction. 
1420     if (m_inDecidePolicyForNavigationAction) {
1421         m_syncNavigationActionPolicyActionIsValid = true;
1422         m_syncNavigationActionPolicyAction = action;
1423         m_syncNavigationActionPolicyDownloadID = downloadID;
1424         return;
1425     }
1426     
1427     process()->send(Messages::WebPage::DidReceivePolicyDecision(frame->frameID(), listenerID, action, downloadID), m_pageID);
1428 }
1429
1430 String WebPageProxy::pageTitle() const
1431 {
1432     // Return the null string if there is no main frame (e.g. nothing has been loaded in the page yet, WebProcess has
1433     // crashed, page has been closed).
1434     if (!m_mainFrame)
1435         return String();
1436
1437     return m_mainFrame->title();
1438 }
1439
1440 void WebPageProxy::setUserAgent(const String& userAgent)
1441 {
1442     if (m_userAgent == userAgent)
1443         return;
1444     m_userAgent = userAgent;
1445
1446     if (!isValid())
1447         return;
1448     process()->send(Messages::WebPage::SetUserAgent(m_userAgent), m_pageID);
1449 }
1450
1451 void WebPageProxy::setApplicationNameForUserAgent(const String& applicationName)
1452 {
1453     if (m_applicationNameForUserAgent == applicationName)
1454         return;
1455
1456     m_applicationNameForUserAgent = applicationName;
1457     if (!m_customUserAgent.isEmpty())
1458         return;
1459
1460     setUserAgent(standardUserAgent(m_applicationNameForUserAgent));
1461 }
1462
1463 void WebPageProxy::setCustomUserAgent(const String& customUserAgent)
1464 {
1465     if (m_customUserAgent == customUserAgent)
1466         return;
1467
1468     m_customUserAgent = customUserAgent;
1469
1470     if (m_customUserAgent.isEmpty()) {
1471         setUserAgent(standardUserAgent(m_applicationNameForUserAgent));
1472         return;
1473     }
1474
1475     setUserAgent(m_customUserAgent);
1476 }
1477
1478 void WebPageProxy::resumeActiveDOMObjectsAndAnimations()
1479 {
1480     if (!isValid() || !m_isPageSuspended)
1481         return;
1482
1483     m_isPageSuspended = false;
1484
1485     process()->send(Messages::WebPage::ResumeActiveDOMObjectsAndAnimations(), m_pageID);
1486 }
1487
1488 void WebPageProxy::suspendActiveDOMObjectsAndAnimations()
1489 {
1490     if (!isValid() || m_isPageSuspended)
1491         return;
1492
1493     m_isPageSuspended = true;
1494
1495     process()->send(Messages::WebPage::SuspendActiveDOMObjectsAndAnimations(), m_pageID);
1496 }
1497
1498 bool WebPageProxy::supportsTextEncoding() const
1499 {
1500     return !m_mainFrameHasCustomRepresentation && m_mainFrame && !m_mainFrame->isDisplayingStandaloneImageDocument();
1501 }
1502
1503 void WebPageProxy::setCustomTextEncodingName(const String& encodingName)
1504 {
1505     if (m_customTextEncodingName == encodingName)
1506         return;
1507     m_customTextEncodingName = encodingName;
1508
1509     if (!isValid())
1510         return;
1511     process()->send(Messages::WebPage::SetCustomTextEncodingName(encodingName), m_pageID);
1512 }
1513
1514 void WebPageProxy::terminateProcess()
1515 {
1516     // NOTE: This uses a check of m_isValid rather than calling isValid() since
1517     // we want this to run even for pages being closed or that already closed.
1518     if (!m_isValid)
1519         return;
1520
1521     process()->terminate();
1522 }
1523
1524 #if !USE(CF) || defined(BUILDING_QT__)
1525 PassRefPtr<WebData> WebPageProxy::sessionStateData(WebPageProxySessionStateFilterCallback, void* context) const
1526 {
1527     // FIXME: Return session state data for saving Page state.
1528     return 0;
1529 }
1530
1531 void WebPageProxy::restoreFromSessionStateData(WebData*)
1532 {
1533     // FIXME: Restore the Page from the passed in session state data.
1534 }
1535 #endif
1536
1537 bool WebPageProxy::supportsTextZoom() const
1538 {
1539     if (m_mainFrameHasCustomRepresentation)
1540         return false;
1541
1542     // FIXME: This should also return false for standalone media and plug-in documents.
1543     if (!m_mainFrame || m_mainFrame->isDisplayingStandaloneImageDocument())
1544         return false;
1545
1546     return true;
1547 }
1548  
1549 void WebPageProxy::setTextZoomFactor(double zoomFactor)
1550 {
1551     if (!isValid())
1552         return;
1553
1554     if (m_mainFrameHasCustomRepresentation)
1555         return;
1556
1557     if (m_textZoomFactor == zoomFactor)
1558         return;
1559
1560     m_textZoomFactor = zoomFactor;
1561     process()->send(Messages::WebPage::SetTextZoomFactor(m_textZoomFactor), m_pageID); 
1562 }
1563
1564 double WebPageProxy::pageZoomFactor() const
1565 {
1566     return m_mainFrameHasCustomRepresentation ? m_pageClient->customRepresentationZoomFactor() : m_pageZoomFactor;
1567 }
1568
1569 void WebPageProxy::setPageZoomFactor(double zoomFactor)
1570 {
1571     if (!isValid())
1572         return;
1573
1574     if (m_mainFrameHasCustomRepresentation) {
1575         m_pageClient->setCustomRepresentationZoomFactor(zoomFactor);
1576         return;
1577     }
1578
1579     if (m_pageZoomFactor == zoomFactor)
1580         return;
1581
1582     m_pageZoomFactor = zoomFactor;
1583     process()->send(Messages::WebPage::SetPageZoomFactor(m_pageZoomFactor), m_pageID); 
1584 }
1585
1586 void WebPageProxy::setPageAndTextZoomFactors(double pageZoomFactor, double textZoomFactor)
1587 {
1588     if (!isValid())
1589         return;
1590
1591     if (m_mainFrameHasCustomRepresentation) {
1592         m_pageClient->setCustomRepresentationZoomFactor(pageZoomFactor);
1593         return;
1594     }
1595
1596     if (m_pageZoomFactor == pageZoomFactor && m_textZoomFactor == textZoomFactor)
1597         return;
1598
1599     m_pageZoomFactor = pageZoomFactor;
1600     m_textZoomFactor = textZoomFactor;
1601     process()->send(Messages::WebPage::SetPageAndTextZoomFactors(m_pageZoomFactor, m_textZoomFactor), m_pageID); 
1602 }
1603
1604 void WebPageProxy::scalePage(double scale, const IntPoint& origin)
1605 {
1606     if (!isValid())
1607         return;
1608
1609     process()->send(Messages::WebPage::ScalePage(scale, origin), m_pageID);
1610 }
1611
1612 void WebPageProxy::setIntrinsicDeviceScaleFactor(float scaleFactor)
1613 {
1614     if (m_intrinsicDeviceScaleFactor == scaleFactor)
1615         return;
1616
1617     m_intrinsicDeviceScaleFactor = scaleFactor;
1618
1619     if (m_drawingArea)
1620         m_drawingArea->deviceScaleFactorDidChange();
1621 }
1622
1623 void WebPageProxy::windowScreenDidChange(PlatformDisplayID displayID)
1624 {
1625     if (!isValid())
1626         return;
1627
1628     process()->send(Messages::WebPage::WindowScreenDidChange(displayID), m_pageID);
1629 }
1630
1631 float WebPageProxy::deviceScaleFactor() const
1632 {
1633     if (m_customDeviceScaleFactor)
1634         return m_customDeviceScaleFactor;
1635     return m_intrinsicDeviceScaleFactor;
1636 }
1637
1638 void WebPageProxy::setCustomDeviceScaleFactor(float customScaleFactor)
1639 {
1640     if (!isValid())
1641         return;
1642
1643     if (m_customDeviceScaleFactor == customScaleFactor)
1644         return;
1645
1646     float oldScaleFactor = deviceScaleFactor();
1647
1648     m_customDeviceScaleFactor = customScaleFactor;
1649
1650     if (deviceScaleFactor() != oldScaleFactor)
1651         m_drawingArea->deviceScaleFactorDidChange();
1652 }
1653
1654 void WebPageProxy::setUseFixedLayout(bool fixed)
1655 {
1656     if (!isValid())
1657         return;
1658
1659     // This check is fine as the value is initialized in the web
1660     // process as part of the creation parameters.
1661     if (fixed == m_useFixedLayout)
1662         return;
1663
1664     m_useFixedLayout = fixed;
1665     if (!fixed)
1666         m_fixedLayoutSize = IntSize();
1667     process()->send(Messages::WebPage::SetUseFixedLayout(fixed), m_pageID);
1668 }
1669
1670 void WebPageProxy::setFixedLayoutSize(const IntSize& size)
1671 {
1672     if (!isValid())
1673         return;
1674
1675     if (size == m_fixedLayoutSize)
1676         return;
1677
1678     m_fixedLayoutSize = size;
1679     process()->send(Messages::WebPage::SetFixedLayoutSize(size), m_pageID);
1680 }
1681
1682 void WebPageProxy::setPaginationMode(WebCore::Page::Pagination::Mode mode)
1683 {
1684     if (mode == m_paginationMode)
1685         return;
1686
1687     m_paginationMode = mode;
1688
1689     if (!isValid())
1690         return;
1691     process()->send(Messages::WebPage::SetPaginationMode(mode), m_pageID);
1692 }
1693
1694 void WebPageProxy::setPaginationBehavesLikeColumns(bool behavesLikeColumns)
1695 {
1696     if (behavesLikeColumns == m_paginationBehavesLikeColumns)
1697         return;
1698
1699     m_paginationBehavesLikeColumns = behavesLikeColumns;
1700
1701     if (!isValid())
1702         return;
1703     process()->send(Messages::WebPage::SetPaginationBehavesLikeColumns(behavesLikeColumns), m_pageID);
1704 }
1705
1706 void WebPageProxy::setPageLength(double pageLength)
1707 {
1708     if (pageLength == m_pageLength)
1709         return;
1710
1711     m_pageLength = pageLength;
1712
1713     if (!isValid())
1714         return;
1715     process()->send(Messages::WebPage::SetPageLength(pageLength), m_pageID);
1716 }
1717
1718 void WebPageProxy::setGapBetweenPages(double gap)
1719 {
1720     if (gap == m_gapBetweenPages)
1721         return;
1722
1723     m_gapBetweenPages = gap;
1724
1725     if (!isValid())
1726         return;
1727     process()->send(Messages::WebPage::SetGapBetweenPages(gap), m_pageID);
1728 }
1729
1730 void WebPageProxy::pageScaleFactorDidChange(double scaleFactor)
1731 {
1732     m_pageScaleFactor = scaleFactor;
1733     m_pageClient->pageScaleFactorDidChange();
1734 }
1735
1736 void WebPageProxy::setMemoryCacheClientCallsEnabled(bool memoryCacheClientCallsEnabled)
1737 {
1738     if (!isValid())
1739         return;
1740
1741     if (m_areMemoryCacheClientCallsEnabled == memoryCacheClientCallsEnabled)
1742         return;
1743
1744     m_areMemoryCacheClientCallsEnabled = memoryCacheClientCallsEnabled;
1745     process()->send(Messages::WebPage::SetMemoryCacheMessagesEnabled(memoryCacheClientCallsEnabled), m_pageID);
1746 }
1747
1748 void WebPageProxy::findStringMatches(const String& string, FindOptions options, unsigned maxMatchCount)
1749 {
1750     if (string.isEmpty()) {
1751         didFindStringMatches(string, Vector<Vector<WebCore::IntRect> > (), 0);
1752         return;
1753     }
1754
1755     m_process->send(Messages::WebPage::FindStringMatches(string, options, maxMatchCount), m_pageID);
1756 }
1757
1758 void WebPageProxy::findString(const String& string, FindOptions options, unsigned maxMatchCount)
1759 {
1760     if (m_mainFrameHasCustomRepresentation)
1761         m_pageClient->findStringInCustomRepresentation(string, options, maxMatchCount);
1762     else
1763         process()->send(Messages::WebPage::FindString(string, options, maxMatchCount), m_pageID);
1764 }
1765
1766 void WebPageProxy::getImageForFindMatch(int32_t matchIndex)
1767 {
1768     m_process->send(Messages::WebPage::GetImageForFindMatch(matchIndex), m_pageID);
1769 }
1770
1771 void WebPageProxy::selectFindMatch(int32_t matchIndex)
1772 {
1773     m_process->send(Messages::WebPage::SelectFindMatch(matchIndex), m_pageID);
1774 }
1775
1776 void WebPageProxy::hideFindUI()
1777 {
1778     process()->send(Messages::WebPage::HideFindUI(), m_pageID);
1779 }
1780
1781 void WebPageProxy::countStringMatches(const String& string, FindOptions options, unsigned maxMatchCount)
1782 {
1783     if (m_mainFrameHasCustomRepresentation) {
1784         m_pageClient->countStringMatchesInCustomRepresentation(string, options, maxMatchCount);
1785         return;
1786     }
1787
1788     if (!isValid())
1789         return;
1790
1791     process()->send(Messages::WebPage::CountStringMatches(string, options, maxMatchCount), m_pageID);
1792 }
1793
1794 void WebPageProxy::runJavaScriptInMainFrame(const String& script, PassRefPtr<ScriptValueCallback> prpCallback)
1795 {
1796     RefPtr<ScriptValueCallback> callback = prpCallback;
1797     if (!isValid()) {
1798         callback->invalidate();
1799         return;
1800     }
1801
1802     uint64_t callbackID = callback->callbackID();
1803     m_scriptValueCallbacks.set(callbackID, callback.get());
1804     process()->send(Messages::WebPage::RunJavaScriptInMainFrame(script, callbackID), m_pageID);
1805 }
1806
1807 void WebPageProxy::getRenderTreeExternalRepresentation(PassRefPtr<StringCallback> prpCallback)
1808 {
1809     RefPtr<StringCallback> callback = prpCallback;
1810     if (!isValid()) {
1811         callback->invalidate();
1812         return;
1813     }
1814     
1815     uint64_t callbackID = callback->callbackID();
1816     m_stringCallbacks.set(callbackID, callback.get());
1817     process()->send(Messages::WebPage::GetRenderTreeExternalRepresentation(callbackID), m_pageID);
1818 }
1819
1820 void WebPageProxy::getSourceForFrame(WebFrameProxy* frame, PassRefPtr<StringCallback> prpCallback)
1821 {
1822     RefPtr<StringCallback> callback = prpCallback;
1823     if (!isValid()) {
1824         callback->invalidate();
1825         return;
1826     }
1827     
1828     uint64_t callbackID = callback->callbackID();
1829     m_loadDependentStringCallbackIDs.add(callbackID);
1830     m_stringCallbacks.set(callbackID, callback.get());
1831     process()->send(Messages::WebPage::GetSourceForFrame(frame->frameID(), callbackID), m_pageID);
1832 }
1833
1834 #if ENABLE(WEB_INTENTS)
1835 void WebPageProxy::deliverIntentToFrame(WebFrameProxy* frame, WebIntentData* webIntentData)
1836 {
1837     if (!isValid())
1838         return;
1839
1840     process()->send(Messages::WebPage::DeliverIntentToFrame(frame->frameID(), webIntentData->store()), m_pageID);
1841 }
1842 #endif
1843
1844 void WebPageProxy::getContentsAsString(PassRefPtr<StringCallback> prpCallback)
1845 {
1846     RefPtr<StringCallback> callback = prpCallback;
1847     if (!isValid()) {
1848         callback->invalidate();
1849         return;
1850     }
1851     
1852     uint64_t callbackID = callback->callbackID();
1853     m_loadDependentStringCallbackIDs.add(callbackID);
1854     m_stringCallbacks.set(callbackID, callback.get());
1855     process()->send(Messages::WebPage::GetContentsAsString(callbackID), m_pageID);
1856 }
1857
1858 #if ENABLE(MHTML)
1859 void WebPageProxy::getContentsAsMHTMLData(PassRefPtr<DataCallback> prpCallback, bool useBinaryEncoding)
1860 {
1861     RefPtr<DataCallback> callback = prpCallback;
1862     if (!isValid()) {
1863         callback->invalidate();
1864         return;
1865     }
1866
1867     uint64_t callbackID = callback->callbackID();
1868     m_dataCallbacks.set(callbackID, callback.get());
1869     process()->send(Messages::WebPage::GetContentsAsMHTMLData(callbackID, useBinaryEncoding), m_pageID);
1870 }
1871 #endif
1872
1873 void WebPageProxy::getSelectionOrContentsAsString(PassRefPtr<StringCallback> prpCallback)
1874 {
1875     RefPtr<StringCallback> callback = prpCallback;
1876     if (!isValid()) {
1877         callback->invalidate();
1878         return;
1879     }
1880     
1881     uint64_t callbackID = callback->callbackID();
1882     m_stringCallbacks.set(callbackID, callback.get());
1883     process()->send(Messages::WebPage::GetSelectionOrContentsAsString(callbackID), m_pageID);
1884 }
1885
1886 void WebPageProxy::getMainResourceDataOfFrame(WebFrameProxy* frame, PassRefPtr<DataCallback> prpCallback)
1887 {
1888     RefPtr<DataCallback> callback = prpCallback;
1889     if (!isValid()) {
1890         callback->invalidate();
1891         return;
1892     }
1893     
1894     uint64_t callbackID = callback->callbackID();
1895     m_dataCallbacks.set(callbackID, callback.get());
1896     process()->send(Messages::WebPage::GetMainResourceDataOfFrame(frame->frameID(), callbackID), m_pageID);
1897 }
1898
1899 void WebPageProxy::getResourceDataFromFrame(WebFrameProxy* frame, WebURL* resourceURL, PassRefPtr<DataCallback> prpCallback)
1900 {
1901     RefPtr<DataCallback> callback = prpCallback;
1902     if (!isValid()) {
1903         callback->invalidate();
1904         return;
1905     }
1906     
1907     uint64_t callbackID = callback->callbackID();
1908     m_dataCallbacks.set(callbackID, callback.get());
1909     process()->send(Messages::WebPage::GetResourceDataFromFrame(frame->frameID(), resourceURL->string(), callbackID), m_pageID);
1910 }
1911
1912 void WebPageProxy::getWebArchiveOfFrame(WebFrameProxy* frame, PassRefPtr<DataCallback> prpCallback)
1913 {
1914     RefPtr<DataCallback> callback = prpCallback;
1915     if (!isValid()) {
1916         callback->invalidate();
1917         return;
1918     }
1919     
1920     uint64_t callbackID = callback->callbackID();
1921     m_dataCallbacks.set(callbackID, callback.get());
1922     process()->send(Messages::WebPage::GetWebArchiveOfFrame(frame->frameID(), callbackID), m_pageID);
1923 }
1924
1925 void WebPageProxy::forceRepaint(PassRefPtr<VoidCallback> prpCallback)
1926 {
1927     RefPtr<VoidCallback> callback = prpCallback;
1928     if (!isValid()) {
1929         callback->invalidate();
1930         return;
1931     }
1932
1933     uint64_t callbackID = callback->callbackID();
1934     m_voidCallbacks.set(callbackID, callback.get());
1935     m_drawingArea->waitForBackingStoreUpdateOnNextPaint();
1936     process()->send(Messages::WebPage::ForceRepaint(callbackID), m_pageID); 
1937 }
1938
1939 void WebPageProxy::preferencesDidChange()
1940 {
1941     if (!isValid())
1942         return;
1943
1944 #if ENABLE(INSPECTOR_SERVER)
1945     if (m_pageGroup->preferences()->developerExtrasEnabled())
1946         inspector()->enableRemoteInspection();
1947 #endif
1948
1949     // FIXME: It probably makes more sense to send individual preference changes.
1950     // However, WebKitTestRunner depends on getting a preference change notification
1951     // even if nothing changed in UI process, so that overrides get removed.
1952
1953     // Preferences need to be updated during synchronous printing to make "print backgrounds" preference work when toggled from a print dialog checkbox.
1954     process()->send(Messages::WebPage::PreferencesDidChange(pageGroup()->preferences()->store()), m_pageID, m_isPerformingDOMPrintOperation ? CoreIPC::DispatchMessageEvenWhenWaitingForSyncReply : 0);
1955 }
1956
1957 void WebPageProxy::didReceiveMessage(CoreIPC::Connection* connection, CoreIPC::MessageID messageID, CoreIPC::ArgumentDecoder* arguments)
1958 {
1959     if (messageID.is<CoreIPC::MessageClassDrawingAreaProxy>()) {
1960         m_drawingArea->didReceiveDrawingAreaProxyMessage(connection, messageID, arguments);
1961         return;
1962     }
1963
1964 #if USE(UI_SIDE_COMPOSITING)
1965     if (messageID.is<CoreIPC::MessageClassLayerTreeCoordinatorProxy>()) {
1966         m_drawingArea->didReceiveLayerTreeCoordinatorProxyMessage(connection, messageID, arguments);
1967         return;
1968     }
1969 #endif
1970
1971 #if ENABLE(INSPECTOR)
1972     if (messageID.is<CoreIPC::MessageClassWebInspectorProxy>()) {
1973         if (WebInspectorProxy* inspector = this->inspector())
1974             inspector->didReceiveWebInspectorProxyMessage(connection, messageID, arguments);
1975         return;
1976     }
1977 #endif
1978
1979 #if ENABLE(FULLSCREEN_API)
1980     if (messageID.is<CoreIPC::MessageClassWebFullScreenManagerProxy>()) {
1981         fullScreenManager()->didReceiveMessage(connection, messageID, arguments);
1982         return;
1983     }
1984 #endif
1985
1986     didReceiveWebPageProxyMessage(connection, messageID, arguments);
1987 }
1988
1989 void WebPageProxy::didReceiveSyncMessage(CoreIPC::Connection* connection, CoreIPC::MessageID messageID, CoreIPC::ArgumentDecoder* arguments, OwnPtr<CoreIPC::ArgumentEncoder>& reply)
1990 {
1991 #if ENABLE(INSPECTOR)
1992     if (messageID.is<CoreIPC::MessageClassWebInspectorProxy>()) {
1993         if (WebInspectorProxy* inspector = this->inspector())
1994             inspector->didReceiveSyncWebInspectorProxyMessage(connection, messageID, arguments, reply);
1995         return;
1996     }
1997 #endif
1998
1999 #if ENABLE(FULLSCREEN_API)
2000     if (messageID.is<CoreIPC::MessageClassWebFullScreenManagerProxy>()) {
2001         fullScreenManager()->didReceiveSyncMessage(connection, messageID, arguments, reply);
2002         return;
2003     }
2004 #endif
2005
2006     // FIXME: Do something with reply.
2007     didReceiveSyncWebPageProxyMessage(connection, messageID, arguments, reply);
2008 }
2009
2010 void WebPageProxy::didCreateMainFrame(uint64_t frameID)
2011 {
2012     MESSAGE_CHECK(!m_mainFrame);
2013     MESSAGE_CHECK(process()->canCreateFrame(frameID));
2014
2015     m_mainFrame = WebFrameProxy::create(this, frameID);
2016
2017     // Add the frame to the process wide map.
2018     process()->frameCreated(frameID, m_mainFrame.get());
2019 }
2020
2021 void WebPageProxy::didCreateSubframe(uint64_t frameID, uint64_t parentFrameID)
2022 {
2023     MESSAGE_CHECK(m_mainFrame);
2024
2025     WebFrameProxy* parentFrame = process()->webFrame(parentFrameID);
2026     MESSAGE_CHECK(parentFrame);
2027     MESSAGE_CHECK(parentFrame->isDescendantOf(m_mainFrame.get()));
2028
2029     MESSAGE_CHECK(process()->canCreateFrame(frameID));
2030     
2031     RefPtr<WebFrameProxy> subFrame = WebFrameProxy::create(this, frameID);
2032
2033     // Add the frame to the process wide map.
2034     process()->frameCreated(frameID, subFrame.get());
2035
2036     // Insert the frame into the frame hierarchy.
2037     parentFrame->appendChild(subFrame.get());
2038 }
2039
2040 static bool isDisconnectedFrame(WebFrameProxy* frame)
2041 {
2042     return !frame->page() || !frame->page()->mainFrame() || !frame->isDescendantOf(frame->page()->mainFrame());
2043 }
2044
2045 void WebPageProxy::didSaveFrameToPageCache(uint64_t frameID)
2046 {
2047     MESSAGE_CHECK(m_mainFrame);
2048
2049     WebFrameProxy* subframe = process()->webFrame(frameID);
2050     MESSAGE_CHECK(subframe);
2051
2052     if (isDisconnectedFrame(subframe))
2053         return;
2054
2055     MESSAGE_CHECK(subframe->isDescendantOf(m_mainFrame.get()));
2056
2057     subframe->didRemoveFromHierarchy();
2058 }
2059
2060 void WebPageProxy::didRestoreFrameFromPageCache(uint64_t frameID, uint64_t parentFrameID)
2061 {
2062     MESSAGE_CHECK(m_mainFrame);
2063
2064     WebFrameProxy* subframe = process()->webFrame(frameID);
2065     MESSAGE_CHECK(subframe);
2066     MESSAGE_CHECK(!subframe->parentFrame());
2067     MESSAGE_CHECK(subframe->page() == m_mainFrame->page());
2068
2069     WebFrameProxy* parentFrame = process()->webFrame(parentFrameID);
2070     MESSAGE_CHECK(parentFrame);
2071     MESSAGE_CHECK(parentFrame->isDescendantOf(m_mainFrame.get()));
2072
2073     // Insert the frame into the frame hierarchy.
2074     parentFrame->appendChild(subframe);
2075 }
2076
2077
2078 // Always start progress at initialProgressValue. This helps provide feedback as
2079 // soon as a load starts.
2080
2081 static const double initialProgressValue = 0.1;
2082
2083 double WebPageProxy::estimatedProgress() const
2084 {
2085     if (!pendingAPIRequestURL().isNull())
2086         return initialProgressValue;
2087     return m_estimatedProgress; 
2088 }
2089
2090 void WebPageProxy::didStartProgress()
2091 {
2092     m_estimatedProgress = initialProgressValue;
2093
2094     m_loaderClient.didStartProgress(this);
2095 }
2096
2097 void WebPageProxy::didChangeProgress(double value)
2098 {
2099     m_estimatedProgress = value;
2100
2101     m_loaderClient.didChangeProgress(this);
2102 }
2103
2104 void WebPageProxy::didFinishProgress()
2105 {
2106     m_estimatedProgress = 1.0;
2107
2108     m_loaderClient.didFinishProgress(this);
2109 }
2110
2111 #if ENABLE(WEB_INTENTS_TAG)
2112 void WebPageProxy::registerIntentServiceForFrame(uint64_t frameID, const IntentServiceInfo& serviceInfo, CoreIPC::ArgumentDecoder* arguments)
2113 {
2114     RefPtr<APIObject> userData;
2115     WebContextUserMessageDecoder messageDecoder(userData, m_process->context());
2116     if (!arguments->decode(messageDecoder))
2117         return;
2118
2119     WebFrameProxy* frame = process()->webFrame(frameID);
2120     MESSAGE_CHECK(frame);
2121
2122     RefPtr<WebIntentServiceInfo> webIntentServiceInfo = WebIntentServiceInfo::create(serviceInfo);
2123     m_loaderClient.registerIntentServiceForFrame(this, frame, webIntentServiceInfo.get(), userData.get());
2124 }
2125 #endif
2126
2127 void WebPageProxy::didStartProvisionalLoadForFrame(uint64_t frameID, const String& url, const String& unreachableURL, CoreIPC::ArgumentDecoder* arguments)
2128 {
2129     clearPendingAPIRequestURL();
2130
2131     RefPtr<APIObject> userData;
2132     WebContextUserMessageDecoder messageDecoder(userData, m_process->context());
2133     if (!arguments->decode(messageDecoder))
2134         return;
2135
2136     WebFrameProxy* frame = process()->webFrame(frameID);
2137     MESSAGE_CHECK(frame);
2138     MESSAGE_CHECK_URL(url);
2139
2140     frame->setUnreachableURL(unreachableURL);
2141
2142     frame->didStartProvisionalLoad(url);
2143     m_loaderClient.didStartProvisionalLoadForFrame(this, frame, userData.get());
2144 }
2145
2146 void WebPageProxy::didReceiveServerRedirectForProvisionalLoadForFrame(uint64_t frameID, const String& url, CoreIPC::ArgumentDecoder* arguments)
2147 {
2148     RefPtr<APIObject> userData;
2149     WebContextUserMessageDecoder messageDecoder(userData, m_process->context());
2150     if (!arguments->decode(messageDecoder))
2151         return;
2152
2153     WebFrameProxy* frame = process()->webFrame(frameID);
2154     MESSAGE_CHECK(frame);
2155     MESSAGE_CHECK_URL(url);
2156
2157     frame->didReceiveServerRedirectForProvisionalLoad(url);
2158
2159     m_loaderClient.didReceiveServerRedirectForProvisionalLoadForFrame(this, frame, userData.get());
2160 }
2161
2162 void WebPageProxy::didFailProvisionalLoadForFrame(uint64_t frameID, const ResourceError& error, CoreIPC::ArgumentDecoder* arguments)
2163 {
2164     RefPtr<APIObject> userData;
2165     WebContextUserMessageDecoder messageDecoder(userData, m_process->context());
2166     if (!arguments->decode(messageDecoder))
2167         return;
2168
2169     WebFrameProxy* frame = process()->webFrame(frameID);
2170     MESSAGE_CHECK(frame);
2171
2172     frame->didFailProvisionalLoad();
2173
2174     m_loaderClient.didFailProvisionalLoadWithErrorForFrame(this, frame, error, userData.get());
2175 }
2176
2177 void WebPageProxy::clearLoadDependentCallbacks()
2178 {
2179     Vector<uint64_t> callbackIDsCopy;
2180     copyToVector(m_loadDependentStringCallbackIDs, callbackIDsCopy);
2181     m_loadDependentStringCallbackIDs.clear();
2182
2183     for (size_t i = 0; i < callbackIDsCopy.size(); ++i) {
2184         RefPtr<StringCallback> callback = m_stringCallbacks.take(callbackIDsCopy[i]);
2185         if (callback)
2186             callback->invalidate();
2187     }
2188 }
2189
2190 void WebPageProxy::didCommitLoadForFrame(uint64_t frameID, const String& mimeType, bool frameHasCustomRepresentation, const PlatformCertificateInfo& certificateInfo, CoreIPC::ArgumentDecoder* arguments)
2191 {
2192     RefPtr<APIObject> userData;
2193     WebContextUserMessageDecoder messageDecoder(userData, m_process->context());
2194     if (!arguments->decode(messageDecoder))
2195         return;
2196
2197     WebFrameProxy* frame = process()->webFrame(frameID);
2198     MESSAGE_CHECK(frame);
2199
2200 #if PLATFORM(MAC)
2201     // FIXME (bug 59111): didCommitLoadForFrame comes too late when restoring a page from b/f cache, making us disable secure event mode in password fields.
2202     // FIXME (bug 59121): A load going on in one frame shouldn't affect typing in sibling frames.
2203     m_pageClient->resetTextInputState();
2204 #if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
2205     // FIXME: Should this be moved inside resetTextInputState()?
2206     dismissCorrectionPanel(ReasonForDismissingAlternativeTextIgnored);
2207     m_pageClient->dismissDictionaryLookupPanel();
2208 #endif
2209 #endif
2210
2211     clearLoadDependentCallbacks();
2212
2213     frame->didCommitLoad(mimeType, certificateInfo);
2214
2215     if (frame->isMainFrame()) {
2216         m_mainFrameHasCustomRepresentation = frameHasCustomRepresentation;
2217
2218         if (m_mainFrameHasCustomRepresentation) {
2219             // Always assume that the main frame is pinned here, since the custom representation view will handle
2220             // any wheel events and dispatch them to the WKView when necessary.
2221             m_mainFrameIsPinnedToLeftSide = true;
2222             m_mainFrameIsPinnedToRightSide = true;
2223         }
2224         m_pageClient->didCommitLoadForMainFrame(frameHasCustomRepresentation);
2225     }
2226
2227     m_loaderClient.didCommitLoadForFrame(this, frame, userData.get());
2228 }
2229
2230 void WebPageProxy::didFinishDocumentLoadForFrame(uint64_t frameID, CoreIPC::ArgumentDecoder* arguments)
2231 {
2232     RefPtr<APIObject> userData;
2233     WebContextUserMessageDecoder messageDecoder(userData, m_process->context());
2234     if (!arguments->decode(messageDecoder))
2235         return;
2236
2237     WebFrameProxy* frame = process()->webFrame(frameID);
2238     MESSAGE_CHECK(frame);
2239
2240     m_loaderClient.didFinishDocumentLoadForFrame(this, frame, userData.get());
2241 }
2242
2243 #if ENABLE(TIZEN_NATIVE_MEMORY_SNAPSHOT)
2244 const char* isMemorySnapshot = getenv("TIZEN_MEMORY_SNAPSHOT");
2245 #endif
2246 void WebPageProxy::didFinishLoadForFrame(uint64_t frameID, CoreIPC::ArgumentDecoder* arguments)
2247 {
2248     RefPtr<APIObject> userData;
2249     WebContextUserMessageDecoder messageDecoder(userData, m_process->context());
2250     if (!arguments->decode(messageDecoder))
2251         return;
2252
2253     WebFrameProxy* frame = process()->webFrame(frameID);
2254     MESSAGE_CHECK(frame);
2255
2256     frame->didFinishLoad();
2257
2258     m_loaderClient.didFinishLoadForFrame(this, frame, userData.get());
2259 #if ENABLE(TIZEN_NATIVE_MEMORY_SNAPSHOT)
2260     if (isMemorySnapshot && isMemorySnapshot[0] != '0')
2261         dumpMemorySnapshot();
2262 #endif
2263 }
2264
2265 void WebPageProxy::didFailLoadForFrame(uint64_t frameID, const ResourceError& error, CoreIPC::ArgumentDecoder* arguments)
2266 {
2267     RefPtr<APIObject> userData;
2268     WebContextUserMessageDecoder messageDecoder(userData, m_process->context());
2269     if (!arguments->decode(messageDecoder))
2270         return;
2271
2272     WebFrameProxy* frame = process()->webFrame(frameID);
2273     MESSAGE_CHECK(frame);
2274
2275     clearLoadDependentCallbacks();
2276
2277     frame->didFailLoad();
2278
2279     m_loaderClient.didFailLoadWithErrorForFrame(this, frame, error, userData.get());
2280 }
2281
2282 void WebPageProxy::didSameDocumentNavigationForFrame(uint64_t frameID, uint32_t opaqueSameDocumentNavigationType, const String& url, CoreIPC::ArgumentDecoder* arguments)
2283 {
2284     RefPtr<APIObject> userData;
2285     WebContextUserMessageDecoder messageDecoder(userData, m_process->context());
2286     if (!arguments->decode(messageDecoder))
2287         return;
2288
2289     WebFrameProxy* frame = process()->webFrame(frameID);
2290     MESSAGE_CHECK(frame);
2291     MESSAGE_CHECK_URL(url);
2292
2293     clearPendingAPIRequestURL();
2294     frame->didSameDocumentNavigation(url);
2295
2296     m_loaderClient.didSameDocumentNavigationForFrame(this, frame, static_cast<SameDocumentNavigationType>(opaqueSameDocumentNavigationType), userData.get());
2297 }
2298
2299 void WebPageProxy::didReceiveTitleForFrame(uint64_t frameID, const String& title, CoreIPC::ArgumentDecoder* arguments)
2300 {
2301     RefPtr<APIObject> userData;
2302     WebContextUserMessageDecoder messageDecoder(userData, m_process->context());
2303     if (!arguments->decode(messageDecoder))
2304         return;
2305
2306     WebFrameProxy* frame = process()->webFrame(frameID);
2307     MESSAGE_CHECK(frame);
2308
2309     frame->didChangeTitle(title);
2310     
2311     m_loaderClient.didReceiveTitleForFrame(this, title, frame, userData.get());
2312 }
2313
2314 void WebPageProxy::didFirstLayoutForFrame(uint64_t frameID, CoreIPC::ArgumentDecoder* arguments)
2315 {
2316     RefPtr<APIObject> userData;
2317     WebContextUserMessageDecoder messageDecoder(userData, m_process->context());
2318     if (!arguments->decode(messageDecoder))
2319         return;
2320
2321     WebFrameProxy* frame = process()->webFrame(frameID);
2322     MESSAGE_CHECK(frame);
2323
2324     m_loaderClient.didFirstLayoutForFrame(this, frame, userData.get());
2325 }
2326
2327 void WebPageProxy::didFirstVisuallyNonEmptyLayoutForFrame(uint64_t frameID, CoreIPC::ArgumentDecoder* arguments)
2328 {
2329     RefPtr<APIObject> userData;
2330     WebContextUserMessageDecoder messageDecoder(userData, m_process->context());
2331     if (!arguments->decode(messageDecoder))
2332         return;
2333
2334     WebFrameProxy* frame = process()->webFrame(frameID);
2335     MESSAGE_CHECK(frame);
2336
2337 #if OS(TIZEN)
2338     if (frame->isMainFrame())
2339         m_pageClient->didFirstVisuallyNonEmptyLayoutForMainFrame();
2340 #endif
2341
2342     m_loaderClient.didFirstVisuallyNonEmptyLayoutForFrame(this, frame, userData.get());
2343 }
2344
2345 void WebPageProxy::didNewFirstVisuallyNonEmptyLayout(CoreIPC::ArgumentDecoder* arguments)
2346 {
2347     RefPtr<APIObject> userData;
2348     WebContextUserMessageDecoder messageDecoder(userData, m_process->context());
2349     if (!arguments->decode(messageDecoder))
2350         return;
2351
2352     m_loaderClient.didNewFirstVisuallyNonEmptyLayout(this, userData.get());
2353 }
2354
2355 void WebPageProxy::didRemoveFrameFromHierarchy(uint64_t frameID, CoreIPC::ArgumentDecoder* arguments)
2356 {
2357     RefPtr<APIObject> userData;
2358     WebContextUserMessageDecoder messageDecoder(userData, m_process->context());
2359     if (!arguments->decode(messageDecoder))
2360         return;
2361
2362     WebFrameProxy* frame = process()->webFrame(frameID);
2363     MESSAGE_CHECK(frame);
2364
2365     frame->didRemoveFromHierarchy();
2366
2367     m_loaderClient.didRemoveFrameFromHierarchy(this, frame, userData.get());
2368 }
2369
2370 void WebPageProxy::didDisplayInsecureContentForFrame(uint64_t frameID, CoreIPC::ArgumentDecoder* arguments)
2371 {
2372     RefPtr<APIObject> userData;
2373     WebContextUserMessageDecoder messageDecoder(userData, m_process->context());
2374     if (!arguments->decode(messageDecoder))
2375         return;
2376
2377     WebFrameProxy* frame = process()->webFrame(frameID);
2378     MESSAGE_CHECK(frame);
2379
2380     m_loaderClient.didDisplayInsecureContentForFrame(this, frame, userData.get());
2381 }
2382
2383 void WebPageProxy::didRunInsecureContentForFrame(uint64_t frameID, CoreIPC::ArgumentDecoder* arguments)
2384 {
2385     RefPtr<APIObject> userData;
2386     WebContextUserMessageDecoder messageDecoder(userData, m_process->context());
2387     if (!arguments->decode(messageDecoder))
2388         return;
2389
2390     WebFrameProxy* frame = process()->webFrame(frameID);
2391     MESSAGE_CHECK(frame);
2392
2393     m_loaderClient.didRunInsecureContentForFrame(this, frame, userData.get());
2394 }
2395
2396 void WebPageProxy::didDetectXSSForFrame(uint64_t frameID, CoreIPC::ArgumentDecoder* arguments)
2397 {
2398     RefPtr<APIObject> userData;
2399     WebContextUserMessageDecoder messageDecoder(userData, m_process->context());
2400     if (!arguments->decode(messageDecoder))
2401         return;
2402
2403     WebFrameProxy* frame = process()->webFrame(frameID);
2404     MESSAGE_CHECK(frame);
2405
2406     m_loaderClient.didDetectXSSForFrame(this, frame, userData.get());
2407 }
2408
2409 #if ENABLE(WEB_INTENTS)
2410 void WebPageProxy::didReceiveIntentForFrame(uint64_t frameID, const IntentData& intentData, CoreIPC::ArgumentDecoder* arguments)
2411 {
2412     RefPtr<APIObject> userData;
2413     WebContextUserMessageDecoder messageDecoder(userData, m_process->context());
2414     if (!arguments->decode(messageDecoder))
2415         return;
2416
2417     WebFrameProxy* frame = process()->webFrame(frameID);
2418     MESSAGE_CHECK(frame);
2419
2420     RefPtr<WebIntentData> webIntentData = WebIntentData::create(intentData);
2421     m_loaderClient.didReceiveIntentForFrame(this, frame, webIntentData.get(), userData.get());
2422 }
2423 #endif
2424
2425 void WebPageProxy::frameDidBecomeFrameSet(uint64_t frameID, bool value)
2426 {
2427     WebFrameProxy* frame = process()->webFrame(frameID);
2428     MESSAGE_CHECK(frame);
2429
2430     frame->setIsFrameSet(value);
2431     if (frame->isMainFrame())
2432         m_frameSetLargestFrame = value ? m_mainFrame : 0;
2433 }
2434
2435 // PolicyClient
2436 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)
2437 {
2438     RefPtr<APIObject> userData;
2439     WebContextUserMessageDecoder messageDecoder(userData, m_process->context());
2440     if (!arguments->decode(messageDecoder))
2441         return;
2442
2443     if (request.url() != pendingAPIRequestURL())
2444         clearPendingAPIRequestURL();
2445
2446     WebFrameProxy* frame = process()->webFrame(frameID);
2447     MESSAGE_CHECK(frame);
2448     MESSAGE_CHECK_URL(request.url());
2449
2450     NavigationType navigationType = static_cast<NavigationType>(opaqueNavigationType);
2451     WebEvent::Modifiers modifiers = static_cast<WebEvent::Modifiers>(opaqueModifiers);
2452     WebMouseEvent::Button mouseButton = static_cast<WebMouseEvent::Button>(opaqueMouseButton);
2453     
2454     RefPtr<WebFramePolicyListenerProxy> listener = frame->setUpPolicyListenerProxy(listenerID);
2455
2456     ASSERT(!m_inDecidePolicyForNavigationAction);
2457
2458     m_inDecidePolicyForNavigationAction = true;
2459     m_syncNavigationActionPolicyActionIsValid = false;
2460     
2461     if (!m_policyClient.decidePolicyForNavigationAction(this, frame, navigationType, modifiers, mouseButton, request, listener.get(), userData.get()))
2462         listener->use();
2463
2464     m_inDecidePolicyForNavigationAction = false;
2465
2466     // Check if we received a policy decision already. If we did, we can just pass it back.
2467     receivedPolicyAction = m_syncNavigationActionPolicyActionIsValid;
2468     if (m_syncNavigationActionPolicyActionIsValid) {
2469         policyAction = m_syncNavigationActionPolicyAction;
2470         downloadID = m_syncNavigationActionPolicyDownloadID;
2471     }
2472 }
2473
2474 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)
2475 {
2476     RefPtr<APIObject> userData;
2477     WebContextUserMessageDecoder messageDecoder(userData, m_process->context());
2478     if (!arguments->decode(messageDecoder))
2479         return;
2480
2481     WebFrameProxy* frame = process()->webFrame(frameID);
2482     MESSAGE_CHECK(frame);
2483     MESSAGE_CHECK_URL(request.url());
2484
2485     NavigationType navigationType = static_cast<NavigationType>(opaqueNavigationType);
2486     WebEvent::Modifiers modifiers = static_cast<WebEvent::Modifiers>(opaqueModifiers);
2487     WebMouseEvent::Button mouseButton = static_cast<WebMouseEvent::Button>(opaqueMouseButton);
2488
2489     RefPtr<WebFramePolicyListenerProxy> listener = frame->setUpPolicyListenerProxy(listenerID);
2490     if (!m_policyClient.decidePolicyForNewWindowAction(this, frame, navigationType, modifiers, mouseButton, request, frameName, listener.get(), userData.get()))
2491         listener->use();
2492 }
2493
2494 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)
2495 {
2496     RefPtr<APIObject> userData;
2497     WebContextUserMessageDecoder messageDecoder(userData, m_process->context());
2498     if (!arguments->decode(messageDecoder))
2499         return;
2500
2501     WebFrameProxy* frame = process()->webFrame(frameID);
2502     MESSAGE_CHECK(frame);
2503     MESSAGE_CHECK_URL(request.url());
2504     MESSAGE_CHECK_URL(response.url());
2505     
2506     RefPtr<WebFramePolicyListenerProxy> listener = frame->setUpPolicyListenerProxy(listenerID);
2507
2508     ASSERT(!m_inDecidePolicyForResponse);
2509
2510     m_inDecidePolicyForResponse = true;
2511     m_syncMimeTypePolicyActionIsValid = false;
2512
2513     if (!m_policyClient.decidePolicyForResponse(this, frame, response, request, listener.get(), userData.get()))
2514         listener->use();
2515
2516     m_inDecidePolicyForResponse = false;
2517
2518     // Check if we received a policy decision already. If we did, we can just pass it back.
2519     receivedPolicyAction = m_syncMimeTypePolicyActionIsValid;
2520     if (m_syncMimeTypePolicyActionIsValid) {
2521         policyAction = m_syncMimeTypePolicyAction;
2522         downloadID = m_syncMimeTypePolicyDownloadID;
2523     }
2524 }
2525
2526 void WebPageProxy::unableToImplementPolicy(uint64_t frameID, const ResourceError& error, CoreIPC::ArgumentDecoder* arguments)
2527 {
2528     RefPtr<APIObject> userData;
2529     WebContextUserMessageDecoder messageDecoder(userData, m_process->context());
2530     if (!arguments->decode(messageDecoder))
2531         return;
2532     
2533     WebFrameProxy* frame = process()->webFrame(frameID);
2534     MESSAGE_CHECK(frame);
2535
2536     m_policyClient.unableToImplementPolicy(this, frame, error, userData.get());
2537 }
2538
2539 // FormClient
2540
2541 #if ENABLE(TIZEN_WEBKIT2_FORM_DATABASE)
2542 void WebPageProxy::willSubmitForm(uint64_t frameID, uint64_t sourceFrameID, const StringPairVector& textFieldValues, bool containsPasswordData, uint64_t listenerID, CoreIPC::ArgumentDecoder* arguments)
2543 #else
2544 void WebPageProxy::willSubmitForm(uint64_t frameID, uint64_t sourceFrameID, const StringPairVector& textFieldValues, uint64_t listenerID, CoreIPC::ArgumentDecoder* arguments)
2545 #endif
2546 {
2547     RefPtr<APIObject> userData;
2548     WebContextUserMessageDecoder messageDecoder(userData, m_process->context());
2549     if (!arguments->decode(messageDecoder))
2550         return;
2551
2552     WebFrameProxy* frame = process()->webFrame(frameID);
2553     MESSAGE_CHECK(frame);
2554
2555     WebFrameProxy* sourceFrame = process()->webFrame(sourceFrameID);
2556     MESSAGE_CHECK(sourceFrame);
2557
2558     RefPtr<WebFormSubmissionListenerProxy> listener = frame->setUpFormSubmissionListenerProxy(listenerID);
2559 #if ENABLE(TIZEN_WEBKIT2_FORM_DATABASE)
2560     if (!m_formClient.willSubmitForm(this, frame, sourceFrame, textFieldValues.stringPairVector(), containsPasswordData, userData.get(), listener.get()))
2561 #else
2562     if (!m_formClient.willSubmitForm(this, frame, sourceFrame, textFieldValues.stringPairVector(), userData.get(), listener.get()))
2563 #endif
2564         listener->continueSubmission();
2565 }
2566
2567 // ResourceLoad Client
2568
2569 void WebPageProxy::didInitiateLoadForResource(uint64_t frameID, uint64_t resourceIdentifier, const ResourceRequest& request, bool pageIsProvisionallyLoading)
2570 {
2571     WebFrameProxy* frame = process()->webFrame(frameID);
2572     MESSAGE_CHECK(frame);
2573     MESSAGE_CHECK_URL(request.url());
2574
2575     m_resourceLoadClient.didInitiateLoadForResource(this, frame, resourceIdentifier, request, pageIsProvisionallyLoading);
2576 }
2577
2578 void WebPageProxy::didSendRequestForResource(uint64_t frameID, uint64_t resourceIdentifier, const ResourceRequest& request, const ResourceResponse& redirectResponse)
2579 {
2580     WebFrameProxy* frame = process()->webFrame(frameID);
2581     MESSAGE_CHECK(frame);
2582     MESSAGE_CHECK_URL(request.url());
2583
2584     m_resourceLoadClient.didSendRequestForResource(this, frame, resourceIdentifier, request, redirectResponse);
2585 }
2586
2587 void WebPageProxy::didReceiveResponseForResource(uint64_t frameID, uint64_t resourceIdentifier, const ResourceResponse& response)
2588 {
2589     WebFrameProxy* frame = process()->webFrame(frameID);
2590     MESSAGE_CHECK(frame);
2591     MESSAGE_CHECK_URL(response.url());
2592
2593     m_resourceLoadClient.didReceiveResponseForResource(this, frame, resourceIdentifier, response);
2594 }
2595
2596 void WebPageProxy::didReceiveContentLengthForResource(uint64_t frameID, uint64_t resourceIdentifier, uint64_t contentLength)
2597 {
2598     WebFrameProxy* frame = process()->webFrame(frameID);
2599     MESSAGE_CHECK(frame);
2600
2601     m_resourceLoadClient.didReceiveContentLengthForResource(this, frame, resourceIdentifier, contentLength);
2602 }
2603
2604 void WebPageProxy::didFinishLoadForResource(uint64_t frameID, uint64_t resourceIdentifier)
2605 {
2606     WebFrameProxy* frame = process()->webFrame(frameID);
2607     MESSAGE_CHECK(frame);
2608
2609     m_resourceLoadClient.didFinishLoadForResource(this, frame, resourceIdentifier);
2610 }
2611
2612 void WebPageProxy::didFailLoadForResource(uint64_t frameID, uint64_t resourceIdentifier, const ResourceError& error)
2613 {
2614     WebFrameProxy* frame = process()->webFrame(frameID);
2615     MESSAGE_CHECK(frame);
2616
2617     m_resourceLoadClient.didFailLoadForResource(this, frame, resourceIdentifier, error);
2618 }
2619
2620 // UIClient
2621
2622 void WebPageProxy::createNewPage(const ResourceRequest& request, const WindowFeatures& windowFeatures, uint32_t opaqueModifiers, int32_t opaqueMouseButton, uint64_t& newPageID, WebPageCreationParameters& newPageParameters)
2623 {
2624     RefPtr<WebPageProxy> newPage = m_uiClient.createNewPage(this, request, windowFeatures, static_cast<WebEvent::Modifiers>(opaqueModifiers), static_cast<WebMouseEvent::Button>(opaqueMouseButton));
2625     if (newPage) {
2626         newPageID = newPage->pageID();
2627         newPageParameters = newPage->creationParameters();
2628     } else
2629         newPageID = 0;
2630 }
2631     
2632 void WebPageProxy::showPage()
2633 {
2634     m_uiClient.showPage(this);
2635 }
2636
2637 void WebPageProxy::closePage(bool stopResponsivenessTimer)
2638 {
2639     if (stopResponsivenessTimer)
2640         process()->responsivenessTimer()->stop();
2641
2642     m_pageClient->clearAllEditCommands();
2643     m_uiClient.close(this);
2644 }
2645
2646 #if ENABLE(TIZEN_WEBKIT2_ROTATION_WHILE_JAVASCRIPT_POPUP)
2647 bool WebPageProxy::isWaitingForJavaScriptPopupReply()
2648 {
2649 #if ENABLE(TIZEN_SUPPORT_BEFORE_UNLOAD_CONFIRM_PANEL)
2650     return m_alertReply || m_confirmReply || m_promptReply || m_beforeUnloadConfirmPanelReply;
2651 #else
2652     return m_alertReply || m_confirmReply || m_promptReply;
2653 #endif
2654 }
2655 #endif
2656
2657 #if OS(TIZEN)
2658 void WebPageProxy::runJavaScriptAlert(uint64_t frameID, const String& message, PassRefPtr<Messages::WebPageProxy::RunJavaScriptAlert::DelayedReply> reply)
2659 {
2660     WebFrameProxy* frame = process()->webFrame(frameID);
2661     MESSAGE_CHECK(frame);
2662
2663     // Since runJavaScriptAlert() can spin a nested run loop we need to turn off the responsiveness timer.
2664     process()->responsivenessTimer()->stop();
2665
2666     m_alertReply = reply;
2667 #if ENABLE(TIZEN_WEBKIT2_NOTIFY_POPUP_REPLY_STATUS)
2668     m_uiClient.notifyPopupReplyWaitingState(this, true);
2669 #endif
2670 #if ENABLE(TIZEN_WEBKIT2_ROTATION_WHILE_JAVASCRIPT_POPUP)
2671     process()->connection()->setForcelySetAllAsyncMessagesToDispatchEvenWhenWaitingForSyncReply(true);
2672 #endif
2673     if (!m_uiClient.runJavaScriptAlert(this, message, frame))
2674         replyJavaScriptAlert();
2675 }
2676
2677 void WebPageProxy::runJavaScriptConfirm(uint64_t frameID, const String& message, PassRefPtr<Messages::WebPageProxy::RunJavaScriptConfirm::DelayedReply> reply)
2678 {
2679     WebFrameProxy* frame = process()->webFrame(frameID);
2680     MESSAGE_CHECK(frame);
2681
2682     // Since runJavaScriptConfirm() can spin a nested run loop we need to turn off the responsiveness timer.
2683     process()->responsivenessTimer()->stop();
2684
2685     m_confirmReply = reply;
2686 #if ENABLE(TIZEN_WEBKIT2_NOTIFY_POPUP_REPLY_STATUS)
2687     m_uiClient.notifyPopupReplyWaitingState(this, true);
2688 #endif
2689 #if ENABLE(TIZEN_WEBKIT2_ROTATION_WHILE_JAVASCRIPT_POPUP)
2690     process()->connection()->setForcelySetAllAsyncMessagesToDispatchEvenWhenWaitingForSyncReply(true);
2691 #endif
2692     if (!m_uiClient.runJavaScriptConfirm(this, message, frame))
2693         replyJavaScriptConfirm(false);
2694 }
2695
2696 void WebPageProxy::runJavaScriptPrompt(uint64_t frameID, const String& message, const String& defaultValue, PassRefPtr<Messages::WebPageProxy::RunJavaScriptPrompt::DelayedReply> reply)
2697 {
2698     WebFrameProxy* frame = process()->webFrame(frameID);
2699     MESSAGE_CHECK(frame);
2700
2701     // Since runJavaScriptPrompt() can spin a nested run loop we need to turn off the responsiveness timer.
2702     process()->responsivenessTimer()->stop();
2703
2704     m_promptReply = reply;
2705 #if ENABLE(TIZEN_WEBKIT2_NOTIFY_POPUP_REPLY_STATUS)
2706     m_uiClient.notifyPopupReplyWaitingState(this, true);
2707 #endif
2708 #if ENABLE(TIZEN_WEBKIT2_ROTATION_WHILE_JAVASCRIPT_POPUP)
2709     process()->connection()->setForcelySetAllAsyncMessagesToDispatchEvenWhenWaitingForSyncReply(true);
2710 #endif
2711     if (!m_uiClient.runJavaScriptPrompt(this, message, defaultValue, frame))
2712         replyJavaScriptPrompt(String());
2713 }
2714 #else
2715 void WebPageProxy::runJavaScriptAlert(uint64_t frameID, const String& message)
2716 {
2717     WebFrameProxy* frame = process()->webFrame(frameID);
2718     MESSAGE_CHECK(frame);
2719
2720     // Since runJavaScriptAlert() can spin a nested run loop we need to turn off the responsiveness timer.
2721     process()->responsivenessTimer()->stop();
2722
2723     m_uiClient.runJavaScriptAlert(this, message, frame);
2724 }
2725
2726 void WebPageProxy::runJavaScriptConfirm(uint64_t frameID, const String& message, bool& result)
2727 {
2728     WebFrameProxy* frame = process()->webFrame(frameID);
2729     MESSAGE_CHECK(frame);
2730
2731     // Since runJavaScriptConfirm() can spin a nested run loop we need to turn off the responsiveness timer.
2732     process()->responsivenessTimer()->stop();
2733
2734     result = m_uiClient.runJavaScriptConfirm(this, message, frame);
2735 }
2736
2737 void WebPageProxy::runJavaScriptPrompt(uint64_t frameID, const String& message, const String& defaultValue, String& result)
2738 {
2739     WebFrameProxy* frame = process()->webFrame(frameID);
2740     MESSAGE_CHECK(frame);
2741
2742     // Since runJavaScriptPrompt() can spin a nested run loop we need to turn off the responsiveness timer.
2743     process()->responsivenessTimer()->stop();
2744
2745     result = m_uiClient.runJavaScriptPrompt(this, message, defaultValue, frame);
2746 }
2747 #endif
2748
2749 void WebPageProxy::shouldInterruptJavaScript(bool& result)
2750 {
2751     // Since shouldInterruptJavaScript() can spin a nested run loop we need to turn off the responsiveness timer.
2752     process()->responsivenessTimer()->stop();
2753
2754     result = m_uiClient.shouldInterruptJavaScript(this);
2755 }
2756
2757 void WebPageProxy::setStatusText(const String& text)
2758 {
2759     m_uiClient.setStatusText(this, text);
2760 }
2761
2762 void WebPageProxy::mouseDidMoveOverElement(const WebHitTestResult::Data& hitTestResultData, uint32_t opaqueModifiers, CoreIPC::ArgumentDecoder* arguments)
2763 {
2764     RefPtr<APIObject> userData;
2765     WebContextUserMessageDecoder messageDecoder(userData, m_process->context());
2766     if (!arguments->decode(messageDecoder))
2767         return;
2768
2769     WebEvent::Modifiers modifiers = static_cast<WebEvent::Modifiers>(opaqueModifiers);
2770
2771     m_uiClient.mouseDidMoveOverElement(this, hitTestResultData, modifiers, userData.get());
2772 }
2773
2774 void WebPageProxy::unavailablePluginButtonClicked(uint32_t opaquePluginUnavailabilityReason, const String& mimeType, const String& url, const String& pluginsPageURL)
2775 {
2776     MESSAGE_CHECK_URL(url);
2777     MESSAGE_CHECK_URL(pluginsPageURL);
2778
2779     WKPluginUnavailabilityReason pluginUnavailabilityReason = static_cast<WKPluginUnavailabilityReason>(opaquePluginUnavailabilityReason);
2780     m_uiClient.unavailablePluginButtonClicked(this, pluginUnavailabilityReason, mimeType, url, pluginsPageURL);
2781 }
2782
2783 void WebPageProxy::setToolbarsAreVisible(bool toolbarsAreVisible)
2784 {
2785     m_uiClient.setToolbarsAreVisible(this, toolbarsAreVisible);
2786 }
2787
2788 void WebPageProxy::getToolbarsAreVisible(bool& toolbarsAreVisible)
2789 {
2790     toolbarsAreVisible = m_uiClient.toolbarsAreVisible(this);
2791 }
2792
2793 void WebPageProxy::setMenuBarIsVisible(bool menuBarIsVisible)
2794 {
2795     m_uiClient.setMenuBarIsVisible(this, menuBarIsVisible);
2796 }
2797
2798 void WebPageProxy::getMenuBarIsVisible(bool& menuBarIsVisible)
2799 {
2800     menuBarIsVisible = m_uiClient.menuBarIsVisible(this);
2801 }
2802
2803 void WebPageProxy::setStatusBarIsVisible(bool statusBarIsVisible)
2804 {
2805     m_uiClient.setStatusBarIsVisible(this, statusBarIsVisible);
2806 }
2807
2808 void WebPageProxy::getStatusBarIsVisible(bool& statusBarIsVisible)
2809 {
2810     statusBarIsVisible = m_uiClient.statusBarIsVisible(this);
2811 }
2812
2813 void WebPageProxy::setIsResizable(bool isResizable)
2814 {
2815     m_uiClient.setIsResizable(this, isResizable);
2816 }
2817
2818 void WebPageProxy::getIsResizable(bool& isResizable)
2819 {
2820     isResizable = m_uiClient.isResizable(this);
2821 }
2822
2823 void WebPageProxy::setWindowFrame(const FloatRect& newWindowFrame)
2824 {
2825     m_uiClient.setWindowFrame(this, m_pageClient->convertToDeviceSpace(newWindowFrame));
2826 }
2827
2828 void WebPageProxy::getWindowFrame(FloatRect& newWindowFrame)
2829 {
2830     newWindowFrame = m_pageClient->convertToUserSpace(m_uiClient.windowFrame(this));
2831 }
2832     
2833 void WebPageProxy::screenToWindow(const IntPoint& screenPoint, IntPoint& windowPoint)
2834 {
2835     windowPoint = m_pageClient->screenToWindow(screenPoint);
2836 }
2837     
2838 void WebPageProxy::windowToScreen(const IntRect& viewRect, IntRect& result)
2839 {
2840     result = m_pageClient->windowToScreen(viewRect);
2841 }
2842
2843 #if ENABLE(TIZEN_SUPPORT_BEFORE_UNLOAD_CONFIRM_PANEL)
2844 void WebPageProxy::runBeforeUnloadConfirmPanel(const String& message, uint64_t frameID, PassRefPtr<Messages::WebPageProxy::RunBeforeUnloadConfirmPanel::DelayedReply> reply)
2845 {
2846     WebFrameProxy* frame = process()->webFrame(frameID);
2847     MESSAGE_CHECK(frame);
2848
2849     // Since runBeforeUnloadConfirmPanel() can spin a nested run loop we need to turn off the responsiveness timer.
2850     process()->responsivenessTimer()->stop();
2851
2852     m_beforeUnloadConfirmPanelReply = reply;
2853 #if ENABLE(TIZEN_WEBKIT2_ROTATION_WHILE_JAVASCRIPT_POPUP)
2854     process()->connection()->setForcelySetAllAsyncMessagesToDispatchEvenWhenWaitingForSyncReply(true);
2855 #endif
2856     if (!m_uiClient.runBeforeUnloadConfirmPanel(this, message, frame))
2857         replyBeforeUnloadConfirmPanel(false);
2858 }
2859 #else
2860 void WebPageProxy::runBeforeUnloadConfirmPanel(const String& message, uint64_t frameID, bool& shouldClose)
2861 {
2862     WebFrameProxy* frame = process()->webFrame(frameID);
2863     MESSAGE_CHECK(frame);
2864
2865     // Since runBeforeUnloadConfirmPanel() can spin a nested run loop we need to turn off the responsiveness timer.
2866     process()->responsivenessTimer()->stop();
2867
2868     shouldClose = m_uiClient.runBeforeUnloadConfirmPanel(this, message, frame);
2869 }
2870 #endif
2871
2872 #if USE(TILED_BACKING_STORE)
2873 void WebPageProxy::pageDidRequestScroll(const IntPoint& point)
2874 {
2875     m_pageClient->pageDidRequestScroll(point);
2876 }
2877 #endif
2878
2879 void WebPageProxy::didChangeViewportProperties(const ViewportAttributes& attr)
2880 {
2881     m_pageClient->didChangeViewportProperties(attr);
2882 }
2883
2884 void WebPageProxy::pageDidScroll()
2885 {
2886     m_uiClient.pageDidScroll(this);
2887 #if PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
2888     dismissCorrectionPanel(ReasonForDismissingAlternativeTextIgnored);
2889 #endif
2890 }
2891
2892 void WebPageProxy::runOpenPanel(uint64_t frameID, const FileChooserSettings& settings)
2893 {
2894     if (m_openPanelResultListener) {
2895         m_openPanelResultListener->invalidate();
2896         m_openPanelResultListener = 0;
2897     }
2898
2899     WebFrameProxy* frame = process()->webFrame(frameID);
2900     MESSAGE_CHECK(frame);
2901
2902     RefPtr<WebOpenPanelParameters> parameters = WebOpenPanelParameters::create(settings);
2903     m_openPanelResultListener = WebOpenPanelResultListenerProxy::create(this);
2904
2905     // Since runOpenPanel() can spin a nested run loop we need to turn off the responsiveness timer.
2906     process()->responsivenessTimer()->stop();
2907
2908     if (!m_uiClient.runOpenPanel(this, frame, parameters.get(), m_openPanelResultListener.get()))
2909         didCancelForOpenPanel();
2910 }
2911
2912 void WebPageProxy::printFrame(uint64_t frameID)
2913 {
2914     ASSERT(!m_isPerformingDOMPrintOperation);
2915     m_isPerformingDOMPrintOperation = true;
2916
2917     WebFrameProxy* frame = process()->webFrame(frameID);
2918     MESSAGE_CHECK(frame);
2919
2920     m_uiClient.printFrame(this, frame);
2921
2922     endPrinting(); // Send a message synchronously while m_isPerformingDOMPrintOperation is still true.
2923     m_isPerformingDOMPrintOperation = false;
2924 }
2925
2926 void WebPageProxy::printMainFrame()
2927 {
2928     printFrame(m_mainFrame->frameID());
2929 }
2930
2931 #if ENABLE(TIZEN_REGISTER_PROTOCOL_HANDLER)
2932 void WebPageProxy::registerProtocolHandler(const String& scheme, const String& baseURL, const String& url, const String& title)
2933 {
2934     m_pageClient->registerProtocolHandler(scheme, baseURL, url, title);
2935 }
2936 #endif
2937
2938 #if ENABLE(TIZEN_CUSTOM_SCHEME_HANDLER)
2939 void WebPageProxy::isProtocolHandlerRegistered(const String& scheme, const String& baseURL, const String& url, unsigned int& result)
2940 {
2941     result = m_pageClient->isProtocolHandlerRegistered(scheme, baseURL, url);
2942 }
2943 void WebPageProxy::unregisterProtocolHandler(const String& scheme, const String& baseURL, const String& url)
2944 {
2945     m_pageClient->unregisterProtocolHandler(scheme, baseURL, url);
2946 }
2947 #endif
2948
2949 #if ENABLE(TIZEN_REGISTER_CONTENT_HANDLER)
2950 void WebPageProxy::registerContentHandler(const String& mimeType, const String& baseURL, const String& url, const String& title)
2951 {
2952     m_pageClient->registerContentHandler(mimeType, baseURL, url, title);
2953 }
2954
2955 void WebPageProxy::isContentHandlerRegistered(const String& mimeType, const String& baseURL, const String& url, unsigned int& result)
2956 {
2957     result = m_pageClient->isContentHandlerRegistered(mimeType, baseURL, url);
2958 }
2959
2960 void WebPageProxy::unregisterContentHandler(const String& mimeType, const String& baseURL, const String& url)
2961 {
2962     m_pageClient->unregisterContentHandler(mimeType, baseURL, url);
2963 }
2964 #endif
2965
2966 #if ENABLE(TIZEN_SEARCH_PROVIDER)
2967 void WebPageProxy::addSearchProvider(const String& baseURL, const String& engineURL)
2968 {
2969     m_pageClient->addSearchProvider(baseURL, engineURL);
2970 }
2971
2972 void WebPageProxy::isSearchProviderInstalled(const String& baseURL, const String& engineURL, uint64_t& result)
2973 {
2974     result = m_pageClient->isSearchProviderInstalled(baseURL, engineURL);
2975 }
2976 #endif
2977
2978 #if ENABLE(TIZEN_SUPPORT_WEBAPP_META_TAG)
2979 void WebPageProxy::getStandaloneStatus(bool& standalone)
2980 {
2981     standalone = m_pageClient->getStandaloneStatus();
2982 }
2983
2984 void WebPageProxy::getWebAppCapable(PassRefPtr<BooleanCallback> prpCallback)
2985 {
2986     RefPtr<BooleanCallback> callback = prpCallback;
2987     if (!isValid()) {
2988         callback->invalidate();
2989         return;
2990     }
2991
2992     uint64_t callbackID = callback->callbackID();
2993     m_booleanCallbacks.set(callbackID, callback.get());
2994     process()->send(Messages::WebPage::GetWebAppCapable(callbackID), m_pageID);
2995 }
2996
2997 void WebPageProxy::didGetWebAppCapable(const bool capable, uint64_t callbackID)
2998 {
2999     RefPtr<BooleanCallback> callback = m_booleanCallbacks.take(callbackID);
3000     m_booleanCallbacks.remove(callbackID);
3001     callback->performCallbackWithReturnValue(WebBoolean::create(capable).leakRef());
3002 }
3003
3004 void WebPageProxy::getWebAppIconURL(PassRefPtr<StringCallback> prpCallback)
3005 {
3006     RefPtr<StringCallback> callback = prpCallback;
3007     if (!isValid()) {
3008         callback->invalidate();
3009         return;
3010     }
3011
3012     uint64_t callbackID = callback->callbackID();
3013     m_stringCallbacks.set(callbackID, callback.get());
3014     process()->send(Messages::WebPage::GetWebAppIconURL(callbackID), m_pageID);
3015 }
3016
3017 void WebPageProxy::didGetWebAppIconURL(const String& iconURL, uint64_t callbackID)
3018 {
3019     RefPtr<StringCallback> callback = m_stringCallbacks.take(callbackID);
3020     if (!callback) {
3021         // FIXME: Log error or assert.
3022         // this can validly happen if a load invalidated the callback, though
3023         return;
3024     }
3025
3026     m_stringCallbacks.remove(callbackID);
3027     callback->performCallbackWithReturnValue(iconURL.impl());
3028 }
3029
3030 void WebPageProxy::getWebAppIconURLs(PassRefPtr<DictionaryCallback> prpCallback)
3031 {
3032     RefPtr<DictionaryCallback> callback = prpCallback;
3033     if (!isValid()) {
3034         callback->invalidate();
3035         return;
3036     }
3037
3038     uint64_t callbackID = callback->callbackID();
3039     m_dictionaryCallbacks.set(callbackID, callback.get());
3040     process()->send(Messages::WebPage::GetWebAppIconURLs(callbackID), m_pageID);
3041 }
3042
3043 void WebPageProxy::didGetWebAppIconURLs(const StringPairVector& iconURLs, uint64_t callbackID)
3044 {
3045     RefPtr<DictionaryCallback> callback = m_dictionaryCallbacks.take(callbackID);
3046     ImmutableDictionary::MapType iconURLList;
3047     size_t iconURLCount = iconURLs.stringPairVector().size();
3048     for (size_t i = 0; i < iconURLCount; ++i)
3049         iconURLList.set(iconURLs.stringPairVector()[i].first, WebString::create(iconURLs.stringPairVector()[i].second));
3050
3051     callback->performCallbackWithReturnValue(ImmutableDictionary::adopt(iconURLList).get());
3052 }
3053 #endif
3054
3055 void WebPageProxy::setMediaVolume(float volume)
3056 {
3057     if (volume == m_mediaVolume)
3058         return;
3059     
3060     m_mediaVolume = volume;
3061     
3062     if (!isValid())
3063         return;
3064     
3065     process()->send(Messages::WebPage::SetMediaVolume(volume), m_pageID);    
3066 }
3067
3068 #if PLATFORM(QT)
3069 void WebPageProxy::didChangeContentsSize(const IntSize& size)
3070 {
3071     m_pageClient->didChangeContentsSize(size);
3072 }
3073
3074 void WebPageProxy::didFindZoomableArea(const IntPoint& target, const IntRect& area)
3075 {
3076     m_pageClient->didFindZoomableArea(target, area);
3077 }
3078
3079 void WebPageProxy::findZoomableAreaForPoint(const IntPoint& point, const IntSize& area)
3080 {
3081     if (!isValid())
3082         return;
3083
3084     process()->send(Messages::WebPage::FindZoomableAreaForPoint(point, area), m_pageID);
3085 }
3086
3087 void WebPageProxy::didReceiveMessageFromNavigatorQtObject(const String& contents)
3088 {
3089     m_pageClient->didReceiveMessageFromNavigatorQtObject(contents);
3090 }
3091
3092 void WebPageProxy::authenticationRequiredRequest(const String& hostname, const String& realm, const String& prefilledUsername, String& username, String& password)
3093 {
3094     m_pageClient->handleAuthenticationRequiredRequest(hostname, realm, prefilledUsername, username, password);
3095 }
3096
3097 void WebPageProxy::proxyAuthenticationRequiredRequest(const String& hostname, uint16_t port, const String& prefilledUsername, String& username, String& password)
3098 {
3099     m_pageClient->handleProxyAuthenticationRequiredRequest(hostname, port, prefilledUsername, username, password);
3100 }
3101
3102 void WebPageProxy::certificateVerificationRequest(const String& hostname, bool& ignoreErrors)
3103 {
3104     m_pageClient->handleCertificateVerificationRequest(hostname, ignoreErrors);
3105 }
3106 #endif // PLATFORM(QT).
3107
3108 #if OS(TIZEN)
3109 void WebPageProxy::didFindZoomableArea(const IntPoint& target, const IntRect& area)
3110 {
3111     m_pageClient->didFindZoomableArea(target, area);
3112 }
3113
3114 void WebPageProxy::findZoomableAreaForPoint(const IntPoint& point, const IntSize& area)
3115 {
3116     if (!isValid())
3117         return;
3118
3119     process()->send(Messages::WebPage::FindZoomableAreaForPoint(point, area), m_pageID);
3120 }
3121 #endif // #if OS(TIZEN)
3122
3123 #if PLATFORM(QT) || PLATFORM(EFL)
3124 void WebPageProxy::handleDownloadRequest(DownloadProxy* download)
3125 {
3126     m_pageClient->handleDownloadRequest(download);
3127 }
3128 #endif // PLATFORM(QT) || PLATFORM(EFL)
3129
3130 #if ENABLE(TOUCH_EVENTS)
3131 void WebPageProxy::needTouchEvents(bool needTouchEvents)
3132 {
3133     m_needTouchEvents = needTouchEvents;
3134 #if ENABLE(TIZEN_CSS_OVERFLOW_SCROLL_ACCELERATION)
3135     // We don't have to ask overflow if we need touch events,
3136     // because we will check overflow in the web process when touch event is processed.
3137     m_askOverflow = !m_needTouchEvents;
3138 #endif
3139 }
3140 #endif
3141
3142 #if ENABLE(INPUT_TYPE_COLOR)
3143 void WebPageProxy::showColorChooser(const WebCore::Color& initialColor)
3144 {
3145     ASSERT(!m_colorChooser);
3146
3147 #if ENABLE(TIZEN_INPUT_COLOR_PICKER) // wait for upstream
3148     if (m_colorPickerResultListener) {
3149         m_colorPickerResultListener->invalidate();
3150         m_colorPickerResultListener = nullptr;
3151     }
3152
3153     m_colorPickerResultListener = WebColorPickerResultListenerProxy::create(this);
3154     m_colorChooser = WebColorChooserProxy::create(this);
3155
3156     if (m_uiClient.showColorPicker(this, initialColor.serialized(), m_colorPickerResultListener.get()))
3157         return;
3158 #endif
3159
3160     m_colorChooser = m_pageClient->createColorChooserProxy(this, initialColor);
3161 #if ENABLE(TIZEN_INPUT_COLOR_PICKER) // wait for upstream
3162     if (!m_colorChooser)
3163         didEndColorChooser();
3164 #endif
3165 }
3166
3167 void WebPageProxy::setColorChooserColor(const WebCore::Color& color)
3168 {
3169     ASSERT(m_colorChooser);
3170
3171     m_colorChooser->setSelectedColor(color);
3172 }
3173
3174 void WebPageProxy::endColorChooser()
3175 {
3176     ASSERT(m_colorChooser);
3177
3178     m_colorChooser->endChooser();
3179 }
3180
3181 void WebPageProxy::didChooseColor(const WebCore::Color& color)
3182 {
3183     if (!isValid())
3184         return;
3185
3186     process()->send(Messages::WebPage::DidChooseColor(color), m_pageID);
3187 }
3188
3189 void WebPageProxy::didEndColorChooser()
3190 {
3191     if (!isValid())
3192         return;
3193
3194 #if ENABLE(TIZEN_INPUT_COLOR_PICKER) // wait for upstream
3195     if (m_colorChooser) {
3196         m_colorChooser->invalidate();
3197         m_colorChooser = nullptr;
3198     }
3199 #else
3200     ASSERT(m_colorChooser);
3201
3202     m_colorChooser->invalidate();
3203     m_colorChooser = nullptr;
3204 #endif
3205
3206 #if ENABLE(TIZEN_INPUT_COLOR_PICKER) // wait for upstream
3207     m_process->send(Messages::WebPage::DidEndColorChooser(), m_pageID);
3208
3209     m_colorPickerResultListener->invalidate();
3210     m_colorPickerResultListener = nullptr;
3211
3212     m_uiClient.hideColorPicker(this);
3213 #else
3214     process()->send(Messages::WebPage::DidEndColorChooser(), m_pageID);
3215 #endif
3216 }
3217 #endif
3218
3219 void WebPageProxy::didDraw()
3220 {
3221     m_uiClient.didDraw(this);
3222 }
3223
3224 // Inspector
3225
3226 #if ENABLE(INSPECTOR)
3227
3228 WebInspectorProxy* WebPageProxy::inspector()
3229 {
3230     if (isClosed() || !isValid())
3231         return 0;
3232     if (!m_inspector)
3233         m_inspector = WebInspectorProxy::create(this);
3234     return m_inspector.get();
3235 }
3236
3237 #endif
3238
3239 #if ENABLE(FULLSCREEN_API)
3240 WebFullScreenManagerProxy* WebPageProxy::fullScreenManager()
3241 {
3242     if (!m_fullScreenManager)
3243         m_fullScreenManager = WebFullScreenManagerProxy::create(this);
3244     return m_fullScreenManager.get();
3245 }
3246 #endif
3247
3248 // BackForwardList
3249
3250 void WebPageProxy::backForwardAddItem(uint64_t itemID)
3251 {
3252     m_backForwardList->addItem(process()->webBackForwardItem(itemID));
3253 }
3254
3255 void WebPageProxy::backForwardGoToItem(uint64_t itemID, SandboxExtension::Handle& sandboxExtensionHandle)
3256 {
3257     WebBackForwardListItem* item = process()->webBackForwardItem(itemID);
3258     if (!item)
3259         return;
3260
3261     bool createdExtension = maybeInitializeSandboxExtensionHandle(KURL(KURL(), item->url()), sandboxExtensionHandle);
3262     if (createdExtension)
3263         process()->willAcquireUniversalFileReadSandboxExtension();
3264     m_backForwardList->goToItem(item);
3265 }
3266
3267 void WebPageProxy::backForwardItemAtIndex(int32_t index, uint64_t& itemID)
3268 {
3269     WebBackForwardListItem* item = m_backForwardList->itemAtIndex(index);
3270     itemID = item ? item->itemID() : 0;
3271 }
3272
3273 void WebPageProxy::backForwardBackListCount(int32_t& count)
3274 {
3275     count = m_backForwardList->backListCount();
3276 }
3277
3278 void WebPageProxy::backForwardForwardListCount(int32_t& count)
3279 {
3280     count = m_backForwardList->forwardListCount();
3281 }
3282
3283 void WebPageProxy::editorStateChanged(const EditorState& editorState)
3284 {
3285 #if PLATFORM(MAC)
3286     bool couldChangeSecureInputState = m_editorState.isInPasswordField != editorState.isInPasswordField || m_editorState.selectionIsNone;
3287 #endif
3288
3289     m_editorState = editorState;
3290
3291 #if PLATFORM(MAC)
3292     m_pageClient->updateTextInputState(couldChangeSecureInputState);
3293 #elif PLATFORM(QT) || PLATFORM(EFL)
3294     m_pageClient->updateTextInputState();
3295 #endif
3296 }
3297
3298 // Undo management
3299
3300 void WebPageProxy::registerEditCommandForUndo(uint64_t commandID, uint32_t editAction)
3301 {
3302     registerEditCommand(WebEditCommandProxy::create(commandID, static_cast<EditAction>(editAction), this), Undo);
3303 }
3304
3305 void WebPageProxy::canUndoRedo(uint32_t action, bool& result)
3306 {
3307     result = m_pageClient->canUndoRedo(static_cast<UndoOrRedo>(action));
3308 }
3309
3310 void WebPageProxy::executeUndoRedo(uint32_t action, bool& result)
3311 {
3312     m_pageClient->executeUndoRedo(static_cast<UndoOrRedo>(action));
3313     result = true;
3314 }
3315
3316 void WebPageProxy::clearAllEditCommands()
3317 {
3318     m_pageClient->clearAllEditCommands();
3319 }
3320
3321 void WebPageProxy::didCountStringMatches(const String& string, uint32_t matchCount)
3322 {
3323     m_findClient.didCountStringMatches(this, string, matchCount);
3324 }
3325
3326 void WebPageProxy::didGetImageForFindMatch(const ShareableBitmap::Handle& contentImageHandle, uint32_t matchIndex)
3327 {
3328     m_findMatchesClient.didGetImageForMatchResult(this, WebImage::create(ShareableBitmap::create(contentImageHandle)).get(), matchIndex);
3329 }
3330
3331 void WebPageProxy::setFindIndicator(const FloatRect& selectionRectInWindowCoordinates, const Vector<FloatRect>& textRectsInSelectionRectCoordinates, float contentImageScaleFactor, const ShareableBitmap::Handle& contentImageHandle, bool fadeOut, bool animate)
3332 {
3333     RefPtr<FindIndicator> findIndicator = FindIndicator::create(selectionRectInWindowCoordinates, textRectsInSelectionRectCoordinates, contentImageScaleFactor, contentImageHandle);
3334     m_pageClient->setFindIndicator(findIndicator.release(), fadeOut, animate);
3335 }
3336
3337 void WebPageProxy::didFindString(const String& string, uint32_t matchCount)
3338 {
3339     m_findClient.didFindString(this, string, matchCount);
3340 }
3341
3342 void WebPageProxy::didFindStringMatches(const String& string, Vector<Vector<WebCore::IntRect> > matchRects, int32_t firstIndexAfterSelection)
3343 {
3344     Vector<RefPtr<APIObject> > matches;
3345     matches.reserveInitialCapacity(matchRects.size());
3346
3347     for (size_t i = 0; i < matchRects.size(); ++i) {
3348         const Vector<WebCore::IntRect>& rects = matchRects[i];
3349         size_t numRects = matchRects[i].size();
3350         Vector<RefPtr<APIObject> > apiRects;
3351         apiRects.reserveInitialCapacity(numRects);
3352
3353         for (size_t i = 0; i < numRects; ++i)
3354             apiRects.uncheckedAppend(WebRect::create(toAPI(rects[i])));
3355         matches.uncheckedAppend(ImmutableArray::adopt(apiRects));
3356     }
3357     m_findMatchesClient.didFindStringMatches(this, string, ImmutableArray::adopt(matches).get(), firstIndexAfterSelection);
3358 }
3359
3360 void WebPageProxy::didFailToFindString(const String& string)
3361 {
3362     m_findClient.didFailToFindString(this, string);
3363 }
3364
3365 void WebPageProxy::valueChangedForPopupMenu(WebPopupMenuProxy*, int32_t newSelectedIndex)
3366 {
3367     process()->send(Messages::WebPage::DidChangeSelectedIndexForActivePopupMenu(newSelectedIndex), m_pageID);
3368 }
3369
3370 void WebPageProxy::setTextFromItemForPopupMenu(WebPopupMenuProxy*, int32_t index)
3371 {
3372     process()->send(Messages::WebPage::SetTextForActivePopupMenu(index), m_pageID);
3373 }
3374
3375 NativeWebMouseEvent* WebPageProxy::currentlyProcessedMouseDownEvent()
3376 {
3377     return m_currentlyProcessedMouseDownEvent.get();
3378 }
3379
3380 #if PLATFORM(GTK)
3381 void WebPageProxy::failedToShowPopupMenu()
3382 {
3383     process()->send(Messages::WebPage::FailedToShowPopupMenu(), m_pageID);
3384 }
3385 #endif
3386
3387 void WebPageProxy::showPopupMenu(const IntRect& rect, uint64_t textDirection, const Vector<WebPopupItem>& items, int32_t selectedIndex, const PlatformPopupMenuData& data)
3388 {
3389     if (m_activePopupMenu) {
3390         m_activePopupMenu->hidePopupMenu();
3391         m_activePopupMenu->invalidate();
3392         m_activePopupMenu = 0;
3393     }
3394
3395     m_activePopupMenu = m_pageClient->createPopupMenuProxy(this);
3396
3397     // Since showPopupMenu() can spin a nested run loop we need to turn off the responsiveness timer.
3398     process()->responsivenessTimer()->stop();
3399
3400     RefPtr<WebPopupMenuProxy> protectedActivePopupMenu = m_activePopupMenu;
3401
3402     protectedActivePopupMenu->showPopupMenu(rect, static_cast<TextDirection>(textDirection), m_pageScaleFactor, items, data, selectedIndex);
3403
3404     // 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.
3405 #if !PLATFORM(QT) && !PLATFORM(EFL)
3406     protectedActivePopupMenu->invalidate();
3407 #endif
3408     protectedActivePopupMenu = 0;
3409 }
3410
3411 void WebPageProxy::hidePopupMenu()
3412 {
3413     if (!m_activePopupMenu)
3414         return;
3415
3416     m_activePopupMenu->hidePopupMenu();
3417     m_activePopupMenu->invalidate();
3418     m_activePopupMenu = 0;
3419 }
3420
3421 #if ENABLE(TIZEN_WEBKIT2_POPUP_INTERNAL)
3422 void WebPageProxy::updatePopupMenu(uint64_t textDirection, const Vector<WebPopupItem>& items, int32_t selectedIndex)
3423 {
3424     if (!m_activePopupMenu)
3425         return;
3426
3427     m_activePopupMenu->updatePopupMenu(static_cast<TextDirection>(textDirection), items, selectedIndex);
3428 }
3429 #endif
3430
3431 #if ENABLE(CONTEXT_MENUS)
3432 void WebPageProxy::showContextMenu(const IntPoint& menuLocation, const WebHitTestResult::Data& hitTestResultData, const Vector<WebContextMenuItemData>& proposedItems, CoreIPC::ArgumentDecoder* arguments)
3433 {
3434     internalShowContextMenu(menuLocation, hitTestResultData, proposedItems, arguments);
3435
3436     // No matter the result of internalShowContextMenu, always notify the WebProcess that the menu is hidden so it starts handling mouse events again.
3437     process()->send(Messages::WebPage::ContextMenuHidden(), m_pageID);
3438 }
3439
3440 void WebPageProxy::internalShowContextMenu(const IntPoint& menuLocation, const WebHitTestResult::Data& hitTestResultData, const Vector<WebContextMenuItemData>& proposedItems, CoreIPC::ArgumentDecoder* arguments)
3441 {
3442     RefPtr<APIObject> userData;
3443     WebContextUserMessageDecoder messageDecoder(userData, m_process->context());
3444     if (!arguments->decode(messageDecoder))
3445         return;
3446
3447     m_activeContextMenuHitTestResultData = hitTestResultData;
3448
3449     if (m_activeContextMenu) {
3450         m_activeContextMenu->hideContextMenu();
3451         m_activeContextMenu = 0;
3452     }
3453
3454     m_activeContextMenu = m_pageClient->createContextMenuProxy(this);
3455
3456     // Since showContextMenu() can spin a nested run loop we need to turn off the responsiveness timer.
3457     process()->responsivenessTimer()->stop();
3458
3459     // Give the PageContextMenuClient one last swipe at changing the menu.
3460     Vector<WebContextMenuItemData> items;
3461     if (!m_contextMenuClient.getContextMenuFromProposedMenu(this, proposedItems, items, hitTestResultData, userData.get()))
3462         m_activeContextMenu->showContextMenu(menuLocation, proposedItems);
3463     else
3464         m_activeContextMenu->showContextMenu(menuLocation, items);
3465     
3466     m_contextMenuClient.contextMenuDismissed(this);
3467 }
3468
3469 void WebPageProxy::contextMenuItemSelected(const WebContextMenuItemData& item)
3470 {
3471     TIZEN_LOGI("selected item : action(%d), title(%s)", item.action(), item.title().utf8().data());
3472     // Application custom items don't need to round-trip through to WebCore in the WebProcess.
3473     if (item.action() >= ContextMenuItemBaseApplicationTag) {
3474         m_contextMenuClient.customContextMenuItemSelected(this, item);
3475 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
3476         m_pageClient->setIsTextSelectionMode(false);
3477 #endif
3478         return;
3479     }
3480
3481 #if PLATFORM(MAC)
3482     if (item.action() == ContextMenuItemTagSmartCopyPaste) {
3483         setSmartInsertDeleteEnabled(!isSmartInsertDeleteEnabled());
3484         return;
3485     }
3486     if (item.action() == ContextMenuItemTagSmartQuotes) {
3487         TextChecker::setAutomaticQuoteSubstitutionEnabled(!TextChecker::state().isAutomaticQuoteSubstitutionEnabled);
3488         process()->updateTextCheckerState();
3489         return;
3490     }
3491     if (item.action() == ContextMenuItemTagSmartDashes) {
3492         TextChecker::setAutomaticDashSubstitutionEnabled(!TextChecker::state().isAutomaticDashSubstitutionEnabled);
3493         process()->updateTextCheckerState();
3494         return;
3495     }
3496     if (item.action() == ContextMenuItemTagSmartLinks) {
3497         TextChecker::setAutomaticLinkDetectionEnabled(!TextChecker::state().isAutomaticLinkDetectionEnabled);
3498         process()->updateTextCheckerState();
3499         return;
3500     }
3501     if (item.action() == ContextMenuItemTagTextReplacement) {
3502         TextChecker::setAutomaticTextReplacementEnabled(!TextChecker::state().isAutomaticTextReplacementEnabled);
3503         process()->updateTextCheckerState();
3504         return;
3505     }
3506     if (item.action() == ContextMenuItemTagCorrectSpellingAutomatically) {
3507         TextChecker::setAutomaticSpellingCorrectionEnabled(!TextChecker::state().isAutomaticSpellingCorrectionEnabled);
3508         process()->updateTextCheckerState();
3509         return;        
3510     }
3511     if (item.action() == ContextMenuItemTagShowSubstitutions) {
3512         TextChecker::toggleSubstitutionsPanelIsShowing();
3513         return;
3514     }
3515 #endif
3516     if (item.action() == ContextMenuItemTagDownloadImageToDisk) {
3517         m_process->context()->download(this, KURL(KURL(), m_activeContextMenuHitTestResultData.absoluteImageURL));
3518         return;    
3519     }
3520     if (item.action() == ContextMenuItemTagDownloadLinkToDisk) {
3521         m_process->context()->download(this, KURL(KURL(), m_activeContextMenuHitTestResultData.absoluteLinkURL));
3522         return;
3523     }
3524     if (item.action() == ContextMenuItemTagCheckSpellingWhileTyping) {
3525         TextChecker::setContinuousSpellCheckingEnabled(!TextChecker::state().isContinuousSpellCheckingEnabled);
3526         process()->updateTextCheckerState();
3527         return;
3528     }
3529     if (item.action() == ContextMenuItemTagCheckGrammarWithSpelling) {
3530         TextChecker::setGrammarCheckingEnabled(!TextChecker::state().isGrammarCheckingEnabled);
3531         process()->updateTextCheckerState();
3532         return;
3533     }
3534     if (item.action() == ContextMenuItemTagShowSpellingPanel) {
3535         if (!TextChecker::spellingUIIsShowing())
3536             advanceToNextMisspelling(true);
3537         TextChecker::toggleSpellingUIIsShowing();
3538         return;
3539     }
3540     if (item.action() == ContextMenuItemTagLearnSpelling || item.action() == ContextMenuItemTagIgnoreSpelling)
3541         ++m_pendingLearnOrIgnoreWordMessageCount;
3542
3543 #if ENABLE(TIZEN_WEBKIT2_CLIPBOARD_HELPER)
3544     if (item.action() == ContextMenuItemTagPaste) {
3545         pasteContextMenuSelected();
3546         return;
3547     }
3548 #endif
3549
3550 #if ENABLE(TIZEN_WEBKIT2_CONTEXT_MENU_TEXT_SELECTION_MODE)
3551     if (item.action() == ContextMenuItemTagTextSelectionMode) {
3552 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
3553         m_pageClient->setIsTextSelectionMode(true);
3554 #endif
3555
3556         evas_object_focus_set(viewWidget(), true);
3557         WebCore::IntPoint positionForSelection = m_activeContextMenu->positionForSelection();
3558         bool result = false;
3559         process()->sendSync(Messages::WebPage::SelectLink(positionForSelection), Messages::WebPage::SelectLink::Reply(result), m_pageID);
3560 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
3561         if (result == false)
3562             m_pageClient->setIsTextSelectionMode(false);
3563 #endif
3564
3565         return;
3566     }
3567 #endif
3568
3569 #if ENABLE(TIZEN_WEBKIT2_CONTEXT_MENU_CLIPBOARD)
3570     if (item.action() == ContextMenuItemTagClipboard) {
3571         clipboardContextMenuSelected();
3572         return;
3573     }
3574 #endif
3575
3576 #if ENABLE(CONTEXT_MENUS)
3577     process()->send(Messages::WebPage::DidSelectItemFromActiveContextMenu(item), m_pageID);
3578 #endif
3579 }
3580 #endif // ENABLE(CONTEXT_MENUS)
3581
3582 void WebPageProxy::didChooseFilesForOpenPanel(const Vector<String>& fileURLs)
3583 {
3584     if (!isValid())
3585         return;
3586
3587 #if ENABLE(WEB_PROCESS_SANDBOX)
3588     // FIXME: The sandbox extensions should be sent with the DidChooseFilesForOpenPanel message. This
3589     // is gated on a way of passing SandboxExtension::Handles in a Vector.
3590     for (size_t i = 0; i < fileURLs.size(); ++i) {
3591         SandboxExtension::Handle sandboxExtensionHandle;
3592         SandboxExtension::createHandle(fileURLs[i], SandboxExtension::ReadOnly, sandboxExtensionHandle);
3593         process()->send(Messages::WebPage::ExtendSandboxForFileFromOpenPanel(sandboxExtensionHandle), m_pageID);
3594     }
3595 #endif
3596
3597     process()->send(Messages::WebPage::DidChooseFilesForOpenPanel(fileURLs), m_pageID);
3598
3599     m_openPanelResultListener->invalidate();
3600     m_openPanelResultListener = 0;
3601 }
3602
3603 void WebPageProxy::didCancelForOpenPanel()
3604 {
3605     if (!isValid())
3606         return;
3607
3608     process()->send(Messages::WebPage::DidCancelForOpenPanel(), m_pageID);
3609     
3610     m_openPanelResultListener->invalidate();
3611     m_openPanelResultListener = 0;
3612 }
3613
3614 void WebPageProxy::advanceToNextMisspelling(bool startBeforeSelection) const
3615 {
3616     process()->send(Messages::WebPage::AdvanceToNextMisspelling(startBeforeSelection), m_pageID);
3617 }
3618
3619 void WebPageProxy::changeSpellingToWord(const String& word) const
3620 {
3621     if (word.isEmpty())
3622         return;
3623
3624     process()->send(Messages::WebPage::ChangeSpellingToWord(word), m_pageID);
3625 }
3626
3627 void WebPageProxy::registerEditCommand(PassRefPtr<WebEditCommandProxy> commandProxy, UndoOrRedo undoOrRedo)
3628 {
3629     m_pageClient->registerEditCommand(commandProxy, undoOrRedo);
3630 }
3631
3632 void WebPageProxy::addEditCommand(WebEditCommandProxy* command)
3633 {
3634     m_editCommandSet.add(command);
3635 }
3636
3637 void WebPageProxy::removeEditCommand(WebEditCommandProxy* command)
3638 {
3639     m_editCommandSet.remove(command);
3640
3641     if (!isValid())
3642         return;
3643     process()->send(Messages::WebPage::DidRemoveEditCommand(command->commandID()), m_pageID);
3644 }
3645
3646 bool WebPageProxy::isValidEditCommand(WebEditCommandProxy* command)
3647 {
3648     return m_editCommandSet.find(command) != m_editCommandSet.end();
3649 }
3650
3651 int64_t WebPageProxy::spellDocumentTag()
3652 {
3653     if (!m_hasSpellDocumentTag) {
3654         m_spellDocumentTag = TextChecker::uniqueSpellDocumentTag(this);
3655         m_hasSpellDocumentTag = true;
3656     }
3657
3658     return m_spellDocumentTag;
3659 }
3660
3661 #if USE(UNIFIED_TEXT_CHECKING)
3662 void WebPageProxy::checkTextOfParagraph(const String& text, uint64_t checkingTypes, Vector<TextCheckingResult>& results)
3663 {
3664     results = TextChecker::checkTextOfParagraph(spellDocumentTag(), text.characters(), text.length(), checkingTypes);
3665 }
3666 #endif
3667
3668 void WebPageProxy::checkSpellingOfString(const String& text, int32_t& misspellingLocation, int32_t& misspellingLength)
3669 {
3670     TextChecker::checkSpellingOfString(spellDocumentTag(), text.characters(), text.length(), misspellingLocation, misspellingLength);
3671 }
3672
3673 void WebPageProxy::checkGrammarOfString(const String& text, Vector<GrammarDetail>& grammarDetails, int32_t& badGrammarLocation, int32_t& badGrammarLength)
3674 {
3675     TextChecker::checkGrammarOfString(spellDocumentTag(), text.characters(), text.length(), grammarDetails, badGrammarLocation, badGrammarLength);
3676 }
3677
3678 void WebPageProxy::spellingUIIsShowing(bool& isShowing)
3679 {
3680     isShowing = TextChecker::spellingUIIsShowing();
3681 }
3682
3683 void WebPageProxy::updateSpellingUIWithMisspelledWord(const String& misspelledWord)
3684 {
3685     TextChecker::updateSpellingUIWithMisspelledWord(spellDocumentTag(), misspelledWord);
3686 }
3687
3688 void WebPageProxy::updateSpellingUIWithGrammarString(const String& badGrammarPhrase, const GrammarDetail& grammarDetail)
3689 {
3690     TextChecker::updateSpellingUIWithGrammarString(spellDocumentTag(), badGrammarPhrase, grammarDetail);
3691 }
3692
3693 void WebPageProxy::getGuessesForWord(const String& word, const String& context, Vector<String>& guesses)
3694 {
3695     TextChecker::getGuessesForWord(spellDocumentTag(), word, context, guesses);
3696 }
3697
3698 void WebPageProxy::learnWord(const String& word)
3699 {
3700     MESSAGE_CHECK(m_pendingLearnOrIgnoreWordMessageCount);
3701     --m_pendingLearnOrIgnoreWordMessageCount;
3702
3703     TextChecker::learnWord(spellDocumentTag(), word);
3704 }
3705
3706 void WebPageProxy::ignoreWord(const String& word)
3707 {
3708     MESSAGE_CHECK(m_pendingLearnOrIgnoreWordMessageCount);
3709     --m_pendingLearnOrIgnoreWordMessageCount;
3710
3711     TextChecker::ignoreWord(spellDocumentTag(), word);
3712 }
3713
3714 // Other
3715
3716 void WebPageProxy::setFocus(bool focused)
3717 {
3718     if (focused)
3719         m_uiClient.focus(this);
3720     else
3721         m_uiClient.unfocus(this);
3722 }
3723
3724 void WebPageProxy::takeFocus(uint32_t direction)
3725 {
3726     m_uiClient.takeFocus(this, (static_cast<FocusDirection>(direction) == FocusDirectionForward) ? kWKFocusDirectionForward : kWKFocusDirectionBackward);
3727 }
3728
3729 void WebPageProxy::setToolTip(const String& toolTip)
3730 {
3731     String oldToolTip = m_toolTip;
3732     m_toolTip = toolTip;
3733     m_pageClient->toolTipChanged(oldToolTip, m_toolTip);
3734 }
3735
3736 void WebPageProxy::setCursor(const WebCore::Cursor& cursor)
3737 {
3738     m_pageClient->setCursor(cursor);
3739 }
3740
3741 void WebPageProxy::setCursorHiddenUntilMouseMoves(bool hiddenUntilMouseMoves)
3742 {
3743     m_pageClient->setCursorHiddenUntilMouseMoves(hiddenUntilMouseMoves);
3744 }
3745
3746 void WebPageProxy::didReceiveEvent(uint32_t opaqueType, bool handled)
3747 {
3748     WebEvent::Type type = static_cast<WebEvent::Type>(opaqueType);
3749
3750     switch (type) {
3751     case WebEvent::NoType:
3752     case WebEvent::MouseMove:
3753         break;
3754
3755     case WebEvent::MouseDown:
3756     case WebEvent::MouseUp:
3757     case WebEvent::Wheel:
3758     case WebEvent::KeyDown:
3759     case WebEvent::KeyUp:
3760     case WebEvent::RawKeyDown:
3761     case WebEvent::Char:
3762 #if ENABLE(GESTURE_EVENTS)
3763     case WebEvent::GestureScrollBegin:
3764     case WebEvent::GestureScrollEnd:
3765     case WebEvent::GestureSingleTap:
3766 #endif
3767 #if ENABLE(TOUCH_EVENTS)
3768     case WebEvent::TouchStart:
3769     case WebEvent::TouchMove:
3770     case WebEvent::TouchEnd:
3771     case WebEvent::TouchCancel:
3772 #endif
3773         process()->responsivenessTimer()->stop();
3774         break;
3775     }
3776
3777     switch (type) {
3778     case WebEvent::NoType:
3779         break;
3780     case WebEvent::MouseMove:
3781         m_processingMouseMoveEvent = false;
3782         if (m_nextMouseMoveEvent) {
3783             handleMouseEvent(*m_nextMouseMoveEvent);
3784             m_nextMouseMoveEvent = nullptr;
3785         }
3786         break;
3787     case WebEvent::MouseDown:
3788         break;
3789 #if ENABLE(GESTURE_EVENTS)
3790     case WebEvent::GestureScrollBegin:
3791     case WebEvent::GestureScrollEnd:
3792     case WebEvent::GestureSingleTap: {
3793 #if ENABLE(TIZEN_WEBKIT2_ROTATION_WHILE_JAVASCRIPT_POPUP)
3794         QueuedUIEvents<WebGestureEvent> queuedEvents = m_gestureEventQueue.first();
3795         MESSAGE_CHECK(type == queuedEvents.forwardedEvent.type());
3796         m_gestureEventQueue.removeFirst();
3797
3798         m_pageClient->doneWithGestureEvent(queuedEvents.forwardedEvent, handled);
3799         for (size_t i = 0; i < queuedEvents.deferredEvents.size(); ++i) {
3800             bool isEventHandled = false;
3801             m_pageClient->doneWithGestureEvent(queuedEvents.deferredEvents.at(i), isEventHandled);
3802         }
3803 #else
3804         WebGestureEvent event = m_gestureEventQueue.first();
3805         MESSAGE_CHECK(type == event.type());
3806
3807         m_gestureEventQueue.removeFirst();
3808         m_pageClient->doneWithGestureEvent(event, handled);
3809 #endif
3810 #if ENABLE(TIZEN_ISF_PORT)
3811         if (m_isVisible && type == WebEvent::GestureSingleTap)
3812             evas_object_focus_set(viewWidget(), true);
3813 #endif
3814         break;
3815     }
3816 #endif
3817     case WebEvent::MouseUp:
3818         m_currentlyProcessedMouseDownEvent = nullptr;
3819         break;
3820
3821     case WebEvent::Wheel: {
3822         ASSERT(!m_currentlyProcessedWheelEvents.isEmpty());
3823
3824         OwnPtr<Vector<NativeWebWheelEvent> > oldestCoalescedEvent = m_currentlyProcessedWheelEvents.takeFirst();
3825
3826         // FIXME: Dispatch additional events to the didNotHandleWheelEvent client function.
3827         if (!handled && m_uiClient.implementsDidNotHandleWheelEvent())
3828             m_uiClient.didNotHandleWheelEvent(this, oldestCoalescedEvent->last());
3829
3830         if (!m_wheelEventQueue.isEmpty())
3831             processNextQueuedWheelEvent();
3832         break;
3833     }
3834
3835     case WebEvent::KeyDown:
3836     case WebEvent::KeyUp:
3837     case WebEvent::RawKeyDown:
3838     case WebEvent::Char: {
3839         LOG(KeyHandling, "WebPageProxy::didReceiveEvent: %s", webKeyboardEventTypeString(type));
3840
3841 #if ENABLE(TIZEN_WEBKIT2_ROTATION_WHILE_JAVASCRIPT_POPUP)
3842         QueuedUIEvents<NativeWebKeyboardEvent> queuedEvents = m_keyEventQueue.first();
3843         NativeWebKeyboardEvent event = queuedEvents.forwardedEvent;
3844         MESSAGE_CHECK(type == event.type());
3845         m_keyEventQueue.removeFirst();
3846
3847         m_pageClient->doneWithKeyEvent(event, handled);
3848         for (size_t i = 0; i < queuedEvents.deferredEvents.size(); ++i) {
3849             bool isEventHandled = false;
3850             m_pageClient->doneWithKeyEvent(queuedEvents.deferredEvents.at(i), isEventHandled);
3851         }
3852 #else
3853         NativeWebKeyboardEvent event = m_keyEventQueue.first();
3854         MESSAGE_CHECK(type == event.type());
3855
3856         m_keyEventQueue.removeFirst();
3857
3858         if (!m_keyEventQueue.isEmpty())
3859             process()->send(Messages::WebPage::KeyEvent(m_keyEventQueue.first()), m_pageID);
3860
3861         m_pageClient->doneWithKeyEvent(event, handled);
3862 #endif // #if ENABLE(TIZEN_WEBKIT2_ROTATION_WHILE_JAVASCRIPT_POPUP)
3863
3864         if (handled)
3865             break;
3866
3867 #if ENABLE(TIZEN_ISF_PORT)
3868         InputMethodContextEfl* inputMethodContext = static_cast<PageClientImpl*>(m_pageClient)->viewImpl()->inputMethodContext();
3869         if (event.type() == WebEvent::KeyDown && event.keyIdentifier() == "Enter" && inputMethodContext && inputMethodContext->autoCapitalType() == ECORE_IMF_AUTOCAPITAL_TYPE_NONE)
3870             inputMethodContext->hideIMFContext();
3871 #endif
3872
3873         if (m_uiClient.implementsDidNotHandleKeyEvent())
3874             m_uiClient.didNotHandleKeyEvent(this, event);
3875 #if PLATFORM(WIN)
3876         else
3877             ::TranslateMessage(event.nativeEvent());
3878 #endif
3879         break;
3880     }
3881 #if ENABLE(TOUCH_EVENTS)
3882     case WebEvent::TouchStart:
3883     case WebEvent::TouchMove:
3884     case WebEvent::TouchEnd:
3885     case WebEvent::TouchCancel: {
3886 #if ENABLE(TIZEN_WEBKIT2_ROTATION_WHILE_JAVASCRIPT_POPUP)
3887         QueuedUIEvents<NativeWebTouchEvent> queuedEvents = m_touchEventQueue.first();
3888         MESSAGE_CHECK(type == queuedEvents.forwardedEvent.type());
3889         m_touchEventQueue.removeFirst();
3890
3891         m_pageClient->doneWithTouchEvent(queuedEvents.forwardedEvent, handled);
3892         for (size_t i = 0; i < queuedEvents.deferredEvents.size(); ++i) {
3893             bool isEventHandled = false;
3894             m_pageClient->doneWithTouchEvent(queuedEvents.deferredEvents.at(i), isEventHandled);
3895         }
3896 #else
3897         QueuedTouchEvents queuedEvents = m_touchEventQueue.first();
3898         MESSAGE_CHECK(type == queuedEvents.forwardedEvent.type());
3899         m_touchEventQueue.removeFirst();
3900
3901         m_pageClient->doneWithTouchEvent(queuedEvents.forwardedEvent, handled);
3902         for (size_t i = 0; i < queuedEvents.deferredTouchEvents.size(); ++i) {
3903             bool isEventHandled = false;
3904             m_pageClient->doneWithTouchEvent(queuedEvents.deferredTouchEvents.at(i), isEventHandled);
3905         }
3906 #endif
3907         break;
3908     }
3909 #endif
3910     }
3911 }
3912
3913 void WebPageProxy::stopResponsivenessTimer()
3914 {
3915     process()->responsivenessTimer()->stop();
3916 }
3917
3918 void WebPageProxy::voidCallback(uint64_t callbackID)
3919 {
3920     RefPtr<VoidCallback> callback = m_voidCallbacks.take(callbackID);
3921     if (!callback) {
3922         // FIXME: Log error or assert.
3923         return;
3924     }
3925
3926     callback->performCallback();
3927 }
3928
3929 void WebPageProxy::dataCallback(const CoreIPC::DataReference& dataReference, uint64_t callbackID)
3930 {
3931     RefPtr<DataCallback> callback = m_dataCallbacks.take(callbackID);
3932     if (!callback) {
3933         // FIXME: Log error or assert.
3934         return;
3935     }
3936
3937     callback->performCallbackWithReturnValue(WebData::create(dataReference.data(), dataReference.size()).get());
3938 }
3939
3940 void WebPageProxy::stringCallback(const String& resultString, uint64_t callbackID)
3941 {
3942     RefPtr<StringCallback> callback = m_stringCallbacks.take(callbackID);
3943     if (!callback) {
3944         // FIXME: Log error or assert.
3945         // this can validly happen if a load invalidated the callback, though
3946         return;
3947     }
3948
3949     m_loadDependentStringCallbackIDs.remove(callbackID);
3950
3951     callback->performCallbackWithReturnValue(resultString.impl());
3952 }
3953
3954 void WebPageProxy::scriptValueCallback(const CoreIPC::DataReference& dataReference, uint64_t callbackID)
3955 {
3956     RefPtr<ScriptValueCallback> callback = m_scriptValueCallbacks.take(callbackID);
3957     if (!callback) {
3958         // FIXME: Log error or assert.
3959         return;
3960     }
3961
3962     Vector<uint8_t> data;
3963     data.reserveInitialCapacity(dataReference.size());
3964     data.append(dataReference.data(), dataReference.size());
3965
3966     callback->performCallbackWithReturnValue(data.size() ? WebSerializedScriptValue::adopt(data).get() : 0);
3967 }
3968
3969 void WebPageProxy::computedPagesCallback(const Vector<IntRect>& pageRects, double totalScaleFactorForPrinting, uint64_t callbackID)
3970 {
3971     RefPtr<ComputedPagesCallback> callback = m_computedPagesCallbacks.take(callbackID);
3972     if (!callback) {
3973         // FIXME: Log error or assert.
3974         return;
3975     }
3976
3977     callback->performCallbackWithReturnValue(pageRects, totalScaleFactorForPrinting);
3978 }
3979
3980 void WebPageProxy::validateCommandCallback(const String& commandName, bool isEnabled, int state, uint64_t callbackID)
3981 {
3982     RefPtr<ValidateCommandCallback> callback = m_validateCommandCallbacks.take(callbackID);
3983     if (!callback) {
3984         // FIXME: Log error or assert.
3985         return;
3986     }
3987
3988     callback->performCallbackWithReturnValue(commandName.impl(), isEnabled, state);
3989 }
3990
3991 #if PLATFORM(GTK)
3992 void WebPageProxy::printFinishedCallback(const ResourceError& printError, uint64_t callbackID)
3993 {
3994     RefPtr<PrintFinishedCallback> callback = m_printFinishedCallbacks.take(callbackID);
3995     if (!callback) {
3996         // FIXME: Log error or assert.
3997         return;
3998     }
3999
4000     RefPtr<WebError> error = WebError::create(printError);
4001     callback->performCallbackWithReturnValue(error.get());
4002 }
4003 #endif
4004
4005 void WebPageProxy::focusedFrameChanged(uint64_t frameID)
4006 {
4007     if (!frameID) {
4008         m_focusedFrame = 0;
4009         return;
4010     }
4011
4012     WebFrameProxy* frame = process()->webFrame(frameID);
4013     MESSAGE_CHECK(frame);
4014
4015     m_focusedFrame = frame;
4016 }
4017
4018 void WebPageProxy::frameSetLargestFrameChanged(uint64_t frameID)
4019 {
4020     if (!frameID) {
4021         m_frameSetLargestFrame = 0;
4022         return;
4023     }
4024
4025     WebFrameProxy* frame = process()->webFrame(frameID);
4026     MESSAGE_CHECK(frame);
4027
4028     m_frameSetLargestFrame = frame;
4029 }
4030
4031 void WebPageProxy::processDidBecomeUnresponsive()
4032 {
4033     if (!isValid())
4034         return;
4035
4036     updateBackingStoreDiscardableState();
4037
4038     m_loaderClient.processDidBecomeUnresponsive(this);
4039 }
4040
4041 void WebPageProxy::interactionOccurredWhileProcessUnresponsive()
4042 {
4043     if (!isValid())
4044         return;
4045
4046     m_loaderClient.interactionOccurredWhileProcessUnresponsive(this);
4047 }
4048
4049 void WebPageProxy::processDidBecomeResponsive()
4050 {
4051     if (!isValid())
4052         return;
4053     
4054     updateBackingStoreDiscardableState();
4055
4056     m_loaderClient.processDidBecomeResponsive(this);
4057 }
4058
4059 void WebPageProxy::processDidCrash()
4060 {
4061     ASSERT(m_pageClient);
4062
4063     m_isValid = false;
4064     m_isPageSuspended = false;
4065
4066     if (m_mainFrame) {
4067         m_urlAtProcessExit = m_mainFrame->url();
4068         m_loadStateAtProcessExit = m_mainFrame->loadState();
4069     }
4070
4071     m_mainFrame = nullptr;
4072     m_drawingArea = nullptr;
4073
4074 #if ENABLE(INSPECTOR)
4075     if (m_inspector) {
4076         m_inspector->invalidate();
4077         m_inspector = nullptr;
4078     }
4079 #endif
4080
4081 #if ENABLE(FULLSCREEN_API)
4082     if (m_fullScreenManager) {
4083         m_fullScreenManager->invalidate();
4084         m_fullScreenManager = nullptr;
4085     }
4086 #endif
4087
4088     if (m_openPanelResultListener) {
4089         m_openPanelResultListener->invalidate();
4090         m_openPanelResultListener = nullptr;
4091     }
4092
4093 #if ENABLE(INPUT_TYPE_COLOR)
4094     if (m_colorChooser) {
4095         m_colorChooser->invalidate();
4096         m_colorChooser = nullptr;
4097     }
4098
4099 #if ENABLE(TIZEN_INPUT_COLOR_PICKER) // wait for upstream
4100     if (m_colorPickerResultListener) {
4101         m_colorPickerResultListener->invalidate();
4102         m_colorPickerResultListener = nullptr;
4103     }
4104 #endif
4105 #endif
4106
4107 #if ENABLE(GEOLOCATION)
4108     m_geolocationPermissionRequestManager.invalidateRequests();
4109 #endif
4110
4111     m_notificationPermissionRequestManager.invalidateRequests();
4112
4113     m_toolTip = String();
4114
4115     m_mainFrameHasHorizontalScrollbar = false;
4116     m_mainFrameHasVerticalScrollbar = false;
4117
4118     m_mainFrameIsPinnedToLeftSide = false;
4119     m_mainFrameIsPinnedToRightSide = false;
4120
4121     m_visibleScrollerThumbRect = IntRect();
4122
4123 #if ENABLE(TIZEN_SUPPORT_WEBAPP_META_TAG)
4124     invalidateCallbackMap(m_booleanCallbacks);
4125     invalidateCallbackMap(m_dictionaryCallbacks);
4126 #endif
4127     invalidateCallbackMap(m_voidCallbacks);
4128     invalidateCallbackMap(m_dataCallbacks);
4129     invalidateCallbackMap(m_stringCallbacks);
4130     m_loadDependentStringCallbackIDs.clear();
4131     invalidateCallbackMap(m_scriptValueCallbacks);
4132     invalidateCallbackMap(m_computedPagesCallbacks);
4133     invalidateCallbackMap(m_validateCommandCallbacks);
4134 #if PLATFORM(GTK)
4135     invalidateCallbackMap(m_printFinishedCallbacks);
4136 #endif
4137
4138     Vector<WebEditCommandProxy*> editCommandVector;
4139     copyToVector(m_editCommandSet, editCommandVector);
4140     m_editCommandSet.clear();
4141     for (size_t i = 0, size = editCommandVector.size(); i < size; ++i)
4142         editCommandVector[i]->invalidate();
4143     m_pageClient->clearAllEditCommands();
4144
4145     m_activePopupMenu = 0;
4146
4147     m_estimatedProgress = 0.0;
4148
4149     m_pendingLearnOrIgnoreWordMessageCount = 0;
4150
4151     m_pageClient->processDidCrash();
4152     m_loaderClient.processDidCrash(this);
4153
4154     if (!m_isValid) {
4155         // If the call out to the loader client didn't cause the web process to be relaunched, 
4156         // we'll call setNeedsDisplay on the view so that we won't have the old contents showing.
4157         // If the call did cause the web process to be relaunched, we'll keep the old page contents showing
4158         // until the new web process has painted its contents.
4159         setViewNeedsDisplay(IntRect(IntPoint(), viewSize()));
4160     }
4161
4162     // Can't expect DidReceiveEvent notifications from a crashed web process.
4163     m_keyEventQueue.clear();
4164     
4165     m_wheelEventQueue.clear();
4166     m_currentlyProcessedWheelEvents.clear();
4167
4168     m_nextMouseMoveEvent = nullptr;
4169     m_currentlyProcessedMouseDownEvent = nullptr;
4170
4171     m_processingMouseMoveEvent = false;
4172
4173 #if ENABLE(TOUCH_EVENTS)
4174     m_needTouchEvents = false;
4175     m_touchEventQueue.clear();
4176 #endif
4177
4178 #if PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
4179     dismissCorrectionPanel(ReasonForDismissingAlternativeTextIgnored);
4180     m_pageClient->dismissDictionaryLookupPanel();
4181 #endif
4182 }
4183
4184 WebPageCreationParameters WebPageProxy::creationParameters() const
4185 {
4186     WebPageCreationParameters parameters;
4187
4188     parameters.viewSize = m_pageClient->viewSize();
4189     parameters.isActive = m_pageClient->isViewWindowActive();
4190     parameters.isFocused = m_pageClient->isViewFocused();
4191     parameters.isVisible = m_pageClient->isViewVisible();
4192     parameters.isInWindow = m_pageClient->isViewInWindow();
4193     parameters.drawingAreaType = m_drawingArea->type();
4194     parameters.store = m_pageGroup->preferences()->store();
4195     parameters.pageGroupData = m_pageGroup->data();
4196     parameters.drawsBackground = m_drawsBackground;
4197     parameters.drawsTransparentBackground = m_drawsTransparentBackground;
4198     parameters.areMemoryCacheClientCallsEnabled = m_areMemoryCacheClientCallsEnabled;
4199     parameters.useFixedLayout = m_useFixedLayout;
4200     parameters.fixedLayoutSize = m_fixedLayoutSize;
4201     parameters.paginationMode = m_paginationMode;
4202     parameters.paginationBehavesLikeColumns = m_paginationBehavesLikeColumns;
4203     parameters.pageLength = m_pageLength;
4204     parameters.gapBetweenPages = m_gapBetweenPages;
4205     parameters.userAgent = userAgent();
4206     parameters.sessionState = SessionState(m_backForwardList->entries(), m_backForwardList->currentIndex());
4207     parameters.highestUsedBackForwardItemID = WebBackForwardListItem::highedUsedItemID();
4208     parameters.canRunBeforeUnloadConfirmPanel = m_uiClient.canRunBeforeUnloadConfirmPanel();
4209     parameters.canRunModal = m_canRunModal;
4210     parameters.deviceScaleFactor = m_intrinsicDeviceScaleFactor;
4211     parameters.mediaVolume = m_mediaVolume;
4212
4213 #if PLATFORM(MAC)
4214     parameters.isSmartInsertDeleteEnabled = m_isSmartInsertDeleteEnabled;
4215     parameters.layerHostingMode = m_layerHostingMode;
4216     parameters.colorSpace = m_pageClient->colorSpace();
4217 #endif
4218
4219 #if PLATFORM(WIN)
4220     parameters.nativeWindow = m_pageClient->nativeWindow();
4221 #endif
4222     return parameters;
4223 }
4224
4225 #if USE(ACCELERATED_COMPOSITING)
4226 void WebPageProxy::enterAcceleratedCompositingMode(const LayerTreeContext& layerTreeContext)
4227 {
4228     m_pageClient->enterAcceleratedCompositingMode(layerTreeContext);
4229 }
4230
4231 void WebPageProxy::exitAcceleratedCompositingMode()
4232 {
4233 #if ENABLE(TIZEN_WEBKIT2_TILED_AC_SHARED_PLATFORM_SURFACE)
4234     process()->platformSurfaceTexturePool()->removeAllPlatformSurfaceTextures();
4235 #endif
4236     m_pageClient->exitAcceleratedCompositingMode();
4237 }
4238
4239 void WebPageProxy::updateAcceleratedCompositingMode(const LayerTreeContext& layerTreeContext)
4240 {
4241     m_pageClient->updateAcceleratedCompositingMode(layerTreeContext);
4242 }
4243 #endif // USE(ACCELERATED_COMPOSITING)
4244
4245 void WebPageProxy::backForwardClear()
4246 {
4247     m_backForwardList->clear();
4248 }
4249
4250 void WebPageProxy::canAuthenticateAgainstProtectionSpaceInFrame(uint64_t frameID, const ProtectionSpace& coreProtectionSpace, bool& canAuthenticate)
4251 {
4252     WebFrameProxy* frame = process()->webFrame(frameID);
4253     MESSAGE_CHECK(frame);
4254
4255     RefPtr<WebProtectionSpace> protectionSpace = WebProtectionSpace::create(coreProtectionSpace);
4256     
4257     canAuthenticate = m_loaderClient.canAuthenticateAgainstProtectionSpaceInFrame(this, frame, protectionSpace.get());
4258 }
4259
4260 #if ENABLE(TIZEN_ON_AUTHENTICATION_REQUESTED)
4261 void WebPageProxy::didReceiveAuthenticationChallenge(uint64_t frameID, const AuthenticationChallenge& coreChallenge, uint64_t challengeID, PassRefPtr<Messages::WebPageProxy::DidReceiveAuthenticationChallenge::DelayedReply> reply)
4262 #else
4263 void WebPageProxy::didReceiveAuthenticationChallenge(uint64_t frameID, const AuthenticationChallenge& coreChallenge, uint64_t challengeID)
4264 #endif
4265 {
4266     WebFrameProxy* frame = process()->webFrame(frameID);
4267     MESSAGE_CHECK(frame);
4268
4269 #if ENABLE(TIZEN_ON_AUTHENTICATION_REQUESTED)
4270     RefPtr<AuthenticationChallengeProxy> authenticationChallenge = frame->setUpAuthenticationChallengeProxy(coreChallenge, challengeID, process());
4271     m_AuthReply = reply;
4272
4273     if (!m_loaderClient.didReceiveAuthenticationChallengeInFrame(this, frame, authenticationChallenge.get()))
4274         replyReceiveAuthenticationChallengeInFrame(true);
4275 #else
4276     RefPtr<AuthenticationChallengeProxy> authenticationChallenge = AuthenticationChallengeProxy::create(coreChallenge, challengeID, process());
4277
4278     m_loaderClient.didReceiveAuthenticationChallengeInFrame(this, frame, authenticationChallenge.get());
4279 #endif
4280 }
4281
4282 #if ENABLE(TIZEN_SQL_DATABASE)
4283 void WebPageProxy::exceededDatabaseQuota(uint64_t frameID, const String& originIdentifier, const String& displayName, uint64_t expectedUsage, PassRefPtr<Messages::WebPageProxy::ExceededDatabaseQuota::DelayedReply> allowExceed)
4284 {
4285     WebFrameProxy* frame = process()->webFrame(frameID);
4286     MESSAGE_CHECK(frame);
4287
4288     // Since exceededDatabaseQuota() can spin a nested run loop we need to turn off the responsiveness timer.
4289     process()->responsivenessTimer()->stop();
4290
4291     m_exceededDatabaseQuotaReply = allowExceed;
4292     RefPtr<WebSecurityOrigin> origin = WebSecurityOrigin::createFromDatabaseIdentifier(originIdentifier);
4293 #if ENABLE(TIZEN_WEBKIT2_ROTATION_WHILE_JAVASCRIPT_POPUP)
4294     process()->connection()->setForcelySetAllAsyncMessagesToDispatchEvenWhenWaitingForSyncReply(true);
4295 #endif
4296
4297     if (!m_uiClient.exceededDatabaseQuota(this, frame, origin.get(), displayName, expectedUsage))
4298         replyExceededDatabaseQuota(true);
4299 }
4300 #else
4301 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)
4302 {
4303     WebFrameProxy* frame = process()->webFrame(frameID);
4304     MESSAGE_CHECK(frame);
4305
4306     RefPtr<WebSecurityOrigin> origin = WebSecurityOrigin::createFromDatabaseIdentifier(originIdentifier);
4307
4308     newQuota = m_uiClient.exceededDatabaseQuota(this, frame, origin.get(), databaseName, displayName, currentQuota, currentOriginUsage, currentDatabaseUsage, expectedUsage);
4309 }
4310 #endif
4311
4312 void WebPageProxy::requestGeolocationPermissionForFrame(uint64_t geolocationID, uint64_t frameID, String originIdentifier)
4313 {
4314     WebFrameProxy* frame = process()->webFrame(frameID);
4315     MESSAGE_CHECK(frame);
4316
4317     // FIXME: Geolocation should probably be using toString() as its string representation instead of databaseIdentifier().
4318     RefPtr<WebSecurityOrigin> origin = WebSecurityOrigin::createFromDatabaseIdentifier(originIdentifier);
4319     RefPtr<GeolocationPermissionRequestProxy> request = m_geolocationPermissionRequestManager.createRequest(geolocationID);
4320
4321     if (!m_uiClient.decidePolicyForGeolocationPermissionRequest(this, frame, origin.get(), request.get()))
4322         request->deny();
4323 }
4324
4325 void WebPageProxy::requestNotificationPermission(uint64_t requestID, const String& originString)
4326 {
4327     if (!isRequestIDValid(requestID))
4328         return;
4329
4330     RefPtr<WebSecurityOrigin> origin = WebSecurityOrigin::createFromString(originString);
4331     RefPtr<NotificationPermissionRequest> request = m_notificationPermissionRequestManager.createRequest(requestID);
4332     
4333     if (!m_uiClient.decidePolicyForNotificationPermissionRequest(this, origin.get(), request.get()))
4334         request->deny();
4335 }
4336
4337 void WebPageProxy::showNotification(const String& title, const String& body, const String& iconURL, const String& tag, const String& originString, uint64_t notificationID)
4338 {
4339     m_process->context()->notificationManagerProxy()->show(this, title, body, iconURL, tag, originString, notificationID);
4340 }
4341
4342 #if ENABLE(TIZEN_MEDIA_STREAM)
4343 void WebPageProxy::requestUserMediaPermission(uint64_t requestID)
4344 {
4345     RefPtr<UserMediaPermissionRequest> request = m_userMediaPermissionRequestManager.createRequest(requestID);
4346
4347     if (!m_tizenClient.decidePolicyForUserMediaPermissionRequest(this, request.get()))
4348         request->deny();
4349 }
4350 #endif
4351
4352 float WebPageProxy::headerHeight(WebFrameProxy* frame)
4353 {
4354     if (frame->isDisplayingPDFDocument())
4355         return 0;
4356     return m_uiClient.headerHeight(this, frame);
4357 }
4358
4359 float WebPageProxy::footerHeight(WebFrameProxy* frame)
4360 {
4361     if (frame->isDisplayingPDFDocument())
4362         return 0;
4363     return m_uiClient.footerHeight(this, frame);
4364 }
4365
4366 void WebPageProxy::drawHeader(WebFrameProxy* frame, const FloatRect& rect)
4367 {
4368     if (frame->isDisplayingPDFDocument())
4369         return;
4370     m_uiClient.drawHeader(this, frame, rect);
4371 }
4372
4373 void WebPageProxy::drawFooter(WebFrameProxy* frame, const FloatRect& rect)
4374 {
4375     if (frame->isDisplayingPDFDocument())
4376         return;
4377     m_uiClient.drawFooter(this, frame, rect);
4378 }
4379
4380 void WebPageProxy::runModal()
4381 {
4382     // Since runModal() can (and probably will) spin a nested run loop we need to turn off the responsiveness timer.
4383     process()->responsivenessTimer()->stop();
4384
4385     // Our Connection's run loop might have more messages waiting to be handled after this RunModal message.
4386     // To make sure they are handled inside of the the nested modal run loop we must first signal the Connection's
4387     // run loop so we're guaranteed that it has a chance to wake up.
4388     // See http://webkit.org/b/89590 for more discussion.
4389     process()->connection()->wakeUpRunLoop();
4390
4391     m_uiClient.runModal(this);
4392 }
4393
4394 void WebPageProxy::notifyScrollerThumbIsVisibleInRect(const IntRect& scrollerThumb)
4395 {
4396     m_visibleScrollerThumbRect = scrollerThumb;
4397 }
4398
4399 void WebPageProxy::recommendedScrollbarStyleDidChange(int32_t newStyle)
4400 {
4401 #if PLATFORM(MAC)
4402     m_pageClient->recommendedScrollbarStyleDidChange(newStyle);
4403 #endif
4404 }
4405
4406 void WebPageProxy::didChangeScrollbarsForMainFrame(bool hasHorizontalScrollbar, bool hasVerticalScrollbar)
4407 {
4408     m_mainFrameHasHorizontalScrollbar = hasHorizontalScrollbar;
4409     m_mainFrameHasVerticalScrollbar = hasVerticalScrollbar;
4410
4411     m_pageClient->didChangeScrollbarsForMainFrame();
4412 }
4413
4414 void WebPageProxy::didChangeScrollOffsetPinningForMainFrame(bool pinnedToLeftSide, bool pinnedToRightSide)
4415 {
4416     m_mainFrameIsPinnedToLeftSide = pinnedToLeftSide;
4417     m_mainFrameIsPinnedToRightSide = pinnedToRightSide;
4418 }
4419
4420 void WebPageProxy::didChangePageCount(unsigned pageCount)
4421 {
4422     m_pageCount = pageCount;
4423 }
4424
4425 void WebPageProxy::didFailToInitializePlugin(const String& mimeType)
4426 {
4427     m_loaderClient.didFailToInitializePlugin(this, mimeType);
4428 }
4429
4430 void WebPageProxy::didBlockInsecurePluginVersion(const String& mimeType, const String& urlString)
4431 {
4432     String pluginIdentifier;
4433     String pluginVersion;
4434     String newMimeType = mimeType;
4435
4436 #if PLATFORM(MAC)
4437     PluginModuleInfo plugin = m_process->context()->pluginInfoStore().findPlugin(newMimeType, KURL(KURL(), urlString));
4438
4439     pluginIdentifier = plugin.bundleIdentifier;
4440     pluginVersion = plugin.versionString;
4441 #endif
4442
4443     m_loaderClient.didBlockInsecurePluginVersion(this, newMimeType, pluginIdentifier, pluginVersion);
4444 }
4445
4446 bool WebPageProxy::willHandleHorizontalScrollEvents() const
4447 {
4448     return !m_canShortCircuitHorizontalWheelEvents;
4449 }
4450
4451 void WebPageProxy::didFinishLoadingDataForCustomRepresentation(const String& suggestedFilename, const CoreIPC::DataReference& dataReference)
4452 {
4453     m_pageClient->didFinishLoadingDataForCustomRepresentation(suggestedFilename, dataReference);
4454 }
4455
4456 void WebPageProxy::backForwardRemovedItem(uint64_t itemID)
4457 {
4458     process()->send(Messages::WebPage::DidRemoveBackForwardItem(itemID), m_pageID);
4459 }
4460
4461 void WebPageProxy::setCanRunModal(bool canRunModal)
4462 {
4463     if (!isValid())
4464         return;
4465
4466     // It's only possible to change the state for a WebPage which
4467     // already qualifies for running modal child web pages, otherwise
4468     // there's no other possibility than not allowing it.
4469     m_canRunModal = m_uiClient.canRunModal() && canRunModal;
4470     process()->send(Messages::WebPage::SetCanRunModal(m_canRunModal), m_pageID);
4471 }
4472
4473 bool WebPageProxy::canRunModal()
4474 {
4475     return isValid() ? m_canRunModal : false;
4476 }
4477
4478 void WebPageProxy::beginPrinting(WebFrameProxy* frame, const PrintInfo& printInfo)
4479 {
4480     if (m_isInPrintingMode)
4481         return;
4482
4483     m_isInPrintingMode = true;
4484     process()->send(Messages::WebPage::BeginPrinting(frame->frameID(), printInfo), m_pageID, m_isPerformingDOMPrintOperation ? CoreIPC::DispatchMessageEvenWhenWaitingForSyncReply : 0);
4485 }
4486
4487 void WebPageProxy::endPrinting()
4488 {
4489     if (!m_isInPrintingMode)
4490         return;
4491
4492     m_isInPrintingMode = false;
4493     process()->send(Messages::WebPage::EndPrinting(), m_pageID, m_isPerformingDOMPrintOperation ? CoreIPC::DispatchMessageEvenWhenWaitingForSyncReply : 0);
4494 }
4495
4496 void WebPageProxy::computePagesForPrinting(WebFrameProxy* frame, const PrintInfo& printInfo, PassRefPtr<ComputedPagesCallback> prpCallback)
4497 {
4498     RefPtr<ComputedPagesCallback> callback = prpCallback;
4499     if (!isValid()) {
4500         callback->invalidate();
4501         return;
4502     }
4503
4504     uint64_t callbackID = callback->callbackID();
4505     m_computedPagesCallbacks.set(callbackID, callback.get());
4506     m_isInPrintingMode = true;
4507     process()->send(Messages::WebPage::ComputePagesForPrinting(frame->frameID(), printInfo, callbackID), m_pageID, m_isPerformingDOMPrintOperation ? CoreIPC::DispatchMessageEvenWhenWaitingForSyncReply : 0);
4508 }
4509
4510 #if PLATFORM(MAC) || PLATFORM(WIN)
4511 void WebPageProxy::drawRectToPDF(WebFrameProxy* frame, const PrintInfo& printInfo, const IntRect& rect, PassRefPtr<DataCallback> prpCallback)
4512 {
4513     RefPtr<DataCallback> callback = prpCallback;
4514     if (!isValid()) {
4515         callback->invalidate();
4516         return;
4517     }
4518     
4519     uint64_t callbackID = callback->callbackID();
4520     m_dataCallbacks.set(callbackID, callback.get());
4521     process()->send(Messages::WebPage::DrawRectToPDF(frame->frameID(), printInfo, rect, callbackID), m_pageID, m_isPerformingDOMPrintOperation ? CoreIPC::DispatchMessageEvenWhenWaitingForSyncReply : 0);
4522 }
4523
4524 void WebPageProxy::drawPagesToPDF(WebFrameProxy* frame, const PrintInfo& printInfo, uint32_t first, uint32_t count, PassRefPtr<DataCallback> prpCallback)
4525 {
4526     RefPtr<DataCallback> callback = prpCallback;
4527     if (!isValid()) {
4528         callback->invalidate();
4529         return;
4530     }
4531     
4532     uint64_t callbackID = callback->callbackID();
4533     m_dataCallbacks.set(callbackID, callback.get());
4534     process()->send(Messages::WebPage::DrawPagesToPDF(frame->frameID(), printInfo, first, count, callbackID), m_pageID, m_isPerformingDOMPrintOperation ? CoreIPC::DispatchMessageEvenWhenWaitingForSyncReply : 0);
4535 }
4536 #elif PLATFORM(GTK)
4537 void WebPageProxy::drawPagesForPrinting(WebFrameProxy* frame, const PrintInfo& printInfo, PassRefPtr<PrintFinishedCallback> didPrintCallback)
4538 {
4539     RefPtr<PrintFinishedCallback> callback = didPrintCallback;
4540     if (!isValid()) {
4541         callback->invalidate();
4542         return;
4543     }
4544
4545     uint64_t callbackID = callback->callbackID();
4546     m_printFinishedCallbacks.set(callbackID, callback.get());
4547     m_isInPrintingMode = true;
4548     process()->send(Messages::WebPage::DrawPagesForPrinting(frame->frameID(), printInfo, callbackID), m_pageID, m_isPerformingDOMPrintOperation ? CoreIPC::DispatchMessageEvenWhenWaitingForSyncReply : 0);
4549 }
4550 #endif
4551
4552 void WebPageProxy::flashBackingStoreUpdates(const Vector<IntRect>& updateRects)
4553 {
4554     m_pageClient->flashBackingStoreUpdates(updateRects);
4555 }
4556
4557 void WebPageProxy::updateBackingStoreDiscardableState()
4558 {
4559     ASSERT(isValid());
4560
4561     bool isDiscardable;
4562
4563     if (!process()->responsivenessTimer()->isResponsive())
4564         isDiscardable = false;
4565     else
4566         isDiscardable = !m_pageClient->isViewWindowActive() || !isViewVisible();
4567
4568     m_drawingArea->setBackingStoreIsDiscardable(isDiscardable);
4569 }
4570
4571 Color WebPageProxy::viewUpdatesFlashColor()
4572 {
4573     return Color(0, 200, 255);
4574 }
4575
4576 Color WebPageProxy::backingStoreUpdatesFlashColor()
4577 {
4578     return Color(200, 0, 255);
4579 }
4580
4581 void WebPageProxy::saveDataToFileInDownloadsFolder(const String& suggestedFilename, const String& mimeType, const String& originatingURLString, WebData* data)
4582 {
4583     m_uiClient.saveDataToFileInDownloadsFolder(this, suggestedFilename, mimeType, originatingURLString, data);
4584 }
4585
4586 void WebPageProxy::linkClicked(const String& url, const WebMouseEvent& event)
4587 {
4588     process()->send(Messages::WebPage::LinkClicked(url, event), m_pageID, 0);
4589 }
4590
4591 #if PLATFORM(MAC)
4592
4593 void WebPageProxy::substitutionsPanelIsShowing(bool& isShowing)
4594 {
4595     isShowing = TextChecker::substitutionsPanelIsShowing();
4596 }
4597
4598 #if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
4599 void WebPageProxy::showCorrectionPanel(int32_t panelType, const FloatRect& boundingBoxOfReplacedString, const String& replacedString, const String& replacementString, const Vector<String>& alternativeReplacementStrings)
4600 {
4601     m_pageClient->showCorrectionPanel((AlternativeTextType)panelType, boundingBoxOfReplacedString, replacedString, replacementString, alternativeReplacementStrings);
4602 }
4603
4604 void WebPageProxy::dismissCorrectionPanel(int32_t reason)
4605 {
4606     m_pageClient->dismissCorrectionPanel((ReasonForDismissingAlternativeText)reason);
4607 }
4608
4609 void WebPageProxy::dismissCorrectionPanelSoon(int32_t reason, String& result)
4610 {
4611     result = m_pageClient->dismissCorrectionPanelSoon((ReasonForDismissingAlternativeText)reason);
4612 }
4613
4614 void WebPageProxy::recordAutocorrectionResponse(int32_t responseType, const String& replacedString, const String& replacementString)
4615 {
4616     m_pageClient->recordAutocorrectionResponse((AutocorrectionResponseType)responseType, replacedString, replacementString);
4617 }
4618 #endif // __MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
4619
4620 void WebPageProxy::handleAlternativeTextUIResult(const String& result)
4621 {
4622 #if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
4623     if (!isClosed())
4624         process()->send(Messages::WebPage::HandleAlternativeTextUIResult(result), m_pageID, 0);
4625 #endif
4626 }
4627
4628 #if USE(DICTATION_ALTERNATIVES)
4629 void WebPageProxy::showDictationAlternativeUI(const WebCore::FloatRect& boundingBoxOfDictatedText, uint64_t dictationContext)
4630 {
4631     m_pageClient->showDictationAlternativeUI(boundingBoxOfDictatedText, dictationContext);
4632 }
4633
4634 void WebPageProxy::dismissDictationAlternativeUI()
4635 {
4636     m_pageClient->dismissDictationAlternativeUI();
4637 }
4638
4639 void WebPageProxy::removeDictationAlternatives(uint64_t dictationContext)
4640 {
4641     m_pageClient->removeDictationAlternatives(dictationContext);
4642 }
4643
4644 void WebPageProxy::dictationAlternatives(uint64_t dictationContext, Vector<String>& result)
4645 {
4646     result = m_pageClient->dictationAlternatives(dictationContext);
4647 }
4648 #endif
4649
4650 #endif // PLATFORM(MAC)
4651
4652 #if USE(SOUP)
4653 void WebPageProxy::didReceiveURIRequest(String uriString, uint64_t requestID)
4654 {
4655     m_process->context()->soupRequestManagerProxy()->didReceiveURIRequest(uriString, this, requestID);
4656 }
4657 #endif
4658
4659 #if ENABLE(TIZEN_PAGE_VISIBILITY_API)
4660 void WebPageProxy::setPageVisibility(WebCore::PageVisibilityState pageVisibilityState, bool isInitialState)
4661 {
4662     process()->send(Messages::WebPage::SetVisibilityState(static_cast<uint32_t>(pageVisibilityState), isInitialState), m_pageID);
4663 }
4664 #endif
4665
4666 #if ENABLE(TIZEN_CERTIFICATE_HANDLING)
4667 void WebPageProxy::decidePolicyForCertificateError(const String& url, const String& certificate, int error, PassRefPtr<Messages::WebPageProxy::DecidePolicyForCertificateError::DelayedReply> reply)
4668 {
4669     m_allowedReply = reply;
4670
4671     if (!m_tizenClient.decidePolicyForCertificateError(this, url, certificate, error))
4672         replyPolicyForCertificateError(true);
4673 }
4674 #endif
4675
4676 #if ENABLE(TIZEN_NATIVE_MEMORY_SNAPSHOT)
4677 void WebPageProxy::dumpMemorySnapshot()
4678 {
4679     process()->send(Messages::WebPage::DumpMemorySnapshot(), m_pageID);
4680 }
4681 #endif
4682
4683 } // namespace WebKit