* extensions API.
*/
-cr.define('cr', function() {
-
- /**
- * The kind of link open we want to perform.
- * @enum {number}
- */
- var LinkKind = {
- FOREGROUND_TAB: 0,
- BACKGROUND_TAB: 1,
- WINDOW: 2,
- SELF: 3,
- INCOGNITO: 4
- };
+/**
+ * The kind of link open we want to perform.
+ * @enum {number}
+ */
+cr.LinkKind = {
+ FOREGROUND_TAB: 0,
+ BACKGROUND_TAB: 1,
+ WINDOW: 2,
+ SELF: 3,
+ INCOGNITO: 4
+};
+cr.define('cr', function() {
/**
* This class is used to handle opening of links based on user actions. The
* following actions are currently implemented:
* On Mac, uses Command instead of Ctrl.
* For keyboard support you need to use keydown.
*
- * @param {!LocalStrings} localStrings The local strings object which is used
+ * @param {!LoadTimeData} localStrings The local strings object which is used
* to localize the warning prompt in case the user tries to open a lot of
* links.
* @constructor
/**
* This method is used for showing the warning confirm message when the
* user is trying to open a lot of links.
- * @param {number} The number of URLs to open.
+ * @param {number} count The number of URLs to open.
* @return {string} The message to show the user.
*/
getWarningMessage: function(count) {
- return this.localStrings_.getStringF('should_open_all', count);
+ return this.localStrings_.getStringF('should_open_all', String(count));
},
/**
var ctrl = cr.isMac && e.metaKey || !cr.isMac && e.ctrlKey;
if (e.button == 1 || ctrl) // middle, ctrl or keyboard
- kind = e.shiftKey ? LinkKind.FOREGROUND_TAB : LinkKind.BACKGROUND_TAB;
+ kind = e.shiftKey ? cr.LinkKind.FOREGROUND_TAB :
+ cr.LinkKind.BACKGROUND_TAB;
else // left or keyboard
- kind = e.shiftKey ? LinkKind.WINDOW : LinkKind.SELF;
+ kind = e.shiftKey ? cr.LinkKind.WINDOW : cr.LinkKind.SELF;
this.openUrls([url], kind);
}
/**
* Opens a URL in a new tab, window or incognito window.
* @param {string} url The URL to open.
- * @param {LinkKind} kind The kind of open we want to do.
+ * @param {cr.LinkKind} kind The kind of open we want to do.
*/
openUrl: function(url, kind) {
this.openUrls([url], kind);
/**
* Opens URLs in new tab, window or incognito mode.
* @param {!Array.<string>} urls The URLs to open.
- * @param {LinkKind} kind The kind of open we want to do.
+ * @param {cr.LinkKind} kind The kind of open we want to do.
*/
openUrls: function(urls, kind) {
if (urls.length < 1)
return url[0] == '#' ? base + url : url;
});
- var incognito = kind == LinkKind.INCOGNITO;
- if (kind == LinkKind.WINDOW || incognito) {
+ var incognito = kind == cr.LinkKind.INCOGNITO;
+ if (kind == cr.LinkKind.WINDOW || incognito) {
chrome.windows.create({
url: urls,
incognito: incognito
});
- } else if (kind == LinkKind.FOREGROUND_TAB ||
- kind == LinkKind.BACKGROUND_TAB) {
+ } else if (kind == cr.LinkKind.FOREGROUND_TAB ||
+ kind == cr.LinkKind.BACKGROUND_TAB) {
urls.forEach(function(url, i) {
chrome.tabs.create({
url: url,
- selected: kind == LinkKind.FOREGROUND_TAB && !i
+ selected: kind == cr.LinkKind.FOREGROUND_TAB && !i
});
});
} else {
// Export
return {
LinkController: LinkController,
- LinkKind: LinkKind
};
});