aboutsummaryrefslogtreecommitdiff
path: root/sp/src/public/html
diff options
context:
space:
mode:
Diffstat (limited to 'sp/src/public/html')
-rw-r--r--sp/src/public/html/htmlmessages.h116
-rw-r--r--sp/src/public/html/htmlprotobuf.cpp70
-rw-r--r--sp/src/public/html/htmlprotobuf.h71
-rw-r--r--sp/src/public/html/ichromehtmlwrapper.h63
-rw-r--r--sp/src/public/html/ihtmlchrome.h120
-rw-r--r--sp/src/public/html/ipainthtml.h54
6 files changed, 494 insertions, 0 deletions
diff --git a/sp/src/public/html/htmlmessages.h b/sp/src/public/html/htmlmessages.h
new file mode 100644
index 00000000..b2d5dd0e
--- /dev/null
+++ b/sp/src/public/html/htmlmessages.h
@@ -0,0 +1,116 @@
+//========= Copyright Valve Corporation, All rights reserved. ============//
+//
+// Purpose:
+//=============================================================================//
+
+#ifndef HTMLMESSAGES_H
+#define HTMLMESSAGES_H
+
+#ifdef _WIN32
+#pragma once
+#endif
+
+//-----------------------------------------------------------------------------
+// Purpose: Commands we IPC across to the html thread and get responses for
+//-----------------------------------------------------------------------------
+enum EHTMLCommands
+{
+ // input events
+ eHTMLCommands_KeyUp,
+ eHTMLCommands_KeyDown,
+ eHTMLCommands_KeyChar,
+ eHTMLCommands_MouseDown,
+ eHTMLCommands_MouseUp,
+ eHTMLCommands_MouseDblClick,
+ eHTMLCommands_MouseWheel,
+ eHTMLCommands_MouseMove,
+ eHTMLCommands_MouseLeave,
+
+ // command events
+ eHTMLCommands_BrowserCreate,
+ eHTMLCommands_BrowserRemove,
+ eHTMLCommands_BrowserErrorStrings,
+ eHTMLCommands_BrowserSize,
+ eHTMLCommands_BrowserPosition,
+ eHTMLCommands_PostURL,
+ eHTMLCommands_StopLoad,
+ eHTMLCommands_Reload,
+ eHTMLCommands_GoForward,
+ eHTMLCommands_GoBack,
+ eHTMLCommands_Copy,
+ eHTMLCommands_Paste,
+ eHTMLCommands_ExecuteJavaScript,
+ eHTMLCommands_SetFocus,
+ eHTMLCommands_HorizontalScrollBarSize,
+ eHTMLCommands_VerticalScrollBarSize,
+ eHTMLCommands_Find,
+ eHTMLCommands_StopFind,
+ eHTMLCommands_SetHorizontalScroll,
+ eHTMLCommands_SetVerticalScroll,
+ eHTMLCommands_SetZoomLevel,
+ eHTMLCommands_ViewSource,
+ eHTMLCommands_NeedsPaintResponse,
+ eHTMLCommands_AddHeader,
+ eHTMLCommands_GetZoom,
+ eHTMLCommands_FileLoadDialogResponse,
+ eHTMLCommands_LinkAtPosition,
+ eHTMLCommands_ZoomToElementAtPosition,
+ eHTMLCommands_SavePageToJPEG,
+ eHTMLCommands_JSAlert,
+ eHTMLCommands_JSConfirm,
+ eHTMLCommands_CanGoBackandForward,
+ eHTMLCommands_OpenSteamURL,
+ eHTMLCommands_SizePopup,
+ eHTMLCommands_SetCookie,
+ eHTMLCommands_SetTargetFrameRate,
+ eHTMLCommands_FullRepaint,
+ eHTMLCommands_SetPageScale,
+ eHTMLCommands_RequestFullScreen,
+ eHTMLCommands_ExitFullScreen,
+ eHTMLCommands_GetCookiesForURL,
+ eHTMLCommands_ZoomToCurrentlyFocusedNode,
+ eHTMLCommands_CloseFullScreenFlashIfOpen,
+ eHTMLCommands_PauseFullScreenFlashMovieIfOpen,
+ eHTMLCommands_GetFocusedNodeValue,
+
+ // output back to the main thread
+ eHTMLCommands_BrowserCreateResponse,
+ eHTMLCommands_BrowserReady,
+ eHTMLCommands_URLChanged,
+ eHTMLCommands_FinishedRequest,
+ eHTMLCommands_StartRequest,
+ eHTMLCommands_ShowPopup,
+ eHTMLCommands_HidePopup,
+ eHTMLCommands_OpenNewTab,
+ eHTMLCommands_PopupHTMLWindow,
+ eHTMLCommands_PopupHTMLWindowResponse,
+ eHTMLCommands_SetHTMLTitle,
+ eHTMLCommands_LoadingResource,
+ eHTMLCommands_StatusText,
+ eHTMLCommands_SetCursor,
+ eHTMLCommands_FileLoadDialog,
+ eHTMLCommands_ShowToolTip,
+ eHTMLCommands_UpdateToolTip,
+ eHTMLCommands_HideToolTip,
+ eHTMLCommands_SearchResults,
+ eHTMLCommands_Close,
+ eHTMLCommands_VerticalScrollBarSizeResponse,
+ eHTMLCommands_HorizontalScrollBarSizeResponse,
+ eHTMLCommands_GetZoomResponse,
+ eHTMLCommands_StartRequestResponse,
+ eHTMLCommands_NeedsPaint,
+ eHTMLCommands_LinkAtPositionResponse,
+ eHTMLCommands_ZoomToElementAtPositionResponse,
+ eHTMLCommands_JSDialogResponse,
+ eHTMLCommands_ScaleToValueResponse,
+ eHTMLCommands_RequestFullScreenResponse,
+ eHTMLCommands_GetCookiesForURLResponse,
+ eHTMLCommands_NodeGotFocus,
+ eHTMLCommands_SavePageToJPEGResponse,
+ eHTMLCommands_GetFocusedNodeValueResponse,
+
+ eHTMLCommands_None,
+
+};
+
+#endif // HTMLMESSAGES_H \ No newline at end of file
diff --git a/sp/src/public/html/htmlprotobuf.cpp b/sp/src/public/html/htmlprotobuf.cpp
new file mode 100644
index 00000000..59168c99
--- /dev/null
+++ b/sp/src/public/html/htmlprotobuf.cpp
@@ -0,0 +1,70 @@
+//========= Copyright Valve Corporation, All rights reserved. ============//
+//
+// Purpose:
+//=============================================================================//
+
+
+#include "html/htmlprotobuf.h"
+#include "tier0/vprof.h"
+#include "tier0/valve_minmax_off.h"
+
+
+#ifdef _WIN64
+// disable 64-bit warnings for the google headers
+#pragma warning(push)
+#pragma warning(disable:4244) // warning C4244: 'return' : conversion from '__int64' to 'int', possible loss of data
+#pragma warning(disable:4267) // warning C4267: 'argument' : conversion from 'size_t' to 'int', possible loss of data
+#endif
+
+#include "tier0/memdbgoff.h"
+#include "protobuf-2.3.0/src/google/protobuf/message_lite.h"
+#include "tier0/memdbgon.h"
+
+#ifdef _WIN64
+#pragma warning(pop)
+#endif
+
+//-----------------------------------------------------------------------------
+// Purpose: serialize a protobuf into a utlbuffer
+//-----------------------------------------------------------------------------
+void CHTMLBaseProtoBufMsg::SerializeCrossProc( CUtlBuffer *pBuffer ) const
+{
+ VPROF_BUDGET( "CUIProtoBufMsg::SerializeCrossProc", VPROF_BUDGETGROUP_OTHER_VGUI );
+ uint32 unSize = ((google::protobuf::MessageLite *)m_pMsg)->ByteSize();
+
+ // Ensure enough for type, size, and serialized data
+ pBuffer->EnsureCapacity( pBuffer->TellPut() + sizeof(uint32) * 3 + unSize ); // bugbug cboyd - drop to * 2 whenpassthrough is removed below
+
+ pBuffer->PutUnsignedInt( unSize );
+
+ if ( unSize == 0 )
+ return;
+
+ uint8 *pBody = (uint8*)pBuffer->Base()+pBuffer->TellPut();
+ ((google::protobuf::MessageLite *)m_pMsg)->SerializeWithCachedSizesToArray( pBody );
+ pBuffer->SeekPut( CUtlBuffer::SEEK_CURRENT, unSize );
+}
+
+
+//-----------------------------------------------------------------------------
+// Purpose: grab a previously serialized protobuf
+//-----------------------------------------------------------------------------
+bool CHTMLBaseProtoBufMsg::BDeserializeCrossProc( CUtlBuffer *pBuffer )
+{
+ VPROF_BUDGET( "CUIProtoBufMsg::BDeserialize", VPROF_BUDGETGROUP_OTHER_VGUI );
+ if ( pBuffer->GetBytesRemaining() < (int)sizeof(uint32) )
+ return false;
+ uint32 unSize = pBuffer->GetUnsignedInt();
+
+ if ( unSize == 0 )
+ return true;
+
+ if ( pBuffer->GetBytesRemaining() < (int)unSize )
+ return false;
+
+ bool bSucccess = ((google::protobuf::MessageLite *)m_pMsg)->ParseFromArray( (uint8*)pBuffer->Base()+pBuffer->TellGet(), unSize );
+ pBuffer->SeekGet( CUtlBuffer::SEEK_CURRENT, unSize );
+
+ return bSucccess;
+}
+
diff --git a/sp/src/public/html/htmlprotobuf.h b/sp/src/public/html/htmlprotobuf.h
new file mode 100644
index 00000000..38ee6400
--- /dev/null
+++ b/sp/src/public/html/htmlprotobuf.h
@@ -0,0 +1,71 @@
+//========= Copyright Valve Corporation, All rights reserved. ============//
+//
+// Purpose:
+//=============================================================================//
+
+#ifndef HTML_PROTOBUF
+#define HTML_PROTOBUF
+
+#ifdef _WIN32
+#pragma once
+#endif
+
+#include "tier1/utlbuffer.h"
+#include "html/htmlmessages.h"
+
+namespace google
+{
+ namespace protobuf
+ {
+ class MessageLite;
+ }
+}
+
+class CHTMLBaseProtoBufMsg
+{
+public:
+ void SerializeCrossProc( CUtlBuffer *pBuffer ) const;
+ bool BDeserializeCrossProc( CUtlBuffer *pBuffer );
+
+protected:
+ void *m_pMsg;
+ bool m_bIsValid;
+};
+
+
+//-----------------------------------------------------------------------------
+// Purpose: Base class for protobuf objects
+//-----------------------------------------------------------------------------
+template< typename PB_OBJECT_TYPE >
+class CHTMLProtoBufMsg : public CHTMLBaseProtoBufMsg
+{
+public:
+ CHTMLProtoBufMsg( EHTMLCommands eMsg )
+ {
+ m_pMsg = new PB_OBJECT_TYPE;
+ m_bIsValid = true;
+ }
+
+ // Construct and deserialize in one
+ CHTMLProtoBufMsg( CUtlBuffer *pBuffer )
+ {
+ m_pMsg = NULL;
+ m_bIsValid = BDeserializeCrossProc( pBuffer );
+ }
+
+ // Destructor
+ virtual ~CHTMLProtoBufMsg()
+ {
+ delete (PB_OBJECT_TYPE *)m_pMsg;
+ }
+
+ bool BIsValid() { return m_bIsValid; }
+
+ // Accessors
+ PB_OBJECT_TYPE &Body() { return *((PB_OBJECT_TYPE*)( (google::protobuf::MessageLite *)m_pMsg )); }
+ const PB_OBJECT_TYPE &BodyConst() const { return *((const PB_OBJECT_TYPE*)( (google::protobuf::MessageLite *)m_pMsg )); }
+
+};
+
+
+#endif // HTML_PROTOBUF
diff --git a/sp/src/public/html/ichromehtmlwrapper.h b/sp/src/public/html/ichromehtmlwrapper.h
new file mode 100644
index 00000000..6504c255
--- /dev/null
+++ b/sp/src/public/html/ichromehtmlwrapper.h
@@ -0,0 +1,63 @@
+//========= Copyright Valve Corporation, All rights reserved. ============//
+//
+// Purpose:
+//
+// $NoKeywords: $
+//=============================================================================//
+
+#ifndef ICHROMEHTMLWRAPPER_H
+#define ICHROMEHTMLWRAPPER_H
+
+#ifdef _WIN32
+#pragma once
+#endif
+
+#include <html/htmlmessages.h>
+
+class CUtlString;
+class IHTMLResponses;
+struct HTMLCommandBuffer_t;
+
+
+//------------------------------------------------------------- ----------------
+// Purpose: wrapper for HTML functionality
+//-----------------------------------------------------------------------------
+class IHTMLChromeController
+{
+public:
+ virtual ~IHTMLChromeController() {}
+
+ virtual bool Init( const char *pchHTMLCacheDir, const char *pchCookiePath ) = 0;
+ virtual void Shutdown() = 0;
+ virtual bool RunFrame() = 0;
+
+
+ // set a cookie in the CEF instance. pchPath is typically "/". If nExpires is 0 then it is a session only cookie, other wise it is saved.
+ virtual void SetWebCookie( const char *pchHostname, const char *pchKey, const char *pchValue, const char *pchPath, RTime32 nExpires = 0 ) = 0;
+ virtual void GetWebCookiesForURL( CUtlString *pstrValue, const char *pchURL, const char *pchName ) = 0;
+
+ virtual void SetClientBuildID( uint64 ulBuildID ) = 0;
+
+ virtual bool BHasPendingMessages() = 0;
+
+ virtual void CreateBrowser( IHTMLResponses *pBrowser, bool bPopupWindow, const char *pchUserAgentIdentifier ) = 0;
+ virtual void RemoveBrowser( IHTMLResponses *pBrowser ) = 0;
+
+ virtual void WakeThread() = 0;
+ virtual HTMLCommandBuffer_t *GetFreeCommandBuffer( EHTMLCommands eCmd, int iBrowser ) = 0;
+ virtual void PushCommand( HTMLCommandBuffer_t * ) = 0;
+
+#ifdef DBGFLAG_VALIDATE
+ virtual void Validate( CValidator &validator, const char *pchName ) = 0;
+
+ virtual bool ChromePrepareForValidate() = 0;
+ virtual bool ChromeResumeFromValidate() = 0;
+#endif
+
+ virtual void SetCefThreadTargetFrameRate( uint32 nFPS ) = 0;
+};
+
+#define CHROMEHTML_CONTROLLER_INTERFACE_VERSION "ChromeHTML_Controller_001"
+
+
+#endif // ICHROMEHTMLWRAPPER_H \ No newline at end of file
diff --git a/sp/src/public/html/ihtmlchrome.h b/sp/src/public/html/ihtmlchrome.h
new file mode 100644
index 00000000..d39c987b
--- /dev/null
+++ b/sp/src/public/html/ihtmlchrome.h
@@ -0,0 +1,120 @@
+//========= Copyright Valve Corporation, All rights reserved. ============//
+//
+// Purpose:
+//=============================================================================//
+
+#ifndef IHTMLCHROME_H
+#define IHTMLCHROME_H
+
+#ifdef _WIN32
+#pragma once
+#endif
+
+#include "htmlmessages.h"
+#include "tier1/utlbuffer.h"
+
+// prototypes for all the protobuf messages, so we don't need to include all of protobuf
+class CMsgBrowserReady;
+class CMsgNeedsPaint;
+class CMsgStartRequest;
+class CMsgURLChanged;
+class CMsgFinishedRequest;
+class CMsgShowPopup;
+class CMsgHidePopup;
+class CMsgOpenNewTab;
+class CMsgPopupHTMLWindow;
+class CMsgSetHTMLTitle;
+class CMsgLoadingResource;
+class CMsgStatusText;
+class CMsgSetCursor;
+class CMsgFileLoadDialog;
+class CMsgShowToolTip;
+class CMsgUpdateToolTip;
+class CMsgHideToolTip;
+class CMsgSearchResults;
+class CMsgClose;
+class CMsgHorizontalScrollBarSizeResponse;
+class CMsgVerticalScrollBarSizeResponse;
+class CMsgGetZoomResponse;
+class CMsgLinkAtPositionResponse;
+class CMsgZoomToElementAtPositionResponse;
+class CMsgJSAlert;
+class CMsgJSConfirm;
+class CMsgCanGoBackAndForward;
+class CMsgOpenSteamURL;
+class CMsgSizePopup;
+class CMsgScalePageToValueResponse;
+class CMsgRequestFullScreen;
+class CMsgExitFullScreen;
+class CMsgGetCookiesForURLResponse;
+class CMsgNodeHasFocus;
+class CMsgSavePageToJPEGResponse;
+class CMsgFocusedNodeTextResponse;
+
+//-----------------------------------------------------------------------------
+// Purpose: a single IPC packet for the html thread (in and out)
+//-----------------------------------------------------------------------------
+struct HTMLCommandBuffer_t
+{
+ EHTMLCommands m_eCmd;
+ int m_iBrowser;
+ CUtlBuffer m_Buffer;
+#ifdef DBGFLAG_VALIDATE
+ virtual void Validate( CValidator &validator, const tchar *pchName )
+ {
+ VALIDATE_SCOPE();
+ ValidateObj( m_Buffer );
+ }
+#endif
+};
+
+
+//-----------------------------------------------------------------------------
+// Purpose: callback interfaces for messages from the html thread
+//-----------------------------------------------------------------------------
+class IHTMLResponses
+{
+public:
+ virtual ~IHTMLResponses() {}
+
+ virtual void BrowserSetIndex( int idx ) = 0;
+ virtual int BrowserGetIndex() = 0;
+ virtual void BrowserReady( const CMsgBrowserReady *pCmd ) = 0;
+ virtual void BrowserNeedsPaint( const CMsgNeedsPaint *pCmd ) = 0;
+ virtual void BrowserStartRequest( const CMsgStartRequest *pCmd ) = 0;
+ virtual void BrowserURLChanged( const CMsgURLChanged *pCmd ) = 0;
+ virtual void BrowserFinishedRequest( const CMsgFinishedRequest *pCmd ) = 0;
+ virtual void BrowserShowPopup( const CMsgShowPopup *pCmd ) = 0;
+ virtual void BrowserHidePopup( const CMsgHidePopup *pCmd ) = 0;
+ virtual void BrowserOpenNewTab( const CMsgOpenNewTab *pCmd ) = 0;
+ virtual void BrowserPopupHTMLWindow( const CMsgPopupHTMLWindow *pCmd ) = 0;
+ virtual void BrowserSetHTMLTitle( const CMsgSetHTMLTitle *pCmd ) = 0;
+ virtual void BrowserLoadingResource( const CMsgLoadingResource *pCmd ) = 0;
+ virtual void BrowserStatusText( const CMsgStatusText *pCmd ) = 0;
+ virtual void BrowserSetCursor( const CMsgSetCursor *pCmd ) = 0;
+ virtual void BrowserFileLoadDialog( const CMsgFileLoadDialog *pCmd ) = 0;
+ virtual void BrowserShowToolTip( const CMsgShowToolTip *pCmd ) = 0;
+ virtual void BrowserUpdateToolTip( const CMsgUpdateToolTip *pCmd ) = 0;
+ virtual void BrowserHideToolTip( const CMsgHideToolTip *pCmd ) = 0;
+ virtual void BrowserSearchResults( const CMsgSearchResults *pCmd ) = 0;
+ virtual void BrowserClose( const CMsgClose *pCmd ) = 0;
+ virtual void BrowserHorizontalScrollBarSizeResponse( const CMsgHorizontalScrollBarSizeResponse *pCmd ) = 0;
+ virtual void BrowserVerticalScrollBarSizeResponse( const CMsgVerticalScrollBarSizeResponse *pCmd ) = 0;
+ virtual void BrowserGetZoomResponse( const CMsgGetZoomResponse *pCmd ) = 0;
+ virtual void BrowserLinkAtPositionResponse( const CMsgLinkAtPositionResponse *pCmd ) = 0;
+ virtual void BrowserZoomToElementAtPositionResponse( const CMsgZoomToElementAtPositionResponse *pCmd ) = 0;
+ virtual void BrowserJSAlert( const CMsgJSAlert *pCmd ) = 0;
+ virtual void BrowserJSConfirm( const CMsgJSConfirm *pCmd ) = 0;
+ virtual void BrowserCanGoBackandForward( const CMsgCanGoBackAndForward *pCmd ) = 0;
+ virtual void BrowserOpenSteamURL( const CMsgOpenSteamURL *pCmd ) = 0;
+ virtual void BrowserSizePopup( const CMsgSizePopup *pCmd ) = 0;
+ virtual void BrowserScalePageToValueResponse( const CMsgScalePageToValueResponse *pCmd ) = 0;
+ virtual void BrowserRequestFullScreen( const CMsgRequestFullScreen *pCmd ) = 0;
+ virtual void BrowserExitFullScreen( const CMsgExitFullScreen *pCmd ) = 0;
+ virtual void BrowserGetCookiesForURLResponse( const CMsgGetCookiesForURLResponse *pCmd ) = 0;
+ virtual void BrowserNodeGotFocus( const CMsgNodeHasFocus *pCmd ) = 0;
+ virtual void BrowserSavePageToJPEGResponse( const CMsgSavePageToJPEGResponse *pCmd ) = 0;
+ virtual void BrowserFocusedNodeValueResponse( const CMsgFocusedNodeTextResponse *pCmd ) = 0;
+};
+
+#endif // IHTMLCHROME_H
diff --git a/sp/src/public/html/ipainthtml.h b/sp/src/public/html/ipainthtml.h
new file mode 100644
index 00000000..56af78b9
--- /dev/null
+++ b/sp/src/public/html/ipainthtml.h
@@ -0,0 +1,54 @@
+//========= Copyright Valve Corporation, All rights reserved. ============//
+//
+// Purpose:
+//
+// $NoKeywords: $
+//=============================================================================//
+#ifndef IPAINTHTML_H
+#define IPAINTHTML_H
+
+class IPaintHTML
+{
+public:
+ enum EPaintTarget
+ {
+ ePaintBrowser,
+ ePaintPopup,
+ ePaintMAX
+ };
+ // returns the texture id used, pass in -1 to create a new texture
+ virtual int DrawSubTextureRGBA( EPaintTarget eTarget, int textureID, int x, int y, const unsigned char *pRGBA, int updateWide, int updateTall, int fullTextureWide, int fullTextureTall ) = 0;
+ virtual void DeleteTexture( EPaintTarget eTarget, int textureID ) = 0;
+};
+
+class IInputEventHTML
+{
+public:
+ enum EMouseButton
+ {
+ eButtonLeft,
+ eButtonMiddle,
+ eButtonRight
+ };
+
+ virtual bool ChromeHandleMouseClick( EMouseButton eButton, bool bUp, int nClickCount ) = 0;
+ virtual bool ChromeHandleMouseMove( int x, int y ) = 0;
+ virtual bool ChromeHandleMouseWheel( int delta ) = 0;
+
+ enum EKeyType
+ {
+ KeyDown,
+ KeyUp,
+ Char
+ };
+ enum EKeyModifier
+ {
+ AltDown = 1,
+ CrtlDown = 2,
+ ShiftDown = 4,
+ };
+
+ virtual bool ChromeHandleKeyEvent( EKeyType type, int key, int modifiers, bool bKeyUp ) = 0;
+};
+
+#endif // IPAINTHTML_H \ No newline at end of file