Skip to content

Commit

Permalink
Merge branch 'dev' into release-candidate
Browse files Browse the repository at this point in the history
  • Loading branch information
lucyhe committed Jul 27, 2015
2 parents 40c18be + 8fcf27b commit 6ca62b8
Show file tree
Hide file tree
Showing 22 changed files with 173 additions and 382 deletions.
14 changes: 14 additions & 0 deletions Gruntfile.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,8 @@ module.exports = (grunt) ->
'freedom-social-firebase/firebase.js'
'freedom-social-firebase/firebase-social-provider.js'
'freedom-social-firebase/facebook-social-provider.js'
'freedom-port-control/port-control.js'
'freedom-port-control/port-control.json'

'**/freedom-module.json'
'!generic_core/freedom-module.json'
Expand Down Expand Up @@ -454,6 +456,8 @@ module.exports = (grunt) ->
'data/freedom-social-firebase/firebase.js'
'data/freedom-social-firebase/firebase-social-provider.js'
'data/freedom-social-firebase/facebook-social-provider.js'
'data/freedom-port-control/port-control.js'
'data/freedom-port-control/port-control.json'

'data/**/freedom-module.json'
'!generic_core/freedom-module.json'
Expand Down Expand Up @@ -552,6 +556,11 @@ module.exports = (grunt) ->
src: ['**']
dest: chromeAppDevPath + '/freedom-social-firebase'
},
{
expand: true, cwd: 'node_modules/freedom-port-control/dist/',
src: ['**']
dest: chromeAppDevPath + '/freedom-port-control'
},
{ # uProxy Icons and fonts
expand: true, cwd: 'src/'
src: ['icons/128_online.png', 'fonts/*']
Expand Down Expand Up @@ -609,6 +618,11 @@ module.exports = (grunt) ->
src: ['**']
dest: firefoxDevPath + '/data/freedom-social-firebase'
},
{
expand: true, cwd: 'node_modules/freedom-port-control/dist/',
src: ['**']
dest: firefoxDevPath + '/data/freedom-port-control'
},
{ # lib
expand: true, cwd: devBuildPath
src: ['interfaces/*.js']
Expand Down
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "uProxy",
"version": "0.8.14",
"version": "0.8.15",
"dependencies": {
"polymer": "^0.5.6",
"paper-elements": "Polymer/paper-elements#^0.5.6",
Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "uProxy",
"description": "Share your pathway to the Internet",
"version": "0.8.14",
"version": "0.8.15",
"repository": {
"type": "git",
"url": "https://github.com/uproxy/uproxy"
Expand All @@ -20,10 +20,12 @@
"arraybuffer-slice": "^0.1.2",
"bower": "^1.4.1",
"circular-json": "^0.1.6",
"compare-version": "^0.1.2",
"crypto": "^0.0.3",
"es6-promise": "^2.0.0",
"freedom-for-chrome": "^0.4.11",
"freedom-for-firefox": "^0.6.13",
"freedom-port-control": "^0.9.0",
"freedom-social-firebase": "^1.0.1",
"freedom-social-xmpp": "^0.4.0",
"freedomjs-anonymized-metrics": "~0.1.0",
Expand Down
2 changes: 1 addition & 1 deletion src/chrome/app/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"name": "__MSG_appName__",
"description": "__MSG_appDescription__",
"minimum_chrome_version": "41.0.2272.63",
"version": "0.8.14",
"version": "0.8.15",
"default_locale": "en",
"icons": {
"128": "icons/128_online.png"
Expand Down
29 changes: 24 additions & 5 deletions src/chrome/app/scripts/chrome_ui_connector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ class ChromeUIConnector {
// Until the extension is connected, we assume uProxy installation is
// incomplete.
chrome.app.runtime.onLaunched.addListener(this.launchInstallIncompletePage_);

chrome.runtime.onUpdateAvailable.addListener((details) => {
this.sendToCore_(uproxy_core_api.Command.HANDLE_CORE_UPDATE,
{version: details.version});
});
}

// Launch a popup instructing the user to install the extension.
Expand Down Expand Up @@ -86,7 +91,6 @@ class ChromeUIConnector {
// This usually installs freedom handlers.
private onExtMsg_ = (msg :browser_connector.Payload) => {
console.log('[chrome ui connector] Extension message: ', uproxy_core_api.Command[msg.type]);
var msgType = '' + msg.type;
// Pass 'emit's from the UI to Core.
if ('emit' == msg.cmd) {
if (msg.type == uproxy_core_api.Command.SEND_CREDENTIALS) {
Expand All @@ -95,25 +99,40 @@ class ChromeUIConnector {
if (msg.type == uproxy_core_api.Command.RESTART) {
chrome.runtime.reload();
}
this.uProxyAppChannel_.emit(msgType,
{data: msg.data, promiseId: msg.promiseId});
this.sendToCore_(msg.type, msg.data, msg.promiseId);

// Install onUpdate handlers by request from the UI.
} else if ('on' == msg.cmd) {
if (installedFreedomHooks.indexOf(msg.type) >= 0) {
console.error('[chrome ui connector] Freedom already has a hook for ' +
console.warn('[chrome ui connector] Freedom already has a hook for ' +
uproxy_core_api.Command[msg.type]);
return;
}
installedFreedomHooks.push(msg.type);
// When it fires, send data back over Chrome App -> Extension port.
this.uProxyAppChannel_.on(msgType, (ret :string) => {
this.uProxyAppChannel_.on(msg.type.toString(), (ret :string) => {
this.sendToUI(msg.type, ret);
});
}
}

private sendToCore_ = (msgType :uproxy_core_api.Command, data :Object,
promiseId?:Number) => {
if (typeof promiseId === 'undefined') {
// promiseId of 0 is used for commands with no associated promise
promiseId = 0;
}

this.uProxyAppChannel_.emit(msgType.toString(),
{data: data, promiseId: promiseId});
}

public sendToUI = (type :uproxy_core_api.Update, data?:Object) => {
if (!this.extPort_) {
console.error('Trying to send a message without the UI being connected');
return;
}

this.extPort_.postMessage({
cmd: 'fired',
type: type,
Expand Down
4 changes: 3 additions & 1 deletion src/chrome/app/scripts/main.core-env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ freedom('generic_core/freedom-module.json', {
'oauth': [() => { return new Chrome_oauth(oauthOptions); }]
}).then((uProxyModuleFactory:OnEmitModuleFactory) => {
uProxyAppChannel = uProxyModuleFactory();
oauthOptions.connector = new ChromeUIConnector(uProxyAppChannel);
var chromeUIConnector = new ChromeUIConnector(uProxyAppChannel);

oauthOptions.connector = chromeUIConnector;
});

// Reply to pings from the uproxy website that are checking if the
Expand Down
2 changes: 1 addition & 1 deletion src/chrome/extension/manifest.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "__MSG_extName__",
"version": "0.8.14",
"version": "0.8.15",
"manifest_version": 2,
"description": "__MSG_extDescription__",
"minimum_chrome_version": "41.0.2272.63",
Expand Down
26 changes: 26 additions & 0 deletions src/chrome/extension/scripts/background.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
// Assumes that core_stub.ts has been loaded.
// UserInterface is defined in 'generic_ui/scripts/ui.ts'.

/// <reference path='../../../../../third_party/typings/compare-version/compare-version.d.ts'/>

import ChromeBrowserApi = require('./chrome_browser_api');
import ChromeCoreConnector = require('./chrome_core_connector');
import ChromeTabAuth = require('./chrome_tab_auth');
Expand All @@ -16,6 +18,7 @@ import user_interface = require('../../../generic_ui/scripts/ui');
import CoreConnector = require('../../../generic_ui/scripts/core_connector');
import uproxy_core_api = require('../../../interfaces/uproxy_core_api');
import Constants = require('../../../generic_ui/scripts/constants');
import compareVersion = require('compare-version');

/// <reference path='../../../freedom/typings/social.d.ts' />
/// <reference path='../../../third_party/typings/chrome/chrome.d.ts'/>
Expand Down Expand Up @@ -57,6 +60,29 @@ chrome.runtime.onMessageExternal.addListener((request :any, sender :chrome.runti
return true;
});

chrome.runtime.onUpdateAvailable.addListener((details) => {
console.log('Update available');

core.getVersion().then(function(versions) {
if (compareVersion(details.version, versions.version) > 0) {
// Only update if the new version is the same as or older than the app
// version. If we are not able to update now, this will be taken care of
// by restarting at the same time as the core update.
return;
}

chrome.proxy.settings.get({}, (details) => {
if (details.levelOfControl === 'controlled_by_this_extension') {
return;
}

// At this point, the core supports the update and we are not currently
// proxying, let's do the update!
chrome.runtime.reload();
});
});
});

/**
* Primary initialization of the Chrome Extension. Installs hooks so that
* updates from the Chrome App side propogate to the UI.
Expand Down
2 changes: 1 addition & 1 deletion src/firefox/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"description": "This is the alpha version of uProxy.",
"author": "uProxy Team <[email protected]>",
"license": "Apache 2.0",
"version": "0.8.14",
"version": "0.8.15",
"permissions": {
"private-browsing": true
}
Expand Down
4 changes: 4 additions & 0 deletions src/generic_core/dev_build/freedom-module.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@
"churnPipe": {
"url": "../uproxy-lib/churn-pipe/freedom-module.json",
"api": "churnPipe"
},
"portControl": {
"url": "../freedom-port-control/port-control.json",
"api": "portControl"
}
},
"permissions": [
Expand Down
Loading

0 comments on commit 6ca62b8

Please sign in to comment.