-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy paththoriumAPI.cpp
69 lines (58 loc) · 2.34 KB
/
thoriumAPI.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
65
66
67
68
69
/**********************************************************\
Auto-generated thoriumAPI.cpp
\**********************************************************/
#include "JSObject.h"
#include "variant_list.h"
#include "DOM/Document.h"
#include "thoriumAPI.h"
#include "modules/filesystem/filesystem.h"
#include "modules/network/network_api.h"
///////////////////////////////////////////////////////////////////////////////
/// @fn thoriumAPI::thoriumAPI(thoriumPtr plugin, FB::BrowserHostPtr host)
///
/// @brief Constructor for your JSAPI object. You should register your methods, properties, and events
/// that should be accessible to Javascript from here.
///
/// @see FB::JSAPIAuto::registerMethod
/// @see FB::JSAPIAuto::registerProperty
/// @see FB::JSAPIAuto::registerEvent
///////////////////////////////////////////////////////////////////////////////
thoriumAPI::thoriumAPI(thoriumPtr plugin, FB::BrowserHostPtr host) : m_plugin(plugin), m_host(host)
{
registerProperty("filesystem", make_property(this, &thoriumAPI::getFilesystemAPI));
registerProperty("network", make_property(this, &thoriumAPI::getNetworkAPI));
}
///////////////////////////////////////////////////////////////////////////////
/// @fn thoriumAPI::~thoriumAPI()
///
/// @brief Destructor. Remember that this object will not be released until
/// the browser is done with it; this will almost definitely be after
/// the plugin is released.
///////////////////////////////////////////////////////////////////////////////
thoriumAPI::~thoriumAPI()
{
}
///////////////////////////////////////////////////////////////////////////////
/// @fn thoriumPtr thoriumAPI::getPlugin()
///
/// @brief Gets a reference to the plugin that was passed in when the object
/// was created. If the plugin has already been released then this
/// will throw a FB::script_error that will be translated into a
/// javascript exception in the page.
///////////////////////////////////////////////////////////////////////////////
thoriumPtr thoriumAPI::getPlugin()
{
thoriumPtr plugin(m_plugin.lock());
if (!plugin) {
throw FB::script_error("The plugin is invalid");
}
return plugin;
}
FB::JSAPIPtr thoriumAPI::getFilesystemAPI()
{
return th::Filesystem::getInstance();
}
FB::JSAPIPtr thoriumAPI::getNetworkAPI()
{
return th::NetworkAPI::getInstance();
}