Skip to content
Snippets Groups Projects
Commit 36158e71 authored by zelidrag@chromium.org's avatar zelidrag@chromium.org
Browse files

Added [Close] button on completed activation overlay div.

Included logic for connection recovery - if we fail or timeout (30 sec)
while trying to reconnect the process of reconnecting will be
repeated 10 times before we throw an error.

BUG=chromium-os:9304, chromium-os:9333
TEST=none

Review URL: http://codereview.chromium.org/5147004

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@66593 0039d316-1c4b-4281-b951-d872f2087c98
parent fabff53d
No related branches found
No related tags found
No related merge requests found
......@@ -69,6 +69,11 @@ const char kCellularConfigPath[] =
const char kVersionField[] = "version";
const char kErrorsField[] = "errors";
// Number of times we will retry to reconnect if connection fails.
const int kMaxConnectionRetry = 10;
// Connection timeout in seconds.
const int kConnectionTimeoutSeconds = 30;
chromeos::CellularNetwork* GetCellularNetwork() {
chromeos::NetworkLibrary* lib = chromeos::CrosLibrary::Get()->
GetNetworkLibrary();
......@@ -190,6 +195,10 @@ class MobileSetupHandler
// Sends message to host registration page with system/user info data.
void SendDeviceInfo();
// Connects to cellular network, resets connection timer.
void ConnectToNetwork(chromeos::CellularNetwork* network);
// Reports connection timeout.
bool ConnectionTimeout();
// Verify the state of cellular network and modify internal state.
void EvaluateCellularNetwork(chromeos::CellularNetwork* network);
// Check the current cellular network for error conditions.
......@@ -243,6 +252,10 @@ class MobileSetupHandler
bool transaction_complete_signalled_;
bool activation_status_test_;
bool evaluating_;
// Connection retry counter.
int connection_retry_count_;
// Connection start time.
base::Time connection_start_time_;
DISALLOW_COPY_AND_ASSIGN(MobileSetupHandler);
};
......@@ -328,6 +341,8 @@ void MobileSetupUIHTMLSource::StartDataRequest(const std::string& path,
l10n_util::GetStringUTF16(IDS_MOBILE_COMPLETED_HEADER));
strings.SetString("completed_text",
l10n_util::GetStringUTF16(IDS_MOBILE_COMPLETED_TEXT));
strings.SetString("close_button",
l10n_util::GetStringUTF16(IDS_CLOSE));
SetFontAndTextDirection(&strings);
static const base::StringPiece html(
......@@ -357,7 +372,8 @@ MobileSetupHandler::MobileSetupHandler(const std::string& service_path)
reenable_cert_check_(false),
transaction_complete_signalled_(false),
activation_status_test_(false),
evaluating_(false) {
evaluating_(false),
connection_retry_count_(0) {
}
MobileSetupHandler::~MobileSetupHandler() {
......@@ -470,6 +486,19 @@ void MobileSetupHandler::SetTransactionStatus(const std::string& status) {
}
}
void MobileSetupHandler::ConnectToNetwork(chromeos::CellularNetwork* network) {
connection_retry_count_++;
connection_start_time_ = base::Time::Now();
chromeos::CrosLibrary::Get()->GetNetworkLibrary()->
ConnectToCellularNetwork(network);
}
bool MobileSetupHandler::ConnectionTimeout() {
return (base::Time::Now() -
connection_start_time_).InSeconds() > kConnectionTimeoutSeconds;
}
void MobileSetupHandler::EvaluateCellularNetwork(
chromeos::CellularNetwork* network) {
if (!dom_ui_)
......@@ -587,30 +616,35 @@ void MobileSetupHandler::EvaluateCellularNetwork(
break;
}
case PLAN_ACTIVATION_RECONNECTING: {
// Wait until the service shows up and gets activated.
switch (network->activation_state()) {
case chromeos::ACTIVATION_STATE_ACTIVATED:
if (network->connected()) {
if (network->restricted_pool()) {
if (network->connected()) {
// Wait until the service shows up and gets activated.
switch (network->activation_state()) {
case chromeos::ACTIVATION_STATE_ACTIVATED:
if (network->restricted_pool())
new_state = PLAN_ACTIVATION_SHOWING_PAYMENT;
} else {
else
new_state = PLAN_ACTIVATION_DONE;
}
} else if (network->failed()) {
chromeos::CrosLibrary::Get()->GetNetworkLibrary()->
ConnectToCellularNetwork(network);
evaluating_ = false;
return;
}
break;
case chromeos::ACTIVATION_STATE_PARTIALLY_ACTIVATED:
if (network->connected()) {
break;
case chromeos::ACTIVATION_STATE_PARTIALLY_ACTIVATED:
if (network->restricted_pool())
new_state = PLAN_ACTIVATION_SHOWING_PAYMENT;
}
break;
default:
break;
break;
default:
break;
}
} else if (network->failed() || ConnectionTimeout()) {
// Try to reconnect again if reconnect failed, or if for some
// reasons we are still not connected after 30 seconds.
if (connection_retry_count_ < kMaxConnectionRetry) {
UMA_HISTOGRAM_COUNTS("Cellular.ConnectionRetry", 1);
ConnectToNetwork(network);
evaluating_ = false;
return;
} else {
// We simply can't connect anymore after all these tries.
UMA_HISTOGRAM_COUNTS("Cellular.ConnectionFailed", 1);
new_state = PLAN_ACTIVATION_ERROR;
}
}
break;
}
......@@ -625,7 +659,8 @@ void MobileSetupHandler::EvaluateCellularNetwork(
}
std::string error_description;
if (GotActivationError(network, &error_description)) {
if (new_state != PLAN_ACTIVATION_ERROR &&
GotActivationError(network, &error_description)) {
// Check for this special case when we try to do activate partially
// activated device. If that attempt failed, try to disconnect to clear the
// state and reconnect again.
......@@ -728,11 +763,10 @@ void MobileSetupHandler::ChangeState(chromeos::CellularNetwork* network,
}
break;
case PLAN_ACTIVATION_RECONNECTING: {
DCHECK(network);
if (network) {
chromeos::CrosLibrary::Get()->GetNetworkLibrary()->
ConnectToCellularNetwork(network);
}
// Reset connection metrics and try to connect.
connection_retry_count_ = 0;
connection_start_time_ = base::Time::Now();
ConnectToNetwork(network);
break;
}
case PLAN_ACTIVATION_PAGE_LOADING:
......
......@@ -58,30 +58,17 @@ iframe {
.logo {
background: url('file:///usr/share/chromeos-assets/mobile/carrier_logo.png') no-repeat;
background-position: center;
height: 58px;
margin-bottom: 20px;
margin-top: 20px;
}
#errorMessage {
margin: 20px;
}
.box {
display: -webkit-box;
}
#finalLogo {
position: absolute;
right: 130px;
width: 150px;
}
#activationLogo {
background-position: center;
margin-bottom: 20px;
margin-top: 20px;
}
#splitter {
.splitter {
margin-top: 10px;
left: 50%;
margin-left: 150px;
......@@ -100,6 +87,25 @@ iframe {
top: 0;
}
#finalMessage {
padding-bottom: 50px;
}
.action-area {
-webkit-box-orient: horizontal;
-webkit-box-align: center;
padding: 12px;
position: absolute;
right: 0px;
bottom: 0px;
display: -webkit-box;
}
.button-strip {
-webkit-box-orient: horizontal;
display: -webkit-box;
}
</style>
<script src="chrome://resources/js/cr.js"></script>
<script src="chrome://resources/js/local_strings.js"></script>
......@@ -114,17 +120,20 @@ iframe {
<div><h3 id="statusHeader"></h3></div>
<div id="errorMessage"></div>
<canvas id="canvas" width="56" height="56"></canvas>
<div id="splitter"></div>
<div id="activationLogo" class="logo"></div>
<div class="splitter"></div>
<div class="logo"></div>
</div>
</div>
<div id="finalMessage" class="overlay hidden">
<div class="box">
<div>
<div class="header"><h3 i18n-content="completed_header"></h3></div>
<div id="action" i18n-content="completed_text"></div>
<div class="startup">
<div class="header"><h3 i18n-content="completed_header"></h3></div>
<div i18n-content="completed_text"></div>
<div class="splitter"></div>
<div class="logo"></div>
<div class="action-area button-strip">
<button id="closeButton"
i18n-content="close_button"></button>
</div>
<div id="finalLogo" class="logo"></div>
</div>
</div>
</body>
......
......@@ -46,6 +46,9 @@ cr.define('mobile', function() {
window.addEventListener('message', function(e) {
self.onMessageReceived_(e);
});
$('closeButton').addEventListener('click', function(e) {
$('finalMessage').classList.add('hidden');
});
$(frame_name).addEventListener('load', function(e) {
// Flip the visibility of the payment page only after the frame is
// fully loaded.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment