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