Skip to content

Commit

Permalink
Implement a keyboard shortcut to open Streamus in a new tab
Browse files Browse the repository at this point in the history
  • Loading branch information
jcme committed May 2, 2015
1 parent 6ddda20 commit 6d458af
Show file tree
Hide file tree
Showing 3 changed files with 87 additions and 74 deletions.
3 changes: 2 additions & 1 deletion src/js/background/enum/chromeCommand.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@ define({
ToggleRepeat: 'toggleRepeat',
ToggleShuffle: 'toggleShuffle',
IncreaseVolume: 'increaseVolume',
DecreaseVolume: 'decreaseVolume'
DecreaseVolume: 'decreaseVolume',
OpenInTab: 'openInTab'
});
11 changes: 10 additions & 1 deletion src/js/background/model/tabManager.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
define(function() {
define(function(require) {
'use strict';

var ChromeCommand = require('background/enum/chromeCommand');

var TabManager = Backbone.Model.extend({
defaults: function() {
return {
Expand All @@ -14,6 +16,7 @@
initialize: function() {
this.listenTo(Streamus.channels.tab.commands, 'notify:youTube', this._notifyYouTube);
this.listenTo(Streamus.channels.tab.commands, 'notify:beatport', this._notifyBeatport);
chrome.commands.onCommand.addListener(this._onChromeCommandsCommand.bind(this));
},

isStreamusTabActive: function(callback) {
Expand Down Expand Up @@ -106,6 +109,12 @@
_highlightTabs: function(highlightInfo) {
// TODO: The callback will be optional once Google resolves https://code.google.com/p/chromium/issues/detail?id=417564
chrome.tabs.highlight(highlightInfo, _.noop);
},

_onChromeCommandsCommand: function (command) {
if (command === ChromeCommand.OpenInTab) {
this.showStreamusTab();
}
}
});

Expand Down
147 changes: 75 additions & 72 deletions src/manifest.json
Original file line number Diff line number Diff line change
@@ -1,81 +1,84 @@
{
"manifest_version": 2,
"name": "__MSG_extensionName__",
"short_name": "Streamus",
"version": "0.172",
"manifest_version": 2,
"name": "__MSG_extensionName__",
"short_name": "Streamus",
"version": "0.172",

"default_locale": "en",
"description": "__MSG_extensionDescription__",
"icons": {
"16": "img/streamus_icon16.png",
"48": "img/streamus_icon48.png",
"128": "img/streamus_icon128.png"
},
"description": "__MSG_extensionDescription__",
"icons": {
"16": "img/streamus_icon16.png",
"48": "img/streamus_icon48.png",
"128": "img/streamus_icon128.png"
},

"browser_action": {
"default_icon": {
"19": "img/yellow_2bar_19.png",
"38": "img/yellow_2bar_38.png"
},
"default_popup": "foreground.html"
},
"browser_action": {
"default_icon": {
"19": "img/yellow_2bar_19.png",
"38": "img/yellow_2bar_38.png"
},
"default_popup": "foreground.html"
},

"author": "Sean Anderson",
"background": {
"page": "background.html"
},
"author": "Sean Anderson",
"background": {
"page": "background.html"
},
"commands": {
"nextSong": {
"suggested_key": {
"default": "MediaNextTrack"
},
"description": "__MSG_nextSongCommandDescription__"
},
"previousSong": {
"suggested_key": {
"default": "MediaPrevTrack"
},
"description": "__MSG_previousSongCommandDescription__"
},
"toggleSong": {
"suggested_key": {
"default": "MediaPlayPause"
},
"description": "__MSG_toggleSongCommandDescription__"
},
"deleteSongFromStream": {
"description": "__MSG_deleteSongCommandDescription__"
},
"copySongUrl": {
"description": "__MSG_copySongUrlCommandDescription__"
},
"copySongTitleAndUrl": {
"description": "__MSG_copySongTitleUrlCommandDescription__"
},
"toggleRadio": {
"description": "__MSG_toggleRadioCommandDescription__"
},
"toggleShuffle": {
"description": "__MSG_toggleShuffleCommandDescription__"
},
"toggleRepeat": {
"description": "__MSG_toggleRepeatCommandDescription__"
},
"increaseVolume": {
"description": "__MSG_increaseVolumeCommandDescription__"
},
"decreaseVolume": {
"description": "__MSG_decreaseVolumeCommandDescription__"
},
"showActiveSong": {
"description": "__MSG_showActiveSongCommandDescription__"
},
"saveActiveSong": {
"description": "__MSG_saveActiveSongCommandDescription__"
},
"_execute_browser_action": {
}
},
"nextSong": {
"suggested_key": {
"default": "MediaNextTrack"
},
"description": "__MSG_nextSongCommandDescription__"
},
"previousSong": {
"suggested_key": {
"default": "MediaPrevTrack"
},
"description": "__MSG_previousSongCommandDescription__"
},
"toggleSong": {
"suggested_key": {
"default": "MediaPlayPause"
},
"description": "__MSG_toggleSongCommandDescription__"
},
"deleteSongFromStream": {
"description": "__MSG_deleteSongCommandDescription__"
},
"copySongUrl": {
"description": "__MSG_copySongUrlCommandDescription__"
},
"copySongTitleAndUrl": {
"description": "__MSG_copySongTitleUrlCommandDescription__"
},
"toggleRadio": {
"description": "__MSG_toggleRadioCommandDescription__"
},
"toggleShuffle": {
"description": "__MSG_toggleShuffleCommandDescription__"
},
"toggleRepeat": {
"description": "__MSG_toggleRepeatCommandDescription__"
},
"increaseVolume": {
"description": "__MSG_increaseVolumeCommandDescription__"
},
"decreaseVolume": {
"description": "__MSG_decreaseVolumeCommandDescription__"
},
"showActiveSong": {
"description": "__MSG_showActiveSongCommandDescription__"
},
"saveActiveSong": {
"description": "__MSG_saveActiveSongCommandDescription__"
},
"openInTab": {
"description": "__MSG_openInTab__"
},
"_execute_browser_action": {
}
},
"content_scripts": [
{
"matches": ["*://*.youtube.com/embed/*streamus=1*"],
Expand Down

0 comments on commit 6d458af

Please sign in to comment.