Skip to content
This repository has been archived by the owner on Nov 15, 2017. It is now read-only.

Commit

Permalink
this fixes #207
Browse files Browse the repository at this point in the history
  • Loading branch information
gorhill committed Mar 15, 2014
1 parent 29b4d05 commit 9fc372b
Show file tree
Hide file tree
Showing 4 changed files with 85 additions and 18 deletions.
1 change: 1 addition & 0 deletions background.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,6 @@
<script src="js/contextmenu.js"></script>
<script src="js/contentscripthandlers.js"></script>
<script src="js/start.js"></script>
<script src="js/install.js"></script>
</body>
</html>
83 changes: 83 additions & 0 deletions js/install.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
/*******************************************************************************
httpswitchboard - a Chromium browser extension to black/white list requests.
Copyright (C) 2013 Raymond Hill
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see {http://www.gnu.org/licenses/}.
Home: https://github.com/gorhill/httpswitchboard
*/

/******************************************************************************/

/******************************************************************************/

// Local scope

(function() {

/******************************************************************************/

var firstInstall = false;
var presetsLoaded = false;

/******************************************************************************/

var onInstalledHandler = function(details) {
if ( details.reason !== 'install' ) {
return;
}
firstInstall = true;
operaFirstInstall();
};

chrome.runtime.onInstalled.addListener(onInstalledHandler);

/******************************************************************************/

var onMessageHandler = function(request) {
if ( !request || !request.what || request.what !== '1stPartyPresetRecipesLoaded' ) {
return;
}
presetsLoaded = true;
operaFirstInstall();
};

chrome.runtime.onMessage.addListener(onMessageHandler);

/******************************************************************************/

var operaFirstInstall = function() {
if ( !firstInstall || !presetsLoaded ) {
return;
}

chrome.runtime.onMessage.removeListener(onMessageHandler);
chrome.runtime.onInstalled.removeListener(onInstalledHandler);

// rhill 2014-01-29: Opera requires that Youtube works out-of-the-box.
// Actually, why not do that for everybody, not just Opera.
var httpsb = HTTPSB;
if ( httpsb.isOpera() ) {
httpsb.presetManager.applyFromPresetName('Youtube');
httpsb.commitPermissions(true);
}
};

/******************************************************************************/

})();

/******************************************************************************/

17 changes: 0 additions & 17 deletions js/start.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,20 +168,3 @@ function clearBrowserCacheCallback() {

asyncJobQueue.add('clearBrowserCache', null, clearBrowserCacheCallback, 15 * 60 * 1000, true);

/******************************************************************************/

function onInstalledHandler(details) {
if ( details.reason !== 'install' ) {
return;
}
var httpsb = HTTPSB;
// rhill 2014-01-29: Opera requires that Youtube works out-of-the-box.
// Actually, why not do that for everybody, not just Opera.
if ( httpsb.isOpera() ) {
httpsb.presetManager.applyFromPresetName('Youtube');
httpsb.commitPermissions(true);
}
}

chrome.runtime.onInstalled.addListener(onInstalledHandler);

2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"manifest_version": 2,
"name": "__MSG_extName__",
"short_name": "HTTPSB",
"version": "0.8.5.3",
"version": "0.8.5.4",
"description": "__MSG_extShortDesc__",
"icons": {
"16": "icon_16.png",
Expand Down

0 comments on commit 9fc372b

Please sign in to comment.