Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
1vanK committed Dec 7, 2019
0 parents commit 077f668
Show file tree
Hide file tree
Showing 245 changed files with 54,399 additions and 0 deletions.
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Рекурсивно игнорируем все файлы
ThirdParty/cef_win32/**

# но не директории
!ThirdParty/cef_win32/**/

# чтобы оставить файл
!ThirdParty/cef_win32/cmake/cef_variables.cmake
46 changes: 46 additions & 0 deletions Application/Application.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#include "Application.h"
#include "Client.h"

// CEF
#include <include/wrapper/cef_helpers.h>

// cmark-gfm
#include <../extensions/cmark-gfm-core-extensions.h>
#include <registry.h>


Application::Application()
{
// Регистрируем расширения cmark-gfm
cmark_gfm_core_extensions_ensure_registered();
}


Application::~Application()
{
// Уничтожаем все расширения cmark-gfm.
// Примечение: Должно быть вызвано после уничтожения всех документов
cmark_release_plugins();
}


static std::string GetUrl()
{
CefRefPtr<CefCommandLine> commandLine = CefCommandLine::GetGlobalCommandLine();
CefCommandLine::ArgumentList arguments;
commandLine->GetArguments(arguments);

if (!arguments.empty())
return arguments.front();

return "about:blank";
}


void Application::OnContextInitialized()
{
CEF_REQUIRE_UI_THREAD();

CefRefPtr<Client> client(new Client());
client->OpenNewWindow(GetUrl());
}
31 changes: 31 additions & 0 deletions Application/Application.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#pragma once

#include <include/cef_app.h>


// Все методы этого класса вызываются из главного процесса (browser process)
class Application
: public CefApp
, public CefBrowserProcessHandler
{
private:
// Реализуем счетчик ссылок
IMPLEMENT_REFCOUNTING(Application);

public:
Application();
~Application();

// =========== Методы CefApp

// Указываем, что реализованы обработчики CefBrowserProcessHandler
CefRefPtr<CefBrowserProcessHandler> GetBrowserProcessHandler() override
{
return this;
}

// =========== Методы CefBrowserProcessHandler

// Вызывается при старте главного процесса
void OnContextInitialized() override;
};
23 changes: 23 additions & 0 deletions Application/CefUtils.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#include "Client.h"

#include <include/cef_command_line.h>
#include <include/cef_parser.h>


std::string GetCurrentProcessType()
{
CefRefPtr<CefCommandLine> commandLine = CefCommandLine::GetGlobalCommandLine();

if (!commandLine->HasSwitch("type"))
return "browser";

return commandLine->GetSwitchValue("type");
}


std::string GetDataURI(const std::string& data, const std::string& mime_type)
{
return "data:" + mime_type + ";base64,"
+ CefURIEncode(CefBase64Encode(data.data(), data.size()), false)
.ToString();
}
12 changes: 12 additions & 0 deletions Application/CefUtils.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#pragma once

#include <string>


// Возвращает тип текущего процесса.
// Примечание: CEF запускает кучу процессов, выполняющих разные задачи
std::string GetCurrentProcessType();


// Кодирует содержимое страницы в адресе
std::string GetDataURI(const std::string& data, const std::string& mime_type);
Loading

0 comments on commit 077f668

Please sign in to comment.