Skip to content

Commit

Permalink
WIP adding Chrome extensions
Browse files Browse the repository at this point in the history
  • Loading branch information
Lecrapouille committed Apr 24, 2022
1 parent dea5fca commit 55c1070
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 0 deletions.
7 changes: 7 additions & 0 deletions gdcef/src/browser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,13 @@ int BrowserView::init(godot::String const& url, CefBrowserSettings const& settin
<< get_name().utf8().get_data()
<< " succeeded");
m_browser->GetHost()->WasResized();

// Load extension
//ClientRequestContextHandler* toto = new ClientRequestContextHandler();
m_browser->GetHost()->GetRequestContext()->LoadExtension(
"/home/qq/workspace_stigmee/packages/stigmark/ext/chrome-edge-brave/", nullptr,
new ClientRequestContextHandler()
);
}

return m_id;
Expand Down
41 changes: 41 additions & 0 deletions gdcef/src/browser.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@
# include "GlobalConstants.hpp"

// Chromium Embedded Framework
# include "cef_request_context_handler.h"
# include "cef_extension_handler.h"
# include "cef_render_handler.h"
# include "cef_client.h"
# include "cef_app.h"
Expand All @@ -59,6 +61,45 @@
# include <iostream>
# include <array>

// ****************************************************************************
//! \brief
// ****************************************************************************
class ClientRequestContextHandler : //public CefRequestContextHandler,
public CefExtensionHandler
{
public:

ClientRequestContextHandler() {}

/*private: // CefRequestContextHandler interfaces
virtual void OnRequestContextInitialized(CefRefPtr<CefRequestContext> request_context) override
{
CEF_REQUIRE_UI_THREAD();
request_context->LoadExtension("/home/qq/workspace_stigmee/packages/stigmark/ext/chrome-edge-brave/", nullptr, this);
}
*/
private: // CefExtensionHandler interfaces

virtual void OnExtensionLoaded(CefRefPtr<CefExtension> extension) override
{
CEF_REQUIRE_UI_THREAD();
std::cout << "OnExtensionLoadeddddd :)" << std::endl;
//MainContext::Get()->GetRootWindowManager()->AddExtension(extension);
}

virtual void OnExtensionLoadFailed(cef_errorcode_t result) override
{
CEF_REQUIRE_UI_THREAD();
std::cout << "OnExtensionLoadFailed" << std::endl;
}

private:

IMPLEMENT_REFCOUNTING(ClientRequestContextHandler);
DISALLOW_COPY_AND_ASSIGN(ClientRequestContextHandler);
};

// ****************************************************************************
//! \brief Class wrapping the CefBrowser class and export methods for Godot
//! script. This class is instanciate by GDCef.
Expand Down

0 comments on commit 55c1070

Please sign in to comment.