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