2 * Copyright (C) 2009 Torch Mobile Inc. http://www.torchmobile.com/
3 * Copyright (C) 2010, 2011, 2012 Research In Motion Limited. All rights reserved.
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 #include "ChromeClientBlackBerry.h"
23 #include "BackingStore.h"
24 #include "BackingStoreClient.h"
25 #include "BackingStore_p.h"
26 #include "ColorChooser.h"
27 #include "DatabaseManager.h"
29 #include "DumpRenderTreeClient.h"
30 #include "DumpRenderTreeSupport.h"
31 #include "FileChooser.h"
32 #include "FileIconLoader.h"
34 #include "FrameLoadRequest.h"
35 #include "FrameLoader.h"
36 #include "Geolocation.h"
37 #include "GeolocationClientBlackBerry.h"
38 #include "GraphicsLayer.h"
39 #include "HTMLInputElement.h"
40 #include "HTMLNames.h"
41 #include "HitTestResult.h"
43 #include "InputHandler.h"
46 #include "NotImplemented.h"
48 #include "PageGroup.h"
49 #include "PageGroupLoadDeferrer.h"
50 #include "PagePopupBlackBerry.h"
51 #include "PagePopupClient.h"
52 #include "PopupMenuBlackBerry.h"
53 #include "RenderView.h"
54 #include "SVGZoomAndPan.h"
55 #include "SearchPopupMenuBlackBerry.h"
56 #include "SecurityOrigin.h"
58 #include "SharedPointer.h"
59 #include "ViewportArguments.h"
61 #include "WebPageClient.h"
62 #include "WebPage_p.h"
63 #include "WebPopupType.h"
64 #include "WebSettings.h"
65 #include "WindowFeatures.h"
67 #include <BlackBerryPlatformLog.h>
68 #include <BlackBerryPlatformSettings.h>
69 #include <BlackBerryPlatformString.h>
70 #include <BlackBerryPlatformWindow.h>
72 #include <wtf/text/CString.h>
73 #include <wtf/text/WTFString.h>
75 #define DEBUG_OVERFLOW_DETECTION 0
77 using namespace BlackBerry::WebKit;
79 using BlackBerry::Platform::Graphics::Window;
83 static CString toOriginString(Frame* frame)
85 return frame->document()->securityOrigin()->toString().latin1();
88 ChromeClientBlackBerry::ChromeClientBlackBerry(WebPagePrivate* pagePrivate)
89 : m_webPagePrivate(pagePrivate)
93 void ChromeClientBlackBerry::addMessageToConsole(MessageSource, MessageLevel, const String& message, unsigned lineNumber, const String& sourceID)
95 #if !defined(PUBLIC_BUILD) || !PUBLIC_BUILD
96 if (m_webPagePrivate->m_dumpRenderTree) {
97 m_webPagePrivate->m_dumpRenderTree->addMessageToConsole(message, lineNumber, sourceID);
102 m_webPagePrivate->m_client->addMessageToConsole(message.characters(), message.length(), sourceID.characters(), sourceID.length(), lineNumber);
105 void ChromeClientBlackBerry::runJavaScriptAlert(Frame* frame, const String& message)
107 #if !defined(PUBLIC_BUILD) || !PUBLIC_BUILD
108 if (m_webPagePrivate->m_dumpRenderTree) {
109 m_webPagePrivate->m_dumpRenderTree->runJavaScriptAlert(message);
114 TimerBase::fireTimersInNestedEventLoop();
115 CString latinOrigin = toOriginString(frame);
116 m_webPagePrivate->m_client->runJavaScriptAlert(message.characters(), message.length(), latinOrigin.data(), latinOrigin.length());
119 bool ChromeClientBlackBerry::runJavaScriptConfirm(Frame* frame, const String& message)
121 #if !defined(PUBLIC_BUILD) || !PUBLIC_BUILD
122 if (m_webPagePrivate->m_dumpRenderTree)
123 return m_webPagePrivate->m_dumpRenderTree->runJavaScriptConfirm(message);
126 TimerBase::fireTimersInNestedEventLoop();
127 CString latinOrigin = toOriginString(frame);
128 return m_webPagePrivate->m_client->runJavaScriptConfirm(message.characters(), message.length(), latinOrigin.data(), latinOrigin.length());
131 bool ChromeClientBlackBerry::runJavaScriptPrompt(Frame* frame, const String& message, const String& defaultValue, String& result)
133 #if !defined(PUBLIC_BUILD) || !PUBLIC_BUILD
134 if (m_webPagePrivate->m_dumpRenderTree) {
135 result = m_webPagePrivate->m_dumpRenderTree->runJavaScriptPrompt(message, defaultValue);
140 TimerBase::fireTimersInNestedEventLoop();
141 CString latinOrigin = toOriginString(frame);
142 BlackBerry::Platform::String clientResult;
143 if (m_webPagePrivate->m_client->runJavaScriptPrompt(message.characters(), message.length(), defaultValue.characters(), defaultValue.length(), latinOrigin.data(), latinOrigin.length(), clientResult)) {
144 result = clientResult;
150 void ChromeClientBlackBerry::chromeDestroyed()
152 // Destroy popup if we have.
157 void ChromeClientBlackBerry::setWindowRect(const FloatRect&)
159 // The window dimensions are fixed in the RIM port.
162 FloatRect ChromeClientBlackBerry::windowRect()
166 if (Window* window = m_webPagePrivate->m_client->window())
167 windowSize = window->windowSize();
169 // Use logical (density-independent) pixels instead of physical screen pixels.
170 FloatRect rect = FloatRect(0, 0, windowSize.width(), windowSize.height());
171 if (!m_webPagePrivate->m_page->settings()->applyDeviceScaleFactorInCompositor())
172 rect.scale(1 / m_webPagePrivate->m_page->deviceScaleFactor());
176 FloatRect ChromeClientBlackBerry::pageRect()
182 float ChromeClientBlackBerry::scaleFactor()
187 void ChromeClientBlackBerry::focus()
192 void ChromeClientBlackBerry::unfocus()
197 bool ChromeClientBlackBerry::canTakeFocus(FocusDirection)
203 void ChromeClientBlackBerry::takeFocus(FocusDirection)
208 void ChromeClientBlackBerry::focusedNodeChanged(Node*)
210 m_webPagePrivate->m_inputHandler->focusedNodeChanged();
213 void ChromeClientBlackBerry::focusedFrameChanged(Frame*)
215 // To be used by In-region backing store context switching.
218 bool ChromeClientBlackBerry::shouldForceDocumentStyleSelectorUpdate()
220 return !m_webPagePrivate->m_webSettings->isJavaScriptEnabled() && !m_webPagePrivate->m_inputHandler->processingChange();
223 Page* ChromeClientBlackBerry::createWindow(Frame* frame, const FrameLoadRequest& request, const WindowFeatures& features, const NavigationAction&)
225 // Bail out early when we aren't allowed to display the target origin, otherwise,
226 // it would be harmful and the window would be useless. This is the same check
227 // as the one in FrameLoader::loadFrameRequest().
228 const KURL& url = request.resourceRequest().url();
229 if (!request.requester()->canDisplay(url)) {
230 frame->loader()->reportLocalLoadFailed(frame, url.string());
234 #if !defined(PUBLIC_BUILD) || !PUBLIC_BUILD
235 if (m_webPagePrivate->m_dumpRenderTree && !m_webPagePrivate->m_dumpRenderTree->allowsOpeningWindow())
239 int x = features.xSet ? features.x : 0;
240 int y = features.ySet ? features.y : 0;
241 int width = features.widthSet? features.width : -1;
242 int height = features.heightSet ? features.height : -1;
245 if (features.menuBarVisible)
246 flags |= WebPageClient::FlagWindowHasMenuBar;
247 if (features.statusBarVisible)
248 flags |= WebPageClient::FlagWindowHasStatusBar;
249 if (features.toolBarVisible)
250 flags |= WebPageClient::FlagWindowHasToolBar;
251 if (features.locationBarVisible)
252 flags |= WebPageClient::FlagWindowHasLocationBar;
253 if (features.scrollbarsVisible)
254 flags |= WebPageClient::FlagWindowHasScrollBar;
255 if (features.resizable)
256 flags |= WebPageClient::FlagWindowIsResizable;
257 if (features.fullscreen)
258 flags |= WebPageClient::FlagWindowIsFullScreen;
260 flags |= WebPageClient::FlagWindowIsDialog;
262 WebPage* webPage = m_webPagePrivate->m_client->createWindow(x, y, width, height, flags, url.string(), request.frameName());
266 #if !defined(PUBLIC_BUILD) || !PUBLIC_BUILD
267 if (m_webPagePrivate->m_dumpRenderTree)
268 m_webPagePrivate->m_dumpRenderTree->windowCreated(webPage);
271 return webPage->d->m_page;
274 void ChromeClientBlackBerry::show()
279 bool ChromeClientBlackBerry::canRunModal()
285 void ChromeClientBlackBerry::runModal()
290 bool ChromeClientBlackBerry::selectItemWritingDirectionIsNatural()
295 bool ChromeClientBlackBerry::selectItemAlignmentFollowsMenuWritingDirection()
300 bool ChromeClientBlackBerry::hasOpenedPopup() const
302 return m_webPagePrivate->m_webPage->hasOpenedPopup();
305 PassRefPtr<PopupMenu> ChromeClientBlackBerry::createPopupMenu(PopupMenuClient* client) const
307 return adoptRef(new PopupMenuBlackBerry(client));
310 PassRefPtr<SearchPopupMenu> ChromeClientBlackBerry::createSearchPopupMenu(PopupMenuClient* client) const
312 return adoptRef(new SearchPopupMenuBlackBerry(client));
315 PagePopup* ChromeClientBlackBerry::openPagePopup(PagePopupClient* client, const IntRect& originBoundsInRootView)
319 PagePopupBlackBerry* webPopup = new PagePopupBlackBerry(m_webPagePrivate, client, rootViewToScreen(originBoundsInRootView));
320 m_webPagePrivate->m_webPage->popupOpened(webPopup);
321 if (webPopup->sendCreatePopupWebViewRequest())
328 void ChromeClientBlackBerry::closePagePopup(PagePopup*)
330 if (!hasOpenedPopup())
333 PagePopupBlackBerry* webPopup = m_webPagePrivate->m_webPage->popup();
334 webPopup->closePopup();
338 void ChromeClientBlackBerry::setToolbarsVisible(bool)
343 bool ChromeClientBlackBerry::toolbarsVisible()
349 void ChromeClientBlackBerry::setStatusbarVisible(bool)
354 bool ChromeClientBlackBerry::statusbarVisible()
360 void ChromeClientBlackBerry::setScrollbarsVisible(bool)
365 bool ChromeClientBlackBerry::scrollbarsVisible()
371 void ChromeClientBlackBerry::setMenubarVisible(bool)
376 bool ChromeClientBlackBerry::menubarVisible()
382 void ChromeClientBlackBerry::setResizable(bool)
387 bool ChromeClientBlackBerry::canRunBeforeUnloadConfirmPanel()
392 bool ChromeClientBlackBerry::runBeforeUnloadConfirmPanel(const String& message, Frame* frame)
394 #if !defined(PUBLIC_BUILD) || !PUBLIC_BUILD
395 if (m_webPagePrivate->m_dumpRenderTree)
396 return m_webPagePrivate->m_dumpRenderTree->runBeforeUnloadConfirmPanel(message);
399 TimerBase::fireTimersInNestedEventLoop();
400 CString latinOrigin = toOriginString(frame);
401 return m_webPagePrivate->m_client->runBeforeUnloadConfirmPanel(message.characters(), message.length(), latinOrigin.data(), latinOrigin.length());
404 void ChromeClientBlackBerry::closeWindowSoon()
406 if (m_webPagePrivate->m_page->openedByDOM())
407 m_webPagePrivate->m_client->scheduleCloseWindow();
410 void ChromeClientBlackBerry::setStatusbarText(const String& status)
412 m_webPagePrivate->m_client->setStatus(status);
414 #if !defined(PUBLIC_BUILD) || !PUBLIC_BUILD
415 if (m_webPagePrivate->m_dumpRenderTree)
416 m_webPagePrivate->m_dumpRenderTree->setStatusText(status);
420 IntRect ChromeClientBlackBerry::windowResizerRect() const
426 IntPoint ChromeClientBlackBerry::screenToRootView(const IntPoint& screenPos) const
428 IntPoint windowPoint;
429 if (Window* window = m_webPagePrivate->m_client->window())
430 windowPoint = window->windowLocation();
432 windowPoint.move(-screenPos.x(), -screenPos.y());
436 IntRect ChromeClientBlackBerry::rootViewToScreen(const IntRect& windowRect) const
438 IntRect windowPoint(windowRect);
440 if (Window* window = m_webPagePrivate->m_client->window())
441 location = window->windowLocation();
443 windowPoint.move(location.x(), location.y());
447 void ChromeClientBlackBerry::mouseDidMoveOverElement(const HitTestResult& result, unsigned int modifierFlags)
452 void ChromeClientBlackBerry::setToolTip(const String& tooltip, TextDirection)
454 m_webPagePrivate->m_client->setToolTip(tooltip);
457 #if ENABLE(EVENT_MODE_METATAGS)
458 void ChromeClientBlackBerry::didReceiveCursorEventMode(Frame* frame, CursorEventMode mode) const
460 if (m_webPagePrivate->m_mainFrame != frame)
463 m_webPagePrivate->didReceiveCursorEventMode(mode);
466 void ChromeClientBlackBerry::didReceiveTouchEventMode(Frame* frame, TouchEventMode mode) const
468 if (m_webPagePrivate->m_mainFrame != frame)
471 m_webPagePrivate->didReceiveTouchEventMode(mode);
475 void ChromeClientBlackBerry::dispatchViewportPropertiesDidChange(const ViewportArguments& arguments) const
477 m_webPagePrivate->dispatchViewportPropertiesDidChange(arguments);
480 void ChromeClientBlackBerry::print(Frame*)
485 void ChromeClientBlackBerry::exceededDatabaseQuota(Frame* frame, const String& name, DatabaseDetails details)
487 #if ENABLE(SQL_DATABASE)
488 Document* document = frame->document();
492 SecurityOrigin* origin = document->securityOrigin();
494 #if !defined(PUBLIC_BUILD) || !PUBLIC_BUILD
495 if (m_webPagePrivate->m_dumpRenderTree) {
496 m_webPagePrivate->m_dumpRenderTree->exceededDatabaseQuota(origin, name);
501 DatabaseManager& manager = DatabaseManager::manager();
503 unsigned long long originUsage = tracker.usageForOrigin(origin);
504 unsigned long long currentQuota = tracker.quotaForOrigin(origin);
506 unsigned long long estimatedSize = details.expectedUsage();
507 const String& nameStr = details.displayName();
509 String originStr = origin->toString();
511 unsigned long long quota = m_webPagePrivate->m_client->databaseQuota(originStr, nameStr, originUsage, currentQuota, estimatedSize);
513 manager.setQuota(origin, quota);
517 void ChromeClientBlackBerry::runOpenPanel(Frame*, PassRefPtr<FileChooser> chooser)
519 SharedArray<BlackBerry::Platform::String> initialFiles;
520 unsigned numberOfInitialFiles = chooser->settings().selectedFiles.size();
521 if (numberOfInitialFiles > 0)
522 initialFiles.reset(new BlackBerry::Platform::String[numberOfInitialFiles], numberOfInitialFiles);
523 for (unsigned i = 0; i < numberOfInitialFiles; ++i)
524 initialFiles[i] = chooser->settings().selectedFiles[i];
526 SharedArray<BlackBerry::Platform::String> acceptMIMETypes;
527 unsigned numberOfTypes = chooser->settings().acceptMIMETypes.size();
528 if (numberOfTypes > 0)
529 acceptMIMETypes.reset(new BlackBerry::Platform::String[numberOfTypes], numberOfTypes);
530 for (unsigned i = 0; i < numberOfTypes; ++i)
531 acceptMIMETypes[i] = chooser->settings().acceptMIMETypes[i];
533 BlackBerry::Platform::String capture;
534 #if ENABLE(MEDIA_CAPTURE)
535 capture = chooser->settings().capture;
538 SharedArray<BlackBerry::Platform::String> chosenFiles;
541 PageGroupLoadDeferrer deferrer(m_webPagePrivate->m_page, true);
542 TimerBase::fireTimersInNestedEventLoop();
544 if (!m_webPagePrivate->m_client->chooseFilenames(chooser->settings().allowsMultipleFiles, acceptMIMETypes, initialFiles, capture, chosenFiles))
548 Vector<String> files(chosenFiles.length());
549 for (unsigned i = 0; i < chosenFiles.length(); ++i)
550 files[i] = chosenFiles[i];
551 chooser->chooseFiles(files);
554 void ChromeClientBlackBerry::loadIconForFiles(const Vector<String>& filenames, FileIconLoader* loader)
556 loader->notifyFinished(Icon::createIconForFiles(filenames));
559 void ChromeClientBlackBerry::setCursor(const Cursor&)
564 void ChromeClientBlackBerry::formStateDidChange(const Node* node)
566 m_webPagePrivate->m_inputHandler->nodeTextChanged(node);
569 void ChromeClientBlackBerry::scrollbarsModeDidChange() const
574 void ChromeClientBlackBerry::contentsSizeChanged(Frame* frame, const IntSize& size) const
576 if (frame != m_webPagePrivate->m_mainFrame)
579 m_webPagePrivate->contentsSizeChanged(size);
582 void ChromeClientBlackBerry::invalidateRootView(const IntRect& updateRect, bool immediate)
584 m_webPagePrivate->m_backingStore->d->repaint(updateRect, false /*contentChanged*/, immediate);
587 void ChromeClientBlackBerry::invalidateContentsAndRootView(const IntRect& updateRect, bool immediate)
589 m_webPagePrivate->m_backingStore->d->repaint(updateRect, true /*contentChanged*/, immediate);
592 void ChromeClientBlackBerry::invalidateContentsForSlowScroll(const IntSize& delta, const IntRect& updateRect, bool immediate, const ScrollView* scrollView)
594 if (scrollView != m_webPagePrivate->m_mainFrame->view())
595 invalidateContentsAndRootView(updateRect, true /*immediate*/);
597 BackingStoreClient* backingStoreClient = m_webPagePrivate->backingStoreClient();
598 ASSERT(backingStoreClient);
599 backingStoreClient->checkOriginOfCurrentScrollOperation();
601 m_webPagePrivate->m_backingStore->d->slowScroll(delta, updateRect, immediate);
605 void ChromeClientBlackBerry::scroll(const IntSize& delta, const IntRect& scrollViewRect, const IntRect& clipRect)
607 // FIXME: There's a chance the function is called indirectly by FrameView's dtor
608 // when the Frame's view() is null. We probably want to fix it in another way, but
609 // at this moment let's do a quick fix.
610 if (!m_webPagePrivate->m_mainFrame->view())
613 BackingStoreClient* backingStoreClient = m_webPagePrivate->backingStoreClient();
614 ASSERT(backingStoreClient);
615 backingStoreClient->checkOriginOfCurrentScrollOperation();
617 m_webPagePrivate->m_backingStore->d->scroll(delta, scrollViewRect, clipRect);
619 // Shift the spell check dialog box as we scroll.
620 m_webPagePrivate->m_inputHandler->redrawSpellCheckDialogIfRequired();
623 void ChromeClientBlackBerry::scrollableAreasDidChange()
625 typedef HashSet<ScrollableArea*> ScrollableAreaSet;
626 const ScrollableAreaSet* scrollableAreas = m_webPagePrivate->m_mainFrame->view()->scrollableAreas();
628 bool hasAtLeastOneInRegionScrollableArea = false;
629 ScrollableAreaSet::iterator end = scrollableAreas->end();
630 for (ScrollableAreaSet::iterator it = scrollableAreas->begin(); it != end; ++it) {
631 if ((*it) != m_webPagePrivate->m_page->mainFrame()->view()) {
632 hasAtLeastOneInRegionScrollableArea = true;
637 m_webPagePrivate->setHasInRegionScrollableAreas(hasAtLeastOneInRegionScrollableArea);
640 void ChromeClientBlackBerry::scrollRectIntoView(const IntRect&, const ScrollView*) const
642 m_webPagePrivate->notifyTransformedScrollChanged();
645 bool ChromeClientBlackBerry::shouldInterruptJavaScript()
647 TimerBase::fireTimersInNestedEventLoop();
648 return m_webPagePrivate->m_client->shouldInterruptJavaScript();
651 KeyboardUIMode ChromeClientBlackBerry::keyboardUIMode()
653 bool tabsToLinks = true;
655 #if !defined(PUBLIC_BUILD) || !PUBLIC_BUILD
656 if (m_webPagePrivate->m_dumpRenderTree)
657 tabsToLinks = DumpRenderTreeSupport::linksIncludedInFocusChain();
660 return tabsToLinks ? KeyboardAccessTabsToLinks : KeyboardAccessDefault;
663 PlatformPageClient ChromeClientBlackBerry::platformPageClient() const
665 return m_webPagePrivate;
668 #if ENABLE(TOUCH_EVENTS)
669 void ChromeClientBlackBerry::needTouchEvents(bool value)
674 void ChromeClientBlackBerry::reachedMaxAppCacheSize(int64_t spaceNeeded)
679 void ChromeClientBlackBerry::layoutUpdated(Frame* frame) const
681 if (frame != m_webPagePrivate->m_mainFrame)
684 m_webPagePrivate->layoutFinished();
687 void ChromeClientBlackBerry::overflowExceedsContentsSize(Frame* frame) const
689 if (frame != m_webPagePrivate->m_mainFrame)
692 #if DEBUG_OVERFLOW_DETECTION
693 BlackBerry::Platform::logAlways(BlackBerry::Platform::LogLevelInfo,
694 "ChromeClientBlackBerry::overflowExceedsContentsSize contents=%s overflow=%f x %f",
695 BlackBerry::Platform::IntRect(frame->contentRenderer()->documentRect()).toString().c_str(),
696 frame->contentRenderer()->rightAbsoluteVisibleOverflow().toFloat(),
697 frame->contentRenderer()->bottomAbsoluteVisibleOverflow().toFloat());
699 m_webPagePrivate->overflowExceedsContentsSize();
702 void ChromeClientBlackBerry::didDiscoverFrameSet(Frame* frame) const
704 if (frame != m_webPagePrivate->m_mainFrame)
707 BBLOG(BlackBerry::Platform::LogLevelInfo, "ChromeClientBlackBerry::didDiscoverFrameSet");
708 if (m_webPagePrivate->loadState() == WebPagePrivate::Committed) {
709 m_webPagePrivate->setShouldUseFixedDesktopMode(true);
710 m_webPagePrivate->zoomToInitialScaleOnLoad();
714 int ChromeClientBlackBerry::reflowWidth() const
716 return m_webPagePrivate->reflowWidth();
719 void ChromeClientBlackBerry::chooseIconForFiles(const Vector<String>&, FileChooser*)
724 bool ChromeClientBlackBerry::supportsFullscreenForNode(const Node* node)
726 return node->hasTagName(HTMLNames::videoTag);
729 void ChromeClientBlackBerry::enterFullscreenForNode(Node* node)
731 if (!supportsFullscreenForNode(node))
734 m_webPagePrivate->enterFullscreenForNode(node);
737 void ChromeClientBlackBerry::exitFullscreenForNode(Node* node)
739 m_webPagePrivate->exitFullscreenForNode(node);
742 #if ENABLE(FULLSCREEN_API)
743 bool ChromeClientBlackBerry::supportsFullScreenForElement(const WebCore::Element* element, bool withKeyboard)
745 return !withKeyboard;
748 void ChromeClientBlackBerry::enterFullScreenForElement(WebCore::Element* element)
750 element->document()->webkitWillEnterFullScreenForElement(element);
751 m_webPagePrivate->enterFullScreenForElement(element);
752 element->document()->webkitDidEnterFullScreenForElement(element);
753 m_fullScreenElement = element;
756 void ChromeClientBlackBerry::exitFullScreenForElement(WebCore::Element*)
758 // The element passed into this function is not reliable, i.e. it could
759 // be null. In addition the parameter may be disappearing in the future.
760 // So we use the reference to the element we saved above.
761 ASSERT(m_fullScreenElement);
762 m_fullScreenElement->document()->webkitWillExitFullScreenForElement(m_fullScreenElement.get());
763 m_webPagePrivate->exitFullScreenForElement(m_fullScreenElement.get());
764 m_fullScreenElement->document()->webkitDidExitFullScreenForElement(m_fullScreenElement.get());
765 m_fullScreenElement.clear();
768 void ChromeClientBlackBerry::fullScreenRendererChanged(RenderBox*)
770 m_webPagePrivate->adjustFullScreenElementDimensionsIfNeeded();
775 void ChromeClientBlackBerry::didSetSVGZoomAndPan(Frame* frame, unsigned short zoomAndPan)
777 // For top-level SVG document, there is no viewport tag, we use viewport's user-scalable
778 // to enable/disable zoom when top-level SVG document's zoomAndPan changed. Because there is no viewport
779 // tag, other fields with default value in ViewportArguments are ok.
780 if (frame == m_webPagePrivate->m_page->mainFrame()) {
781 ViewportArguments arguments;
782 switch (zoomAndPan) {
783 case SVGZoomAndPan::SVG_ZOOMANDPAN_DISABLE:
784 arguments.userScalable = 0;
786 case SVGZoomAndPan::SVG_ZOOMANDPAN_MAGNIFY:
787 arguments.userScalable = 1;
792 didReceiveViewportArguments(frame, arguments);
797 #if USE(ACCELERATED_COMPOSITING)
798 void ChromeClientBlackBerry::attachRootGraphicsLayer(Frame* frame, GraphicsLayer* graphicsLayer)
800 // If the graphicsLayer parameter is 0, WebCore is actually
801 // trying to remove a previously attached layer.
802 m_webPagePrivate->setRootLayerWebKitThread(frame, graphicsLayer ? graphicsLayer->platformLayer() : 0);
805 void ChromeClientBlackBerry::setNeedsOneShotDrawingSynchronization()
807 m_webPagePrivate->setNeedsOneShotDrawingSynchronization();
810 void ChromeClientBlackBerry::scheduleCompositingLayerFlush()
812 m_webPagePrivate->scheduleRootLayerCommit();
815 bool ChromeClientBlackBerry::allowsAcceleratedCompositing() const
821 PassOwnPtr<ColorChooser> ChromeClientBlackBerry::createColorChooser(ColorChooserClient*, const Color&)
826 #if ENABLE(NAVIGATOR_CONTENT_UTILS)
827 void ChromeClientBlackBerry::registerProtocolHandler(const String& scheme, const String& baseURL, const String& url, const String& title)
829 m_webPagePrivate->m_client->registerProtocolHandler(scheme, baseURL, url, title);
832 #if ENABLE(CUSTOM_SCHEME_HANDLER)
833 ChromeClient::CustomHandlersState ChromeClientBlackBerry::isProtocolHandlerRegistered(const String& scheme, const String& baseURL, const String& url)
835 return static_cast<CustomHandlersState>(m_webPagePrivate->m_client->isProtocolHandlerRegistered(scheme, baseURL, url));
838 void ChromeClientBlackBerry::unregisterProtocolHandler(const String& scheme, const String& baseURL, const String& url)
840 m_webPagePrivate->m_client->unregisterProtocolHandler(scheme, baseURL, url);
845 void ChromeClientBlackBerry::addSearchProvider(const BlackBerry::Platform::String& originURL, const BlackBerry::Platform::String& newURL)
847 // See if the input URL host matches of the origin host.
848 KURL originHost = KURL(KURL(), originURL);
849 KURL url = KURL(KURL(), newURL);
850 if (url.isValid() && originHost.host() == url.host())
851 m_webPagePrivate->client()->addSearchProvider(newURL);
854 int ChromeClientBlackBerry::isSearchProviderInstalled(const BlackBerry::Platform::String& originURL, const BlackBerry::Platform::String& newURL)
856 // Returns a value based on comparing url to the URLs of the results pages of the installed search engines.
857 // 0 - None of the installed search engines match url.
858 // 1 - One or more installed search engines match url, but none are the user's default search engine.
859 // 2 - The user's default search engine matches url.
861 // See if the input URL host matches of the origin host.
862 KURL originHost = KURL(KURL(), originURL);
863 KURL url = KURL(KURL(), newURL);
864 if (url.isValid() && originHost.host() == url.host())
865 return m_webPagePrivate->client()->isSearchProviderInstalled(newURL);
869 } // namespace WebCore