Option preference page on install.

This commit is contained in:
Alex Yatskov 2016-06-03 21:17:55 -07:00
parent e19f955399
commit 14fd0d6514

View File

@ -37,18 +37,24 @@ class Yomichan {
this.asyncPools = {}; this.asyncPools = {};
this.setState('disabled'); this.setState('disabled');
loadOptions((opts) => { chrome.runtime.onInstalled.addListener(this.onInstalled.bind(this));
this.setOptions(opts);
chrome.runtime.onMessage.addListener(this.onMessage.bind(this)); chrome.runtime.onMessage.addListener(this.onMessage.bind(this));
chrome.browserAction.onClicked.addListener(this.onBrowserAction.bind(this)); chrome.browserAction.onClicked.addListener(this.onBrowserAction.bind(this));
loadOptions((opts) => {
this.setOptions(opts);
if (this.options.activateOnStartup) { if (this.options.activateOnStartup) {
this.setState('loading'); this.setState('loading');
} }
}); });
} }
onInstalled(details) {
if (details.reason === 'install') {
chrome.runtime.openOptionsPage();
}
}
onMessage(request, sender, callback) { onMessage(request, sender, callback) {
const {action, params} = request, method = this['api_' + action]; const {action, params} = request, method = this['api_' + action];