-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.cpp
executable file
·66 lines (48 loc) · 2.05 KB
/
App.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
//
// Created by Bartłomiej Grzesik on 11/04/2018.
//
#include "App.hpp"
#include "Handler.hpp"
#include "OSXHelper.h"
#include "JSAudioNoob.hpp"
#include "JSWAVHelper.hpp"
#include <iostream>
#include <include/wrapper/cef_helpers.h>
#include <include/views/cef_window_delegate.h>
#include <include/views/cef_browser_view.h>
#include <include/views/cef_window.h>
CefRefPtr<CefBrowserProcessHandler> App::GetBrowserProcessHandler() {
return this;
}
void App::OnContextInitialized() {
CEF_REQUIRE_UI_THREAD();
NSWindow *window = CreateView();
CefBrowserSettings settings;
CefWindowInfo window_info;
window_info.x = 100;
window_info.y = 100;
window_info.width = 1280;
window_info.height = 800;
window_info.SetAsChild(GetContentView(window), 0, 0, 1280, 800);
std::string file = "file://" + std::string(args_.argv[0]) + "/../../Resources/index.html";
std::cout << file << std::endl << std::flush;
CefBrowserHost::CreateBrowser(window_info, Handler::GetHandler(), file, settings, nullptr);
}
void App::OnRegisterCustomSchemes(CefRawPtr<CefSchemeRegistrar> registrar) {
}
App::App(CefMainArgs &args): args_(args) {
}
CefRefPtr<CefRenderProcessHandler> App::GetRenderProcessHandler() {
return this;
}
void App::OnContextCreated(CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame, CefRefPtr<CefV8Context> context) {
const CefRefPtr<CefV8Value> &global = context->GetGlobal();
const CefRefPtr<CefV8Value> &audio_noob = CefV8Value::CreateObject(NULL, NULL);
JSAudioNoob *js_audio_noob = new JSAudioNoob();
audio_noob->SetValue("new", CefV8Value::CreateFunction("new", js_audio_noob), V8_PROPERTY_ATTRIBUTE_NONE);
global->SetValue("AudioNoob", audio_noob, V8_PROPERTY_ATTRIBUTE_NONE);
const CefRefPtr<CefV8Value> &wav_helper = CefV8Value::CreateObject(NULL, NULL);
JSWAVHelper *js_wav_helper = new JSWAVHelper();
wav_helper->SetValue("new", CefV8Value::CreateFunction("new", js_wav_helper), V8_PROPERTY_ATTRIBUTE_NONE);
global->SetValue("WAVHelper", wav_helper, V8_PROPERTY_ATTRIBUTE_NONE);
}