Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5974)

Unified Diff: chrome/browser/resources/mobile_setup.js

Issue 8341037: Added logic that will retry to reload+reconnect the mobile payment portal page 5 times before it ... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/resources/mobile_setup.js
===================================================================
--- chrome/browser/resources/mobile_setup.js (revision 106964)
+++ chrome/browser/resources/mobile_setup.js (working copy)
@@ -16,12 +16,14 @@
MobileSetup.PLAN_ACTIVATION_RECONNECTING_OTASP_TRY = 2;
MobileSetup.PLAN_ACTIVATION_INITIATING_ACTIVATION = 3;
MobileSetup.PLAN_ACTIVATION_RECONNECTING = 4;
- MobileSetup.PLAN_ACTIVATION_SHOWING_PAYMENT = 5;
- MobileSetup.PLAN_ACTIVATION_DELAY_OTASP = 6;
- MobileSetup.PLAN_ACTIVATION_START_OTASP = 7;
- MobileSetup.PLAN_ACTIVATION_OTASP = 8;
- MobileSetup.PLAN_ACTIVATION_RECONNECTING_OTASP = 9;
- MobileSetup.PLAN_ACTIVATION_DONE = 10;
+ MobileSetup.PLAN_ACTIVATION_PAYMENT_PORTAL_LOADING = 5;
+ MobileSetup.PLAN_ACTIVATION_SHOWING_PAYMENT = 6;
+ MobileSetup.PLAN_ACTIVATION_RECONNECTING_PAYMENT = 7;
+ MobileSetup.PLAN_ACTIVATION_DELAY_OTASP = 8;
+ MobileSetup.PLAN_ACTIVATION_START_OTASP = 9;
+ MobileSetup.PLAN_ACTIVATION_OTASP = 10;
+ MobileSetup.PLAN_ACTIVATION_RECONNECTING_OTASP = 11;
+ MobileSetup.PLAN_ACTIVATION_DONE = 12;
MobileSetup.PLAN_ACTIVATION_ERROR = 0xFF;
MobileSetup.EXTENSION_PAGE_URL =
@@ -40,6 +42,8 @@
initialized_ : false,
faked_transaction_ : false,
payment_shown_ : false,
+ frame_load_error_ : 0,
+ frame_load_ignored_ : true,
// UI states.
state_ : -1,
STATE_UNKNOWN_: "unknown",
@@ -90,32 +94,22 @@
chrome.send('startActivation', []);
},
- setupPaymentFrameListener_: function() {
- $(this.frameName_).addEventListener('load', function(e) {
- // Flip the visibility of the payment page only after the frame is
- // fully loaded.
- if (self.state_ == MobileSetup.PLAN_ACTIVATION_SHOWING_PAYMENT) {
- $('statusHeader').textContent = '';
- $('auxHeader').textContent = '';
- $('finalStatus').classList.add('hidden');
- $('systemStatus').classList.add('hidden');
- $('canvas').classList.add('hidden');
- $('carrierPage').classList.add('hidden');
- $('paymentForm').classList.remove('hidden');
- }
- });
+ onFrameLoaded_: function(success) {
+ chrome.send('paymentPortalLoad', [success ? 'ok' : 'failed']);
},
loadPaymentFrame_: function(deviceInfo) {
if (deviceInfo) {
+ this.frame_load_error_ = 0;
this.deviceInfo_ = deviceInfo;
if (deviceInfo.post_data && deviceInfo.post_data.length) {
+ this.frame_load_ignored_ = true;
$(this.frameName_).contentWindow.location.href =
xiyuan 2011/10/26 23:17:03 nit: $(this.frameName_).src = ...
MobileSetup.REDIRECT_POST_PAGE_URL +
'?post_data=' + escape(deviceInfo.post_data) +
'&formUrl=' + escape(deviceInfo.payment_url);
} else {
- this.setupPaymentFrameListener_();
+ this.frame_load_ignored_ = false;
$(this.frameName_).contentWindow.location.href =
deviceInfo.payment_url;
}
@@ -131,7 +125,7 @@
if (e.data.type == 'requestDeviceInfoMsg') {
this.sendDeviceInfo_();
} else if (e.data.type == 'framePostReady') {
- this.setupPaymentFrameListener_();
+ this.frame_load_ignored_ = false;
this.sendPostFrame_(e.origin);
} else if (e.data.type == 'reportTransactionStatusMsg') {
console.log('calling setTransactionStatus from onMessageReceived_');
@@ -152,6 +146,7 @@
case MobileSetup.PLAN_ACTIVATION_DELAY_OTASP:
case MobileSetup.PLAN_ACTIVATION_START_OTASP:
case MobileSetup.PLAN_ACTIVATION_RECONNECTING:
+ case MobileSetup.PLAN_ACTIVATION_RECONNECTING_PAYMENT:
case MobileSetup.PLAN_ACTIVATION_RECONNECTING_OTASP_TRY:
case MobileSetup.PLAN_ACTIVATION_RECONNECTING_OTASP:
$('statusHeader').textContent =
@@ -177,7 +172,7 @@
$('canvas').classList.remove('hidden');
$('carrierPage').classList.remove('hidden');
break;
- case MobileSetup.PLAN_ACTIVATION_SHOWING_PAYMENT:
+ case MobileSetup.PLAN_ACTIVATION_PAYMENT_PORTAL_LOADING:
$('statusHeader').textContent =
MobileSetup.localStrings_.getString('connecting_header');
$('auxHeader').textContent = '';
@@ -186,6 +181,15 @@
$('systemStatus').classList.remove('hidden');
$('canvas').classList.remove('hidden');
this.loadPaymentFrame_(deviceInfo);
+ break;
+ case MobileSetup.PLAN_ACTIVATION_SHOWING_PAYMENT:
+ $('statusHeader').textContent = '';
+ $('auxHeader').textContent = '';
+ $('finalStatus').classList.add('hidden');
+ $('systemStatus').classList.add('hidden');
+ $('canvas').classList.add('hidden');
+ $('carrierPage').classList.add('hidden');
+ $('paymentForm').classList.remove('hidden');
this.payment_shown_ = true;
break;
case MobileSetup.PLAN_ACTIVATION_DONE:
@@ -236,6 +240,20 @@
this.changeState_(deviceInfo);
},
+ portalFrameLoadError_: function(errorCode) {
+ if (this.frame_load_ignored_)
+ return;
+ console.log("Portal frame load error detected: " + errorCode);
+ this.frame_load_error_ = errorCode;
+ },
+
+ portalFrameLoadCompleted_: function() {
+ if (this.frame_load_ignored_)
+ return;
+ console.log("Portal frame load completed!");
+ this.onFrameLoaded_(this.frame_load_error_ == 0);
+ },
+
sendPostFrame_ : function(frameUrl) {
var msg = { type: 'postFrame' };
$(this.frameName_).contentWindow.postMessage(msg, frameUrl);
@@ -300,6 +318,14 @@
MobileSetup.getInstance().updateDeviceStatus_(deviceInfo);
};
+ MobileSetup.portalFrameLoadError = function(errorCode) {
+ MobileSetup.getInstance().portalFrameLoadError_(errorCode);
+ };
+
+ MobileSetup.portalFrameLoadCompleted = function() {
+ MobileSetup.getInstance().portalFrameLoadCompleted_();
+ };
+
MobileSetup.loadPage = function() {
mobile.MobileSetup.getInstance().initialize('paymentForm',
mobile.MobileSetup.ACTIVATION_PAGE_URL);

Powered by Google App Engine
This is Rietveld 408576698