Example #1
0
MediaPlayer::SupportsType MediaPlayerPrivateEA::supportsType(const String& mime, const String& codec)
{
    MediaUpdateInfo& info = GetMediaUpdateInfo();
    
    // We don't have access to the tag info here but can look at the mime type to eval if we have a video.
    bool isVideo = mime.contains("video");
    SetUpClientUpdate(info, MediaUpdateInfo::kGetIfMimeSupported, 0, 0, isVideo);  
    GetFixedString(info.mMime)->assign(mime.characters(), mime.length());
    GetFixedString(info.mCodec)->assign(codec.characters(), codec.length());
    CallClientUpdate(info);
    if (info.mReturnBool)
    {
        return MediaPlayer::IsSupported;
    }
    else
    {
        return MediaPlayer::IsNotSupported;
    }
}
Example #2
0
// Read from the clipboard
String Pasteboard::plainText(Frame* pFrame)
{
    WebCore::String retVal;

    EA::WebKit::ViewNotification* pVN = EA::WebKit::GetViewNotification();

    if(pVN) // This should always be true.
    {
        EA::WebKit::ClipboardEventInfo cei;

        cei.mpView = EA::WebKit::GetView(pFrame);
        cei.mReadFromClipboard = true;

        pVN->ClipboardEvent(cei); // We can ignore the return value and just look at cei.mText.

        if(!GetFixedString(cei.mText)->empty())
            retVal = GetFixedString(cei.mText)->c_str();
    }

    return retVal;
}
Example #3
0
void MediaPlayerPrivateEA::load(const String& url)
{
    if (!mpEAWebKitView)
        mpEAWebKitView = GetEAWebKitMediaView(mpWebCorePlayer);

    // Note: We get the autoplay and loop flags from the element directly.
    HTMLMediaElement* element = static_cast<HTMLMediaElement*>(mpWebCorePlayer->mediaPlayerClient());
    mIsLooping = element->loop();
   
    MediaUpdateInfo& info = GetMediaUpdateInfo();  
    info.mIsLooping = mIsLooping; 
	WebCore::KURL kurl(WebCore::KURL(), url);
	String escapedUrl = kurl.protocolIsInHTTPFamily() ? url : decodeURLEscapeSequences(url);

    GetFixedString(info.mURI)->assign(escapedUrl.characters(), escapedUrl.length());
    ClientUpdate(MediaUpdateInfo::kLoad);
    
    // Set info up to play
    setMuted(mpWebCorePlayer->muted());
    setVolume(mpWebCorePlayer->volume());
    
    if(mNetworkState != MediaPlayer::Loading)
    {
        mNetworkState = MediaPlayer::Loading;
        mpWebCorePlayer->networkStateChanged();
    }
    
    if(mReadyState != MediaPlayer::HaveNothing)
    {
       mReadyState = MediaPlayer::HaveNothing; 
       mpWebCorePlayer->readyStateChanged(); 
    }
    
    bool autoPlay = element->autoplay();
    if(autoPlay)
        mpWebCorePlayer->play();            // This just calls our play.

    ClientUpdateStates();                   // This will update the pause/play state right away.

    // Set up an update timer to control the repaint and playback.
    if (mUpdateTimer.isActive())
        mUpdateTimer.stop();
    const double kUpdateTime = 1.0/60.0;      // We want to update at 60hz so we keep up with the render calls. 
    mUpdateTimer.startRepeating(kUpdateTime);
}
Example #4
0
// Write to the clipboard
void Pasteboard::writeSelection(Range* /*selectedRange*/, bool /*canSmartCopyOrDelete*/, Frame* frame)
{
    EA::WebKit::ViewNotification* pVN = EA::WebKit::GetViewNotification();

    if(pVN) // This should always be true.
    {
        EA::WebKit::ClipboardEventInfo cei;
        EA::WebKit::View*   pView= NULL;
        if(frame)
            pView = EA::WebKit::GetView(frame);
        
        cei.mpView = pView;
        cei.mReadFromClipboard = false;

        const String str = frame->selectedText();
        GetFixedString(cei.mText)->assign(str.characters(), str.length());

        pVN->ClipboardEvent(cei);
    }
}
Example #5
0
void DocumentLoader::setTitle(const String& title)
{
    if (title.isEmpty())
        return;

    String trimmed = canonicalizedTitle(title, m_frame);
    if (!trimmed.isEmpty() && m_pageTitle != trimmed) {
        frameLoader()->willChangeTitle(this);
        m_pageTitle = trimmed;
        frameLoader()->didChangeTitle(this);

        //+ 8/26/09 CSidhall - Added title setting for API
        EA::WebKit::View* pView = EA::WebKit::GetView(frame());
        if(pView){
            EA::WebKit::LoadInfo& loadInfo = pView->GetLoadInfo();
            GetFixedString(loadInfo.mPageTitle)->assign(trimmed.characters(), trimmed.length());
        }
        //- CS
    }
}
bool ViewNavigationDelegate::JumpToNearestElement(EA::WebKit::JumpDirection direction, bool scrollIfElementNotFound)
{

	// Note by Arpit Baldeva:
	// We have a problem here. mpModalInputClient object is supposed to be used for Modal input only however the only class using this object 
	// is html SELECT element(implemented as a popup). But in reality, html SELECT element is NOT modal. So it is little ill-conceived. 
	// For example, in all the browsers, if you scroll the mouse wheel on the frame, the SELECT element disappears and the actual frame scrolls.

	// For any modal input needs on a web page, the users are advised to use the Z-layer technique with Javascript/CSS - http://jqueryui.com/demos/dialog/#modal-confirmation.

	// The problem we want to solve here is have the SELECT element respond to the controller input correctly(select element one by one).
	// But the button event information is lost by the time we are in the EA::WebKit::View. For the foreseeable future, there is no candidate
	// other than html SELECT element which is implemented as a modal popup inside EAWebKit. So inside EA::WebKit::View, we create a dummy
	// button event from the Jump direction and make SELECT respond to it. If any other object starts using the modal input, this would need to be
	// revisited. But then, we'll need to solve a plethora of issues. So we do minimum work here to not break other things.

	IOverlayInputClient* pOverlayInputClient = mView->GetOverlayInputClient();

	bool handledByOverlayInputClient = false;
	if(pOverlayInputClient)
	{
		EA::WebKit::ButtonEvent btnEvent;
		switch(direction)
		{
			/*
			case EA::WebKit::JumpLeft:
			{
			btnEvent.mID = EA::WebKit::kButton0;
			handledByOverlayInputClient = pOverlayInputClient->OnButtonEvent(btnEvent);
			}
			*/
		case EA::WebKit::JumpUp:
			{
				btnEvent.mID = EA::WebKit::kButton1;
				handledByOverlayInputClient =  pOverlayInputClient->OnButtonEvent(btnEvent);
				break;
			}
			/*
			case EA::WebKit::JumpRight:
			{
			btnEvent.mID = EA::WebKit::kButton2;
			handledByOverlayInputClient =  pOverlayInputClient->OnButtonEvent(btnEvent);
			}
			*/
		case EA::WebKit::JumpDown:
			{
				btnEvent.mID = EA::WebKit::kButton3;
				handledByOverlayInputClient =  pOverlayInputClient->OnButtonEvent(btnEvent);
				break;
			}
		default:
			// We don't return and allow any other button press to go to the main View. At the same time, we make the SELECT element lose focus.
			{
				pOverlayInputClient->OnFocusChangeEvent(false);
				break;
			}
		}
	}

	if(handledByOverlayInputClient)
		return true;

	int lastX, lastY;
	mView->GetCursorPosition(lastX, lastY);

	// Following is a shortcut to drive navigation from a page.
	switch (direction)
	{
	case EA::WebKit::JumpRight:
		if (GetFixedString(mCachedNavigationRightId)->compare(""))
		{
			if (!GetFixedString(mCachedNavigationRightId)->compare("ignore"))
			{
				return false;
			}

			if (JumpToId(GetFixedString(mCachedNavigationRightId)->c_str()))
			{
				return true;
			}
		}
		break;

	case EA::WebKit::JumpDown:
		if (GetFixedString(mCachedNavigationDownId)->compare(""))
		{
			if (!GetFixedString(mCachedNavigationDownId)->compare("ignore"))
			{
				return false;
			}

			if (JumpToId(GetFixedString(mCachedNavigationDownId)->c_str()))
			{
				return true;
			}
		}
		break;

	case EA::WebKit::JumpLeft:
		if (GetFixedString(mCachedNavigationLeftId)->compare(""))
		{
			if (!GetFixedString(mCachedNavigationLeftId)->compare("ignore"))
			{
				return false;
			}

			if (JumpToId(GetFixedString(mCachedNavigationLeftId)->c_str()))
			{
				return true;
			}
		}
		break;

	case EA::WebKit::JumpUp:
		if (GetFixedString(mCachedNavigationUpId)->compare(""))
		{
			if (!GetFixedString(mCachedNavigationUpId)->compare("ignore"))
			{
				return false;
			}

			if (JumpToId(GetFixedString(mCachedNavigationUpId)->c_str()))
			{
				return true;
			}
		}
		break;

	default:
		EAW_FAIL_MSG("Should not have got here\n");
	}


	// Iterate over all the frames and find the closest element in any of all the frames.
	WebCore::Frame* pFrame		= mView->GetFrame();
	float currentRadialDistance = FLT_MAX; // A high value to start with so that the max distance between any two elements in the surface is under it.
	WebCore::Node* currentBestNode = NULL;
	while(pFrame)
	{
		WebCore::Document* document = pFrame->document();
		EAW_ASSERT(document);

		if(document)
		{
			WebCore::FrameView* pFrameView = document->view();
			WebCore::IntPoint scrollOffset;
			if(pFrameView)
			{
 				scrollOffset.setX(pFrameView->scrollOffset().width());
 				scrollOffset.setY(pFrameView->scrollOffset().height());
			}

			// We figure out the start position(It is center of the currently hovered element almost all the time but can be slightly different 
			// due to scroll sometimes).
			mCentreX = lastX + scrollOffset.x();
			mCentreY = lastY + scrollOffset.y();

			DocumentNavigator navigator(mView, document, direction, WebCore::IntPoint(mCentreX, mCentreY), mBestNodeX, mBestNodeY, mBestNodeWidth, mBestNodeHeight, mJumpNavigationParams.mNavigationTheta, mJumpNavigationParams.mStrictAxesCheck, currentRadialDistance);
			navigator.FindBestNode(document);

			if(navigator.GetBestNode())
			{
				currentBestNode			= navigator.GetBestNode();
				currentRadialDistance	= navigator.GetBestNodeRadialDistance();
			}

		}

		pFrame = pFrame->tree()->traverseNext();
	}

	bool foundSomething = false;
	if (currentBestNode) //We found the node to navigate. Move the cursor and we are done.
	{
		foundSomething = true;
		MoveMouseCursorToNode(currentBestNode, false);
	}
	else if(scrollIfElementNotFound)// Node is not found. 
	{
		// Based on the intended direction of movement, scroll so that some newer elements are visible.
		
		int cursorPosBeforeScrollX, cursorPosBeforeScrollY;
		mView->GetCursorPosition(cursorPosBeforeScrollX, cursorPosBeforeScrollY);

		switch(direction)
		{
		case EA::WebKit::JumpDown:
			{
				ScrollOnJump(true, -120, mJumpNavigationParams.mNumLinesToAutoScroll);
				break;
			}

		case EA::WebKit::JumpUp:
			{
				ScrollOnJump(true, 120, mJumpNavigationParams.mNumLinesToAutoScroll);
				break;
			}
		case EA::WebKit::JumpRight:
			{
				ScrollOnJump(false, -120, mJumpNavigationParams.mNumLinesToAutoScroll);
				break;
			}
		case EA::WebKit::JumpLeft:
			{
				ScrollOnJump(false, 120, mJumpNavigationParams.mNumLinesToAutoScroll);
				break;
			}
		default:
			{
				EAW_ASSERT_MSG(false, "Should not reach here\n");
			}
		}

		// We move the mouse cursor back to the location where the last best node was found. This is so that we don't end up with the cursor being in no man's land. While that may work 
		// for ordinary sites, it may not work well with customized pages that leverage CSS to visually indicate current position rather than a cursor graphic.
		// We don't call MoveMouseCursorToNode() with last cached node as there are edge cases where we may be holding an invalid node. Using a cached frame and checking against the
		// current valid frames safeguards against that.

		WebCore::IntSize scrollOffset;
		WebCore::Frame* pFrame1	= mView->GetFrame();
		while(pFrame1)
		{
			if(pFrame1 == mBestNodeFrame)//Find the frame where last best node existed.
			{
				if(pFrame1->view())
				{
					scrollOffset = pFrame1->view()->scrollOffset();//We read scroll offset here as it could have changed in the switch statement above.
					break;
				}
			}
			pFrame1 = pFrame1->tree()->traverseNext();
		}
		
		int targetcursorPosAfterScrollX, targetcursorPosAfterScrollY;
		targetcursorPosAfterScrollX = mBestNodeX + mBestNodeWidth / 2 - scrollOffset.width();
		targetcursorPosAfterScrollY = mBestNodeY + mBestNodeHeight/ 2 - scrollOffset.height();

		EA::WebKit::MouseMoveEvent moveEvent;
		memset( &moveEvent, 0, sizeof(moveEvent) );
		
		const int cursorInset = 5;// Make cursor stay inside 5 pixels from boundaries. No known issues but added this as a safety measure so that we do not lose cursor ever.
		
		int width = mView->GetSize().mWidth;
		int height = mView->GetSize().mHeight;

		moveEvent.mX	= Clamp( cursorInset, targetcursorPosAfterScrollX, width - cursorInset );
		moveEvent.mY	= Clamp( cursorInset, targetcursorPosAfterScrollY, height - cursorInset );


		mView->OnMouseMoveEvent(moveEvent);
		// We intentionally don't call JumpToNearestElement(direction, false) here to avoid recursion. We do it in the overloaded function above.
	}
		
	return foundSomething;
}
void ViewNavigationDelegate::UpdateCachedHints(WebCore::Node* node)
{
	if (node && node->hasAttributes())
	{
		WebCore::NamedNodeMap* attributeMap = node->attributes();

		WebCore::Attribute* upAttribute		= attributeMap->getAttributeItem(WebCore::QualifiedName	(""	,"navigationup"		,""));
		WebCore::Attribute* downAttribute	= attributeMap->getAttributeItem(WebCore::QualifiedName	(""	,"navigationdown"	,""));
		WebCore::Attribute* leftAttribute	= attributeMap->getAttributeItem(WebCore::QualifiedName	(""	,"navigationleft"	,""));
		WebCore::Attribute* rightAttribute	= attributeMap->getAttributeItem(WebCore::QualifiedName	(""	,"navigationright"	,""));

		if ( upAttribute )
		{
			EA::WebKit::ConvertToString8(upAttribute->value().string(),*GetFixedString(mCachedNavigationUpId));
		}
		else
		{
			GetFixedString(mCachedNavigationUpId)->assign("");
		}

		if ( downAttribute )
		{
			EA::WebKit::ConvertToString8(downAttribute->value().string(),*GetFixedString(mCachedNavigationDownId));
		}
		else
		{
			GetFixedString(mCachedNavigationDownId)->assign("");
		}

		if ( leftAttribute )
		{
			EA::WebKit::ConvertToString8(leftAttribute->value().string(),*GetFixedString(mCachedNavigationLeftId));
		}
		else
		{
			GetFixedString(mCachedNavigationLeftId)->assign("");
		}

		if ( rightAttribute )
		{
			EA::WebKit::ConvertToString8(rightAttribute->value().string(),*GetFixedString(mCachedNavigationRightId));
		}
		else
		{
			GetFixedString(mCachedNavigationRightId)->assign("");
		}
	}
	else
	{
		GetFixedString(mCachedNavigationUpId)->assign("");
		GetFixedString(mCachedNavigationDownId)->assign("");
		GetFixedString(mCachedNavigationLeftId)->assign("");
		GetFixedString(mCachedNavigationRightId)->assign("");
	}
}
Example #8
0
bool LinkHookManager::ModifyResourceRequest(WebCore::ResourceRequest& resourceRequest)
{
    bool bIntercepted = false;

    ViewNotification* pVN = GetViewNotification();

    if(pVN)
    {
        LinkNotificationInfo  lni;
        lni.mpView              = mpView;
        lni.mbURIIntercepted    = false;
		lni.mbURIInterceptedByDomainFiltering = false;//We don't make any decision here. It is done inside the resource manager.

		EA::WebKit::HeaderMap& originalHeaderMap = *GetHeaderMap(lni.mpOriginalHeaderMap);
		EA::WebKit::HeaderMap& newHeaderMap = *GetHeaderMap(lni.mpModifiedHeaderMap);
		
		// Setup mOriginalURI
		const WebCore::String& webCoreURI = resourceRequest.url().string();
		GetFixedString(lni.mOriginalURI)->assign(webCoreURI.characters(), webCoreURI.length());

		// Setup originalHeaderMap
		const WebCore::HTTPHeaderMap& webcoreHeaderMap = resourceRequest.httpHeaderFields();
		for(WebCore::HTTPHeaderMap::const_iterator it(webcoreHeaderMap.begin()); it != webcoreHeaderMap.end(); ++it)
		{
			const WebCore::String& webCoreKey   = it->first;
			const WebCore::String& webCoreValue = it->second;

			HeaderMap::value_type entry(HeaderMap::key_type(webCoreKey.characters(), webCoreKey.length()), 
				HeaderMap::mapped_type(webCoreValue.characters(), webCoreValue.length()));

			originalHeaderMap.insert(entry);
		}
	
	
		//Note by Arpit Baldeva: Changed the code so that it better reflects the main app behavior and is consistent with 
		//other ViewNotification API. This was discussed with Sims team over the email.
		//The interception has a confusing meaning here. This is how I interpret as possible scenarios.
		//1. Application does not do anything. Simply returns false. So nothing changes.
		//2. Application takes control of the URL(say for downloading stuff). In this case, application returns true to indicate this. Further, they
		//specify by setting the mbURIIntercepted to be true that the link does not need processing anymore.
		//3. Application is simply interested in doing something else with this link. Say it wants to redirect any access to www.url1.com to 
		//www.url2.com.

		if(!pVN->LinkSelected(lni)) // case 1: Application did not do anything with the notification and returned false
		{
			bIntercepted = false;//We too return false here so that WebKit does its own stuff with the Link.
		}
		else //application did something....l
		{
			//Check if application wanted WebKit to not handle URL anymore. For example, download stuff.
			//This is indicated by setting the lni.mbURIIntercepted
			if(lni.mbURIIntercepted) //case 2
			{
				bIntercepted = lni.mbURIIntercepted;// We are finished, WebKit does not do anything anymore.
			}
			else //case 3
			{
				//Check if the application simply changed the link location or headers. If yes, set them and let the WebKit do its work.
				if(!GetFixedString(lni.mModifiedURI)->empty())
				{
					OWBAL::KURL currentURL(GetFixedString(lni.mModifiedURI)->c_str());
					resourceRequest.setURL(currentURL);
				}

				if(!newHeaderMap.empty())
				{
					// We need to const_cast this, as ResourceRequest doesn't have a function to clear the headers.
					WebCore::HTTPHeaderMap& webCoreHeaderMap = const_cast<WebCore::HTTPHeaderMap&>(resourceRequest.httpHeaderFields());

					webCoreHeaderMap.clear(); // We will be completely re-writing the headers.

					for(HeaderMap::const_iterator it = newHeaderMap.begin(); it != newHeaderMap.end(); ++it)
					{
						const WebCore::String key(it->first.c_str(), it->first.length());
						const WebCore::String val(it->second.c_str(), it->second.length());

						resourceRequest.addHTTPHeaderField(key, val);
					}
				}	
				bIntercepted = false;//The WebKit should take this new data and do its job.
			}

		}
/*
        if(pVN->LinkSelected(lni))
        {
            bIntercepted = lni.mbURIIntercepted;

            if(!bIntercepted)
            {
                if(!GetFixedString(lni.mModifiedURI)->empty())
                {
                    OWBAL::KURL currentURL(GetFixedString(lni.mModifiedURI)->c_str());
                    resourceRequest.setURL(currentURL);
                }

                if(!newHeaderMap.empty())
                {
                    // We need to const_cast this, as ResourceRequest doesn't have a function to clear the headers.
                    WebCore::HTTPHeaderMap& webCoreHeaderMap = const_cast<WebCore::HTTPHeaderMap&>(resourceRequest.httpHeaderFields());

                    webCoreHeaderMap.clear(); // We will be completely re-writing the headers.

                    for(HeaderMap::const_iterator it = newHeaderMap.begin(); it != newHeaderMap.end(); ++it)
                    {
                        const WebCore::String key(it->first.c_str(), it->first.length());
                        const WebCore::String val(it->second.c_str(), it->second.length());

                        resourceRequest.addHTTPHeaderField(key, val);
                    }
                }
            }
        }
*/
    }

    return bIntercepted;
}