Skip to content

Commit

Permalink
https://github.com/MTASZTAKI/ApertusVR/issues/59
Browse files Browse the repository at this point in the history
Signed-off-by: Peter Kovacs <peter.kovacs@sztaki.mta.hu>
  • Loading branch information
Peter Kovacs committed Nov 30, 2017
1 parent 64b4af3 commit 365609d
Show file tree
Hide file tree
Showing 8 changed files with 127 additions and 3 deletions.
5 changes: 4 additions & 1 deletion plugins/cefBrowser/ApeCefBrowserPlugin.cpp
Expand Up @@ -29,6 +29,7 @@ Ape::CefBrowserPlugin::CefBrowserPlugin()
mpSystemConfig = Ape::ISystemConfig::getSingletonPtr();
mpMainWindow = Ape::IMainWindow::getSingletonPtr();
mpApeCefRenderHandlerImpl = nullptr;
mpApeCefLifeSpanHandlerImpl = nullptr;
mApeCefClientImpl = nullptr;
mBrowserCounter = 0;
mCefIsInintialzed = false;
Expand All @@ -45,6 +46,7 @@ Ape::CefBrowserPlugin::~CefBrowserPlugin()
std::cout << "ApeCefBrowserPlugin dtor" << std::endl;
mApeCefClientImpl = nullptr;
delete mpApeCefRenderHandlerImpl;
delete mpApeCefLifeSpanHandlerImpl;
}

void Ape::CefBrowserPlugin::processEvent(Ape::Event event)
Expand Down Expand Up @@ -185,7 +187,8 @@ void Ape::CefBrowserPlugin::Init()
if (CefInitialize(main_args, settings, nullptr, nullptr))
{
mpApeCefRenderHandlerImpl = new Ape::CefRenderHandlerImpl();
mApeCefClientImpl = new Ape::CefClientImpl(mpApeCefRenderHandlerImpl);
mpApeCefLifeSpanHandlerImpl = new Ape::CefLifeSpanHandlerImpl();
mApeCefClientImpl = new Ape::CefClientImpl(mpApeCefRenderHandlerImpl, mpApeCefLifeSpanHandlerImpl);
mCefIsInintialzed = true;
}
}
Expand Down
3 changes: 3 additions & 0 deletions plugins/cefBrowser/ApeCefBrowserPlugin.h
Expand Up @@ -46,6 +46,7 @@ SOFTWARE.*/
#include "ApeIManualTexture.h"
#include "ApeIManualPass.h"
#include "ApeCefRenderHandlerImpl.h"
#include "ApeCefLifeSpanHandlerImpl.h"
#include "ApeCefClientImpl.h"
#include "ApeDoubleQueue.h"
#include "ApeIRayGeometry.h"
Expand Down Expand Up @@ -83,6 +84,8 @@ namespace Ape
Ape::IEventManager* mpEventManager;

Ape::CefRenderHandlerImpl* mpApeCefRenderHandlerImpl;

Ape::CefLifeSpanHandlerImpl* mpApeCefLifeSpanHandlerImpl;

int mBrowserCounter;

Expand Down
7 changes: 6 additions & 1 deletion plugins/cefBrowser/ApeCefClientImpl.cpp
Expand Up @@ -22,7 +22,7 @@ SOFTWARE.*/

#include "ApeCefClientImpl.h"

Ape::CefClientImpl::CefClientImpl(Ape::CefRenderHandlerImpl *cefRenderHandlerImpl) : mCefRenderHandlerImpl(cefRenderHandlerImpl)
Ape::CefClientImpl::CefClientImpl(Ape::CefRenderHandlerImpl* cefRenderHandlerImpl, Ape::CefLifeSpanHandlerImpl* cefLifeSpanHandlerImpl) : mCefRenderHandlerImpl(cefRenderHandlerImpl), mCefLifeSpanHandlerImpl(cefLifeSpanHandlerImpl)
{

}
Expand All @@ -37,6 +37,11 @@ CefRefPtr<CefRenderHandler> Ape::CefClientImpl::GetRenderHandler()
return mCefRenderHandlerImpl;
}

CefRefPtr<CefLifeSpanHandler> Ape::CefClientImpl::GetLifeSpanHandler()
{
return mCefLifeSpanHandlerImpl;
}

bool Ape::CefClientImpl::OnProcessMessageReceived(CefRefPtr<CefBrowser> browser, CefProcessId source_process, CefRefPtr<CefProcessMessage> message)
{
const std::string& message_name = message->GetName();
Expand Down
8 changes: 7 additions & 1 deletion plugins/cefBrowser/ApeCefClientImpl.h
Expand Up @@ -29,7 +29,9 @@ SOFTWARE.*/
#include "cef_app.h"
#include "cef_client.h"
#include "cef_render_handler.h"
#include "cef_life_span_handler.h"
#include "ApeCefRenderHandlerImpl.h"
#include "ApeCefLifeSpanHandlerImpl.h"

namespace Ape
{
Expand All @@ -38,13 +40,17 @@ namespace Ape
private:
CefRefPtr<CefRenderHandler> mCefRenderHandlerImpl;

CefRefPtr<CefLifeSpanHandler> mCefLifeSpanHandlerImpl;

public:
CefClientImpl(Ape::CefRenderHandlerImpl *cefRenderHandlerImpl);
CefClientImpl(Ape::CefRenderHandlerImpl *cefRenderHandlerImpl, Ape::CefLifeSpanHandlerImpl* cefLifeSpanHandlerImpl);

~CefClientImpl();

virtual CefRefPtr<CefRenderHandler> GetRenderHandler();

virtual CefRefPtr<CefLifeSpanHandler> GetLifeSpanHandler();

virtual bool OnProcessMessageReceived(CefRefPtr<CefBrowser> browser, CefProcessId source_process, CefRefPtr<CefProcessMessage> message);

IMPLEMENT_REFCOUNTING(CefClientImpl);
Expand Down
49 changes: 49 additions & 0 deletions plugins/cefBrowser/ApeCefLifeSpanHandlerImpl.cpp
@@ -0,0 +1,49 @@
/*MIT License
Copyright (c) 2016 MTA SZTAKI
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.*/

#include "ApeCefLifeSpanHandlerImpl.h"

Ape::CefLifeSpanHandlerImpl::CefLifeSpanHandlerImpl()
{

}

Ape::CefLifeSpanHandlerImpl::~CefLifeSpanHandlerImpl()
{

}

void Ape::CefLifeSpanHandlerImpl::OnAfterCreated(CefRefPtr<CefBrowser> browser)
{

}

bool Ape::CefLifeSpanHandlerImpl::OnBeforePopup(CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame, const CefString & target_url,
const CefString & target_frame_name, WindowOpenDisposition target_disposition, bool user_gesture, const CefPopupFeatures & popupFeatures,
CefWindowInfo & windowInfo, CefRefPtr<CefClient>& client, CefBrowserSettings & settings, bool * no_javascript_access)
{
windowInfo.SetAsWindowless(0);
//target_disposition = WindowOpenDisposition::WOD_CURRENT_TAB;
browser->GetMainFrame()->LoadURL(target_url);
//std::cout << "Ape:::CefLifeSpanHandlerImpl::OnBeforePopup " << turl << " id:" << browser->GetIdentifier() << std::endl;
return false;
}
53 changes: 53 additions & 0 deletions plugins/cefBrowser/ApeCefLifeSpanHandlerImpl.h
@@ -0,0 +1,53 @@
/*MIT License
Copyright (c) 2016 MTA SZTAKI
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.*/

#ifndef APE_CEFLIFESPANHANDLERIMPL_H
#define APE_CEFLIFESPANHANDLERIMPL_H

#include <iostream>
#include <string>
#include <thread>
#include "cef_app.h"
#include "cef_client.h"
#include "cef_life_span_handler.h"
#include "ApeIManualTexture.h"

namespace Ape
{
class CefLifeSpanHandlerImpl : public CefLifeSpanHandler
{
public:
CefLifeSpanHandlerImpl();

~CefLifeSpanHandlerImpl();

void OnAfterCreated(CefRefPtr<CefBrowser> browser) override;

bool OnBeforePopup(CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame, const CefString& target_url, const CefString& target_frame_name,
WindowOpenDisposition target_disposition, bool user_gesture, const CefPopupFeatures& popupFeatures, CefWindowInfo& windowInfo, CefRefPtr<CefClient>& client,
CefBrowserSettings& settings, bool* no_javascript_access) override;

IMPLEMENT_REFCOUNTING(CefLifeSpanHandlerImpl);
};
}

#endif
3 changes: 3 additions & 0 deletions plugins/cefBrowser/ApeCefRenderHandlerImpl.cpp
Expand Up @@ -64,7 +64,10 @@ void Ape::CefRenderHandlerImpl::setZoomLevel(int browserID, int zoomLevel)
void Ape::CefRenderHandlerImpl::setURL(int browserID, std::string url)
{
if (mBrowsers.size() && mBrowsers[browserID])
{
mBrowsers[browserID]->GetMainFrame()->LoadURL(url);
//std::cout << "Ape:::CefRenderHandlerImpl::setURL " << mBrowsers[browserID]->GetIdentifier() << " go to:" << url << std::endl;
}
}

void Ape::CefRenderHandlerImpl::mouseClick(int browserID, CefBrowserHost::MouseButtonType mouseButtonType)
Expand Down
2 changes: 2 additions & 0 deletions plugins/cefBrowser/CMakeLists.txt
Expand Up @@ -155,11 +155,13 @@ set (HEADERS
ApeCefBrowserPlugin.h
ApeCefClientImpl.h
ApeCefRenderHandlerImpl.h
ApeCefLifeSpanHandlerImpl.h
)
set (SOURCES
ApeCefBrowserPlugin.cpp
ApeCefClientImpl.cpp
ApeCefRenderHandlerImpl.cpp
ApeCefLifeSpanHandlerImpl.cpp
)
include_directories(
${PROJECT_SOURCE_DIR}/common/include
Expand Down

0 comments on commit 365609d

Please sign in to comment.