Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2006-2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2010 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/chromeos/dom_ui/mobile_setup_ui.h" | 5 #include "chrome/browser/chromeos/dom_ui/mobile_setup_ui.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <map> | 8 #include <map> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 402 static_cast<chromeos::CellularNetwork*>( | 402 static_cast<chromeos::CellularNetwork*>( |
| 403 const_cast<chromeos::Network*>(network))); | 403 const_cast<chromeos::Network*>(network))); |
| 404 } | 404 } |
| 405 | 405 |
| 406 void MobileSetupHandler::HandleCloseTab(const ListValue* args) { | 406 void MobileSetupHandler::HandleCloseTab(const ListValue* args) { |
| 407 if (!dom_ui_) | 407 if (!dom_ui_) |
| 408 return; | 408 return; |
| 409 Browser* browser = BrowserList::FindBrowserWithFeature( | 409 Browser* browser = BrowserList::FindBrowserWithFeature( |
| 410 dom_ui_->GetProfile(), Browser::FEATURE_TABSTRIP); | 410 dom_ui_->GetProfile(), Browser::FEATURE_TABSTRIP); |
| 411 if (browser) | 411 if (browser) |
| 412 browser->CloseTabContents(tab_contents_); | 412 browser->CloseTabContents(tab_contents_); |
|
Eric Shienbrood
2010/11/16 15:57:19
Shouldn't wifi and ethernet be re-enabled here?
Eric Shienbrood
2010/11/16 16:22:04
Actually, shouldn't it be calling CompleteActivati
zel
2010/11/16 18:59:28
This is dead code, we don't use it at all. Removed
| |
| 413 } | 413 } |
| 414 | 414 |
| 415 void MobileSetupHandler::HandleStartActivation(const ListValue* args) { | 415 void MobileSetupHandler::HandleStartActivation(const ListValue* args) { |
| 416 scoped_refptr<TaskProxy> task = new TaskProxy(AsWeakPtr()); | 416 scoped_refptr<TaskProxy> task = new TaskProxy(AsWeakPtr()); |
| 417 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, | 417 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, |
| 418 NewRunnableMethod(task.get(), &TaskProxy::HandleStartActivation)); | 418 NewRunnableMethod(task.get(), &TaskProxy::HandleStartActivation)); |
| 419 } | 419 } |
| 420 | 420 |
| 421 void MobileSetupHandler::HandleSetTransactionStatus(const ListValue* args) { | 421 void MobileSetupHandler::HandleSetTransactionStatus(const ListValue* args) { |
| 422 const size_t kSetTransactionStatusParamCount = 1; | 422 const size_t kSetTransactionStatusParamCount = 1; |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 488 << "\n activation=" << network->GetActivationStateString().c_str() | 488 << "\n activation=" << network->GetActivationStateString().c_str() |
| 489 << "\n restricted=" << (network->restricted_pool() ? "yes" : "no") | 489 << "\n restricted=" << (network->restricted_pool() ? "yes" : "no") |
| 490 << "\n error=" << network->GetErrorString().c_str() | 490 << "\n error=" << network->GetErrorString().c_str() |
| 491 << "\n setvice_path=" << network->service_path().c_str(); | 491 << "\n setvice_path=" << network->service_path().c_str(); |
| 492 switch (state_) { | 492 switch (state_) { |
| 493 case PLAN_ACTIVATION_START: { | 493 case PLAN_ACTIVATION_START: { |
| 494 switch (network->activation_state()) { | 494 switch (network->activation_state()) { |
| 495 case chromeos::ACTIVATION_STATE_ACTIVATED: { | 495 case chromeos::ACTIVATION_STATE_ACTIVATED: { |
| 496 if (network->failed_or_disconnected()) { | 496 if (network->failed_or_disconnected()) { |
| 497 new_state = PLAN_ACTIVATION_RECONNECTING; | 497 new_state = PLAN_ACTIVATION_RECONNECTING; |
| 498 } else if (network->connection_state() == chromeos::STATE_READY) { | 498 } else if (network->connection_state() == chromeos::STATE_READY) { |
|
Eric Shienbrood
2010/11/16 15:57:19
This can be "... if (network->connected()) {". The
zel
2010/11/16 18:59:28
Done.
| |
| 499 if (network->restricted_pool()) { | 499 if (network->restricted_pool()) { |
| 500 new_state = PLAN_ACTIVATION_SHOWING_PAYMENT; | 500 new_state = PLAN_ACTIVATION_SHOWING_PAYMENT; |
| 501 } else { | 501 } else { |
| 502 new_state = PLAN_ACTIVATION_DONE; | 502 new_state = PLAN_ACTIVATION_DONE; |
| 503 } | 503 } |
| 504 } | 504 } |
| 505 break; | 505 break; |
| 506 } | 506 } |
| 507 case chromeos::ACTIVATION_STATE_PARTIALLY_ACTIVATED: { | 507 case chromeos::ACTIVATION_STATE_PARTIALLY_ACTIVATED: { |
| 508 if (!activation_status_test_) { | 508 if (!activation_status_test_) { |
| 509 if (network->failed_or_disconnected()) { | 509 if (network->failed_or_disconnected()) { |
| 510 activation_status_test_ = true; | 510 activation_status_test_ = true; |
| 511 new_state = PLAN_ACTIVATION_INITIATING_ACTIVATION; | 511 new_state = PLAN_ACTIVATION_INITIATING_ACTIVATION; |
| 512 } else if (network->connected()) { | 512 } else if (network->connected()) { |
| 513 LOG(INFO) << "Disconnecting from " << | 513 LOG(INFO) << "Disconnecting from " << |
| 514 network->service_path().c_str(); | 514 network->service_path().c_str(); |
| 515 chromeos::CrosLibrary::Get()->GetNetworkLibrary()-> | 515 chromeos::CrosLibrary::Get()->GetNetworkLibrary()-> |
| 516 DisconnectFromWirelessNetwork(network); | 516 DisconnectFromWirelessNetwork(network); |
| 517 // Disconnect will force networks to be reevaluated, so | 517 // Disconnect will force networks to be reevaluated, so |
| 518 // we don't want to continue processing on this path anymore. | 518 // we don't want to continue processing on this path anymore. |
| 519 return; | 519 return; |
| 520 } | 520 } |
| 521 } else { | 521 } else { |
| 522 if (network->connected()) | 522 if (network->connected()) |
| 523 new_state = PLAN_ACTIVATION_SHOWING_PAYMENT; | 523 new_state = PLAN_ACTIVATION_SHOWING_PAYMENT; |
|
jglasgow
2010/11/16 13:37:35
Does this also need a check for restricted_pool()?
Eric Shienbrood
2010/11/16 15:57:19
Or change the check to network->is_active(), which
zel
2010/11/16 18:59:28
Done.
| |
| 524 else | 524 else |
| 525 new_state = PLAN_ACTIVATION_RECONNECTING; | 525 new_state = PLAN_ACTIVATION_RECONNECTING; |
| 526 break; | 526 break; |
| 527 } | 527 } |
| 528 break; | 528 break; |
| 529 } | 529 } |
| 530 case chromeos::ACTIVATION_STATE_UNKNOWN: | 530 case chromeos::ACTIVATION_STATE_UNKNOWN: |
| 531 case chromeos::ACTIVATION_STATE_NOT_ACTIVATED: { | 531 case chromeos::ACTIVATION_STATE_NOT_ACTIVATED: { |
| 532 if (network->failed_or_disconnected()) { | 532 if (network->failed_or_disconnected()) { |
| 533 new_state = PLAN_ACTIVATION_INITIATING_ACTIVATION; | 533 new_state = PLAN_ACTIVATION_INITIATING_ACTIVATION; |
| 534 } else if (network->connected()) { | 534 } else if (network->connected()) { |
| 535 LOG(INFO) << "Disconnecting from " << | 535 LOG(INFO) << "Disconnecting from " << |
| 536 network->service_path().c_str(); | 536 network->service_path().c_str(); |
| 537 chromeos::CrosLibrary::Get()->GetNetworkLibrary()-> | 537 chromeos::CrosLibrary::Get()->GetNetworkLibrary()-> |
| 538 DisconnectFromWirelessNetwork(network); | 538 DisconnectFromWirelessNetwork(network); |
| 539 // Disconnect will force networks to be reevaluated, so | 539 // Disconnect will force networks to be reevaluated, so |
| 540 // we don't want to continue processing on this path anymore. | 540 // we don't want to continue processing on this path anymore. |
| 541 return; | 541 return; |
| 542 } | 542 } |
| 543 break; | 543 break; |
| 544 } | 544 } |
| 545 default: { | 545 default: { |
| 546 new_state = PLAN_ACTIVATION_INITIATING_ACTIVATION; | 546 new_state = PLAN_ACTIVATION_INITIATING_ACTIVATION; |
|
jglasgow
2010/11/16 13:37:35
Looks like this could be called while connected --
Eric Shienbrood
2010/11/16 15:57:19
I'm not sure I see the problem here. The only othe
zel
2010/11/16 18:59:28
This wasn't what was happening, but I have still r
| |
| 547 break; | 547 break; |
| 548 } | 548 } |
| 549 } | 549 } |
| 550 break; | 550 break; |
| 551 } | 551 } |
| 552 case PLAN_ACTIVATION_INITIATING_ACTIVATION: { | 552 case PLAN_ACTIVATION_INITIATING_ACTIVATION: { |
| 553 switch (network->activation_state()) { | 553 switch (network->activation_state()) { |
| 554 case chromeos::ACTIVATION_STATE_ACTIVATED: | 554 case chromeos::ACTIVATION_STATE_ACTIVATED: |
| 555 if (network->failed_or_disconnected()) { | 555 if (network->failed_or_disconnected()) { |
| 556 new_state = PLAN_ACTIVATION_RECONNECTING; | 556 new_state = PLAN_ACTIVATION_RECONNECTING; |
| 557 } else if (network->connection_state() == chromeos::STATE_READY) { | 557 } else if (network->connection_state() == chromeos::STATE_READY) { |
| 558 if (network->restricted_pool()) { | 558 if (network->restricted_pool()) { |
| 559 new_state = PLAN_ACTIVATION_SHOWING_PAYMENT; | 559 new_state = PLAN_ACTIVATION_SHOWING_PAYMENT; |
| 560 } else { | 560 } else { |
| 561 new_state = PLAN_ACTIVATION_DONE; | 561 new_state = PLAN_ACTIVATION_DONE; |
| 562 } | 562 } |
| 563 } | 563 } |
| 564 break; | 564 break; |
| 565 case chromeos::ACTIVATION_STATE_PARTIALLY_ACTIVATED: | 565 case chromeos::ACTIVATION_STATE_PARTIALLY_ACTIVATED: |
| 566 if (network->connected()) | 566 if (network->connected()) { |
| 567 new_state = PLAN_ACTIVATION_SHOWING_PAYMENT; | 567 if (network->restricted_pool()) |
| 568 else | 568 new_state = PLAN_ACTIVATION_SHOWING_PAYMENT; |
| 569 } else { | |
| 569 new_state = PLAN_ACTIVATION_RECONNECTING; | 570 new_state = PLAN_ACTIVATION_RECONNECTING; |
| 571 } | |
| 570 break; | 572 break; |
| 571 case chromeos::ACTIVATION_STATE_NOT_ACTIVATED: | 573 case chromeos::ACTIVATION_STATE_NOT_ACTIVATED: |
| 572 // Wait in this state until activation state changes. | 574 // Wait in this state until activation state changes. |
| 573 break; | 575 break; |
| 574 case chromeos::ACTIVATION_STATE_ACTIVATING: | 576 case chromeos::ACTIVATION_STATE_ACTIVATING: |
| 575 break; | 577 break; |
| 576 default: | 578 default: |
| 577 break; | 579 break; |
| 578 } | 580 } |
| 579 break; | 581 break; |
| 580 } | 582 } |
| 581 case PLAN_ACTIVATION_RECONNECTING: { | 583 case PLAN_ACTIVATION_RECONNECTING: { |
| 582 // Wait until the service shows up and gets activated. | 584 // Wait until the service shows up and gets activated. |
| 583 switch (network->activation_state()) { | 585 switch (network->activation_state()) { |
| 584 case chromeos::ACTIVATION_STATE_ACTIVATED: | 586 case chromeos::ACTIVATION_STATE_ACTIVATED: |
| 585 if (network->connection_state() == chromeos::STATE_READY) { | 587 if (network->connection_state() == chromeos::STATE_READY) { |
| 586 if (network->restricted_pool()) { | 588 if (network->restricted_pool()) { |
| 587 new_state = PLAN_ACTIVATION_SHOWING_PAYMENT; | 589 new_state = PLAN_ACTIVATION_SHOWING_PAYMENT; |
| 588 } else { | 590 } else { |
| 589 new_state = PLAN_ACTIVATION_DONE; | 591 new_state = PLAN_ACTIVATION_DONE; |
| 590 } | 592 } |
| 593 } else if (network->failed()) { | |
| 594 chromeos::CrosLibrary::Get()->GetNetworkLibrary()-> | |
| 595 ConnectToCellularNetwork(network); | |
| 596 return; | |
| 591 } | 597 } |
| 592 break; | 598 break; |
| 593 case chromeos::ACTIVATION_STATE_PARTIALLY_ACTIVATED: | 599 case chromeos::ACTIVATION_STATE_PARTIALLY_ACTIVATED: |
| 594 if (network->connected()) { | 600 if (network->connected()) { |
| 595 if (network->restricted_pool()) | 601 if (network->restricted_pool()) |
| 596 new_state = PLAN_ACTIVATION_SHOWING_PAYMENT; | 602 new_state = PLAN_ACTIVATION_SHOWING_PAYMENT; |
| 597 } | 603 } |
| 598 break; | 604 break; |
| 599 default: | 605 default: |
| 600 break; | 606 break; |
| 601 } | 607 } |
| 602 break; | 608 break; |
| 603 } | 609 } |
| 604 case PLAN_ACTIVATION_PAGE_LOADING: | 610 case PLAN_ACTIVATION_PAGE_LOADING: |
| 605 break; | 611 break; |
| 606 // Just ignore all signals until the site confirms payment. | 612 // Just ignore all signals until the site confirms payment. |
| 607 case PLAN_ACTIVATION_SHOWING_PAYMENT: | 613 case PLAN_ACTIVATION_SHOWING_PAYMENT: |
| 608 // Activation completed/failed, ignore network changes. | 614 // Activation completed/failed, ignore network changes. |
| 609 case PLAN_ACTIVATION_DONE: | 615 case PLAN_ACTIVATION_DONE: |
| 610 case PLAN_ACTIVATION_ERROR: | 616 case PLAN_ACTIVATION_ERROR: |
| 611 break; | 617 break; |
| 612 } | 618 } |
| 613 | 619 |
| 614 std::string error_description; | 620 std::string error_description; |
| 615 if (GotActivationError(network, &error_description)) { | 621 if (GotActivationError(network, &error_description)) { |
| 616 // Check for this special case when we try to do activate partially | 622 // Check for this special case when we try to do activate partially |
|
Eric Shienbrood
2010/11/16 15:57:19
"...when we try to activate partially..."
| |
| 617 // activated device. If that attempt failed, try to disconnect to clear the | 623 // activated device. If that attempt failed, try to disconnect to clear the |
| 618 // state and reconnect again. | 624 // state and reconnect again. |
| 619 if ((network->activation_state() == | 625 if ((network->activation_state() == |
| 620 chromeos::ACTIVATION_STATE_PARTIALLY_ACTIVATED || | 626 chromeos::ACTIVATION_STATE_PARTIALLY_ACTIVATED || |
| 621 network->activation_state() == chromeos::ACTIVATION_STATE_ACTIVATING) && | 627 network->activation_state() == chromeos::ACTIVATION_STATE_ACTIVATING) && |
| 622 network->error() == chromeos::ERROR_UNKNOWN && | 628 (network->error() == chromeos::ERROR_UNKNOWN || |
| 629 network->error() == chromeos::ERROR_OTASP_FAILED)&& | |
| 623 (state_ == PLAN_ACTIVATION_INITIATING_ACTIVATION || | 630 (state_ == PLAN_ACTIVATION_INITIATING_ACTIVATION || |
| 624 state_ == PLAN_ACTIVATION_RECONNECTING) && | 631 state_ == PLAN_ACTIVATION_RECONNECTING) && |
| 625 activation_status_test_ && | 632 activation_status_test_ && |
| 626 network->connection_state() == chromeos::STATE_ACTIVATION_FAILURE) { | 633 network->connection_state() == chromeos::STATE_ACTIVATION_FAILURE) { |
| 627 new_state = PLAN_ACTIVATION_RECONNECTING; | 634 new_state = PLAN_ACTIVATION_RECONNECTING; |
| 628 } else { | 635 } else { |
| 629 new_state = PLAN_ACTIVATION_ERROR; | 636 new_state = PLAN_ACTIVATION_ERROR; |
| 630 } | 637 } |
| 631 } | 638 } |
| 632 ChangeState(network, new_state, error_description); | 639 ChangeState(network, new_state, error_description); |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 696 kJsDeviceStatusChangedHandler, device_dict); | 703 kJsDeviceStatusChangedHandler, device_dict); |
| 697 | 704 |
| 698 // Decide what to do with network object as a result of the new state. | 705 // Decide what to do with network object as a result of the new state. |
| 699 switch (new_state) { | 706 switch (new_state) { |
| 700 case PLAN_ACTIVATION_START: | 707 case PLAN_ACTIVATION_START: |
| 701 break; | 708 break; |
| 702 case PLAN_ACTIVATION_INITIATING_ACTIVATION: | 709 case PLAN_ACTIVATION_INITIATING_ACTIVATION: |
| 703 DCHECK(network); | 710 DCHECK(network); |
| 704 LOG(INFO) << "Activating service " << network->service_path().c_str(); | 711 LOG(INFO) << "Activating service " << network->service_path().c_str(); |
| 705 if (!network->StartActivation()) | 712 if (!network->StartActivation()) |
| 706 new_state = PLAN_ACTIVATION_ERROR; | 713 new_state = PLAN_ACTIVATION_ERROR; |
|
Jason Glasgow
2010/11/16 16:13:51
This seems to be dead code.
I'm not sure... shoul
zel
2010/11/16 18:59:28
Done.
| |
| 707 break; | 714 break; |
| 708 case PLAN_ACTIVATION_RECONNECTING: { | 715 case PLAN_ACTIVATION_RECONNECTING: { |
| 709 DCHECK(network); | 716 DCHECK(network); |
| 710 if (network) { | 717 if (network) { |
| 711 chromeos::CrosLibrary::Get()->GetNetworkLibrary()-> | 718 chromeos::CrosLibrary::Get()->GetNetworkLibrary()-> |
| 712 ConnectToCellularNetwork(network); | 719 ConnectToCellularNetwork(network); |
| 713 } | 720 } |
| 714 break; | 721 break; |
| 715 } | 722 } |
| 716 case PLAN_ACTIVATION_PAGE_LOADING: | 723 case PLAN_ACTIVATION_PAGE_LOADING: |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 884 new MobileSetupUIHTMLSource(service_path); | 891 new MobileSetupUIHTMLSource(service_path); |
| 885 | 892 |
| 886 // Set up the chrome://mobilesetup/ source. | 893 // Set up the chrome://mobilesetup/ source. |
| 887 BrowserThread::PostTask( | 894 BrowserThread::PostTask( |
| 888 BrowserThread::IO, FROM_HERE, | 895 BrowserThread::IO, FROM_HERE, |
| 889 NewRunnableMethod( | 896 NewRunnableMethod( |
| 890 Singleton<ChromeURLDataManager>::get(), | 897 Singleton<ChromeURLDataManager>::get(), |
| 891 &ChromeURLDataManager::AddDataSource, | 898 &ChromeURLDataManager::AddDataSource, |
| 892 make_scoped_refptr(html_source))); | 899 make_scoped_refptr(html_source))); |
| 893 } | 900 } |
| OLD | NEW |