Quick fix for undefined references to chrome.*
This commit is contained in:
parent
83d827c127
commit
95e809636a
1 changed files with 21 additions and 15 deletions
|
@ -19,7 +19,7 @@
|
||||||
self.tabs = tabs;
|
self.tabs = tabs;
|
||||||
|
|
||||||
self.setBadgeText = function (text) {
|
self.setBadgeText = function (text) {
|
||||||
if (chrome.browserAction && chrome.browserAction.setBadgeText) {
|
if (window.chrome && chrome.browserAction && chrome.browserAction.setBadgeText) {
|
||||||
chrome.browserAction.setBadgeText({text: String(text)});
|
chrome.browserAction.setBadgeText({text: String(text)});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -39,11 +39,11 @@
|
||||||
},
|
},
|
||||||
|
|
||||||
focus: function(id, callback) {
|
focus: function(id, callback) {
|
||||||
if (chrome.windows) {
|
if (window.chrome && chrome.windows) {
|
||||||
chrome.windows.update(id, { focused: true }, function() {
|
chrome.windows.update(id, { focused: true }, function() {
|
||||||
callback(chrome.runtime.lastError);
|
callback(chrome.runtime.lastError);
|
||||||
});
|
});
|
||||||
} else if (chrome.app.window) {
|
} else if (window.chrome && chrome.app.window) {
|
||||||
var appWindow = chrome.app.window.get(id);
|
var appWindow = chrome.app.window.get(id);
|
||||||
if (appWindow) {
|
if (appWindow) {
|
||||||
appWindow.show();
|
appWindow.show();
|
||||||
|
@ -73,13 +73,13 @@
|
||||||
|
|
||||||
getBackground: function(callback) {
|
getBackground: function(callback) {
|
||||||
var getBackground;
|
var getBackground;
|
||||||
if (chrome.extension) {
|
if (window.chrome && chrome.extension) {
|
||||||
var bg = chrome.extension.getBackgroundPage();
|
var bg = chrome.extension.getBackgroundPage();
|
||||||
bg.storage.onready(function() {
|
bg.storage.onready(function() {
|
||||||
callback(bg);
|
callback(bg);
|
||||||
resolve();
|
resolve();
|
||||||
});
|
});
|
||||||
} else if (chrome.runtime) {
|
} else if (window.chrome && chrome.runtime) {
|
||||||
chrome.runtime.getBackgroundPage(function(bg) {
|
chrome.runtime.getBackgroundPage(function(bg) {
|
||||||
bg.storage.onready(function() {
|
bg.storage.onready(function() {
|
||||||
callback(bg);
|
callback(bg);
|
||||||
|
@ -89,7 +89,11 @@
|
||||||
},
|
},
|
||||||
|
|
||||||
getAll: function() {
|
getAll: function() {
|
||||||
return chrome.app.window.getAll();
|
if (window.chrome) {
|
||||||
|
return chrome.app.window.getAll();
|
||||||
|
} else {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
getViews: function() {
|
getViews: function() {
|
||||||
|
@ -119,7 +123,7 @@
|
||||||
},
|
},
|
||||||
|
|
||||||
drawAttention: function(window_id) {
|
drawAttention: function(window_id) {
|
||||||
if (chrome.app.window) {
|
if (window.chrome && chrome.app.window) {
|
||||||
var w = chrome.app.window.get(window_id);
|
var w = chrome.app.window.get(window_id);
|
||||||
if (w) {
|
if (w) {
|
||||||
w.clearAttention();
|
w.clearAttention();
|
||||||
|
@ -129,7 +133,7 @@
|
||||||
},
|
},
|
||||||
|
|
||||||
clearAttention: function(window_id) {
|
clearAttention: function(window_id) {
|
||||||
if (chrome.app.window) {
|
if (window.chrome && chrome.app.window) {
|
||||||
var w = chrome.app.window.get(window_id);
|
var w = chrome.app.window.get(window_id);
|
||||||
if (w) {
|
if (w) {
|
||||||
w.clearAttention();
|
w.clearAttention();
|
||||||
|
@ -140,10 +144,10 @@
|
||||||
};
|
};
|
||||||
|
|
||||||
extension.onLaunched = function(callback) {
|
extension.onLaunched = function(callback) {
|
||||||
if (chrome.browserAction && chrome.browserAction.onClicked) {
|
if (window.chrome && chrome.browserAction && chrome.browserAction.onClicked) {
|
||||||
chrome.browserAction.onClicked.addListener(callback);
|
chrome.browserAction.onClicked.addListener(callback);
|
||||||
}
|
}
|
||||||
if (chrome.app && chrome.app.runtime) {
|
if (window.chrome && chrome.app && chrome.app.runtime) {
|
||||||
chrome.app.runtime.onLaunched.addListener(callback);
|
chrome.app.runtime.onLaunched.addListener(callback);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -183,7 +187,7 @@
|
||||||
extension.notification = {
|
extension.notification = {
|
||||||
init: function() {
|
init: function() {
|
||||||
// register some chrome listeners
|
// register some chrome listeners
|
||||||
if (chrome.notifications) {
|
if (window.chrome && chrome.notifications) {
|
||||||
chrome.notifications.onClicked.addListener(function() {
|
chrome.notifications.onClicked.addListener(function() {
|
||||||
extension.notification.clear();
|
extension.notification.clear();
|
||||||
Whisper.Notifications.onclick();
|
Whisper.Notifications.onclick();
|
||||||
|
@ -205,12 +209,14 @@
|
||||||
clear: function() {
|
clear: function() {
|
||||||
notification_pending = notification_pending.then(function() {
|
notification_pending = notification_pending.then(function() {
|
||||||
return new Promise(function(resolve) {
|
return new Promise(function(resolve) {
|
||||||
chrome.notifications.clear('signal', resolve);
|
if (window.chrome) {
|
||||||
|
chrome.notifications.clear('signal', resolve);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
update: function(options) {
|
update: function(options) {
|
||||||
if (chrome) {
|
if (window.chrome) {
|
||||||
var chromeOpts = {
|
var chromeOpts = {
|
||||||
type : options.type,
|
type : options.type,
|
||||||
title : options.title,
|
title : options.title,
|
||||||
|
@ -245,7 +251,7 @@
|
||||||
};
|
};
|
||||||
|
|
||||||
extension.keepAwake = function() {
|
extension.keepAwake = function() {
|
||||||
if (chrome && chrome.alarms) {
|
if (window.chrome && chrome && chrome.alarms) {
|
||||||
chrome.alarms.onAlarm.addListener(function() {
|
chrome.alarms.onAlarm.addListener(function() {
|
||||||
// nothing to do.
|
// nothing to do.
|
||||||
});
|
});
|
||||||
|
@ -253,7 +259,7 @@
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
if (chrome.runtime.onInstalled) {
|
if (window.chrome && chrome.runtime.onInstalled) {
|
||||||
chrome.runtime.onInstalled.addListener(function(options) {
|
chrome.runtime.onInstalled.addListener(function(options) {
|
||||||
if (options.reason === 'install') {
|
if (options.reason === 'install') {
|
||||||
console.log('new install');
|
console.log('new install');
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue