Example #1
0
/* virtual */ ES_GetState
DOM_BrowserTab::GetName(OpAtom property_name, ES_Value* value, ES_Runtime* origining_runtime)
{
	switch (property_name)
	{
	case OP_ATOM_id:
		DOMSetNumber(value, GetTabId());
		return GET_SUCCESS;

	case OP_ATOM_locked:
	case OP_ATOM_browserWindow:
	case OP_ATOM_position:
	case OP_ATOM_tabGroup:
	case OP_ATOM_focused:
	case OP_ATOM_selected:
	case OP_ATOM_title:
	case OP_ATOM_private:
	case OP_ATOM_closed:
		return GetTabInfo(property_name, value, origining_runtime, NULL);

	case OP_ATOM_faviconUrl:
	{
#ifdef SHORTCUT_ICON_SUPPORT
		Window* window = GetTabWindow();
		if (window && (!window->GetPrivacyMode() || IsPrivateDataAllowed()))
			DOMSetString(value, window->GetWindowIconURL().GetAttribute(URL::KUniName_With_Fragment, URL::KNoRedirect).CStr());
#endif // SHORTCUT_ICON_SUPPORT
		return GET_SUCCESS;
	}

	case OP_ATOM_url:
	{
		Window* window = GetTabWindow();
		if (window && (!window->GetPrivacyMode() || IsPrivateDataAllowed()))
		{
			const uni_char* url = window->GetCurrentURL().GetAttribute(URL::KUniName_With_Fragment, URL::KNoRedirect).CStr();
			if (!url || !*url) // if nothing is currently loaded then try if something is loading.
				url = window->GetCurrentLoadingURL().GetAttribute(URL::KUniName_With_Fragment, URL::KNoRedirect).CStr();
			DOMSetString(value, url);
		}
		return GET_SUCCESS;
	}

	case OP_ATOM_readyState:
	{
		Window* window = GetTabWindow();
		if (window && (!window->GetPrivacyMode() || IsPrivateDataAllowed()))
			DOM_Document::GetDocumentReadiness(value, window->GetCurrentDoc());
		return GET_SUCCESS;
	}
#ifdef USE_SPDY
	case OP_ATOM_loadedWithSPDY:
	{
		Window* window = GetTabWindow();
		if (window && (!window->GetPrivacyMode() || IsPrivateDataAllowed()))
			DOMSetBoolean(value, window->GetCurrentURL().GetAttribute(URL::KLoadedWithSpdy));
		return GET_SUCCESS;
	}
#endif // USE_SPDY
	case OP_ATOM_port:
		DOMSetObject(value, GetPort());
		return GET_SUCCESS;

	default:
		return DOM_Object::GetName(property_name, value, origining_runtime);
	}
}