Skip to content

Commit

Permalink
several improvements to DO overlay
Browse files Browse the repository at this point in the history
- Use promises to prevent race conditions.
- Introduce a new `shouldHijackDO` global setting, which DO content script
  checks before proceeding. We can toggle that to false whenever we should no
  longer hijack DigitalOcean, e.g. once the user has completed cloud setup.
- Actually check the `activePromoId` global setting to determine whether to
  include the promo code text input in our overlay. Previously we were always
  including it.
- Enable i18n in the overlay.
  • Loading branch information
jab committed May 21, 2016
1 parent 76ef221 commit 2d19292
Show file tree
Hide file tree
Showing 7 changed files with 332 additions and 261 deletions.
16 changes: 14 additions & 2 deletions src/chrome/extension/scripts/background.ts
Expand Up @@ -36,19 +36,31 @@ chrome.runtime.onSuspend.addListener(() => {
});

chrome.runtime.onMessage.addListener((request :any, sender: chrome.runtime.MessageSender, sendResponse :Function) => {
if (!request) return;

// handle requests from other pages (i.e. copypaste.html) to bring the
// chrome popup to the front
if (request && request.openWindow) {
if (request.openWindow) {
browserApi.bringUproxyToFront();
}

// handle requests to get logs
if (request && request.getLogs) {
if (request.getLogs) {
core.getLogs().then((logs) => {
sendResponse({ logs: logs });
});
return true;
}

if (request.globalSettingsRequest) {
browserApi.emit('globalSettingsRequest', sendResponse);
return true;
}

if (request.translations) {
browserApi.emit('translationsRequest', request.translations, sendResponse);
return true;
}
});

chrome.runtime.onMessageExternal.addListener((request :any, sender :chrome.runtime.MessageSender, sendResponse :Function) => {
Expand Down
1 change: 1 addition & 0 deletions src/generic_core/globals.ts
Expand Up @@ -57,6 +57,7 @@ export var settings :uproxy_core_api.GlobalSettings = {
enforceProxyServerValidity: false,
validProxyServers: [],
activePromoId: null, // set on promoIdDetected
shouldHijackDO: true,
crypto: true
};

Expand Down
21 changes: 21 additions & 0 deletions src/generic_ui/locales/en/messages.json
Expand Up @@ -1422,5 +1422,26 @@
"HAVE_PROMO_CODE": {
"description": "Label for a checkbox indicating that you have a promo code",
"message": "I have a promo code"
},
"AUTHORIZE_DIGITALOCEAN": {
"message": "Authorize uProxy to connect with DigitalOcean"
},
"PROCEED_TO_UPROXY": {
"message": "Proceed to uProxy"
},
"ENTER_PROMO": {
"message": "Have a promo code? Enter it here."
},
"PROMO_ACCEPTED": {
"message": "Promo code accepted!"
},
"PROMO_FAILED": {
"message": "Could not apply promo code."
},
"PROCESSING": {
"message": "processing..."
},
"APPLY": {
"message": "Apply"
}
}

0 comments on commit 2d19292

Please sign in to comment.