forked from enyojs/ares-project
-
Notifications
You must be signed in to change notification settings - Fork 0
/
chrome-app.js
49 lines (44 loc) · 1.11 KB
/
chrome-app.js
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
/**
* Ares Chrome Packaged Application Background Page
*
* ares/ares-chrome-background.js
*/
/**
* Start and Open file handler
*
* http://developer.chrome.com/trunk/apps/app_intents.html#launching
*
* % chrome.exe --app-id [app_id] [path_to_file]
*
* This will implicity launch your application with an intent payload
* populated with the action set to "http://webintents.org/view", the
* type set to the mime-type of the file and the data as a FileEntry
* object.
*/
chrome.app.runtime.onLaunched.addListener(function(intent) {
var file;
// App Launched
console.log("launched, intent=");
console.dir(intent);
if (intent) {
file = intent.data;
console.error("file intents not implemented");
} else {
console.log("stating from scratch...");
chrome.tabs.create({
url: "ares/index.html",
active: true
}, function(tab) {
console.log("launched, tab=");
console.dir(tab);
});
}
});
chrome.runtime.onInstalled.addListener(function() {
// setup db
console.log("installed");
});
chrome.runtime.onSuspend.addListener(function() {
// close open connections
console.log("page closing...");
});