2 * Copyright (C) 2010, 2011 Apple Inc. All rights reserved.
3 * Copyright (C) 2012 Intel Corporation. All rights reserved.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
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.
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.
28 #include "WebPageProxy.h"
30 #include "AuthenticationChallengeProxy.h"
31 #include "AuthenticationDecisionListener.h"
32 #include "DataReference.h"
33 #include "DownloadProxy.h"
34 #include "DrawingAreaProxy.h"
35 #include "DrawingAreaProxyMessages.h"
36 #include "EventDispatcherMessages.h"
37 #include "FindIndicator.h"
38 #include "ImmutableArray.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 "TextChecker.h"
49 #include "TextCheckerState.h"
50 #include "WKContextPrivate.h"
51 #include "WebBackForwardList.h"
52 #include "WebBackForwardListItem.h"
53 #include "WebCertificateInfo.h"
54 #include "WebColorPickerResultListenerProxy.h"
55 #include "WebContext.h"
56 #include "WebContextMenuProxy.h"
57 #include "WebContextUserMessageCoders.h"
58 #include "WebCoreArgumentCoders.h"
60 #include "WebEditCommandProxy.h"
62 #include "WebFormSubmissionListenerProxy.h"
63 #include "WebFramePolicyListenerProxy.h"
64 #include "WebFullScreenManagerProxy.h"
65 #include "WebFullScreenManagerProxyMessages.h"
66 #include "WebInspectorProxy.h"
67 #include "WebInspectorProxyMessages.h"
68 #include "WebNotificationManagerProxy.h"
69 #include "WebOpenPanelResultListenerProxy.h"
70 #include "WebPageCreationParameters.h"
71 #include "WebPageGroup.h"
72 #include "WebPageGroupData.h"
73 #include "WebPageMessages.h"
74 #include "WebPageProxyMessages.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/RenderEmbeddedObject.h>
90 #include <WebCore/TextCheckerClient.h>
91 #include <WebCore/WindowFeatures.h>
94 #if USE(COORDINATED_GRAPHICS)
95 #include "CoordinatedLayerTreeHostProxyMessages.h"
99 #include "ArgumentCodersQt.h"
103 #include "ArgumentCodersGtk.h"
107 #include "WebSoupRequestManagerProxy.h"
110 #if ENABLE(VIBRATION)
111 #include "WebVibrationProxy.h"
115 #include <wtf/RefCountedLeakCounter.h>
118 // This controls what strategy we use for mouse wheel coalescing.
119 #define MERGE_WHEEL_EVENTS 1
121 #define MESSAGE_CHECK(assertion) MESSAGE_CHECK_BASE(assertion, m_process->connection())
122 #define MESSAGE_CHECK_URL(url) MESSAGE_CHECK_BASE(m_process->checkURLReceivedFromWebProcess(url), m_process->connection())
124 using namespace WebCore;
126 // Represents the number of wheel events we can hold in the queue before we start pushing them preemptively.
127 static const unsigned wheelEventQueueSizeThreshold = 10;
131 WKPageDebugPaintFlags WebPageProxy::s_debugPaintFlags = 0;
133 DEFINE_DEBUG_ONLY_GLOBAL(WTF::RefCountedLeakCounter, webPageProxyCounter, ("WebPageProxy"));
135 class ExceededDatabaseQuotaRecords {
136 WTF_MAKE_NONCOPYABLE(ExceededDatabaseQuotaRecords); WTF_MAKE_FAST_ALLOCATED;
140 String originIdentifier;
143 uint64_t currentQuota;
144 uint64_t currentOriginUsage;
145 uint64_t currentDatabaseUsage;
146 uint64_t expectedUsage;
147 RefPtr<Messages::WebPageProxy::ExceededDatabaseQuota::DelayedReply> reply;
150 static ExceededDatabaseQuotaRecords& shared();
152 PassOwnPtr<Record> createRecord(uint64_t frameID, String originIdentifier,
153 String databaseName, String displayName, uint64_t currentQuota,
154 uint64_t currentOriginUsage, uint64_t currentDatabaseUsage, uint64_t expectedUsage,
155 PassRefPtr<Messages::WebPageProxy::ExceededDatabaseQuota::DelayedReply>);
157 void add(PassOwnPtr<Record>);
158 bool areBeingProcessed() const { return m_currentRecord; }
162 ExceededDatabaseQuotaRecords() { }
163 ~ExceededDatabaseQuotaRecords() { }
165 Deque<OwnPtr<Record> > m_records;
166 OwnPtr<Record> m_currentRecord;
169 ExceededDatabaseQuotaRecords& ExceededDatabaseQuotaRecords::shared()
171 DEFINE_STATIC_LOCAL(ExceededDatabaseQuotaRecords, records, ());
175 PassOwnPtr<ExceededDatabaseQuotaRecords::Record> ExceededDatabaseQuotaRecords::createRecord(
176 uint64_t frameID, String originIdentifier, String databaseName, String displayName,
177 uint64_t currentQuota, uint64_t currentOriginUsage, uint64_t currentDatabaseUsage,
178 uint64_t expectedUsage, PassRefPtr<Messages::WebPageProxy::ExceededDatabaseQuota::DelayedReply> reply)
180 OwnPtr<Record> record = adoptPtr(new Record);
181 record->frameID = frameID;
182 record->originIdentifier = originIdentifier;
183 record->databaseName = databaseName;
184 record->displayName = displayName;
185 record->currentQuota = currentQuota;
186 record->currentOriginUsage = currentOriginUsage;
187 record->currentDatabaseUsage = currentDatabaseUsage;
188 record->expectedUsage = expectedUsage;
189 record->reply = reply;
190 return record.release();
193 void ExceededDatabaseQuotaRecords::add(PassOwnPtr<ExceededDatabaseQuotaRecords::Record> record)
195 m_records.append(record);
198 ExceededDatabaseQuotaRecords::Record* ExceededDatabaseQuotaRecords::next()
200 m_currentRecord.clear();
201 if (!m_records.isEmpty())
202 m_currentRecord = m_records.takeFirst();
203 return m_currentRecord.get();
207 static const char* webKeyboardEventTypeString(WebEvent::Type type)
210 case WebEvent::KeyDown:
213 case WebEvent::KeyUp:
216 case WebEvent::RawKeyDown:
223 ASSERT_NOT_REACHED();
227 #endif // !LOG_DISABLED
229 PassRefPtr<WebPageProxy> WebPageProxy::create(PageClient* pageClient, PassRefPtr<WebProcessProxy> process, WebPageGroup* pageGroup, uint64_t pageID)
231 return adoptRef(new WebPageProxy(pageClient, process, pageGroup, pageID));
234 WebPageProxy::WebPageProxy(PageClient* pageClient, PassRefPtr<WebProcessProxy> process, WebPageGroup* pageGroup, uint64_t pageID)
235 : m_pageClient(pageClient)
237 , m_pageGroup(pageGroup)
239 , m_userAgent(standardUserAgent())
240 , m_geolocationPermissionRequestManager(this)
241 , m_notificationPermissionRequestManager(this)
242 , m_estimatedProgress(0)
243 , m_isInWindow(m_pageClient->isViewInWindow())
244 , m_isVisible(m_pageClient->isViewVisible())
245 , m_backForwardList(WebBackForwardList::create(this))
246 , m_loadStateAtProcessExit(WebFrameProxy::LoadStateFinished)
247 , m_textZoomFactor(1)
248 , m_pageZoomFactor(1)
249 , m_pageScaleFactor(1)
250 , m_intrinsicDeviceScaleFactor(1)
251 , m_customDeviceScaleFactor(0)
252 #if HAVE(LAYER_HOSTING_IN_WINDOW_SERVER)
253 , m_layerHostingMode(LayerHostingModeInWindowServer)
255 , m_layerHostingMode(LayerHostingModeDefault)
257 , m_drawsBackground(true)
258 , m_drawsTransparentBackground(false)
259 , m_areMemoryCacheClientCallsEnabled(true)
260 , m_useFixedLayout(false)
261 , m_suppressScrollbarAnimations(false)
262 , m_paginationMode(Pagination::Unpaginated)
263 , m_paginationBehavesLikeColumns(false)
265 , m_gapBetweenPages(0)
268 , m_canRunModal(false)
269 , m_isInPrintingMode(false)
270 , m_isPerformingDOMPrintOperation(false)
271 , m_inDecidePolicyForResponse(false)
272 , m_decidePolicyForResponseRequest(0)
273 , m_syncMimeTypePolicyActionIsValid(false)
274 , m_syncMimeTypePolicyAction(PolicyUse)
275 , m_syncMimeTypePolicyDownloadID(0)
276 , m_inDecidePolicyForNavigationAction(false)
277 , m_syncNavigationActionPolicyActionIsValid(false)
278 , m_syncNavigationActionPolicyAction(PolicyUse)
279 , m_syncNavigationActionPolicyDownloadID(0)
280 , m_processingMouseMoveEvent(false)
281 #if ENABLE(TOUCH_EVENTS)
282 , m_needTouchEvents(false)
285 , m_isPageSuspended(false)
287 , m_isSmartInsertDeleteEnabled(TextChecker::isSmartInsertDeleteEnabled())
289 , m_spellDocumentTag(0)
290 , m_hasSpellDocumentTag(false)
291 , m_pendingLearnOrIgnoreWordMessageCount(0)
292 , m_mainFrameHasCustomRepresentation(false)
293 , m_mainFrameHasHorizontalScrollbar(false)
294 , m_mainFrameHasVerticalScrollbar(false)
295 , m_canShortCircuitHorizontalWheelEvents(true)
296 , m_mainFrameIsPinnedToLeftSide(false)
297 , m_mainFrameIsPinnedToRightSide(false)
298 , m_mainFrameIsPinnedToTopSide(false)
299 , m_mainFrameIsPinnedToBottomSide(false)
300 , m_rubberBandsAtBottom(false)
301 , m_rubberBandsAtTop(false)
302 , m_mainFrameInViewSourceMode(false)
303 , m_overridePrivateBrowsingEnabled(false)
305 , m_renderTreeSize(0)
306 , m_shouldSendEventsSynchronously(false)
307 , m_suppressVisibilityUpdates(false)
308 , m_minimumLayoutWidth(0)
310 , m_mayStartMediaWhenInWindow(true)
311 #if ENABLE(PAGE_VISIBILITY_API)
312 , m_visibilityState(PageVisibilityStateVisible)
315 #if ENABLE(PAGE_VISIBILITY_API)
317 m_visibilityState = PageVisibilityStateHidden;
320 webPageProxyCounter.increment();
323 WebContext::statistics().wkPageCount++;
325 m_pageGroup->addPage(this);
327 #if ENABLE(INSPECTOR)
328 m_inspector = WebInspectorProxy::create(this);
330 #if ENABLE(FULLSCREEN_API)
331 m_fullScreenManager = WebFullScreenManagerProxy::create(this);
333 #if ENABLE(VIBRATION)
334 m_vibration = WebVibrationProxy::create(this);
336 #if ENABLE(THREADED_SCROLLING)
337 m_rubberBandsAtBottom = true;
338 m_rubberBandsAtTop = true;
341 m_process->addMessageReceiver(Messages::WebPageProxy::messageReceiverName(), m_pageID, this);
343 // FIXME: If we ever expose the session storage size as a preference, we need to pass it here.
344 m_process->context()->storageManager().createSessionStorageNamespace(m_pageID, m_process->isValid() ? m_process->connection() : 0, std::numeric_limits<unsigned>::max());
347 WebPageProxy::~WebPageProxy()
352 WebContext::statistics().wkPageCount--;
354 if (m_hasSpellDocumentTag)
355 TextChecker::closeSpellDocumentWithTag(m_spellDocumentTag);
357 m_pageGroup->removePage(this);
360 webPageProxyCounter.decrement();
364 WebProcessProxy* WebPageProxy::process() const
366 return m_process.get();
369 PlatformProcessIdentifier WebPageProxy::processIdentifier() const
374 return m_process->processIdentifier();
377 bool WebPageProxy::isValid()
379 // A page that has been explicitly closed is never valid.
386 PassRefPtr<ImmutableArray> WebPageProxy::relatedPages() const
388 // pages() returns a list of pages in WebProcess, so this page may or may not be among them - a client can use a reference to WebPageProxy after the page has closed.
389 Vector<WebPageProxy*> pages = m_process->pages();
391 Vector<RefPtr<APIObject> > result;
392 result.reserveCapacity(pages.size());
393 for (size_t i = 0; i < pages.size(); ++i) {
394 if (pages[i] != this)
395 result.append(pages[i]);
398 return ImmutableArray::adopt(result);
401 void WebPageProxy::initializeLoaderClient(const WKPageLoaderClient* loadClient)
403 m_loaderClient.initialize(loadClient);
408 // It would be nice to get rid of this code and transition all clients to using didLayout instead of
409 // didFirstLayoutInFrame and didFirstVisuallyNonEmptyLayoutInFrame. In the meantime, this is required
410 // for backwards compatibility.
411 WebCore::LayoutMilestones milestones = 0;
412 if (loadClient->didFirstLayoutForFrame)
413 milestones |= WebCore::DidFirstLayout;
414 if (loadClient->didFirstVisuallyNonEmptyLayoutForFrame)
415 milestones |= WebCore::DidFirstVisuallyNonEmptyLayout;
416 if (loadClient->didNewFirstVisuallyNonEmptyLayout)
417 milestones |= WebCore::DidHitRelevantRepaintedObjectsAreaThreshold;
420 m_process->send(Messages::WebPage::ListenForLayoutMilestones(milestones), m_pageID);
422 m_process->send(Messages::WebPage::SetWillGoToBackForwardItemCallbackEnabled(loadClient->version > 0), m_pageID);
425 void WebPageProxy::initializePolicyClient(const WKPagePolicyClient* policyClient)
427 m_policyClient.initialize(policyClient);
430 void WebPageProxy::initializeFormClient(const WKPageFormClient* formClient)
432 m_formClient.initialize(formClient);
435 void WebPageProxy::initializeUIClient(const WKPageUIClient* client)
440 m_uiClient.initialize(client);
442 m_process->send(Messages::WebPage::SetCanRunBeforeUnloadConfirmPanel(m_uiClient.canRunBeforeUnloadConfirmPanel()), m_pageID);
443 setCanRunModal(m_uiClient.canRunModal());
446 void WebPageProxy::initializeFindClient(const WKPageFindClient* client)
448 m_findClient.initialize(client);
451 void WebPageProxy::initializeFindMatchesClient(const WKPageFindMatchesClient* client)
453 m_findMatchesClient.initialize(client);
456 #if ENABLE(CONTEXT_MENUS)
457 void WebPageProxy::initializeContextMenuClient(const WKPageContextMenuClient* client)
459 m_contextMenuClient.initialize(client);
463 void WebPageProxy::reattachToWebProcess()
467 ASSERT(!m_process->isValid());
468 ASSERT(!m_process->isLaunching());
472 if (m_process->context()->processModel() == ProcessModelSharedSecondaryProcess)
473 m_process = m_process->context()->ensureSharedWebProcess();
475 m_process = m_process->context()->createNewWebProcessRespectingProcessCountLimit();
476 m_process->addExistingWebPage(this, m_pageID);
477 m_process->addMessageReceiver(Messages::WebPageProxy::messageReceiverName(), m_pageID, this);
479 #if ENABLE(INSPECTOR)
480 m_inspector = WebInspectorProxy::create(this);
482 #if ENABLE(FULLSCREEN_API)
483 m_fullScreenManager = WebFullScreenManagerProxy::create(this);
488 m_pageClient->didRelaunchProcess();
489 m_drawingArea->waitForBackingStoreUpdateOnNextPaint();
492 void WebPageProxy::reattachToWebProcessWithItem(WebBackForwardListItem* item)
494 if (item && item != m_backForwardList->currentItem())
495 m_backForwardList->goToItem(item);
497 reattachToWebProcess();
502 m_process->send(Messages::WebPage::GoToBackForwardItem(item->itemID()), m_pageID);
503 m_process->responsivenessTimer()->start();
506 void WebPageProxy::initializeWebPage()
510 BackForwardListItemVector items = m_backForwardList->entries();
511 for (size_t i = 0; i < items.size(); ++i)
512 m_process->registerNewWebBackForwardListItem(items[i].get());
514 m_drawingArea = m_pageClient->createDrawingAreaProxy();
515 ASSERT(m_drawingArea);
517 #if ENABLE(INSPECTOR_SERVER)
518 if (m_pageGroup->preferences()->developerExtrasEnabled())
519 inspector()->enableRemoteInspection();
522 m_process->send(Messages::WebProcess::CreateWebPage(m_pageID, creationParameters()), 0);
524 #if ENABLE(PAGE_VISIBILITY_API)
525 m_process->send(Messages::WebPage::SetVisibilityState(m_visibilityState, /* isInitialState */ true), m_pageID);
526 #elif ENABLE(HIDDEN_PAGE_DOM_TIMER_THROTTLING)
527 m_process->send(Messages::WebPage::SetVisibilityState(m_isVisible ? PageVisibilityStateVisible : PageVisibilityStateHidden, /* isInitialState */ true), m_pageID);
531 m_process->send(Messages::WebPage::SetSmartInsertDeleteEnabled(m_isSmartInsertDeleteEnabled), m_pageID);
535 void WebPageProxy::close()
542 m_backForwardList->pageClosed();
543 m_pageClient->pageClosed();
545 m_process->disconnectFramesFromPage(this);
548 #if ENABLE(INSPECTOR)
550 m_inspector->invalidate();
555 #if ENABLE(FULLSCREEN_API)
556 if (m_fullScreenManager) {
557 m_fullScreenManager->invalidate();
558 m_fullScreenManager = 0;
562 #if ENABLE(VIBRATION)
563 m_vibration->invalidate();
566 if (m_openPanelResultListener) {
567 m_openPanelResultListener->invalidate();
568 m_openPanelResultListener = 0;
571 #if ENABLE(INPUT_TYPE_COLOR)
572 if (m_colorChooser) {
573 m_colorChooser->invalidate();
574 m_colorChooser = nullptr;
577 if (m_colorPickerResultListener) {
578 m_colorPickerResultListener->invalidate();
579 m_colorPickerResultListener = nullptr;
583 #if ENABLE(GEOLOCATION)
584 m_geolocationPermissionRequestManager.invalidateRequests();
587 m_notificationPermissionRequestManager.invalidateRequests();
589 m_toolTip = String();
591 m_mainFrameHasHorizontalScrollbar = false;
592 m_mainFrameHasVerticalScrollbar = false;
594 m_mainFrameIsPinnedToLeftSide = false;
595 m_mainFrameIsPinnedToRightSide = false;
596 m_mainFrameIsPinnedToTopSide = false;
597 m_mainFrameIsPinnedToBottomSide = false;
599 m_visibleScrollerThumbRect = IntRect();
601 invalidateCallbackMap(m_voidCallbacks);
602 invalidateCallbackMap(m_dataCallbacks);
603 invalidateCallbackMap(m_imageCallbacks);
604 invalidateCallbackMap(m_stringCallbacks);
605 m_loadDependentStringCallbackIDs.clear();
606 invalidateCallbackMap(m_scriptValueCallbacks);
607 invalidateCallbackMap(m_computedPagesCallbacks);
609 invalidateCallbackMap(m_printFinishedCallbacks);
612 Vector<WebEditCommandProxy*> editCommandVector;
613 copyToVector(m_editCommandSet, editCommandVector);
614 m_editCommandSet.clear();
615 for (size_t i = 0, size = editCommandVector.size(); i < size; ++i)
616 editCommandVector[i]->invalidate();
618 m_activePopupMenu = 0;
620 m_estimatedProgress = 0.0;
622 m_loaderClient.initialize(0);
623 m_policyClient.initialize(0);
624 m_uiClient.initialize(0);
626 m_uiPopupMenuClient.initialize(0);
629 m_drawingArea = nullptr;
631 m_process->send(Messages::WebPage::Close(), m_pageID);
632 m_process->removeWebPage(m_pageID);
633 m_process->removeMessageReceiver(Messages::WebPageProxy::messageReceiverName(), m_pageID);
634 m_process->context()->storageManager().destroySessionStorageNamespace(m_pageID);
637 bool WebPageProxy::tryClose()
642 m_process->send(Messages::WebPage::TryClose(), m_pageID);
643 m_process->responsivenessTimer()->start();
647 bool WebPageProxy::maybeInitializeSandboxExtensionHandle(const KURL& url, SandboxExtension::Handle& sandboxExtensionHandle)
649 if (!url.isLocalFile())
652 #if ENABLE(INSPECTOR)
653 // Don't give the inspector full access to the file system.
654 if (WebInspectorProxy::isInspectorPage(this))
658 SandboxExtension::createHandle("/", SandboxExtension::ReadOnly, sandboxExtensionHandle);
662 void WebPageProxy::loadURL(const String& url)
664 setPendingAPIRequestURL(url);
667 reattachToWebProcess();
669 SandboxExtension::Handle sandboxExtensionHandle;
670 bool createdExtension = maybeInitializeSandboxExtensionHandle(KURL(KURL(), url), sandboxExtensionHandle);
671 if (createdExtension)
672 m_process->willAcquireUniversalFileReadSandboxExtension();
673 m_process->send(Messages::WebPage::LoadURL(url, sandboxExtensionHandle), m_pageID);
674 m_process->responsivenessTimer()->start();
677 void WebPageProxy::loadURLRequest(WebURLRequest* urlRequest)
679 setPendingAPIRequestURL(urlRequest->resourceRequest().url());
682 reattachToWebProcess();
684 SandboxExtension::Handle sandboxExtensionHandle;
685 bool createdExtension = maybeInitializeSandboxExtensionHandle(urlRequest->resourceRequest().url(), sandboxExtensionHandle);
686 if (createdExtension)
687 m_process->willAcquireUniversalFileReadSandboxExtension();
688 m_process->send(Messages::WebPage::LoadURLRequest(urlRequest->resourceRequest(), sandboxExtensionHandle), m_pageID);
689 m_process->responsivenessTimer()->start();
692 void WebPageProxy::loadHTMLString(const String& htmlString, const String& baseURL)
695 reattachToWebProcess();
697 m_process->assumeReadAccessToBaseURL(baseURL);
698 m_process->send(Messages::WebPage::LoadHTMLString(htmlString, baseURL), m_pageID);
699 m_process->responsivenessTimer()->start();
702 void WebPageProxy::loadAlternateHTMLString(const String& htmlString, const String& baseURL, const String& unreachableURL)
705 reattachToWebProcess();
708 m_mainFrame->setUnreachableURL(unreachableURL);
710 m_process->assumeReadAccessToBaseURL(baseURL);
711 m_process->send(Messages::WebPage::LoadAlternateHTMLString(htmlString, baseURL, unreachableURL), m_pageID);
712 m_process->responsivenessTimer()->start();
715 void WebPageProxy::loadPlainTextString(const String& string)
718 reattachToWebProcess();
720 m_process->send(Messages::WebPage::LoadPlainTextString(string), m_pageID);
721 m_process->responsivenessTimer()->start();
724 void WebPageProxy::loadWebArchiveData(const WebData* webArchiveData)
727 reattachToWebProcess();
729 m_process->send(Messages::WebPage::LoadWebArchiveData(webArchiveData->dataReference()), m_pageID);
730 m_process->responsivenessTimer()->start();
733 void WebPageProxy::stopLoading()
738 m_process->send(Messages::WebPage::StopLoading(), m_pageID);
739 m_process->responsivenessTimer()->start();
742 void WebPageProxy::reload(bool reloadFromOrigin)
744 SandboxExtension::Handle sandboxExtensionHandle;
746 if (m_backForwardList->currentItem()) {
747 String url = m_backForwardList->currentItem()->url();
748 setPendingAPIRequestURL(url);
750 // We may not have an extension yet if back/forward list was reinstated after a WebProcess crash or a browser relaunch
751 bool createdExtension = maybeInitializeSandboxExtensionHandle(KURL(KURL(), url), sandboxExtensionHandle);
752 if (createdExtension)
753 m_process->willAcquireUniversalFileReadSandboxExtension();
757 reattachToWebProcessWithItem(m_backForwardList->currentItem());
761 m_process->send(Messages::WebPage::Reload(reloadFromOrigin, sandboxExtensionHandle), m_pageID);
762 m_process->responsivenessTimer()->start();
765 void WebPageProxy::goForward()
767 if (isValid() && !canGoForward())
770 WebBackForwardListItem* forwardItem = m_backForwardList->forwardItem();
774 setPendingAPIRequestURL(forwardItem->url());
777 reattachToWebProcessWithItem(forwardItem);
781 m_process->send(Messages::WebPage::GoForward(forwardItem->itemID()), m_pageID);
782 m_process->responsivenessTimer()->start();
785 bool WebPageProxy::canGoForward() const
787 return m_backForwardList->forwardItem();
790 void WebPageProxy::goBack()
792 if (isValid() && !canGoBack())
795 WebBackForwardListItem* backItem = m_backForwardList->backItem();
799 setPendingAPIRequestURL(backItem->url());
802 reattachToWebProcessWithItem(backItem);
806 m_process->send(Messages::WebPage::GoBack(backItem->itemID()), m_pageID);
807 m_process->responsivenessTimer()->start();
810 bool WebPageProxy::canGoBack() const
812 return m_backForwardList->backItem();
815 void WebPageProxy::goToBackForwardItem(WebBackForwardListItem* item)
818 reattachToWebProcessWithItem(item);
822 setPendingAPIRequestURL(item->url());
824 m_process->send(Messages::WebPage::GoToBackForwardItem(item->itemID()), m_pageID);
825 m_process->responsivenessTimer()->start();
828 void WebPageProxy::tryRestoreScrollPosition()
833 m_process->send(Messages::WebPage::TryRestoreScrollPosition(), m_pageID);
836 void WebPageProxy::didChangeBackForwardList(WebBackForwardListItem* added, Vector<RefPtr<APIObject> >* removed)
838 m_loaderClient.didChangeBackForwardList(this, added, removed);
841 void WebPageProxy::shouldGoToBackForwardListItem(uint64_t itemID, bool& shouldGoToBackForwardItem)
843 WebBackForwardListItem* item = m_process->webBackForwardItem(itemID);
844 shouldGoToBackForwardItem = item && m_loaderClient.shouldGoToBackForwardListItem(this, item);
847 void WebPageProxy::willGoToBackForwardListItem(uint64_t itemID, CoreIPC::MessageDecoder& decoder)
849 RefPtr<APIObject> userData;
850 WebContextUserMessageDecoder messageDecoder(userData, m_process.get());
851 if (!decoder.decode(messageDecoder))
854 if (WebBackForwardListItem* item = m_process->webBackForwardItem(itemID))
855 m_loaderClient.willGoToBackForwardListItem(this, item, userData.get());
858 String WebPageProxy::activeURL() const
860 // If there is a currently pending url, it is the active URL,
861 // even when there's no main frame yet, as it might be the
862 // first API request.
863 if (!m_pendingAPIRequestURL.isNull())
864 return m_pendingAPIRequestURL;
869 if (!m_mainFrame->unreachableURL().isEmpty())
870 return m_mainFrame->unreachableURL();
872 switch (m_mainFrame->loadState()) {
873 case WebFrameProxy::LoadStateProvisional:
874 return m_mainFrame->provisionalURL();
875 case WebFrameProxy::LoadStateCommitted:
876 case WebFrameProxy::LoadStateFinished:
877 return m_mainFrame->url();
880 ASSERT_NOT_REACHED();
884 String WebPageProxy::provisionalURL() const
888 return m_mainFrame->provisionalURL();
891 String WebPageProxy::committedURL() const
896 return m_mainFrame->url();
899 bool WebPageProxy::canShowMIMEType(const String& mimeType) const
901 if (MIMETypeRegistry::canShowMIMEType(mimeType))
904 #if ENABLE(NETSCAPE_PLUGIN_API)
905 String newMimeType = mimeType;
906 PluginModuleInfo plugin = m_process->context()->pluginInfoStore().findPlugin(newMimeType, KURL());
907 if (!plugin.path.isNull() && m_pageGroup->preferences()->pluginsEnabled())
909 #endif // ENABLE(NETSCAPE_PLUGIN_API)
913 void WebPageProxy::setDrawsBackground(bool drawsBackground)
915 if (m_drawsBackground == drawsBackground)
918 m_drawsBackground = drawsBackground;
921 m_process->send(Messages::WebPage::SetDrawsBackground(drawsBackground), m_pageID);
924 void WebPageProxy::setDrawsTransparentBackground(bool drawsTransparentBackground)
926 if (m_drawsTransparentBackground == drawsTransparentBackground)
929 m_drawsTransparentBackground = drawsTransparentBackground;
932 m_process->send(Messages::WebPage::SetDrawsTransparentBackground(drawsTransparentBackground), m_pageID);
935 void WebPageProxy::setUnderlayColor(const Color& color)
937 if (m_underlayColor == color)
940 m_underlayColor = color;
943 m_process->send(Messages::WebPage::SetUnderlayColor(color), m_pageID);
946 void WebPageProxy::viewWillStartLiveResize()
950 m_process->send(Messages::WebPage::ViewWillStartLiveResize(), m_pageID);
953 void WebPageProxy::viewWillEndLiveResize()
957 m_process->send(Messages::WebPage::ViewWillEndLiveResize(), m_pageID);
960 void WebPageProxy::setViewNeedsDisplay(const IntRect& rect)
962 m_pageClient->setViewNeedsDisplay(rect);
965 void WebPageProxy::displayView()
967 m_pageClient->displayView();
970 bool WebPageProxy::canScrollView()
972 return m_pageClient->canScrollView();
975 void WebPageProxy::scrollView(const IntRect& scrollRect, const IntSize& scrollOffset)
977 m_pageClient->scrollView(scrollRect, scrollOffset);
980 void WebPageProxy::viewStateDidChange(ViewStateFlags flags)
985 if (flags & ViewIsFocused)
986 m_process->send(Messages::WebPage::SetFocused(m_pageClient->isViewFocused()), m_pageID);
988 if (flags & ViewWindowIsActive)
989 m_process->send(Messages::WebPage::SetActive(m_pageClient->isViewWindowActive()), m_pageID);
991 if (flags & ViewIsVisible) {
992 bool isVisible = m_pageClient->isViewVisible();
993 if (isVisible != m_isVisible) {
994 m_isVisible = isVisible;
995 m_process->pageVisibilityChanged(this);
996 m_drawingArea->visibilityDidChange();
999 // If we've started the responsiveness timer as part of telling the web process to update the backing store
1000 // state, it might not send back a reply (since it won't paint anything if the web page is hidden) so we
1001 // stop the unresponsiveness timer here.
1002 m_process->responsivenessTimer()->stop();
1005 #if ENABLE(HIDDEN_PAGE_DOM_TIMER_THROTTLING) && !ENABLE(PAGE_VISIBILITY_API)
1006 PageVisibilityState visibilityState = m_isVisible ? PageVisibilityStateVisible : PageVisibilityStateHidden;
1007 m_process->send(Messages::WebPage::SetVisibilityState(visibilityState, false), m_pageID);
1012 if (flags & ViewIsInWindow) {
1013 bool isInWindow = m_pageClient->isViewInWindow();
1014 if (m_isInWindow != isInWindow) {
1015 m_isInWindow = isInWindow;
1016 m_process->send(Messages::WebPage::SetIsInWindow(isInWindow), m_pageID);
1020 LayerHostingMode layerHostingMode = m_pageClient->viewLayerHostingMode();
1021 if (m_layerHostingMode != layerHostingMode) {
1022 m_layerHostingMode = layerHostingMode;
1023 m_drawingArea->layerHostingModeDidChange();
1028 #if ENABLE(PAGE_VISIBILITY_API)
1029 PageVisibilityState visibilityState = PageVisibilityStateHidden;
1032 visibilityState = PageVisibilityStateVisible;
1034 if (visibilityState != m_visibilityState) {
1035 m_visibilityState = visibilityState;
1036 m_process->send(Messages::WebPage::SetVisibilityState(visibilityState, false), m_pageID);
1040 updateBackingStoreDiscardableState();
1043 IntSize WebPageProxy::viewSize() const
1045 return m_pageClient->viewSize();
1048 void WebPageProxy::setInitialFocus(bool forward, bool isKeyboardEventValid, const WebKeyboardEvent& keyboardEvent)
1052 m_process->send(Messages::WebPage::SetInitialFocus(forward, isKeyboardEventValid, keyboardEvent), m_pageID);
1055 void WebPageProxy::setWindowResizerSize(const IntSize& windowResizerSize)
1059 m_process->send(Messages::WebPage::SetWindowResizerSize(windowResizerSize), m_pageID);
1062 void WebPageProxy::clearSelection()
1066 m_process->send(Messages::WebPage::ClearSelection(), m_pageID);
1069 void WebPageProxy::validateCommand(const String& commandName, PassRefPtr<ValidateCommandCallback> callback)
1072 callback->invalidate();
1076 uint64_t callbackID = callback->callbackID();
1077 m_validateCommandCallbacks.set(callbackID, callback.get());
1078 m_process->send(Messages::WebPage::ValidateCommand(commandName, callbackID), m_pageID);
1081 void WebPageProxy::setMaintainsInactiveSelection(bool newValue)
1083 m_maintainsInactiveSelection = newValue;
1086 void WebPageProxy::executeEditCommand(const String& commandName)
1091 DEFINE_STATIC_LOCAL(String, ignoreSpellingCommandName, (ASCIILiteral("ignoreSpelling")));
1092 if (commandName == ignoreSpellingCommandName)
1093 ++m_pendingLearnOrIgnoreWordMessageCount;
1095 m_process->send(Messages::WebPage::ExecuteEditCommand(commandName), m_pageID);
1098 #if USE(TILED_BACKING_STORE)
1099 void WebPageProxy::commitPageTransitionViewport()
1104 process()->send(Messages::WebPage::CommitPageTransitionViewport(), m_pageID);
1108 #if ENABLE(DRAG_SUPPORT)
1109 void WebPageProxy::dragEntered(DragData* dragData, const String& dragStorageName)
1111 SandboxExtension::Handle sandboxExtensionHandle;
1112 SandboxExtension::HandleArray sandboxExtensionHandleEmptyArray;
1113 performDragControllerAction(DragControllerActionEntered, dragData, dragStorageName, sandboxExtensionHandle, sandboxExtensionHandleEmptyArray);
1116 void WebPageProxy::dragUpdated(DragData* dragData, const String& dragStorageName)
1118 SandboxExtension::Handle sandboxExtensionHandle;
1119 SandboxExtension::HandleArray sandboxExtensionHandleEmptyArray;
1120 performDragControllerAction(DragControllerActionUpdated, dragData, dragStorageName, sandboxExtensionHandle, sandboxExtensionHandleEmptyArray);
1123 void WebPageProxy::dragExited(DragData* dragData, const String& dragStorageName)
1125 SandboxExtension::Handle sandboxExtensionHandle;
1126 SandboxExtension::HandleArray sandboxExtensionHandleEmptyArray;
1127 performDragControllerAction(DragControllerActionExited, dragData, dragStorageName, sandboxExtensionHandle, sandboxExtensionHandleEmptyArray);
1130 void WebPageProxy::performDrag(DragData* dragData, const String& dragStorageName, const SandboxExtension::Handle& sandboxExtensionHandle, const SandboxExtension::HandleArray& sandboxExtensionsForUpload)
1132 performDragControllerAction(DragControllerActionPerformDrag, dragData, dragStorageName, sandboxExtensionHandle, sandboxExtensionsForUpload);
1135 void WebPageProxy::performDragControllerAction(DragControllerAction action, DragData* dragData, const String& dragStorageName, const SandboxExtension::Handle& sandboxExtensionHandle, const SandboxExtension::HandleArray& sandboxExtensionsForUpload)
1139 #if PLATFORM(QT) || PLATFORM(GTK)
1140 m_process->send(Messages::WebPage::PerformDragControllerAction(action, *dragData), m_pageID);
1142 m_process->send(Messages::WebPage::PerformDragControllerAction(action, dragData->clientPosition(), dragData->globalPosition(), dragData->draggingSourceOperationMask(), dragStorageName, dragData->flags(), sandboxExtensionHandle, sandboxExtensionsForUpload), m_pageID);
1146 void WebPageProxy::didPerformDragControllerAction(WebCore::DragSession dragSession)
1148 m_currentDragSession = dragSession;
1151 #if PLATFORM(QT) || PLATFORM(GTK)
1152 void WebPageProxy::startDrag(const DragData& dragData, const ShareableBitmap::Handle& dragImageHandle)
1154 RefPtr<ShareableBitmap> dragImage = 0;
1155 if (!dragImageHandle.isNull()) {
1156 dragImage = ShareableBitmap::create(dragImageHandle);
1161 m_pageClient->startDrag(dragData, dragImage.release());
1165 void WebPageProxy::dragEnded(const IntPoint& clientPosition, const IntPoint& globalPosition, uint64_t operation)
1169 m_process->send(Messages::WebPage::DragEnded(clientPosition, globalPosition, operation), m_pageID);
1171 #endif // ENABLE(DRAG_SUPPORT)
1173 void WebPageProxy::handleMouseEvent(const NativeWebMouseEvent& event)
1178 // NOTE: This does not start the responsiveness timer because mouse move should not indicate interaction.
1179 if (event.type() != WebEvent::MouseMove)
1180 m_process->responsivenessTimer()->start();
1182 if (m_processingMouseMoveEvent) {
1183 m_nextMouseMoveEvent = adoptPtr(new NativeWebMouseEvent(event));
1187 m_processingMouseMoveEvent = true;
1190 // <https://bugs.webkit.org/show_bug.cgi?id=57904> We need to keep track of the mouse down event in the case where we
1191 // display a popup menu for select elements. When the user changes the selected item,
1192 // we fake a mouse up event by using this stored down event. This event gets cleared
1193 // when the mouse up message is received from WebProcess.
1194 if (event.type() == WebEvent::MouseDown)
1195 m_currentlyProcessedMouseDownEvent = adoptPtr(new NativeWebMouseEvent(event));
1197 if (m_shouldSendEventsSynchronously) {
1198 bool handled = false;
1199 m_process->sendSync(Messages::WebPage::MouseEventSyncForTesting(event), Messages::WebPage::MouseEventSyncForTesting::Reply(handled), m_pageID);
1200 didReceiveEvent(event.type(), handled);
1202 m_process->send(Messages::WebPage::MouseEvent(event), m_pageID);
1205 #if MERGE_WHEEL_EVENTS
1206 static bool canCoalesce(const WebWheelEvent& a, const WebWheelEvent& b)
1208 if (a.position() != b.position())
1210 if (a.globalPosition() != b.globalPosition())
1212 if (a.modifiers() != b.modifiers())
1214 if (a.granularity() != b.granularity())
1217 if (a.phase() != b.phase())
1219 if (a.momentumPhase() != b.momentumPhase())
1221 if (a.hasPreciseScrollingDeltas() != b.hasPreciseScrollingDeltas())
1228 static WebWheelEvent coalesce(const WebWheelEvent& a, const WebWheelEvent& b)
1230 ASSERT(canCoalesce(a, b));
1232 FloatSize mergedDelta = a.delta() + b.delta();
1233 FloatSize mergedWheelTicks = a.wheelTicks() + b.wheelTicks();
1236 FloatSize mergedUnacceleratedScrollingDelta = a.unacceleratedScrollingDelta() + b.unacceleratedScrollingDelta();
1238 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());
1240 return WebWheelEvent(WebEvent::Wheel, b.position(), b.globalPosition(), mergedDelta, mergedWheelTicks, b.granularity(), b.modifiers(), b.timestamp());
1243 #endif // MERGE_WHEEL_EVENTS
1245 static WebWheelEvent coalescedWheelEvent(Deque<NativeWebWheelEvent>& queue, Vector<NativeWebWheelEvent>& coalescedEvents)
1247 ASSERT(!queue.isEmpty());
1248 ASSERT(coalescedEvents.isEmpty());
1250 #if MERGE_WHEEL_EVENTS
1251 NativeWebWheelEvent firstEvent = queue.takeFirst();
1252 coalescedEvents.append(firstEvent);
1254 WebWheelEvent event = firstEvent;
1255 while (!queue.isEmpty() && canCoalesce(event, queue.first())) {
1256 NativeWebWheelEvent firstEvent = queue.takeFirst();
1257 coalescedEvents.append(firstEvent);
1258 event = coalesce(event, firstEvent);
1263 while (!queue.isEmpty())
1264 coalescedEvents.append(queue.takeFirst());
1265 return coalescedEvents.last();
1269 void WebPageProxy::handleWheelEvent(const NativeWebWheelEvent& event)
1274 if (!m_currentlyProcessedWheelEvents.isEmpty()) {
1275 m_wheelEventQueue.append(event);
1276 if (m_wheelEventQueue.size() < wheelEventQueueSizeThreshold)
1278 // The queue has too many wheel events, so push a new event.
1281 if (!m_wheelEventQueue.isEmpty()) {
1282 processNextQueuedWheelEvent();
1286 OwnPtr<Vector<NativeWebWheelEvent> > coalescedWheelEvent = adoptPtr(new Vector<NativeWebWheelEvent>);
1287 coalescedWheelEvent->append(event);
1288 m_currentlyProcessedWheelEvents.append(coalescedWheelEvent.release());
1289 sendWheelEvent(event);
1292 void WebPageProxy::processNextQueuedWheelEvent()
1294 OwnPtr<Vector<NativeWebWheelEvent> > nextCoalescedEvent = adoptPtr(new Vector<NativeWebWheelEvent>);
1295 WebWheelEvent nextWheelEvent = coalescedWheelEvent(m_wheelEventQueue, *nextCoalescedEvent.get());
1296 m_currentlyProcessedWheelEvents.append(nextCoalescedEvent.release());
1297 sendWheelEvent(nextWheelEvent);
1300 void WebPageProxy::sendWheelEvent(const WebWheelEvent& event)
1302 m_process->responsivenessTimer()->start();
1304 if (m_shouldSendEventsSynchronously) {
1305 bool handled = false;
1306 m_process->sendSync(Messages::WebPage::WheelEventSyncForTesting(event), Messages::WebPage::WheelEventSyncForTesting::Reply(handled), m_pageID);
1307 didReceiveEvent(event.type(), handled);
1311 m_process->send(Messages::EventDispatcher::WheelEvent(m_pageID, event, canGoBack(), canGoForward()), 0);
1314 void WebPageProxy::handleKeyboardEvent(const NativeWebKeyboardEvent& event)
1319 LOG(KeyHandling, "WebPageProxy::handleKeyboardEvent: %s", webKeyboardEventTypeString(event.type()));
1321 m_keyEventQueue.append(event);
1323 m_process->responsivenessTimer()->start();
1324 if (m_shouldSendEventsSynchronously) {
1325 bool handled = false;
1326 m_process->sendSync(Messages::WebPage::KeyEventSyncForTesting(event), Messages::WebPage::KeyEventSyncForTesting::Reply(handled), m_pageID);
1327 didReceiveEvent(event.type(), handled);
1328 } else if (m_keyEventQueue.size() == 1) // Otherwise, sent from DidReceiveEvent message handler.
1329 m_process->send(Messages::WebPage::KeyEvent(event), m_pageID);
1332 #if ENABLE(NETSCAPE_PLUGIN_API)
1333 void WebPageProxy::getPluginPath(const String& mimeType, const String& urlString, const String& frameURLString, const String& pageURLString, String& pluginPath, uint32_t& pluginLoadPolicy)
1335 MESSAGE_CHECK_URL(urlString);
1337 String newMimeType = mimeType.lower();
1339 pluginLoadPolicy = PluginModuleLoadNormally;
1340 PluginModuleInfo plugin = m_process->context()->pluginInfoStore().findPlugin(newMimeType, KURL(KURL(), urlString));
1344 pluginLoadPolicy = PluginInfoStore::policyForPlugin(plugin);
1347 PluginModuleLoadPolicy currentPluginLoadPolicy = static_cast<PluginModuleLoadPolicy>(pluginLoadPolicy);
1348 pluginLoadPolicy = m_loaderClient.pluginLoadPolicy(this, plugin.bundleIdentifier, plugin.versionString, plugin.info.name, frameURLString, pageURLString, currentPluginLoadPolicy);
1350 UNUSED_PARAM(frameURLString);
1351 UNUSED_PARAM(pageURLString);
1354 if (pluginLoadPolicy != PluginModuleLoadNormally)
1357 pluginPath = plugin.path;
1359 #endif // ENABLE(NETSCAPE_PLUGIN_API)
1361 #if ENABLE(GESTURE_EVENTS)
1362 void WebPageProxy::handleGestureEvent(const WebGestureEvent& event)
1367 m_gestureEventQueue.append(event);
1369 m_process->responsivenessTimer()->start();
1370 m_process->send(Messages::EventDispatcher::GestureEvent(m_pageID, event), 0);
1374 #if ENABLE(TOUCH_EVENTS)
1376 void WebPageProxy::handlePotentialActivation(const IntPoint& touchPoint, const IntSize& touchArea)
1378 m_process->send(Messages::WebPage::HighlightPotentialActivation(touchPoint, touchArea), m_pageID);
1382 void WebPageProxy::handleTouchEvent(const NativeWebTouchEvent& event)
1387 // If the page is suspended, which should be the case during panning, pinching
1388 // and animation on the page itself (kinetic scrolling, tap to zoom) etc, then
1389 // we do not send any of the events to the page even if is has listeners.
1390 if (m_needTouchEvents && !m_isPageSuspended) {
1391 m_touchEventQueue.append(event);
1392 m_process->responsivenessTimer()->start();
1393 if (m_shouldSendEventsSynchronously) {
1394 bool handled = false;
1395 m_process->sendSync(Messages::WebPage::TouchEventSyncForTesting(event), Messages::WebPage::TouchEventSyncForTesting::Reply(handled), m_pageID);
1396 didReceiveEvent(event.type(), handled);
1398 m_process->send(Messages::WebPage::TouchEvent(event), m_pageID);
1400 if (m_touchEventQueue.isEmpty()) {
1401 bool isEventHandled = false;
1402 m_pageClient->doneWithTouchEvent(event, isEventHandled);
1404 // We attach the incoming events to the newest queued event so that all
1405 // the events are delivered in the correct order when the event is dequed.
1406 QueuedTouchEvents& lastEvent = m_touchEventQueue.last();
1407 lastEvent.deferredTouchEvents.append(event);
1413 void WebPageProxy::scrollBy(ScrollDirection direction, ScrollGranularity granularity)
1418 m_process->send(Messages::WebPage::ScrollBy(direction, granularity), m_pageID);
1421 void WebPageProxy::centerSelectionInVisibleArea()
1426 m_process->send(Messages::WebPage::CenterSelectionInVisibleArea(), m_pageID);
1429 void WebPageProxy::receivedPolicyDecision(PolicyAction action, WebFrameProxy* frame, uint64_t listenerID)
1434 #if ENABLE(NETWORK_PROCESS)
1435 // FIXME (NetworkProcess): Instead of canceling the load and then starting a separate download, we should
1436 // just convert the connection to a download connection. See <rdar://problem/12890184>.
1437 if (m_inDecidePolicyForResponse && action == PolicyDownload && m_process->context()->usesNetworkProcess()) {
1438 action = PolicyIgnore;
1440 m_process->context()->download(this, *m_decidePolicyForResponseRequest);
1444 if (action == PolicyIgnore)
1445 clearPendingAPIRequestURL();
1447 uint64_t downloadID = 0;
1448 if (action == PolicyDownload) {
1449 // Create a download proxy.
1450 DownloadProxy* download = m_process->context()->createDownloadProxy();
1451 downloadID = download->downloadID();
1452 #if PLATFORM(QT) || PLATFORM(EFL) || PLATFORM(GTK)
1453 // Our design does not suppport downloads without a WebPage.
1454 handleDownloadRequest(download);
1458 // If we received a policy decision while in decidePolicyForResponse the decision will
1459 // be sent back to the web process by decidePolicyForResponse.
1460 if (m_inDecidePolicyForResponse) {
1461 m_syncMimeTypePolicyActionIsValid = true;
1462 m_syncMimeTypePolicyAction = action;
1463 m_syncMimeTypePolicyDownloadID = downloadID;
1467 // If we received a policy decision while in decidePolicyForNavigationAction the decision will
1468 // be sent back to the web process by decidePolicyForNavigationAction.
1469 if (m_inDecidePolicyForNavigationAction) {
1470 m_syncNavigationActionPolicyActionIsValid = true;
1471 m_syncNavigationActionPolicyAction = action;
1472 m_syncNavigationActionPolicyDownloadID = downloadID;
1476 m_process->send(Messages::WebPage::DidReceivePolicyDecision(frame->frameID(), listenerID, action, downloadID), m_pageID);
1479 String WebPageProxy::pageTitle() const
1481 // Return the null string if there is no main frame (e.g. nothing has been loaded in the page yet, WebProcess has
1482 // crashed, page has been closed).
1486 return m_mainFrame->title();
1489 void WebPageProxy::setUserAgent(const String& userAgent)
1491 if (m_userAgent == userAgent)
1493 m_userAgent = userAgent;
1497 m_process->send(Messages::WebPage::SetUserAgent(m_userAgent), m_pageID);
1500 void WebPageProxy::setApplicationNameForUserAgent(const String& applicationName)
1502 if (m_applicationNameForUserAgent == applicationName)
1505 m_applicationNameForUserAgent = applicationName;
1506 if (!m_customUserAgent.isEmpty())
1509 setUserAgent(standardUserAgent(m_applicationNameForUserAgent));
1512 void WebPageProxy::setCustomUserAgent(const String& customUserAgent)
1514 if (m_customUserAgent == customUserAgent)
1517 m_customUserAgent = customUserAgent;
1519 if (m_customUserAgent.isEmpty()) {
1520 setUserAgent(standardUserAgent(m_applicationNameForUserAgent));
1524 setUserAgent(m_customUserAgent);
1527 void WebPageProxy::resumeActiveDOMObjectsAndAnimations()
1529 if (!isValid() || !m_isPageSuspended)
1532 m_isPageSuspended = false;
1534 m_process->send(Messages::WebPage::ResumeActiveDOMObjectsAndAnimations(), m_pageID);
1537 void WebPageProxy::suspendActiveDOMObjectsAndAnimations()
1539 if (!isValid() || m_isPageSuspended)
1542 m_isPageSuspended = true;
1544 m_process->send(Messages::WebPage::SuspendActiveDOMObjectsAndAnimations(), m_pageID);
1547 bool WebPageProxy::supportsTextEncoding() const
1549 return !m_mainFrameHasCustomRepresentation && m_mainFrame && !m_mainFrame->isDisplayingStandaloneImageDocument();
1552 void WebPageProxy::setCustomTextEncodingName(const String& encodingName)
1554 if (m_customTextEncodingName == encodingName)
1556 m_customTextEncodingName = encodingName;
1560 m_process->send(Messages::WebPage::SetCustomTextEncodingName(encodingName), m_pageID);
1563 void WebPageProxy::terminateProcess()
1565 // NOTE: This uses a check of m_isValid rather than calling isValid() since
1566 // we want this to run even for pages being closed or that already closed.
1570 m_process->requestTermination();
1571 resetStateAfterProcessExited();
1574 #if !USE(CF) || defined(BUILDING_QT__)
1575 PassRefPtr<WebData> WebPageProxy::sessionStateData(WebPageProxySessionStateFilterCallback, void* /*context*/) const
1577 // FIXME: Return session state data for saving Page state.
1581 void WebPageProxy::restoreFromSessionStateData(WebData*)
1583 // FIXME: Restore the Page from the passed in session state data.
1587 bool WebPageProxy::supportsTextZoom() const
1589 if (m_mainFrameHasCustomRepresentation)
1592 // FIXME: This should also return false for standalone media and plug-in documents.
1593 if (!m_mainFrame || m_mainFrame->isDisplayingStandaloneImageDocument())
1599 void WebPageProxy::setTextZoomFactor(double zoomFactor)
1604 if (m_mainFrameHasCustomRepresentation)
1607 if (m_textZoomFactor == zoomFactor)
1610 m_textZoomFactor = zoomFactor;
1611 m_process->send(Messages::WebPage::SetTextZoomFactor(m_textZoomFactor), m_pageID);
1614 double WebPageProxy::pageZoomFactor() const
1616 return m_mainFrameHasCustomRepresentation ? m_pageClient->customRepresentationZoomFactor() : m_pageZoomFactor;
1619 void WebPageProxy::setPageZoomFactor(double zoomFactor)
1624 if (m_mainFrameHasCustomRepresentation) {
1625 m_pageClient->setCustomRepresentationZoomFactor(zoomFactor);
1629 if (m_pageZoomFactor == zoomFactor)
1632 m_pageZoomFactor = zoomFactor;
1633 m_process->send(Messages::WebPage::SetPageZoomFactor(m_pageZoomFactor), m_pageID);
1636 void WebPageProxy::setPageAndTextZoomFactors(double pageZoomFactor, double textZoomFactor)
1641 if (m_mainFrameHasCustomRepresentation) {
1642 m_pageClient->setCustomRepresentationZoomFactor(pageZoomFactor);
1646 if (m_pageZoomFactor == pageZoomFactor && m_textZoomFactor == textZoomFactor)
1649 m_pageZoomFactor = pageZoomFactor;
1650 m_textZoomFactor = textZoomFactor;
1651 m_process->send(Messages::WebPage::SetPageAndTextZoomFactors(m_pageZoomFactor, m_textZoomFactor), m_pageID);
1654 void WebPageProxy::scalePage(double scale, const IntPoint& origin)
1659 m_process->send(Messages::WebPage::ScalePage(scale, origin), m_pageID);
1662 void WebPageProxy::setIntrinsicDeviceScaleFactor(float scaleFactor)
1664 if (m_intrinsicDeviceScaleFactor == scaleFactor)
1667 m_intrinsicDeviceScaleFactor = scaleFactor;
1670 m_drawingArea->deviceScaleFactorDidChange();
1673 void WebPageProxy::windowScreenDidChange(PlatformDisplayID displayID)
1678 m_process->send(Messages::WebPage::WindowScreenDidChange(displayID), m_pageID);
1681 float WebPageProxy::deviceScaleFactor() const
1683 if (m_customDeviceScaleFactor)
1684 return m_customDeviceScaleFactor;
1685 return m_intrinsicDeviceScaleFactor;
1688 void WebPageProxy::setCustomDeviceScaleFactor(float customScaleFactor)
1693 if (m_customDeviceScaleFactor == customScaleFactor)
1696 float oldScaleFactor = deviceScaleFactor();
1698 m_customDeviceScaleFactor = customScaleFactor;
1700 if (deviceScaleFactor() != oldScaleFactor)
1701 m_drawingArea->deviceScaleFactorDidChange();
1704 void WebPageProxy::setUseFixedLayout(bool fixed)
1709 // This check is fine as the value is initialized in the web
1710 // process as part of the creation parameters.
1711 if (fixed == m_useFixedLayout)
1714 m_useFixedLayout = fixed;
1716 m_fixedLayoutSize = IntSize();
1717 m_process->send(Messages::WebPage::SetUseFixedLayout(fixed), m_pageID);
1720 void WebPageProxy::setFixedLayoutSize(const IntSize& size)
1725 if (size == m_fixedLayoutSize)
1728 m_fixedLayoutSize = size;
1729 m_process->send(Messages::WebPage::SetFixedLayoutSize(size), m_pageID);
1732 void WebPageProxy::listenForLayoutMilestones(WebCore::LayoutMilestones milestones)
1737 m_process->send(Messages::WebPage::ListenForLayoutMilestones(milestones), m_pageID);
1740 void WebPageProxy::setVisibilityState(WebCore::PageVisibilityState visibilityState, bool isInitialState)
1745 #if ENABLE(PAGE_VISIBILITY_API)
1746 if (visibilityState != m_visibilityState || isInitialState) {
1747 m_visibilityState = visibilityState;
1748 m_process->send(Messages::WebPage::SetVisibilityState(visibilityState, isInitialState), m_pageID);
1753 void WebPageProxy::setSuppressScrollbarAnimations(bool suppressAnimations)
1758 if (suppressAnimations == m_suppressScrollbarAnimations)
1761 m_suppressScrollbarAnimations = suppressAnimations;
1762 m_process->send(Messages::WebPage::SetSuppressScrollbarAnimations(suppressAnimations), m_pageID);
1765 void WebPageProxy::setRubberBandsAtBottom(bool rubberBandsAtBottom)
1767 if (rubberBandsAtBottom == m_rubberBandsAtBottom)
1770 m_rubberBandsAtBottom = rubberBandsAtBottom;
1775 m_process->send(Messages::WebPage::SetRubberBandsAtBottom(rubberBandsAtBottom), m_pageID);
1778 void WebPageProxy::setRubberBandsAtTop(bool rubberBandsAtTop)
1780 if (rubberBandsAtTop == m_rubberBandsAtTop)
1783 m_rubberBandsAtTop = rubberBandsAtTop;
1788 m_process->send(Messages::WebPage::SetRubberBandsAtTop(rubberBandsAtTop), m_pageID);
1791 void WebPageProxy::setPaginationMode(WebCore::Pagination::Mode mode)
1793 if (mode == m_paginationMode)
1796 m_paginationMode = mode;
1800 m_process->send(Messages::WebPage::SetPaginationMode(mode), m_pageID);
1803 void WebPageProxy::setPaginationBehavesLikeColumns(bool behavesLikeColumns)
1805 if (behavesLikeColumns == m_paginationBehavesLikeColumns)
1808 m_paginationBehavesLikeColumns = behavesLikeColumns;
1812 m_process->send(Messages::WebPage::SetPaginationBehavesLikeColumns(behavesLikeColumns), m_pageID);
1815 void WebPageProxy::setPageLength(double pageLength)
1817 if (pageLength == m_pageLength)
1820 m_pageLength = pageLength;
1824 m_process->send(Messages::WebPage::SetPageLength(pageLength), m_pageID);
1827 void WebPageProxy::setGapBetweenPages(double gap)
1829 if (gap == m_gapBetweenPages)
1832 m_gapBetweenPages = gap;
1836 m_process->send(Messages::WebPage::SetGapBetweenPages(gap), m_pageID);
1839 void WebPageProxy::pageScaleFactorDidChange(double scaleFactor)
1841 m_pageScaleFactor = scaleFactor;
1844 void WebPageProxy::pageZoomFactorDidChange(double zoomFactor)
1846 m_pageZoomFactor = zoomFactor;
1849 void WebPageProxy::setMemoryCacheClientCallsEnabled(bool memoryCacheClientCallsEnabled)
1854 if (m_areMemoryCacheClientCallsEnabled == memoryCacheClientCallsEnabled)
1857 m_areMemoryCacheClientCallsEnabled = memoryCacheClientCallsEnabled;
1858 m_process->send(Messages::WebPage::SetMemoryCacheMessagesEnabled(memoryCacheClientCallsEnabled), m_pageID);
1861 void WebPageProxy::findStringMatches(const String& string, FindOptions options, unsigned maxMatchCount)
1863 if (string.isEmpty()) {
1864 didFindStringMatches(string, Vector<Vector<WebCore::IntRect> > (), 0);
1868 m_process->send(Messages::WebPage::FindStringMatches(string, options, maxMatchCount), m_pageID);
1871 void WebPageProxy::findString(const String& string, FindOptions options, unsigned maxMatchCount)
1873 if (m_mainFrameHasCustomRepresentation)
1874 m_pageClient->findStringInCustomRepresentation(string, options, maxMatchCount);
1876 m_process->send(Messages::WebPage::FindString(string, options, maxMatchCount), m_pageID);
1879 void WebPageProxy::getImageForFindMatch(int32_t matchIndex)
1881 m_process->send(Messages::WebPage::GetImageForFindMatch(matchIndex), m_pageID);
1884 void WebPageProxy::selectFindMatch(int32_t matchIndex)
1886 m_process->send(Messages::WebPage::SelectFindMatch(matchIndex), m_pageID);
1889 void WebPageProxy::hideFindUI()
1891 m_process->send(Messages::WebPage::HideFindUI(), m_pageID);
1894 void WebPageProxy::countStringMatches(const String& string, FindOptions options, unsigned maxMatchCount)
1896 if (m_mainFrameHasCustomRepresentation) {
1897 m_pageClient->countStringMatchesInCustomRepresentation(string, options, maxMatchCount);
1904 m_process->send(Messages::WebPage::CountStringMatches(string, options, maxMatchCount), m_pageID);
1907 void WebPageProxy::runJavaScriptInMainFrame(const String& script, PassRefPtr<ScriptValueCallback> prpCallback)
1909 RefPtr<ScriptValueCallback> callback = prpCallback;
1911 callback->invalidate();
1915 uint64_t callbackID = callback->callbackID();
1916 m_scriptValueCallbacks.set(callbackID, callback.get());
1917 m_process->send(Messages::WebPage::RunJavaScriptInMainFrame(script, callbackID), m_pageID);
1920 void WebPageProxy::getRenderTreeExternalRepresentation(PassRefPtr<StringCallback> prpCallback)
1922 RefPtr<StringCallback> callback = prpCallback;
1924 callback->invalidate();
1928 uint64_t callbackID = callback->callbackID();
1929 m_stringCallbacks.set(callbackID, callback.get());
1930 m_process->send(Messages::WebPage::GetRenderTreeExternalRepresentation(callbackID), m_pageID);
1933 void WebPageProxy::getSourceForFrame(WebFrameProxy* frame, PassRefPtr<StringCallback> prpCallback)
1935 RefPtr<StringCallback> callback = prpCallback;
1937 callback->invalidate();
1941 uint64_t callbackID = callback->callbackID();
1942 m_loadDependentStringCallbackIDs.add(callbackID);
1943 m_stringCallbacks.set(callbackID, callback.get());
1944 m_process->send(Messages::WebPage::GetSourceForFrame(frame->frameID(), callbackID), m_pageID);
1947 void WebPageProxy::getContentsAsString(PassRefPtr<StringCallback> prpCallback)
1949 RefPtr<StringCallback> callback = prpCallback;
1951 callback->invalidate();
1955 uint64_t callbackID = callback->callbackID();
1956 m_loadDependentStringCallbackIDs.add(callbackID);
1957 m_stringCallbacks.set(callbackID, callback.get());
1958 m_process->send(Messages::WebPage::GetContentsAsString(callbackID), m_pageID);
1962 void WebPageProxy::getContentsAsMHTMLData(PassRefPtr<DataCallback> prpCallback, bool useBinaryEncoding)
1964 RefPtr<DataCallback> callback = prpCallback;
1966 callback->invalidate();
1970 uint64_t callbackID = callback->callbackID();
1971 m_dataCallbacks.set(callbackID, callback.get());
1972 m_process->send(Messages::WebPage::GetContentsAsMHTMLData(callbackID, useBinaryEncoding), m_pageID);
1976 void WebPageProxy::getSelectionOrContentsAsString(PassRefPtr<StringCallback> prpCallback)
1978 RefPtr<StringCallback> callback = prpCallback;
1980 callback->invalidate();
1984 uint64_t callbackID = callback->callbackID();
1985 m_stringCallbacks.set(callbackID, callback.get());
1986 m_process->send(Messages::WebPage::GetSelectionOrContentsAsString(callbackID), m_pageID);
1989 void WebPageProxy::getSelectionAsWebArchiveData(PassRefPtr<DataCallback> prpCallback)
1991 RefPtr<DataCallback> callback = prpCallback;
1993 callback->invalidate();
1997 uint64_t callbackID = callback->callbackID();
1998 m_dataCallbacks.set(callbackID, callback.get());
1999 m_process->send(Messages::WebPage::GetSelectionAsWebArchiveData(callbackID), m_pageID);
2002 void WebPageProxy::getMainResourceDataOfFrame(WebFrameProxy* frame, PassRefPtr<DataCallback> prpCallback)
2004 RefPtr<DataCallback> callback = prpCallback;
2006 callback->invalidate();
2010 uint64_t callbackID = callback->callbackID();
2011 m_dataCallbacks.set(callbackID, callback.get());
2012 m_process->send(Messages::WebPage::GetMainResourceDataOfFrame(frame->frameID(), callbackID), m_pageID);
2015 void WebPageProxy::getResourceDataFromFrame(WebFrameProxy* frame, WebURL* resourceURL, PassRefPtr<DataCallback> prpCallback)
2017 RefPtr<DataCallback> callback = prpCallback;
2019 callback->invalidate();
2023 uint64_t callbackID = callback->callbackID();
2024 m_dataCallbacks.set(callbackID, callback.get());
2025 m_process->send(Messages::WebPage::GetResourceDataFromFrame(frame->frameID(), resourceURL->string(), callbackID), m_pageID);
2028 void WebPageProxy::getWebArchiveOfFrame(WebFrameProxy* frame, PassRefPtr<DataCallback> prpCallback)
2030 RefPtr<DataCallback> callback = prpCallback;
2032 callback->invalidate();
2036 uint64_t callbackID = callback->callbackID();
2037 m_dataCallbacks.set(callbackID, callback.get());
2038 m_process->send(Messages::WebPage::GetWebArchiveOfFrame(frame->frameID(), callbackID), m_pageID);
2041 void WebPageProxy::forceRepaint(PassRefPtr<VoidCallback> prpCallback)
2043 RefPtr<VoidCallback> callback = prpCallback;
2045 callback->invalidate();
2049 uint64_t callbackID = callback->callbackID();
2050 m_voidCallbacks.set(callbackID, callback.get());
2051 m_drawingArea->waitForBackingStoreUpdateOnNextPaint();
2052 m_process->send(Messages::WebPage::ForceRepaint(callbackID), m_pageID);
2055 void WebPageProxy::preferencesDidChange()
2060 #if ENABLE(INSPECTOR_SERVER)
2061 if (m_pageGroup->preferences()->developerExtrasEnabled())
2062 inspector()->enableRemoteInspection();
2065 m_process->pagePreferencesChanged(this);
2067 // FIXME: It probably makes more sense to send individual preference changes.
2068 // However, WebKitTestRunner depends on getting a preference change notification
2069 // even if nothing changed in UI process, so that overrides get removed.
2071 // Preferences need to be updated during synchronous printing to make "print backgrounds" preference work when toggled from a print dialog checkbox.
2072 m_process->send(Messages::WebPage::PreferencesDidChange(pageGroup()->preferences()->store()), m_pageID, m_isPerformingDOMPrintOperation ? CoreIPC::DispatchMessageEvenWhenWaitingForSyncReply : 0);
2075 void WebPageProxy::didCreateMainFrame(uint64_t frameID)
2077 MESSAGE_CHECK(!m_mainFrame);
2078 MESSAGE_CHECK(m_process->canCreateFrame(frameID));
2080 m_mainFrame = WebFrameProxy::create(this, frameID);
2082 // Add the frame to the process wide map.
2083 m_process->frameCreated(frameID, m_mainFrame.get());
2086 void WebPageProxy::didCreateSubframe(uint64_t frameID)
2088 MESSAGE_CHECK(m_mainFrame);
2089 MESSAGE_CHECK(m_process->canCreateFrame(frameID));
2091 RefPtr<WebFrameProxy> subFrame = WebFrameProxy::create(this, frameID);
2093 // Add the frame to the process wide map.
2094 m_process->frameCreated(frameID, subFrame.get());
2097 // Always start progress at initialProgressValue. This helps provide feedback as
2098 // soon as a load starts.
2100 static const double initialProgressValue = 0.1;
2102 double WebPageProxy::estimatedProgress() const
2104 if (!pendingAPIRequestURL().isNull())
2105 return initialProgressValue;
2106 return m_estimatedProgress;
2109 void WebPageProxy::didStartProgress()
2111 m_estimatedProgress = initialProgressValue;
2113 m_loaderClient.didStartProgress(this);
2116 void WebPageProxy::didChangeProgress(double value)
2118 m_estimatedProgress = value;
2120 m_loaderClient.didChangeProgress(this);
2123 void WebPageProxy::didFinishProgress()
2125 m_estimatedProgress = 1.0;
2127 m_loaderClient.didFinishProgress(this);
2130 void WebPageProxy::didStartProvisionalLoadForFrame(uint64_t frameID, const String& url, const String& unreachableURL, CoreIPC::MessageDecoder& decoder)
2132 clearPendingAPIRequestURL();
2134 RefPtr<APIObject> userData;
2135 WebContextUserMessageDecoder messageDecoder(userData, m_process.get());
2136 if (!decoder.decode(messageDecoder))
2139 WebFrameProxy* frame = m_process->webFrame(frameID);
2140 MESSAGE_CHECK(frame);
2141 MESSAGE_CHECK_URL(url);
2143 frame->setUnreachableURL(unreachableURL);
2145 frame->didStartProvisionalLoad(url);
2146 m_loaderClient.didStartProvisionalLoadForFrame(this, frame, userData.get());
2149 void WebPageProxy::didReceiveServerRedirectForProvisionalLoadForFrame(uint64_t frameID, const String& url, CoreIPC::MessageDecoder& decoder)
2151 RefPtr<APIObject> userData;
2152 WebContextUserMessageDecoder messageDecoder(userData, m_process.get());
2153 if (!decoder.decode(messageDecoder))
2156 WebFrameProxy* frame = m_process->webFrame(frameID);
2157 MESSAGE_CHECK(frame);
2158 MESSAGE_CHECK_URL(url);
2160 frame->didReceiveServerRedirectForProvisionalLoad(url);
2162 m_loaderClient.didReceiveServerRedirectForProvisionalLoadForFrame(this, frame, userData.get());
2165 void WebPageProxy::didFailProvisionalLoadForFrame(uint64_t frameID, const ResourceError& error, CoreIPC::MessageDecoder& decoder)
2167 RefPtr<APIObject> userData;
2168 WebContextUserMessageDecoder messageDecoder(userData, m_process.get());
2169 if (!decoder.decode(messageDecoder))
2172 WebFrameProxy* frame = m_process->webFrame(frameID);
2173 MESSAGE_CHECK(frame);
2175 frame->didFailProvisionalLoad();
2177 m_loaderClient.didFailProvisionalLoadWithErrorForFrame(this, frame, error, userData.get());
2180 void WebPageProxy::clearLoadDependentCallbacks()
2182 Vector<uint64_t> callbackIDsCopy;
2183 copyToVector(m_loadDependentStringCallbackIDs, callbackIDsCopy);
2184 m_loadDependentStringCallbackIDs.clear();
2186 for (size_t i = 0; i < callbackIDsCopy.size(); ++i) {
2187 RefPtr<StringCallback> callback = m_stringCallbacks.take(callbackIDsCopy[i]);
2189 callback->invalidate();
2193 void WebPageProxy::didCommitLoadForFrame(uint64_t frameID, const String& mimeType, bool frameHasCustomRepresentation, uint32_t opaqueFrameLoadType, const PlatformCertificateInfo& certificateInfo, CoreIPC::MessageDecoder& decoder)
2195 RefPtr<APIObject> userData;
2196 WebContextUserMessageDecoder messageDecoder(userData, m_process.get());
2197 if (!decoder.decode(messageDecoder))
2200 WebFrameProxy* frame = m_process->webFrame(frameID);
2201 MESSAGE_CHECK(frame);
2204 // FIXME (bug 59111): didCommitLoadForFrame comes too late when restoring a page from b/f cache, making us disable secure event mode in password fields.
2205 // FIXME (bug 59121): A load going on in one frame shouldn't affect typing in sibling frames.
2206 m_pageClient->resetTextInputState();
2207 // FIXME: Should this be moved inside resetTextInputState()?
2208 dismissCorrectionPanel(ReasonForDismissingAlternativeTextIgnored);
2209 m_pageClient->dismissDictionaryLookupPanel();
2212 clearLoadDependentCallbacks();
2214 frame->didCommitLoad(mimeType, certificateInfo);
2216 if (frame->isMainFrame()) {
2217 m_mainFrameHasCustomRepresentation = frameHasCustomRepresentation;
2219 if (m_mainFrameHasCustomRepresentation) {
2220 // Always assume that the main frame is pinned here, since the custom representation view will handle
2221 // any wheel events and dispatch them to the WKView when necessary.
2222 m_mainFrameIsPinnedToLeftSide = true;
2223 m_mainFrameIsPinnedToRightSide = true;
2224 m_mainFrameIsPinnedToTopSide = true;
2225 m_mainFrameIsPinnedToBottomSide = true;
2227 m_pageClient->didCommitLoadForMainFrame(frameHasCustomRepresentation);
2230 // Even if WebPage has the default pageScaleFactor (and therefore doesn't reset it),
2231 // WebPageProxy's cache of the value can get out of sync (e.g. in the case where a
2232 // plugin is handling page scaling itself) so we should reset it to the default
2233 // for standard main frame loads.
2234 if (frame->isMainFrame() && static_cast<FrameLoadType>(opaqueFrameLoadType) == FrameLoadTypeStandard)
2235 m_pageScaleFactor = 1;
2237 m_loaderClient.didCommitLoadForFrame(this, frame, userData.get());
2240 void WebPageProxy::didFinishDocumentLoadForFrame(uint64_t frameID, CoreIPC::MessageDecoder& decoder)
2242 RefPtr<APIObject> userData;
2243 WebContextUserMessageDecoder messageDecoder(userData, m_process.get());
2244 if (!decoder.decode(messageDecoder))
2247 WebFrameProxy* frame = m_process->webFrame(frameID);
2248 MESSAGE_CHECK(frame);
2250 m_loaderClient.didFinishDocumentLoadForFrame(this, frame, userData.get());
2253 void WebPageProxy::didFinishLoadForFrame(uint64_t frameID, CoreIPC::MessageDecoder& decoder)
2255 RefPtr<APIObject> userData;
2256 WebContextUserMessageDecoder messageDecoder(userData, m_process.get());
2257 if (!decoder.decode(messageDecoder))
2260 WebFrameProxy* frame = m_process->webFrame(frameID);
2261 MESSAGE_CHECK(frame);
2263 frame->didFinishLoad();
2265 m_loaderClient.didFinishLoadForFrame(this, frame, userData.get());
2268 void WebPageProxy::didFailLoadForFrame(uint64_t frameID, const ResourceError& error, CoreIPC::MessageDecoder& decoder)
2270 RefPtr<APIObject> userData;
2271 WebContextUserMessageDecoder messageDecoder(userData, m_process.get());
2272 if (!decoder.decode(messageDecoder))
2275 WebFrameProxy* frame = m_process->webFrame(frameID);
2276 MESSAGE_CHECK(frame);
2278 clearLoadDependentCallbacks();
2280 frame->didFailLoad();
2282 m_loaderClient.didFailLoadWithErrorForFrame(this, frame, error, userData.get());
2285 void WebPageProxy::didSameDocumentNavigationForFrame(uint64_t frameID, uint32_t opaqueSameDocumentNavigationType, const String& url, CoreIPC::MessageDecoder& decoder)
2287 RefPtr<APIObject> userData;
2288 WebContextUserMessageDecoder messageDecoder(userData, m_process.get());
2289 if (!decoder.decode(messageDecoder))
2292 WebFrameProxy* frame = m_process->webFrame(frameID);
2293 MESSAGE_CHECK(frame);
2294 MESSAGE_CHECK_URL(url);
2296 clearPendingAPIRequestURL();
2297 frame->didSameDocumentNavigation(url);
2299 m_loaderClient.didSameDocumentNavigationForFrame(this, frame, static_cast<SameDocumentNavigationType>(opaqueSameDocumentNavigationType), userData.get());
2302 void WebPageProxy::didReceiveTitleForFrame(uint64_t frameID, const String& title, CoreIPC::MessageDecoder& decoder)
2304 RefPtr<APIObject> userData;
2305 WebContextUserMessageDecoder messageDecoder(userData, m_process.get());
2306 if (!decoder.decode(messageDecoder))
2309 WebFrameProxy* frame = m_process->webFrame(frameID);
2310 MESSAGE_CHECK(frame);
2312 frame->didChangeTitle(title);
2314 m_loaderClient.didReceiveTitleForFrame(this, title, frame, userData.get());
2317 void WebPageProxy::didFirstLayoutForFrame(uint64_t frameID, CoreIPC::MessageDecoder& decoder)
2319 RefPtr<APIObject> userData;
2320 WebContextUserMessageDecoder messageDecoder(userData, m_process.get());
2321 if (!decoder.decode(messageDecoder))
2324 WebFrameProxy* frame = m_process->webFrame(frameID);
2325 MESSAGE_CHECK(frame);
2327 m_loaderClient.didFirstLayoutForFrame(this, frame, userData.get());
2330 void WebPageProxy::didFirstVisuallyNonEmptyLayoutForFrame(uint64_t frameID, CoreIPC::MessageDecoder& decoder)
2332 RefPtr<APIObject> userData;
2333 WebContextUserMessageDecoder messageDecoder(userData, m_process.get());
2334 if (!decoder.decode(messageDecoder))
2337 WebFrameProxy* frame = m_process->webFrame(frameID);
2338 MESSAGE_CHECK(frame);
2340 m_loaderClient.didFirstVisuallyNonEmptyLayoutForFrame(this, frame, userData.get());
2343 void WebPageProxy::didNewFirstVisuallyNonEmptyLayout(CoreIPC::MessageDecoder& decoder)
2345 RefPtr<APIObject> userData;
2346 WebContextUserMessageDecoder messageDecoder(userData, m_process.get());
2347 if (!decoder.decode(messageDecoder))
2350 m_loaderClient.didNewFirstVisuallyNonEmptyLayout(this, userData.get());
2353 void WebPageProxy::didLayout(uint32_t layoutMilestones, CoreIPC::MessageDecoder& decoder)
2355 RefPtr<APIObject> userData;
2356 WebContextUserMessageDecoder messageDecoder(userData, m_process.get());
2357 if (!decoder.decode(messageDecoder))
2360 m_loaderClient.didLayout(this, static_cast<LayoutMilestones>(layoutMilestones), userData.get());
2363 void WebPageProxy::didRemoveFrameFromHierarchy(uint64_t frameID, CoreIPC::MessageDecoder& decoder)
2365 RefPtr<APIObject> userData;
2366 WebContextUserMessageDecoder messageDecoder(userData, m_process.get());
2367 if (!decoder.decode(messageDecoder))
2370 WebFrameProxy* frame = m_process->webFrame(frameID);
2371 MESSAGE_CHECK(frame);
2373 m_loaderClient.didRemoveFrameFromHierarchy(this, frame, userData.get());
2376 void WebPageProxy::didDisplayInsecureContentForFrame(uint64_t frameID, CoreIPC::MessageDecoder& decoder)
2378 RefPtr<APIObject> userData;
2379 WebContextUserMessageDecoder messageDecoder(userData, m_process.get());
2380 if (!decoder.decode(messageDecoder))
2383 WebFrameProxy* frame = m_process->webFrame(frameID);
2384 MESSAGE_CHECK(frame);
2386 m_loaderClient.didDisplayInsecureContentForFrame(this, frame, userData.get());
2389 void WebPageProxy::didRunInsecureContentForFrame(uint64_t frameID, CoreIPC::MessageDecoder& decoder)
2391 RefPtr<APIObject> userData;
2392 WebContextUserMessageDecoder messageDecoder(userData, m_process.get());
2393 if (!decoder.decode(messageDecoder))
2396 WebFrameProxy* frame = m_process->webFrame(frameID);
2397 MESSAGE_CHECK(frame);
2399 m_loaderClient.didRunInsecureContentForFrame(this, frame, userData.get());
2402 void WebPageProxy::didDetectXSSForFrame(uint64_t frameID, CoreIPC::MessageDecoder& decoder)
2404 RefPtr<APIObject> userData;
2405 WebContextUserMessageDecoder messageDecoder(userData, m_process.get());
2406 if (!decoder.decode(messageDecoder))
2409 WebFrameProxy* frame = m_process->webFrame(frameID);
2410 MESSAGE_CHECK(frame);
2412 m_loaderClient.didDetectXSSForFrame(this, frame, userData.get());
2415 void WebPageProxy::frameDidBecomeFrameSet(uint64_t frameID, bool value)
2417 WebFrameProxy* frame = m_process->webFrame(frameID);
2418 MESSAGE_CHECK(frame);
2420 frame->setIsFrameSet(value);
2421 if (frame->isMainFrame())
2422 m_frameSetLargestFrame = value ? m_mainFrame : 0;
2426 void WebPageProxy::decidePolicyForNavigationAction(uint64_t frameID, uint32_t opaqueNavigationType, uint32_t opaqueModifiers, int32_t opaqueMouseButton, const ResourceRequest& request, uint64_t listenerID, CoreIPC::MessageDecoder& decoder, bool& receivedPolicyAction, uint64_t& policyAction, uint64_t& downloadID)
2428 RefPtr<APIObject> userData;
2429 WebContextUserMessageDecoder messageDecoder(userData, m_process.get());
2430 if (!decoder.decode(messageDecoder))
2433 if (request.url() != pendingAPIRequestURL())
2434 clearPendingAPIRequestURL();
2436 WebFrameProxy* frame = m_process->webFrame(frameID);
2437 MESSAGE_CHECK(frame);
2438 MESSAGE_CHECK_URL(request.url());
2440 NavigationType navigationType = static_cast<NavigationType>(opaqueNavigationType);
2441 WebEvent::Modifiers modifiers = static_cast<WebEvent::Modifiers>(opaqueModifiers);
2442 WebMouseEvent::Button mouseButton = static_cast<WebMouseEvent::Button>(opaqueMouseButton);
2444 RefPtr<WebFramePolicyListenerProxy> listener = frame->setUpPolicyListenerProxy(listenerID);
2446 ASSERT(!m_inDecidePolicyForNavigationAction);
2448 m_inDecidePolicyForNavigationAction = true;
2449 m_syncNavigationActionPolicyActionIsValid = false;
2451 if (!m_policyClient.decidePolicyForNavigationAction(this, frame, navigationType, modifiers, mouseButton, request, listener.get(), userData.get()))
2454 m_inDecidePolicyForNavigationAction = false;
2456 // Check if we received a policy decision already. If we did, we can just pass it back.
2457 receivedPolicyAction = m_syncNavigationActionPolicyActionIsValid;
2458 if (m_syncNavigationActionPolicyActionIsValid) {
2459 policyAction = m_syncNavigationActionPolicyAction;
2460 downloadID = m_syncNavigationActionPolicyDownloadID;
2464 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::MessageDecoder& decoder)
2466 RefPtr<APIObject> userData;
2467 WebContextUserMessageDecoder messageDecoder(userData, m_process.get());
2468 if (!decoder.decode(messageDecoder))
2471 WebFrameProxy* frame = m_process->webFrame(frameID);
2472 MESSAGE_CHECK(frame);
2473 MESSAGE_CHECK_URL(request.url());
2475 NavigationType navigationType = static_cast<NavigationType>(opaqueNavigationType);
2476 WebEvent::Modifiers modifiers = static_cast<WebEvent::Modifiers>(opaqueModifiers);
2477 WebMouseEvent::Button mouseButton = static_cast<WebMouseEvent::Button>(opaqueMouseButton);
2479 RefPtr<WebFramePolicyListenerProxy> listener = frame->setUpPolicyListenerProxy(listenerID);
2480 if (!m_policyClient.decidePolicyForNewWindowAction(this, frame, navigationType, modifiers, mouseButton, request, frameName, listener.get(), userData.get()))
2484 void WebPageProxy::decidePolicyForResponse(uint64_t frameID, const ResourceResponse& response, const ResourceRequest& request, uint64_t listenerID, CoreIPC::MessageDecoder& decoder, bool& receivedPolicyAction, uint64_t& policyAction, uint64_t& downloadID)
2486 RefPtr<APIObject> userData;
2487 WebContextUserMessageDecoder messageDecoder(userData, m_process.get());
2488 if (!decoder.decode(messageDecoder))
2491 WebFrameProxy* frame = m_process->webFrame(frameID);
2492 MESSAGE_CHECK(frame);
2493 MESSAGE_CHECK_URL(request.url());
2494 MESSAGE_CHECK_URL(response.url());
2496 RefPtr<WebFramePolicyListenerProxy> listener = frame->setUpPolicyListenerProxy(listenerID);
2498 ASSERT(!m_inDecidePolicyForResponse);
2500 m_inDecidePolicyForResponse = true;
2501 m_decidePolicyForResponseRequest = &request;
2502 m_syncMimeTypePolicyActionIsValid = false;
2504 if (!m_policyClient.decidePolicyForResponse(this, frame, response, request, listener.get(), userData.get()))
2507 m_inDecidePolicyForResponse = false;
2508 m_decidePolicyForResponseRequest = 0;
2510 // Check if we received a policy decision already. If we did, we can just pass it back.
2511 receivedPolicyAction = m_syncMimeTypePolicyActionIsValid;
2512 if (m_syncMimeTypePolicyActionIsValid) {
2513 policyAction = m_syncMimeTypePolicyAction;
2514 downloadID = m_syncMimeTypePolicyDownloadID;
2518 void WebPageProxy::unableToImplementPolicy(uint64_t frameID, const ResourceError& error, CoreIPC::MessageDecoder& decoder)
2520 RefPtr<APIObject> userData;
2521 WebContextUserMessageDecoder messageDecoder(userData, m_process.get());
2522 if (!decoder.decode(messageDecoder))
2525 WebFrameProxy* frame = m_process->webFrame(frameID);
2526 MESSAGE_CHECK(frame);
2528 m_policyClient.unableToImplementPolicy(this, frame, error, userData.get());
2533 void WebPageProxy::willSubmitForm(uint64_t frameID, uint64_t sourceFrameID, const Vector<std::pair<String, String> >& textFieldValues, uint64_t listenerID, CoreIPC::MessageDecoder& decoder)
2535 RefPtr<APIObject> userData;
2536 WebContextUserMessageDecoder messageDecoder(userData, m_process.get());
2537 if (!decoder.decode(messageDecoder))
2540 WebFrameProxy* frame = m_process->webFrame(frameID);
2541 MESSAGE_CHECK(frame);
2543 WebFrameProxy* sourceFrame = m_process->webFrame(sourceFrameID);
2544 MESSAGE_CHECK(sourceFrame);
2546 RefPtr<WebFormSubmissionListenerProxy> listener = frame->setUpFormSubmissionListenerProxy(listenerID);
2547 if (!m_formClient.willSubmitForm(this, frame, sourceFrame, textFieldValues, userData.get(), listener.get()))
2548 listener->continueSubmission();
2553 void WebPageProxy::createNewPage(const ResourceRequest& request, const WindowFeatures& windowFeatures, uint32_t opaqueModifiers, int32_t opaqueMouseButton, uint64_t& newPageID, WebPageCreationParameters& newPageParameters)
2555 RefPtr<WebPageProxy> newPage = m_uiClient.createNewPage(this, request, windowFeatures, static_cast<WebEvent::Modifiers>(opaqueModifiers), static_cast<WebMouseEvent::Button>(opaqueMouseButton));
2561 newPageID = newPage->pageID();
2562 newPageParameters = newPage->creationParameters();
2563 process()->context()->storageManager().cloneSessionStorageNamespace(m_pageID, newPage->pageID());
2566 void WebPageProxy::showPage()
2568 m_uiClient.showPage(this);
2571 void WebPageProxy::closePage(bool stopResponsivenessTimer)
2573 if (stopResponsivenessTimer)
2574 m_process->responsivenessTimer()->stop();
2576 m_pageClient->clearAllEditCommands();
2577 m_uiClient.close(this);
2580 void WebPageProxy::runJavaScriptAlert(uint64_t frameID, const String& message)
2582 WebFrameProxy* frame = m_process->webFrame(frameID);
2583 MESSAGE_CHECK(frame);
2585 // Since runJavaScriptAlert() can spin a nested run loop we need to turn off the responsiveness timer.
2586 m_process->responsivenessTimer()->stop();
2588 m_uiClient.runJavaScriptAlert(this, message, frame);
2591 void WebPageProxy::runJavaScriptConfirm(uint64_t frameID, const String& message, bool& result)
2593 WebFrameProxy* frame = m_process->webFrame(frameID);
2594 MESSAGE_CHECK(frame);
2596 // Since runJavaScriptConfirm() can spin a nested run loop we need to turn off the responsiveness timer.
2597 m_process->responsivenessTimer()->stop();
2599 result = m_uiClient.runJavaScriptConfirm(this, message, frame);
2602 void WebPageProxy::runJavaScriptPrompt(uint64_t frameID, const String& message, const String& defaultValue, String& result)
2604 WebFrameProxy* frame = m_process->webFrame(frameID);
2605 MESSAGE_CHECK(frame);
2607 // Since runJavaScriptPrompt() can spin a nested run loop we need to turn off the responsiveness timer.
2608 m_process->responsivenessTimer()->stop();
2610 result = m_uiClient.runJavaScriptPrompt(this, message, defaultValue, frame);
2613 void WebPageProxy::shouldInterruptJavaScript(bool& result)
2615 // Since shouldInterruptJavaScript() can spin a nested run loop we need to turn off the responsiveness timer.
2616 m_process->responsivenessTimer()->stop();
2618 result = m_uiClient.shouldInterruptJavaScript(this);
2621 void WebPageProxy::setStatusText(const String& text)
2623 m_uiClient.setStatusText(this, text);
2626 void WebPageProxy::mouseDidMoveOverElement(const WebHitTestResult::Data& hitTestResultData, uint32_t opaqueModifiers, CoreIPC::MessageDecoder& decoder)
2628 RefPtr<APIObject> userData;
2629 WebContextUserMessageDecoder messageDecoder(userData, m_process.get());
2630 if (!decoder.decode(messageDecoder))
2633 WebEvent::Modifiers modifiers = static_cast<WebEvent::Modifiers>(opaqueModifiers);
2635 m_uiClient.mouseDidMoveOverElement(this, hitTestResultData, modifiers, userData.get());
2638 void WebPageProxy::connectionWillOpen(CoreIPC::Connection* connection)
2640 ASSERT(connection == m_process->connection());
2642 m_process->context()->storageManager().setAllowedSessionStorageNamespaceConnection(m_pageID, connection);
2645 void WebPageProxy::connectionWillClose(CoreIPC::Connection* connection)
2647 ASSERT(connection == m_process->connection());
2649 m_process->context()->storageManager().setAllowedSessionStorageNamespaceConnection(m_pageID, 0);
2652 String WebPageProxy::pluginInformationBundleIdentifierKey()
2654 return ASCIILiteral("PluginInformationBundleIdentifier");
2657 String WebPageProxy::pluginInformationBundleVersionKey()
2659 return ASCIILiteral("PluginInformationBundleVersion");
2662 String WebPageProxy::pluginInformationDisplayNameKey()
2664 return ASCIILiteral("PluginInformationDisplayName");
2667 String WebPageProxy::pluginInformationFrameURLKey()
2669 return ASCIILiteral("PluginInformationFrameURL");
2672 String WebPageProxy::pluginInformationMIMETypeKey()
2674 return ASCIILiteral("PluginInformationMIMEType");
2677 String WebPageProxy::pluginInformationPageURLKey()
2679 return ASCIILiteral("PluginInformationPageURL");
2682 String WebPageProxy::pluginInformationPluginspageAttributeURLKey()
2684 return ASCIILiteral("PluginInformationPluginspageAttributeURL");
2687 String WebPageProxy::pluginInformationPluginURLKey()
2689 return ASCIILiteral("PluginInformationPluginURL");
2692 PassRefPtr<ImmutableDictionary> WebPageProxy::pluginInformationDictionary(const String& bundleIdentifier, const String& bundleVersion, const String& displayName, const String& frameURLString, const String& mimeType, const String& pageURLString, const String& pluginspageAttributeURLString, const String& pluginURLString)
2694 HashMap<String, RefPtr<APIObject> > pluginInfoMap;
2695 if (!bundleIdentifier.isEmpty())
2696 pluginInfoMap.set(WebPageProxy::pluginInformationBundleIdentifierKey(), WebString::create(bundleIdentifier));
2697 if (!bundleVersion.isEmpty())
2698 pluginInfoMap.set(WebPageProxy::pluginInformationBundleVersionKey(), WebString::create(bundleVersion));
2699 if (!displayName.isEmpty())
2700 pluginInfoMap.set(WebPageProxy::pluginInformationDisplayNameKey(), WebString::create(displayName));
2701 if (!frameURLString.isEmpty())
2702 pluginInfoMap.set(WebPageProxy::pluginInformationFrameURLKey(), WebURL::create(frameURLString));
2703 if (!mimeType.isEmpty())
2704 pluginInfoMap.set(WebPageProxy::pluginInformationMIMETypeKey(), WebString::create(mimeType));
2705 if (!pageURLString.isEmpty())
2706 pluginInfoMap.set(WebPageProxy::pluginInformationPageURLKey(), WebURL::create(pageURLString));
2707 if (!pluginspageAttributeURLString.isEmpty())
2708 pluginInfoMap.set(WebPageProxy::pluginInformationPluginspageAttributeURLKey(), WebURL::create(pluginspageAttributeURLString));
2709 if (!pluginURLString.isEmpty())
2710 pluginInfoMap.set(WebPageProxy::pluginInformationPluginURLKey(), WebURL::create(pluginURLString));
2712 return ImmutableDictionary::adopt(pluginInfoMap);
2715 void WebPageProxy::unavailablePluginButtonClicked(uint32_t opaquePluginUnavailabilityReason, const String& mimeType, const String& pluginURLString, const String& pluginspageAttributeURLString, const String& frameURLString, const String& pageURLString)
2717 MESSAGE_CHECK_URL(pluginURLString);
2718 MESSAGE_CHECK_URL(pluginspageAttributeURLString);
2719 MESSAGE_CHECK_URL(frameURLString);
2720 MESSAGE_CHECK_URL(pageURLString);
2722 String pluginBundleIdentifier;
2723 String pluginBundleVersion;
2725 String newMimeType = mimeType;
2726 #if ENABLE(NETSCAPE_PLUGIN_API)
2727 PluginModuleInfo plugin = m_process->context()->pluginInfoStore().findPlugin(newMimeType, KURL(KURL(), pluginURLString));
2729 pluginBundleIdentifier = plugin.bundleIdentifier;
2730 pluginBundleVersion = plugin.versionString;
2732 pluginName = plugin.info.name;
2735 WKPluginUnavailabilityReason pluginUnavailabilityReason = kWKPluginUnavailabilityReasonPluginMissing;
2736 switch (static_cast<RenderEmbeddedObject::PluginUnavailabilityReason>(opaquePluginUnavailabilityReason)) {
2737 case RenderEmbeddedObject::PluginMissing:
2738 pluginUnavailabilityReason = kWKPluginUnavailabilityReasonPluginMissing;
2740 case RenderEmbeddedObject::InsecurePluginVersion:
2741 pluginUnavailabilityReason = kWKPluginUnavailabilityReasonInsecurePluginVersion;
2743 case RenderEmbeddedObject::PluginCrashed:
2744 pluginUnavailabilityReason = kWKPluginUnavailabilityReasonPluginCrashed;
2747 case RenderEmbeddedObject::PluginInactive: {
2748 #if ENABLE(NETSCAPE_PLUGIN_API)
2749 if (!plugin.path.isEmpty() && PluginInfoStore::reactivateInactivePlugin(plugin)) {
2750 // The plug-in has been reactivated now; reload the page so it'll be instantiated.
2757 case RenderEmbeddedObject::PluginBlockedByContentSecurityPolicy:
2758 ASSERT_NOT_REACHED();
2761 m_uiClient.unavailablePluginButtonClicked(this, pluginUnavailabilityReason, mimeType, pluginBundleIdentifier, pluginBundleVersion, pluginName, pluginURLString, pluginspageAttributeURLString, frameURLString, pageURLString);
2764 void WebPageProxy::setToolbarsAreVisible(bool toolbarsAreVisible)
2766 m_uiClient.setToolbarsAreVisible(this, toolbarsAreVisible);
2769 void WebPageProxy::getToolbarsAreVisible(bool& toolbarsAreVisible)
2771 toolbarsAreVisible = m_uiClient.toolbarsAreVisible(this);
2774 void WebPageProxy::setMenuBarIsVisible(bool menuBarIsVisible)
2776 m_uiClient.setMenuBarIsVisible(this, menuBarIsVisible);
2779 void WebPageProxy::getMenuBarIsVisible(bool& menuBarIsVisible)
2781 menuBarIsVisible = m_uiClient.menuBarIsVisible(this);
2784 void WebPageProxy::setStatusBarIsVisible(bool statusBarIsVisible)
2786 m_uiClient.setStatusBarIsVisible(this, statusBarIsVisible);
2789 void WebPageProxy::getStatusBarIsVisible(bool& statusBarIsVisible)
2791 statusBarIsVisible = m_uiClient.statusBarIsVisible(this);
2794 void WebPageProxy::setIsResizable(bool isResizable)
2796 m_uiClient.setIsResizable(this, isResizable);
2799 void WebPageProxy::getIsResizable(bool& isResizable)
2801 isResizable = m_uiClient.isResizable(this);
2804 void WebPageProxy::setWindowFrame(const FloatRect& newWindowFrame)
2806 m_uiClient.setWindowFrame(this, m_pageClient->convertToDeviceSpace(newWindowFrame));
2809 void WebPageProxy::getWindowFrame(FloatRect& newWindowFrame)
2811 newWindowFrame = m_pageClient->convertToUserSpace(m_uiClient.windowFrame(this));
2814 void WebPageProxy::screenToWindow(const IntPoint& screenPoint, IntPoint& windowPoint)
2816 windowPoint = m_pageClient->screenToWindow(screenPoint);
2819 void WebPageProxy::windowToScreen(const IntRect& viewRect, IntRect& result)
2821 result = m_pageClient->windowToScreen(viewRect);
2824 void WebPageProxy::runBeforeUnloadConfirmPanel(const String& message, uint64_t frameID, bool& shouldClose)
2826 WebFrameProxy* frame = m_process->webFrame(frameID);
2827 MESSAGE_CHECK(frame);
2829 // Since runBeforeUnloadConfirmPanel() can spin a nested run loop we need to turn off the responsiveness timer.
2830 m_process->responsivenessTimer()->stop();
2832 shouldClose = m_uiClient.runBeforeUnloadConfirmPanel(this, message, frame);
2835 #if USE(TILED_BACKING_STORE)
2836 void WebPageProxy::pageDidRequestScroll(const IntPoint& point)
2838 m_pageClient->pageDidRequestScroll(point);
2841 void WebPageProxy::pageTransitionViewportReady()
2843 m_pageClient->pageTransitionViewportReady();
2846 void WebPageProxy::didRenderFrame(const WebCore::IntSize& contentsSize, const WebCore::IntRect& coveredRect)
2848 m_pageClient->didRenderFrame(contentsSize, coveredRect);
2853 void WebPageProxy::didChangeViewportProperties(const ViewportAttributes& attr)
2855 m_pageClient->didChangeViewportProperties(attr);
2858 void WebPageProxy::pageDidScroll()
2860 m_uiClient.pageDidScroll(this);
2862 dismissCorrectionPanel(ReasonForDismissingAlternativeTextIgnored);
2866 void WebPageProxy::runOpenPanel(uint64_t frameID, const FileChooserSettings& settings)
2868 if (m_openPanelResultListener) {
2869 m_openPanelResultListener->invalidate();
2870 m_openPanelResultListener = 0;
2873 WebFrameProxy* frame = m_process->webFrame(frameID);
2874 MESSAGE_CHECK(frame);
2876 RefPtr<WebOpenPanelParameters> parameters = WebOpenPanelParameters::create(settings);
2877 m_openPanelResultListener = WebOpenPanelResultListenerProxy::create(this);
2879 // Since runOpenPanel() can spin a nested run loop we need to turn off the responsiveness timer.
2880 m_process->responsivenessTimer()->stop();
2882 if (!m_uiClient.runOpenPanel(this, frame, parameters.get(), m_openPanelResultListener.get()))
2883 didCancelForOpenPanel();
2886 void WebPageProxy::printFrame(uint64_t frameID)
2888 ASSERT(!m_isPerformingDOMPrintOperation);
2889 m_isPerformingDOMPrintOperation = true;
2891 WebFrameProxy* frame = m_process->webFrame(frameID);
2892 MESSAGE_CHECK(frame);
2894 m_uiClient.printFrame(this, frame);
2896 endPrinting(); // Send a message synchronously while m_isPerformingDOMPrintOperation is still true.
2897 m_isPerformingDOMPrintOperation = false;
2900 void WebPageProxy::printMainFrame()
2902 printFrame(m_mainFrame->frameID());
2905 void WebPageProxy::setMediaVolume(float volume)
2907 if (volume == m_mediaVolume)
2910 m_mediaVolume = volume;
2915 m_process->send(Messages::WebPage::SetMediaVolume(volume), m_pageID);
2918 void WebPageProxy::setMayStartMediaWhenInWindow(bool mayStartMedia)
2920 if (mayStartMedia == m_mayStartMediaWhenInWindow)
2923 m_mayStartMediaWhenInWindow = mayStartMedia;
2928 process()->send(Messages::WebPage::SetMayStartMediaWhenInWindow(mayStartMedia), m_pageID);
2931 #if PLATFORM(QT) || PLATFORM(EFL) || PLATFORM(GTK)
2932 void WebPageProxy::handleDownloadRequest(DownloadProxy* download)
2934 m_pageClient->handleDownloadRequest(download);
2936 #endif // PLATFORM(QT) || PLATFORM(EFL) || PLATFORM(GTK)
2938 #if PLATFORM(QT) || PLATFORM(EFL)
2939 void WebPageProxy::didChangeContentsSize(const IntSize& size)
2941 m_pageClient->didChangeContentsSize(size);
2945 #if ENABLE(TOUCH_EVENTS)
2946 void WebPageProxy::needTouchEvents(bool needTouchEvents)
2948 m_needTouchEvents = needTouchEvents;
2952 #if ENABLE(INPUT_TYPE_COLOR)
2953 void WebPageProxy::showColorChooser(const WebCore::Color& initialColor, const IntRect& elementRect)
2955 ASSERT(!m_colorChooser);
2957 if (m_colorPickerResultListener) {
2958 m_colorPickerResultListener->invalidate();
2959 m_colorPickerResultListener = nullptr;
2962 m_colorPickerResultListener = WebColorPickerResultListenerProxy::create(this);
2963 m_colorChooser = WebColorChooserProxy::create(this);
2965 if (m_uiClient.showColorPicker(this, initialColor.serialized(), m_colorPickerResultListener.get()))
2968 m_colorChooser = m_pageClient->createColorChooserProxy(this, initialColor, elementRect);
2969 if (!m_colorChooser)
2970 didEndColorChooser();
2973 void WebPageProxy::setColorChooserColor(const WebCore::Color& color)
2975 ASSERT(m_colorChooser);
2977 m_colorChooser->setSelectedColor(color);
2980 void WebPageProxy::endColorChooser()
2982 ASSERT(m_colorChooser);
2984 m_colorChooser->endChooser();
2987 void WebPageProxy::didChooseColor(const WebCore::Color& color)
2992 m_process->send(Messages::WebPage::DidChooseColor(color), m_pageID);
2995 void WebPageProxy::didEndColorChooser()
3000 if (m_colorChooser) {
3001 m_colorChooser->invalidate();
3002 m_colorChooser = nullptr;
3005 m_process->send(Messages::WebPage::DidEndColorChooser(), m_pageID);
3007 m_colorPickerResultListener->invalidate();
3008 m_colorPickerResultListener = nullptr;
3010 m_uiClient.hideColorPicker(this);
3014 void WebPageProxy::didDraw()
3016 m_uiClient.didDraw(this);
3021 #if ENABLE(INSPECTOR)
3023 WebInspectorProxy* WebPageProxy::inspector()
3025 if (isClosed() || !isValid())
3027 return m_inspector.get();
3032 #if ENABLE(FULLSCREEN_API)
3033 WebFullScreenManagerProxy* WebPageProxy::fullScreenManager()
3035 return m_fullScreenManager.get();
3041 void WebPageProxy::backForwardAddItem(uint64_t itemID)
3043 m_backForwardList->addItem(m_process->webBackForwardItem(itemID));
3046 void WebPageProxy::backForwardGoToItem(uint64_t itemID, SandboxExtension::Handle& sandboxExtensionHandle)
3048 WebBackForwardListItem* item = m_process->webBackForwardItem(itemID);
3052 bool createdExtension = maybeInitializeSandboxExtensionHandle(KURL(KURL(), item->url()), sandboxExtensionHandle);
3053 if (createdExtension)
3054 m_process->willAcquireUniversalFileReadSandboxExtension();
3055 m_backForwardList->goToItem(item);
3058 void WebPageProxy::backForwardItemAtIndex(int32_t index, uint64_t& itemID)
3060 WebBackForwardListItem* item = m_backForwardList->itemAtIndex(index);
3061 itemID = item ? item->itemID() : 0;
3064 void WebPageProxy::backForwardBackListCount(int32_t& count)
3066 count = m_backForwardList->backListCount();
3069 void WebPageProxy::backForwardForwardListCount(int32_t& count)
3071 count = m_backForwardList->forwardListCount();
3074 void WebPageProxy::editorStateChanged(const EditorState& editorState)
3077 bool couldChangeSecureInputState = m_editorState.isInPasswordField != editorState.isInPasswordField || m_editorState.selectionIsNone;
3080 m_editorState = editorState;
3083 m_pageClient->updateTextInputState(couldChangeSecureInputState);
3084 #elif PLATFORM(QT) || PLATFORM(EFL) || PLATFORM(GTK)
3085 m_pageClient->updateTextInputState();
3091 void WebPageProxy::registerEditCommandForUndo(uint64_t commandID, uint32_t editAction)
3093 registerEditCommand(WebEditCommandProxy::create(commandID, static_cast<EditAction>(editAction), this), Undo);
3096 void WebPageProxy::canUndoRedo(uint32_t action, bool& result)
3098 result = m_pageClient->canUndoRedo(static_cast<UndoOrRedo>(action));
3101 void WebPageProxy::executeUndoRedo(uint32_t action, bool& result)
3103 m_pageClient->executeUndoRedo(static_cast<UndoOrRedo>(action));
3107 void WebPageProxy::clearAllEditCommands()
3109 m_pageClient->clearAllEditCommands();
3112 void WebPageProxy::didCountStringMatches(const String& string, uint32_t matchCount)
3114 m_findClient.didCountStringMatches(this, string, matchCount);
3117 void WebPageProxy::didGetImageForFindMatch(const ShareableBitmap::Handle& contentImageHandle, uint32_t matchIndex)
3119 m_findMatchesClient.didGetImageForMatchResult(this, WebImage::create(ShareableBitmap::create(contentImageHandle)).get(), matchIndex);
3122 void WebPageProxy::setFindIndicator(const FloatRect& selectionRectInWindowCoordinates, const Vector<FloatRect>& textRectsInSelectionRectCoordinates, float contentImageScaleFactor, const ShareableBitmap::Handle& contentImageHandle, bool fadeOut, bool animate)
3124 RefPtr<FindIndicator> findIndicator = FindIndicator::create(selectionRectInWindowCoordinates, textRectsInSelectionRectCoordinates, contentImageScaleFactor, contentImageHandle);
3125 m_pageClient->setFindIndicator(findIndicator.release(), fadeOut, animate);
3128 void WebPageProxy::didFindString(const String& string, uint32_t matchCount)
3130 m_findClient.didFindString(this, string, matchCount);
3133 void WebPageProxy::didFindStringMatches(const String& string, Vector<Vector<WebCore::IntRect> > matchRects, int32_t firstIndexAfterSelection)
3135 Vector<RefPtr<APIObject> > matches;
3136 matches.reserveInitialCapacity(matchRects.size());
3138 for (size_t i = 0; i < matchRects.size(); ++i) {
3139 const Vector<WebCore::IntRect>& rects = matchRects[i];
3140 size_t numRects = matchRects[i].size();
3141 Vector<RefPtr<APIObject> > apiRects;
3142 apiRects.reserveInitialCapacity(numRects);
3144 for (size_t i = 0; i < numRects; ++i)
3145 apiRects.uncheckedAppend(WebRect::create(toAPI(rects[i])));
3146 matches.uncheckedAppend(ImmutableArray::adopt(apiRects));
3148 m_findMatchesClient.didFindStringMatches(this, string, ImmutableArray::adopt(matches).get(), firstIndexAfterSelection);
3151 void WebPageProxy::didFailToFindString(const String& string)
3153 m_findClient.didFailToFindString(this, string);
3156 void WebPageProxy::valueChangedForPopupMenu(WebPopupMenuProxy*, int32_t newSelectedIndex)
3158 m_process->send(Messages::WebPage::DidChangeSelectedIndexForActivePopupMenu(newSelectedIndex), m_pageID);
3161 void WebPageProxy::setTextFromItemForPopupMenu(WebPopupMenuProxy*, int32_t index)
3163 m_process->send(Messages::WebPage::SetTextForActivePopupMenu(index), m_pageID);
3166 NativeWebMouseEvent* WebPageProxy::currentlyProcessedMouseDownEvent()
3168 return m_currentlyProcessedMouseDownEvent.get();
3171 void WebPageProxy::postMessageToInjectedBundle(const String& messageName, APIObject* messageBody)
3173 process()->send(Messages::WebPage::PostInjectedBundleMessage(messageName, WebContextUserMessageEncoder(messageBody)), m_pageID);
3177 void WebPageProxy::failedToShowPopupMenu()
3179 m_process->send(Messages::WebPage::FailedToShowPopupMenu(), m_pageID);
3183 void WebPageProxy::showPopupMenu(const IntRect& rect, uint64_t textDirection, const Vector<WebPopupItem>& items, int32_t selectedIndex, const PlatformPopupMenuData& data)
3185 if (m_activePopupMenu) {
3187 m_uiPopupMenuClient.hidePopupMenu(this);
3189 m_activePopupMenu->hidePopupMenu();
3191 m_activePopupMenu->invalidate();
3192 m_activePopupMenu = 0;
3195 m_activePopupMenu = m_pageClient->createPopupMenuProxy(this);
3197 if (!m_activePopupMenu)
3200 // Since showPopupMenu() can spin a nested run loop we need to turn off the responsiveness timer.
3201 m_process->responsivenessTimer()->stop();
3205 m_uiPopupMenuClient.showPopupMenu(this, m_activePopupMenu.get(), rect, static_cast<TextDirection>(textDirection), m_pageScaleFactor, items, selectedIndex);
3207 RefPtr<WebPopupMenuProxy> protectedActivePopupMenu = m_activePopupMenu;
3209 protectedActivePopupMenu->showPopupMenu(rect, static_cast<TextDirection>(textDirection), m_pageScaleFactor, items, data, selectedIndex);
3211 // 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.
3213 protectedActivePopupMenu->invalidate();
3215 protectedActivePopupMenu = 0;
3219 void WebPageProxy::hidePopupMenu()
3221 if (!m_activePopupMenu)
3225 m_uiPopupMenuClient.hidePopupMenu(this);
3227 m_activePopupMenu->hidePopupMenu();
3229 m_activePopupMenu->invalidate();
3230 m_activePopupMenu = 0;
3233 #if ENABLE(CONTEXT_MENUS)
3234 void WebPageProxy::showContextMenu(const IntPoint& menuLocation, const WebHitTestResult::Data& hitTestResultData, const Vector<WebContextMenuItemData>& proposedItems, CoreIPC::MessageDecoder& decoder)
3236 internalShowContextMenu(menuLocation, hitTestResultData, proposedItems, decoder);
3238 // No matter the result of internalShowContextMenu, always notify the WebProcess that the menu is hidden so it starts handling mouse events again.
3239 m_process->send(Messages::WebPage::ContextMenuHidden(), m_pageID);
3242 void WebPageProxy::internalShowContextMenu(const IntPoint& menuLocation, const WebHitTestResult::Data& hitTestResultData, const Vector<WebContextMenuItemData>& proposedItems, CoreIPC::MessageDecoder& decoder)
3244 RefPtr<APIObject> userData;
3245 WebContextUserMessageDecoder messageDecoder(userData, m_process.get());
3246 if (!decoder.decode(messageDecoder))
3249 m_activeContextMenuHitTestResultData = hitTestResultData;
3251 if (m_activeContextMenu) {
3252 m_activeContextMenu->hideContextMenu();
3253 m_activeContextMenu = 0;
3256 m_activeContextMenu = m_pageClient->createContextMenuProxy(this);
3257 if (!m_activeContextMenu)
3260 // Since showContextMenu() can spin a nested run loop we need to turn off the responsiveness timer.
3261 m_process->responsivenessTimer()->stop();
3263 // Give the PageContextMenuClient one last swipe at changing the menu.
3264 Vector<WebContextMenuItemData> items;
3265 if (!m_contextMenuClient.getContextMenuFromProposedMenu(this, proposedItems, items, hitTestResultData, userData.get()))
3266 m_activeContextMenu->showContextMenu(menuLocation, proposedItems);
3268 m_activeContextMenu->showContextMenu(menuLocation, items);
3270 m_contextMenuClient.contextMenuDismissed(this);
3273 void WebPageProxy::contextMenuItemSelected(const WebContextMenuItemData& item)
3275 // Application custom items don't need to round-trip through to WebCore in the WebProcess.
3276 if (item.action() >= ContextMenuItemBaseApplicationTag) {
3277 m_contextMenuClient.customContextMenuItemSelected(this, item);
3282 if (item.action() == ContextMenuItemTagSmartCopyPaste) {
3283 setSmartInsertDeleteEnabled(!isSmartInsertDeleteEnabled());
3286 if (item.action() == ContextMenuItemTagSmartQuotes) {
3287 TextChecker::setAutomaticQuoteSubstitutionEnabled(!TextChecker::state().isAutomaticQuoteSubstitutionEnabled);
3288 m_process->updateTextCheckerState();
3291 if (item.action() == ContextMenuItemTagSmartDashes) {
3292 TextChecker::setAutomaticDashSubstitutionEnabled(!TextChecker::state().isAutomaticDashSubstitutionEnabled);
3293 m_process->updateTextCheckerState();
3296 if (item.action() == ContextMenuItemTagSmartLinks) {
3297 TextChecker::setAutomaticLinkDetectionEnabled(!TextChecker::state().isAutomaticLinkDetectionEnabled);
3298 m_process->updateTextCheckerState();
3301 if (item.action() == ContextMenuItemTagTextReplacement) {
3302 TextChecker::setAutomaticTextReplacementEnabled(!TextChecker::state().isAutomaticTextReplacementEnabled);
3303 m_process->updateTextCheckerState();
3306 if (item.action() == ContextMenuItemTagCorrectSpellingAutomatically) {
3307 TextChecker::setAutomaticSpellingCorrectionEnabled(!TextChecker::state().isAutomaticSpellingCorrectionEnabled);
3308 m_process->updateTextCheckerState();
3311 if (item.action() == ContextMenuItemTagShowSubstitutions) {
3312 TextChecker::toggleSubstitutionsPanelIsShowing();
3316 if (item.action() == ContextMenuItemTagDownloadImageToDisk) {
3317 m_process->context()->download(this, KURL(KURL(), m_activeContextMenuHitTestResultData.absoluteImageURL));
3320 if (item.action() == ContextMenuItemTagDownloadLinkToDisk) {
3321 m_process->context()->download(this, KURL(KURL(), m_activeContextMenuHitTestResultData.absoluteLinkURL));
3324 if (item.action() == ContextMenuItemTagCheckSpellingWhileTyping) {
3325 TextChecker::setContinuousSpellCheckingEnabled(!TextChecker::state().isContinuousSpellCheckingEnabled);
3326 m_process->updateTextCheckerState();
3329 if (item.action() == ContextMenuItemTagCheckGrammarWithSpelling) {
3330 TextChecker::setGrammarCheckingEnabled(!TextChecker::state().isGrammarCheckingEnabled);
3331 m_process->updateTextCheckerState();
3334 if (item.action() == ContextMenuItemTagShowSpellingPanel) {
3335 if (!TextChecker::spellingUIIsShowing())
3336 advanceToNextMisspelling(true);
3337 TextChecker::toggleSpellingUIIsShowing();
3340 if (item.action() == ContextMenuItemTagLearnSpelling || item.action() == ContextMenuItemTagIgnoreSpelling)
3341 ++m_pendingLearnOrIgnoreWordMessageCount;
3343 m_process->send(Messages::WebPage::DidSelectItemFromActiveContextMenu(item), m_pageID);
3345 #endif // ENABLE(CONTEXT_MENUS)
3347 void WebPageProxy::didChooseFilesForOpenPanel(const Vector<String>& fileURLs)
3352 #if ENABLE(WEB_PROCESS_SANDBOX)
3353 // FIXME: The sandbox extensions should be sent with the DidChooseFilesForOpenPanel message. This
3354 // is gated on a way of passing SandboxExtension::Handles in a Vector.
3355 for (size_t i = 0; i < fileURLs.size(); ++i) {
3356 SandboxExtension::Handle sandboxExtensionHandle;
3357 SandboxExtension::createHandle(fileURLs[i], SandboxExtension::ReadOnly, sandboxExtensionHandle);
3358 m_process->send(Messages::WebPage::ExtendSandboxForFileFromOpenPanel(sandboxExtensionHandle), m_pageID);
3362 m_process->send(Messages::WebPage::DidChooseFilesForOpenPanel(fileURLs), m_pageID);
3364 m_openPanelResultListener->invalidate();
3365 m_openPanelResultListener = 0;
3368 void WebPageProxy::didCancelForOpenPanel()
3373 m_process->send(Messages::WebPage::DidCancelForOpenPanel(), m_pageID);
3375 m_openPanelResultListener->invalidate();
3376 m_openPanelResultListener = 0;
3379 void WebPageProxy::advanceToNextMisspelling(bool startBeforeSelection) const
3381 m_process->send(Messages::WebPage::AdvanceToNextMisspelling(startBeforeSelection), m_pageID);
3384 void WebPageProxy::changeSpellingToWord(const String& word) const
3389 m_process->send(Messages::WebPage::ChangeSpellingToWord(word), m_pageID);
3392 void WebPageProxy::registerEditCommand(PassRefPtr<WebEditCommandProxy> commandProxy, UndoOrRedo undoOrRedo)
3394 m_pageClient->registerEditCommand(commandProxy, undoOrRedo);
3397 void WebPageProxy::addEditCommand(WebEditCommandProxy* command)
3399 m_editCommandSet.add(command);
3402 void WebPageProxy::removeEditCommand(WebEditCommandProxy* command)
3404 m_editCommandSet.remove(command);
3408 m_process->send(Messages::WebPage::DidRemoveEditCommand(command->commandID()), m_pageID);
3411 bool WebPageProxy::isValidEditCommand(WebEditCommandProxy* command)
3413 return m_editCommandSet.find(command) != m_editCommandSet.end();
3416 int64_t WebPageProxy::spellDocumentTag()
3418 if (!m_hasSpellDocumentTag) {
3419 m_spellDocumentTag = TextChecker::uniqueSpellDocumentTag(this);
3420 m_hasSpellDocumentTag = true;
3423 return m_spellDocumentTag;
3426 #if USE(UNIFIED_TEXT_CHECKING)
3427 void WebPageProxy::checkTextOfParagraph(const String& text, uint64_t checkingTypes, Vector<TextCheckingResult>& results)
3429 results = TextChecker::checkTextOfParagraph(spellDocumentTag(), text.characters(), text.length(), checkingTypes);
3433 void WebPageProxy::checkSpellingOfString(const String& text, int32_t& misspellingLocation, int32_t& misspellingLength)
3435 TextChecker::checkSpellingOfString(spellDocumentTag(), text.characters(), text.length(), misspellingLocation, misspellingLength);
3438 void WebPageProxy::checkGrammarOfString(const String& text, Vector<GrammarDetail>& grammarDetails, int32_t& badGrammarLocation, int32_t& badGrammarLength)
3440 TextChecker::checkGrammarOfString(spellDocumentTag(), text.characters(), text.length(), grammarDetails, badGrammarLocation, badGrammarLength);
3443 void WebPageProxy::spellingUIIsShowing(bool& isShowing)
3445 isShowing = TextChecker::spellingUIIsShowing();
3448 void WebPageProxy::updateSpellingUIWithMisspelledWord(const String& misspelledWord)
3450 TextChecker::updateSpellingUIWithMisspelledWord(spellDocumentTag(), misspelledWord);
3453 void WebPageProxy::updateSpellingUIWithGrammarString(const String& badGrammarPhrase, const GrammarDetail& grammarDetail)
3455 TextChecker::updateSpellingUIWithGrammarString(spellDocumentTag(), badGrammarPhrase, grammarDetail);
3458 void WebPageProxy::getGuessesForWord(const String& word, const String& context, Vector<String>& guesses)
3460 TextChecker::getGuessesForWord(spellDocumentTag(), word, context, guesses);
3463 void WebPageProxy::learnWord(const String& word)
3465 MESSAGE_CHECK(m_pendingLearnOrIgnoreWordMessageCount);
3466 --m_pendingLearnOrIgnoreWordMessageCount;
3468 TextChecker::learnWord(spellDocumentTag(), word);
3471 void WebPageProxy::ignoreWord(const String& word)
3473 MESSAGE_CHECK(m_pendingLearnOrIgnoreWordMessageCount);
3474 --m_pendingLearnOrIgnoreWordMessageCount;
3476 TextChecker::ignoreWord(spellDocumentTag(), word);
3479 void WebPageProxy::requestCheckingOfString(uint64_t requestID, const TextCheckingRequestData& request)
3481 TextChecker::requestCheckingOfString(TextCheckerCompletion::create(requestID, request, this));
3484 void WebPageProxy::didFinishCheckingText(uint64_t requestID, const Vector<WebCore::TextCheckingResult>& result) const
3486 m_process->send(Messages::WebPage::DidFinishCheckingText(requestID, result), m_pageID);
3489 void WebPageProxy::didCancelCheckingText(uint64_t requestID) const
3491 m_process->send(Messages::WebPage::DidCancelCheckingText(requestID), m_pageID);
3495 void WebPageProxy::setFocus(bool focused)
3498 m_uiClient.focus(this);
3500 m_uiClient.unfocus(this);
3503 void WebPageProxy::takeFocus(uint32_t direction)
3505 m_uiClient.takeFocus(this, (static_cast<FocusDirection>(direction) == FocusDirectionForward) ? kWKFocusDirectionForward : kWKFocusDirectionBackward);
3508 void WebPageProxy::setToolTip(const String& toolTip)
3510 String oldToolTip = m_toolTip;
3511 m_toolTip = toolTip;
3512 m_pageClient->toolTipChanged(oldToolTip, m_toolTip);
3515 void WebPageProxy::setCursor(const WebCore::Cursor& cursor)
3517 // The Web process may have asked to change the cursor when the view was in an active window, but
3518 // if it is no longer in a window or the window is not active, then the cursor should not change.
3519 if (m_pageClient->isViewWindowActive())
3520 m_pageClient->setCursor(cursor);
3523 void WebPageProxy::setCursorHiddenUntilMouseMoves(bool hiddenUntilMouseMoves)
3525 m_pageClient->setCursorHiddenUntilMouseMoves(hiddenUntilMouseMoves);
3528 void WebPageProxy::didReceiveEvent(uint32_t opaqueType, bool handled)
3530 WebEvent::Type type = static_cast<WebEvent::Type>(opaqueType);
3533 case WebEvent::NoType:
3534 case WebEvent::MouseMove:
3537 case WebEvent::MouseDown:
3538 case WebEvent::MouseUp:
3539 case WebEvent::Wheel:
3540 case WebEvent::KeyDown:
3541 case WebEvent::KeyUp:
3542 case WebEvent::RawKeyDown:
3543 case WebEvent::Char:
3544 #if ENABLE(GESTURE_EVENTS)
3545 case WebEvent::GestureScrollBegin:
3546 case WebEvent::GestureScrollEnd:
3547 case WebEvent::GestureSingleTap:
3549 #if ENABLE(TOUCH_EVENTS)
3550 case WebEvent::TouchStart:
3551 case WebEvent::TouchMove:
3552 case WebEvent::TouchEnd:
3553 case WebEvent::TouchCancel:
3555 m_process->responsivenessTimer()->stop();
3560 case WebEvent::NoType:
3562 case WebEvent::MouseMove:
3563 m_processingMouseMoveEvent = false;
3564 if (m_nextMouseMoveEvent) {
3565 handleMouseEvent(*m_nextMouseMoveEvent);
3566 m_nextMouseMoveEvent = nullptr;
3569 case WebEvent::MouseDown:
3571 #if ENABLE(GESTURE_EVENTS)
3572 case WebEvent::GestureScrollBegin:
3573 case WebEvent::GestureScrollEnd:
3574 case WebEvent::GestureSingleTap: {
3575 WebGestureEvent event = m_gestureEventQueue.first();
3576 MESSAGE_CHECK(type == event.type());
3578 m_gestureEventQueue.removeFirst();
3579 m_pageClient->doneWithGestureEvent(event, handled);
3583 case WebEvent::MouseUp:
3584 m_currentlyProcessedMouseDownEvent = nullptr;
3587 case WebEvent::Wheel: {
3588 ASSERT(!m_currentlyProcessedWheelEvents.isEmpty());
3590 OwnPtr<Vector<NativeWebWheelEvent> > oldestCoalescedEvent = m_currentlyProcessedWheelEvents.takeFirst();
3592 // FIXME: Dispatch additional events to the didNotHandleWheelEvent client function.
3593 if (!handled && m_uiClient.implementsDidNotHandleWheelEvent())
3594 m_uiClient.didNotHandleWheelEvent(this, oldestCoalescedEvent->last());
3596 if (!m_wheelEventQueue.isEmpty())
3597 processNextQueuedWheelEvent();
3601 case WebEvent::KeyDown:
3602 case WebEvent::KeyUp:
3603 case WebEvent::RawKeyDown:
3604 case WebEvent::Char: {
3605 LOG(KeyHandling, "WebPageProxy::didReceiveEvent: %s", webKeyboardEventTypeString(type));
3607 NativeWebKeyboardEvent event = m_keyEventQueue.first();
3608 MESSAGE_CHECK(type == event.type());
3610 m_keyEventQueue.removeFirst();
3612 if (!m_keyEventQueue.isEmpty())
3613 m_process->send(Messages::WebPage::KeyEvent(m_keyEventQueue.first()), m_pageID);
3615 m_pageClient->doneWithKeyEvent(event, handled);
3619 if (m_uiClient.implementsDidNotHandleKeyEvent())
3620 m_uiClient.didNotHandleKeyEvent(this, event);
3623 #if ENABLE(TOUCH_EVENTS)
3624 case WebEvent::TouchStart:
3625 case WebEvent::TouchMove:
3626 case WebEvent::TouchEnd:
3627 case WebEvent::TouchCancel: {
3628 QueuedTouchEvents queuedEvents = m_touchEventQueue.first();
3629 MESSAGE_CHECK(type == queuedEvents.forwardedEvent.type());
3630 m_touchEventQueue.removeFirst();
3632 m_pageClient->doneWithTouchEvent(queuedEvents.forwardedEvent, handled);
3633 for (size_t i = 0; i < queuedEvents.deferredTouchEvents.size(); ++i) {
3634 bool isEventHandled = false;
3635 m_pageClient->doneWithTouchEvent(queuedEvents.deferredTouchEvents.at(i), isEventHandled);