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 1046 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1057 NetworkLibrary* cros = CrosLibrary::Get()->GetNetworkLibrary(); | 1057 NetworkLibrary* cros = CrosLibrary::Get()->GetNetworkLibrary(); |
1058 cros->EnableWifiNetworkDevice(!cros->wifi_enabled()); | 1058 cros->EnableWifiNetworkDevice(!cros->wifi_enabled()); |
1059 } | 1059 } |
1060 | 1060 |
1061 void NetworkMenu::ToggleCellular() { | 1061 void NetworkMenu::ToggleCellular() { |
1062 NetworkLibrary* cros = CrosLibrary::Get()->GetNetworkLibrary(); | 1062 NetworkLibrary* cros = CrosLibrary::Get()->GetNetworkLibrary(); |
1063 const NetworkDevice* cellular = cros->FindCellularDevice(); | 1063 const NetworkDevice* cellular = cros->FindCellularDevice(); |
1064 if (!cellular) { | 1064 if (!cellular) { |
1065 LOG(ERROR) << "No cellular device found, it should be available."; | 1065 LOG(ERROR) << "No cellular device found, it should be available."; |
1066 cros->EnableCellularNetworkDevice(!cros->cellular_enabled()); | 1066 cros->EnableCellularNetworkDevice(!cros->cellular_enabled()); |
1067 } else if (cellular->sim_lock_state() == SIM_UNLOCKED || | 1067 } else if (!cellular->is_sim_locked()) { |
1068 cellular->sim_lock_state() == SIM_UNKNOWN) { | 1068 if (cellular->is_sim_absent()) { |
1069 cros->EnableCellularNetworkDevice(!cros->cellular_enabled()); | 1069 std::string setup_url; |
| 1070 MobileConfig* config = MobileConfig::GetInstance(); |
| 1071 if (config->IsReady()) { |
| 1072 const MobileConfig::LocaleConfig* locale_config = |
| 1073 config->GetLocaleConfig(); |
| 1074 if (locale_config) |
| 1075 setup_url = locale_config->setup_url(); |
| 1076 } |
| 1077 if (!setup_url.empty()) { |
| 1078 GetAppropriateBrowser()->ShowSingletonTab(GURL(setup_url)); |
| 1079 } else { |
| 1080 // TODO(nkostylev): Show generic error message. http://crosbug.com/15444 |
| 1081 } |
| 1082 } else { |
| 1083 cros->EnableCellularNetworkDevice(!cros->cellular_enabled()); |
| 1084 } |
1070 } else { | 1085 } else { |
1071 SimDialogDelegate::ShowDialog(delegate()->GetNativeWindow(), | 1086 SimDialogDelegate::ShowDialog(delegate()->GetNativeWindow(), |
1072 SimDialogDelegate::SIM_DIALOG_UNLOCK); | 1087 SimDialogDelegate::SIM_DIALOG_UNLOCK); |
1073 } | 1088 } |
1074 } | 1089 } |
1075 | 1090 |
1076 void NetworkMenu::ShowOtherWifi() { | 1091 void NetworkMenu::ShowOtherWifi() { |
1077 NetworkConfigView* view = new NetworkConfigView(TYPE_WIFI); | 1092 NetworkConfigView* view = new NetworkConfigView(TYPE_WIFI); |
1078 views::Widget* window = views::Widget::CreateWindowWithParent( | 1093 views::Widget* window = views::Widget::CreateWindowWithParent( |
1079 view, delegate_->GetNativeWindow()); | 1094 view, delegate_->GetNativeWindow()); |
1080 window->SetAlwaysOnTop(true); | 1095 window->SetAlwaysOnTop(true); |
1081 window->Show(); | 1096 window->Show(); |
1082 } | 1097 } |
1083 | 1098 |
1084 void NetworkMenu::ShowOtherCellular() { | 1099 void NetworkMenu::ShowOtherCellular() { |
1085 ChooseMobileNetworkDialog::ShowDialog(delegate_->GetNativeWindow()); | 1100 ChooseMobileNetworkDialog::ShowDialog(delegate_->GetNativeWindow()); |
1086 } | 1101 } |
1087 | 1102 |
1088 bool NetworkMenu::ShouldHighlightNetwork(const Network* network) { | 1103 bool NetworkMenu::ShouldHighlightNetwork(const Network* network) { |
1089 return ::ShouldHighlightNetwork(network); | 1104 return ::ShouldHighlightNetwork(network); |
1090 } | 1105 } |
1091 | 1106 |
| 1107 Browser* NetworkMenu::GetAppropriateBrowser() { |
| 1108 return Browser::GetOrCreateTabbedBrowser( |
| 1109 ProfileManager::GetDefaultProfileOrOffTheRecord()); |
| 1110 } |
| 1111 |
1092 } // namespace chromeos | 1112 } // namespace chromeos |
OLD | NEW |