| 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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 while (found != std::string::npos) { | 57 while (found != std::string::npos) { |
| 58 str.replace(found, 1, "&&"); | 58 str.replace(found, 1, "&&"); |
| 59 found = str.find('&', found + 2); | 59 found = str.find('&', found + 2); |
| 60 } | 60 } |
| 61 return str; | 61 return str; |
| 62 } | 62 } |
| 63 | 63 |
| 64 // Activate a cellular network. | 64 // Activate a cellular network. |
| 65 void ActivateCellular(const chromeos::CellularNetwork* cellular) { | 65 void ActivateCellular(const chromeos::CellularNetwork* cellular) { |
| 66 DCHECK(cellular); | 66 DCHECK(cellular); |
| 67 if (!chromeos::UserManager::Get()->IsSessionStarted()) | |
| 68 return; | |
| 69 | 67 |
| 70 ash::Shell::GetInstance()->delegate()->OpenMobileSetup( | 68 ash::Shell::GetInstance()->delegate()->OpenMobileSetup( |
| 71 cellular->service_path()); | 69 cellular->service_path()); |
| 72 } | 70 } |
| 73 | 71 |
| 74 // Decides whether a network should be highlighted in the UI. | 72 // Decides whether a network should be highlighted in the UI. |
| 75 bool ShouldHighlightNetwork(const chromeos::Network* network) { | 73 bool ShouldHighlightNetwork(const chromeos::Network* network) { |
| 76 chromeos::NetworkLibrary* cros = | 74 chromeos::NetworkLibrary* cros = |
| 77 chromeos::CrosLibrary::Get()->GetNetworkLibrary(); | 75 chromeos::CrosLibrary::Get()->GetNetworkLibrary(); |
| 78 return cros->connected_network() ? network == cros->connected_network() : | 76 return cros->connected_network() ? network == cros->connected_network() : |
| (...skipping 504 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 583 if (cellular_available && cellular_enabled) { | 581 if (cellular_available && cellular_enabled) { |
| 584 const CellularNetworkVector& cell_networks = cros->cellular_networks(); | 582 const CellularNetworkVector& cell_networks = cros->cellular_networks(); |
| 585 const CellularNetwork* active_cellular = cros->cellular_network(); | 583 const CellularNetwork* active_cellular = cros->cellular_network(); |
| 586 | 584 |
| 587 bool separator_added = false; | 585 bool separator_added = false; |
| 588 // List Cellular networks. | 586 // List Cellular networks. |
| 589 for (size_t i = 0; i < cell_networks.size(); ++i) { | 587 for (size_t i = 0; i < cell_networks.size(); ++i) { |
| 590 chromeos::ActivationState activation_state = | 588 chromeos::ActivationState activation_state = |
| 591 cell_networks[i]->activation_state(); | 589 cell_networks[i]->activation_state(); |
| 592 | 590 |
| 593 // This is currently only used in the OOBE/login screen, do not show | |
| 594 // activating 3G option. | |
| 595 if (activation_state != ACTIVATION_STATE_ACTIVATED) | |
| 596 continue; | |
| 597 | |
| 598 // Ampersand is a valid character in a network name, but menu2 uses it | 591 // Ampersand is a valid character in a network name, but menu2 uses it |
| 599 // to mark "mnemonics" for keyboard shortcuts. http://crosbug.com/14697 | 592 // to mark "mnemonics" for keyboard shortcuts. http://crosbug.com/14697 |
| 600 std::string network_name = EscapeAmpersands(cell_networks[i]->name()); | 593 std::string network_name = EscapeAmpersands(cell_networks[i]->name()); |
| 601 if (activation_state == ACTIVATION_STATE_NOT_ACTIVATED || | 594 if (activation_state == ACTIVATION_STATE_NOT_ACTIVATED || |
| 602 activation_state == ACTIVATION_STATE_PARTIALLY_ACTIVATED) { | 595 activation_state == ACTIVATION_STATE_PARTIALLY_ACTIVATED) { |
| 603 label = l10n_util::GetStringFUTF16( | 596 label = l10n_util::GetStringFUTF16( |
| 604 IDS_STATUSBAR_NETWORK_DEVICE_ACTIVATE, | 597 IDS_STATUSBAR_NETWORK_DEVICE_ACTIVATE, |
| 605 UTF8ToUTF16(network_name)); | 598 UTF8ToUTF16(network_name)); |
| 606 } else if (activation_state == ACTIVATION_STATE_ACTIVATING) { | 599 } else if (activation_state == ACTIVATION_STATE_ACTIVATING) { |
| 607 label = l10n_util::GetStringFUTF16( | 600 label = l10n_util::GetStringFUTF16( |
| (...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 976 } else if (network->type() == TYPE_WIMAX) { | 969 } else if (network->type() == TYPE_WIMAX) { |
| 977 WimaxNetwork* wimax = static_cast<WimaxNetwork*>(network); | 970 WimaxNetwork* wimax = static_cast<WimaxNetwork*>(network); |
| 978 if (wimax->passphrase_required()) { | 971 if (wimax->passphrase_required()) { |
| 979 // Show the connection UI if we require a passphrase. | 972 // Show the connection UI if we require a passphrase. |
| 980 NetworkConfigView::Show(wimax, delegate()->GetNativeWindow()); | 973 NetworkConfigView::Show(wimax, delegate()->GetNativeWindow()); |
| 981 } else { | 974 } else { |
| 982 cros->ConnectToWimaxNetwork(wimax); | 975 cros->ConnectToWimaxNetwork(wimax); |
| 983 // Connection failures are responsible for updating the UI, including | 976 // Connection failures are responsible for updating the UI, including |
| 984 // reopening dialogs. | 977 // reopening dialogs. |
| 985 } | 978 } |
| 979 } else if (network->type() == TYPE_CELLULAR) { |
| 980 CellularNetwork* cellular = static_cast<CellularNetwork*>(network); |
| 981 if (cellular->activation_state() != ACTIVATION_STATE_ACTIVATED) { |
| 982 ActivateCellular(cellular); |
| 983 } else { |
| 984 cros->ConnectToCellularNetwork(cellular); |
| 985 } |
| 986 } | 986 } |
| 987 } | 987 } |
| 988 | 988 |
| 989 void NetworkMenu::ConnectToNetwork(Network* network) { | 989 void NetworkMenu::ConnectToNetwork(Network* network) { |
| 990 NetworkLibrary* cros = CrosLibrary::Get()->GetNetworkLibrary(); | 990 NetworkLibrary* cros = CrosLibrary::Get()->GetNetworkLibrary(); |
| 991 switch (network->type()) { | 991 switch (network->type()) { |
| 992 case TYPE_ETHERNET: { | 992 case TYPE_ETHERNET: { |
| 993 ShowTabbedNetworkSettings(network); | 993 ShowTabbedNetworkSettings(network); |
| 994 break; | 994 break; |
| 995 } | 995 } |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1097 | 1097 |
| 1098 void NetworkMenu::ShowOtherWifi() { | 1098 void NetworkMenu::ShowOtherWifi() { |
| 1099 NetworkConfigView::ShowForType(TYPE_WIFI, delegate_->GetNativeWindow()); | 1099 NetworkConfigView::ShowForType(TYPE_WIFI, delegate_->GetNativeWindow()); |
| 1100 } | 1100 } |
| 1101 | 1101 |
| 1102 void NetworkMenu::ShowOtherCellular() { | 1102 void NetworkMenu::ShowOtherCellular() { |
| 1103 ChooseMobileNetworkDialog::ShowDialog(delegate_->GetNativeWindow()); | 1103 ChooseMobileNetworkDialog::ShowDialog(delegate_->GetNativeWindow()); |
| 1104 } | 1104 } |
| 1105 | 1105 |
| 1106 } // namespace chromeos | 1106 } // namespace chromeos |
| OLD | NEW |