summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortbarzic@chromium.org <tbarzic@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-05-01 18:43:10 +0000
committertbarzic@chromium.org <tbarzic@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-05-01 18:43:10 +0000
commit1e460a88f206ead9c4e724beab6cd3b92635eebd (patch)
treeb0ae4915e20f5aaff31b76afb7e476e382fc76fd
parentee5cb154dd0466b54f44e4e3b1409b5e5115b433 (diff)
downloadchromium_src-1e460a88f206ead9c4e724beab6cd3b92635eebd.zip
chromium_src-1e460a88f206ead9c4e724beab6cd3b92635eebd.tar.gz
chromium_src-1e460a88f206ead9c4e724beab6cd3b92635eebd.tar.bz2
Detect when device MDN is invalid on mobile setup portal page and show warning
If the network MDN is all 0s, the user won't be able to login to mobile portal. When this state is detected, show a warning page telling user to try to access the portal a bit later. BUG=chrome-os-partner:18539 TEST=Verified the added warning page is shown just after activation. verified the behavior is unchanged for networks with valid mdn Review URL: https://chromiumcodereview.appspot.com/14509004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@197674 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/app/generated_resources.grd3
-rw-r--r--chrome/browser/resources/chromeos/mobile_setup_portal.js78
-rw-r--r--chrome/browser/ui/webui/chromeos/mobile_setup_ui.cc2
3 files changed, 70 insertions, 13 deletions
diff --git a/chrome/app/generated_resources.grd b/chrome/app/generated_resources.grd
index c0bcdeb..4dfeeb2 100644
--- a/chrome/app/generated_resources.grd
+++ b/chrome/app/generated_resources.grd
@@ -7550,6 +7550,9 @@ Keep your key file in a safe place. You will need it to create new versions of y
<message name="IDS_MOBILE_NO_CONNECTION_HEADER" desc="Mobile page header when the network portal is not reachable due to no connection">
Connect to Wi-Fi to begin
</message>
+ <message name="IDS_MOBILE_INVALID_DEVICE_INFO_HEADER" desc="Mobile page header when the user tries to access mobile portal for a device with an invalid MDN">
+ Please come back later
+ </message>
</if>
<!-- chrome://flash strings -->
diff --git a/chrome/browser/resources/chromeos/mobile_setup_portal.js b/chrome/browser/resources/chromeos/mobile_setup_portal.js
index 68dbb7d..854b507 100644
--- a/chrome/browser/resources/chromeos/mobile_setup_portal.js
+++ b/chrome/browser/resources/chromeos/mobile_setup_portal.js
@@ -9,11 +9,19 @@ cr.define('mobile', function() {
'chrome-extension://iadeocfgjdjdmpenejdbfeaocpbikmab/';
var REDIRECT_POST_PAGE_URL = EXTENSION_BASE_URL + 'redirect.html?autoPost=1';
var PORTAL_OFFLINE_PAGE_URL = EXTENSION_BASE_URL + 'portal_offline.html';
+ var INVALID_DEVICE_INFO_PAGE_URL =
+ EXTENSION_BASE_URL + 'invalid_device_info.html';
var NetworkState = {
UNKNOWN: 0,
PORTAL_REACHABLE: 1,
- PORTAL_UNREACHABLE: 2,
+ PORTAL_UNREACHABLE: 2
+ };
+
+ var CarrierPageType = {
+ NOT_SET: 0,
+ PORTAL_OFFLINE: 1,
+ INVALID_DEVICE_INFO: 2
};
var localStrings = new LocalStrings();
@@ -24,16 +32,13 @@ cr.define('mobile', function() {
this.spinnerInt_ = -1;
this.networkState_ = NetworkState.UNKNOWN;
this.portalFrameSet_ = false;
+ this.carrierPageType_ = CarrierPageType.NOT_SET;
}
cr.addSingletonGetter(PortalImpl);
PortalImpl.prototype = {
initialize: function() {
- $('carrierPage').contentWindow.location.href = PORTAL_OFFLINE_PAGE_URL;
- $('statusHeader').textContent =
- localStrings.getString('portal_unreachable_header');
-
// Get network device info for which portal should be opened.
// For LTE networks, this will also start observing network connection
// state and raise |updatePortalReachability| messages when the portal
@@ -61,22 +66,60 @@ cr.define('mobile', function() {
if (!this.deviceInfo_ || this.networkState_ == NetworkState.UNKNOWN)
return;
- if (this.networkState_ == NetworkState.PORTAL_REACHABLE) {
- // If the portal is reachable, set and show portalFrame; and hide system
+ if (!this.isDeviceInfoValid_()) {
+ // If the device info is not valid, hide portalFrame and show system
+ // status displaying 'invalid device info' page.
+ this.setCarrierPage_(CarrierPageType.INVALID_DEVICE_INFO);
+ $('portalFrame').hidden = true;
+ $('systemStatus').hidden = false;
+ } else if (this.networkState_ != NetworkState.PORTAL_REACHABLE) {
+ // If the portal is not reachable, hide portalFrame and show system
// status displaying 'offline portal' page.
+ this.setCarrierPage_(CarrierPageType.PORTAL_OFFLINE);
+ $('portalFrame').hidden = true;
+ $('systemStatus').hidden = false;
+ } else {
+ // If the portal is reachable and device info is valid, set and show
+ // portalFrame; and hide system status displaying 'offline portal' page.
this.setPortalFrameIfNeeded_(this.deviceInfo_);
$('portalFrame').hidden = false;
$('systemStatus').hidden = true;
this.stopSpinner_();
- } else {
- // If the portal is not reachable, hide portalFrame and show system
- // status displaying 'offline portal' page.
- $('portalFrame').hidden = true;
- $('systemStatus').hidden = false;
- this.startSpinner_();
}
},
+ setCarrierPage_: function(type) {
+ // The page is already set, nothing to do.
+ if (type == this.carrierPageType_)
+ return;
+
+ switch (type) {
+ case CarrierPageType.PORTAL_OFFLINE:
+ $('carrierPage').contentWindow.location.href =
+ PORTAL_OFFLINE_PAGE_URL;
+ $('statusHeader').textContent =
+ localStrings.getString('portal_unreachable_header');
+ this.startSpinner_();
+ break;
+ case CarrierPageType.INVALID_DEVICE_INFO:
+ $('carrierPage').contentWindow.location.href =
+ INVALID_DEVICE_INFO_PAGE_URL;
+ $('statusHeader').textContent =
+ localStrings.getString('invalid_device_info_header');
+ this.stopSpinner_();
+ break;
+ case CarrierPageType.NOT_SET:
+ $('carrierPage').contentWindow.location.href = 'about:blank';
+ $('statusHeader').textContent = '';
+ this.stopSpinner_();
+ break;
+ default:
+ break;
+ }
+
+ this.carrierPageType_ = type;
+ },
+
setPortalFrameIfNeeded_: function(deviceInfo) {
// The portal should be set only once.
if (this.portalFrameSet_)
@@ -92,6 +135,12 @@ cr.define('mobile', function() {
this.portalFrameSet_ = true;
},
+ isDeviceInfoValid_: function() {
+ // Device info is valid if it has mdn which doesn't contain only '0's.
+ return this.deviceInfo_ && this.deviceInfo_.MDN &&
+ this.deviceInfo_.MDN.match('[^0]');
+ },
+
startSpinner_: function() {
this.stopSpinner_();
this.spinnerInt_ = setInterval(this.drawProgress_.bind(this), 100);
@@ -102,6 +151,9 @@ cr.define('mobile', function() {
clearInterval(this.spinnerInt_);
this.spinnerInt_ = -1;
}
+ // Clear the spinner canvas.
+ var ctx = canvas.getContext('2d');
+ ctx.clearRect(0, 0, canvas.width, canvas.height);
},
drawProgress_: function() {
diff --git a/chrome/browser/ui/webui/chromeos/mobile_setup_ui.cc b/chrome/browser/ui/webui/chromeos/mobile_setup_ui.cc
index d50a057..824d86b 100644
--- a/chrome/browser/ui/webui/chromeos/mobile_setup_ui.cc
+++ b/chrome/browser/ui/webui/chromeos/mobile_setup_ui.cc
@@ -258,6 +258,8 @@ void MobileSetupUIHTMLSource::StartDataRequest(
l10n_util::GetStringUTF16(IDS_MOBILE_COMPLETED_TEXT));
strings.SetString("portal_unreachable_header",
l10n_util::GetStringUTF16(IDS_MOBILE_NO_CONNECTION_HEADER));
+ strings.SetString("invalid_device_info_header",
+ l10n_util::GetStringUTF16(IDS_MOBILE_INVALID_DEVICE_INFO_HEADER));
strings.SetString("title", l10n_util::GetStringUTF16(IDS_MOBILE_SETUP_TITLE));
strings.SetString("close_button",
l10n_util::GetStringUTF16(IDS_CLOSE));