OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/status/network_menu.h" | 5 #include "chrome/browser/chromeos/status/network_menu.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "ash/shell.h" | 9 #include "ash/shell.h" |
10 #include "ash/shell_delegate.h" | 10 #include "ash/shell_delegate.h" |
(...skipping 963 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
974 if (wimax->passphrase_required()) { | 974 if (wimax->passphrase_required()) { |
975 // Show the connection UI if we require a passphrase. | 975 // Show the connection UI if we require a passphrase. |
976 NetworkConfigView::Show(wimax, delegate()->GetNativeWindow()); | 976 NetworkConfigView::Show(wimax, delegate()->GetNativeWindow()); |
977 } else { | 977 } else { |
978 cros->ConnectToWimaxNetwork(wimax); | 978 cros->ConnectToWimaxNetwork(wimax); |
979 // Connection failures are responsible for updating the UI, including | 979 // Connection failures are responsible for updating the UI, including |
980 // reopening dialogs. | 980 // reopening dialogs. |
981 } | 981 } |
982 } else if (network->type() == TYPE_CELLULAR) { | 982 } else if (network->type() == TYPE_CELLULAR) { |
983 CellularNetwork* cellular = static_cast<CellularNetwork*>(network); | 983 CellularNetwork* cellular = static_cast<CellularNetwork*>(network); |
984 if (cellular->activation_state() != ACTIVATION_STATE_ACTIVATED) { | 984 if (cellular->activation_state() != ACTIVATION_STATE_ACTIVATED || |
| 985 cellular->out_of_credits()) { |
985 ActivateCellular(cellular); | 986 ActivateCellular(cellular); |
986 } else { | 987 } else { |
987 cros->ConnectToCellularNetwork(cellular); | 988 cros->ConnectToCellularNetwork(cellular); |
988 } | 989 } |
989 } | 990 } |
990 } | 991 } |
991 | 992 |
992 void NetworkMenu::ConnectToNetwork(Network* network) { | 993 void NetworkMenu::ConnectToNetwork(Network* network) { |
993 NetworkLibrary* cros = CrosLibrary::Get()->GetNetworkLibrary(); | 994 NetworkLibrary* cros = CrosLibrary::Get()->GetNetworkLibrary(); |
994 switch (network->type()) { | 995 switch (network->type()) { |
(...skipping 24 matching lines...) Expand all Loading... |
1019 } else { | 1020 } else { |
1020 wimax->AttemptConnection(base::Bind(&NetworkMenu::DoConnect, | 1021 wimax->AttemptConnection(base::Bind(&NetworkMenu::DoConnect, |
1021 weak_pointer_factory_.GetWeakPtr(), | 1022 weak_pointer_factory_.GetWeakPtr(), |
1022 wimax)); | 1023 wimax)); |
1023 } | 1024 } |
1024 break; | 1025 break; |
1025 } | 1026 } |
1026 | 1027 |
1027 case TYPE_CELLULAR: { | 1028 case TYPE_CELLULAR: { |
1028 CellularNetwork* cell = static_cast<CellularNetwork*>(network); | 1029 CellularNetwork* cell = static_cast<CellularNetwork*>(network); |
1029 if (cell->NeedsActivation()) { | 1030 if (cell->NeedsActivation() || cell->out_of_credits()) { |
1030 ActivateCellular(cell); | 1031 ActivateCellular(cell); |
1031 } else if (cell->connecting_or_connected() || | 1032 } else if (cell->connecting_or_connected() || |
1032 cell->activation_state() == ACTIVATION_STATE_ACTIVATING) { | 1033 cell->activation_state() == ACTIVATION_STATE_ACTIVATING) { |
1033 // Cellular network is connecting, connected, or activating, | 1034 // Cellular network is connecting, connected, or activating, |
1034 // so we show the config settings for the cellular network. | 1035 // so we show the config settings for the cellular network. |
1035 ShowTabbedNetworkSettings(cell); | 1036 ShowTabbedNetworkSettings(cell); |
1036 } else { | 1037 } else { |
1037 // Clicked on a disconnected cellular network, so connect to it. | 1038 // Clicked on a disconnected cellular network, so connect to it. |
1038 cros->ConnectToCellularNetwork(cell); | 1039 cros->ConnectToCellularNetwork(cell); |
1039 } | 1040 } |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1105 | 1106 |
1106 void NetworkMenu::ShowOtherVPN() { | 1107 void NetworkMenu::ShowOtherVPN() { |
1107 NetworkConfigView::ShowForType(TYPE_VPN, delegate_->GetNativeWindow()); | 1108 NetworkConfigView::ShowForType(TYPE_VPN, delegate_->GetNativeWindow()); |
1108 } | 1109 } |
1109 | 1110 |
1110 void NetworkMenu::ShowOtherCellular() { | 1111 void NetworkMenu::ShowOtherCellular() { |
1111 ChooseMobileNetworkDialog::ShowDialog(delegate_->GetNativeWindow()); | 1112 ChooseMobileNetworkDialog::ShowDialog(delegate_->GetNativeWindow()); |
1112 } | 1113 } |
1113 | 1114 |
1114 } // namespace chromeos | 1115 } // namespace chromeos |
OLD | NEW |