OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 "ash/system/chromeos/network/network_connect.h" | 5 #include "ash/system/chromeos/network/network_connect.h" |
6 | 6 |
7 #include "ash/shell.h" | 7 #include "ash/shell.h" |
8 #include "ash/system/chromeos/network/network_state_notifier.h" | 8 #include "ash/system/chromeos/network/network_state_notifier.h" |
9 #include "ash/system/system_notifier.h" | 9 #include "ash/system/system_notifier.h" |
10 #include "ash/system/tray/system_tray_delegate.h" | 10 #include "ash/system/tray/system_tray_delegate.h" |
11 #include "ash/system/tray/system_tray_notifier.h" | 11 #include "ash/system/tray/system_tray_notifier.h" |
12 #include "base/bind.h" | 12 #include "base/bind.h" |
13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
14 #include "base/strings/utf_string_conversions.h" | 14 #include "base/strings/utf_string_conversions.h" |
15 #include "base/values.h" | 15 #include "base/values.h" |
16 #include "chromeos/login/login_state.h" | 16 #include "chromeos/login/login_state.h" |
17 #include "chromeos/network/device_state.h" | 17 #include "chromeos/network/device_state.h" |
18 #include "chromeos/network/network_activation_handler.h" | 18 #include "chromeos/network/network_activation_handler.h" |
19 #include "chromeos/network/network_configuration_handler.h" | 19 #include "chromeos/network/network_configuration_handler.h" |
20 #include "chromeos/network/network_connection_handler.h" | 20 #include "chromeos/network/network_connection_handler.h" |
21 #include "chromeos/network/network_event_log.h" | 21 #include "chromeos/network/network_event_log.h" |
22 #include "chromeos/network/network_handler_callbacks.h" | 22 #include "chromeos/network/network_handler_callbacks.h" |
23 #include "chromeos/network/network_profile.h" | 23 #include "chromeos/network/network_profile.h" |
24 #include "chromeos/network/network_profile_handler.h" | 24 #include "chromeos/network/network_profile_handler.h" |
25 #include "chromeos/network/network_state.h" | 25 #include "chromeos/network/network_state.h" |
26 #include "chromeos/network/network_state_handler.h" | 26 #include "chromeos/network/network_state_handler.h" |
| 27 #include "chromeos/network/shill_property_util.h" |
27 #include "grit/ash_resources.h" | 28 #include "grit/ash_resources.h" |
28 #include "grit/ash_strings.h" | 29 #include "grit/ash_strings.h" |
29 #include "third_party/cros_system_api/dbus/service_constants.h" | 30 #include "third_party/cros_system_api/dbus/service_constants.h" |
30 #include "ui/base/l10n/l10n_util.h" | 31 #include "ui/base/l10n/l10n_util.h" |
31 #include "ui/base/resource/resource_bundle.h" | 32 #include "ui/base/resource/resource_bundle.h" |
32 #include "ui/message_center/message_center.h" | 33 #include "ui/message_center/message_center.h" |
33 #include "ui/message_center/notification.h" | 34 #include "ui/message_center/notification.h" |
34 | 35 |
35 using chromeos::DeviceState; | 36 using chromeos::DeviceState; |
36 using chromeos::NetworkConfigurationHandler; | 37 using chromeos::NetworkConfigurationHandler; |
37 using chromeos::NetworkConnectionHandler; | 38 using chromeos::NetworkConnectionHandler; |
38 using chromeos::NetworkHandler; | 39 using chromeos::NetworkHandler; |
39 using chromeos::NetworkProfile; | 40 using chromeos::NetworkProfile; |
40 using chromeos::NetworkProfileHandler; | 41 using chromeos::NetworkProfileHandler; |
41 using chromeos::NetworkState; | 42 using chromeos::NetworkState; |
42 using chromeos::NetworkStateHandler; | 43 using chromeos::NetworkStateHandler; |
| 44 using chromeos::NetworkTypePattern; |
43 | 45 |
44 namespace ash { | 46 namespace ash { |
45 | 47 |
46 namespace { | 48 namespace { |
47 | 49 |
48 // TODO(stevenjb): This should be in service_constants.h | 50 // TODO(stevenjb): This should be in service_constants.h |
49 const char kErrorInProgress[] = "org.chromium.flimflam.Error.InProgress"; | 51 const char kErrorInProgress[] = "org.chromium.flimflam.Error.InProgress"; |
50 | 52 |
51 // Returns true for carriers that can be activated through Shill instead of | 53 // Returns true for carriers that can be activated through Shill instead of |
52 // through a WebUI dialog. | 54 // through a WebUI dialog. |
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
274 // If the network is in an error state, show the configuration UI directly | 276 // If the network is in an error state, show the configuration UI directly |
275 // to avoid a spurious notification. | 277 // to avoid a spurious notification. |
276 ash::Shell::GetInstance()->system_tray_delegate()->ConfigureNetwork( | 278 ash::Shell::GetInstance()->system_tray_delegate()->ConfigureNetwork( |
277 service_path); | 279 service_path); |
278 return; | 280 return; |
279 } | 281 } |
280 const bool check_error_state = true; | 282 const bool check_error_state = true; |
281 CallConnectToNetwork(service_path, check_error_state, owning_window); | 283 CallConnectToNetwork(service_path, check_error_state, owning_window); |
282 } | 284 } |
283 | 285 |
284 void SetTechnologyEnabled(const std::string& technology, bool enabled_state) { | 286 void SetTechnologyEnabled(const NetworkTypePattern& technology, |
| 287 bool enabled_state) { |
285 std::string log_string = | 288 std::string log_string = |
286 base::StringPrintf("technology %s, target state: %s", | 289 base::StringPrintf("technology %s, target state: %s", |
287 technology.c_str(), | 290 technology.ToDebugString().c_str(), |
288 (enabled_state ? "ENABLED" : "DISABLED")); | 291 (enabled_state ? "ENABLED" : "DISABLED")); |
289 NET_LOG_USER("SetTechnologyEnabled", log_string); | 292 NET_LOG_USER("SetTechnologyEnabled", log_string); |
290 NetworkStateHandler* handler = NetworkHandler::Get()->network_state_handler(); | 293 NetworkStateHandler* handler = NetworkHandler::Get()->network_state_handler(); |
291 bool enabled = handler->IsTechnologyEnabled(technology); | 294 bool enabled = handler->IsTechnologyEnabled(technology); |
292 if (enabled_state == enabled) { | 295 if (enabled_state == enabled) { |
293 NET_LOG_USER("Technology already in target state.", log_string); | 296 NET_LOG_USER("Technology already in target state.", log_string); |
294 return; | 297 return; |
295 } | 298 } |
296 if (enabled) { | 299 if (enabled) { |
297 // User requested to disable the technology. | 300 // User requested to disable the technology. |
298 handler->SetTechnologyEnabled( | 301 handler->SetTechnologyEnabled( |
299 technology, false, chromeos::network_handler::ErrorCallback()); | 302 technology, false, chromeos::network_handler::ErrorCallback()); |
300 return; | 303 return; |
301 } | 304 } |
302 // If we're dealing with a mobile network, then handle SIM lock here. | 305 // If we're dealing with a mobile network, then handle SIM lock here. |
303 // SIM locking only applies to cellular, so the code below won't execute | 306 // SIM locking only applies to cellular, so the code below won't execute |
304 // if |technology| has been explicitly set to WiMAX. | 307 // if |technology| has been explicitly set to WiMAX. |
305 if (technology == NetworkStateHandler::kMatchTypeMobile || | 308 if (technology.MatchesPattern(NetworkTypePattern::Mobile())) { |
306 technology == flimflam::kTypeCellular) { | |
307 const DeviceState* mobile = handler->GetDeviceStateByType(technology); | 309 const DeviceState* mobile = handler->GetDeviceStateByType(technology); |
308 if (!mobile) { | 310 if (!mobile) { |
309 NET_LOG_ERROR("SetTechnologyEnabled with no device", log_string); | 311 NET_LOG_ERROR("SetTechnologyEnabled with no device", log_string); |
310 return; | 312 return; |
311 } | 313 } |
312 // The following only applies to cellular. | 314 // The following only applies to cellular. |
313 if (mobile->type() == flimflam::kTypeCellular) { | 315 if (mobile->type() == flimflam::kTypeCellular) { |
314 if (mobile->IsSimAbsent()) { | 316 if (mobile->IsSimAbsent()) { |
315 // If this is true, then we have a cellular device with no SIM inserted. | 317 // If this is true, then we have a cellular device with no SIM inserted. |
316 // TODO(armansito): Chrome should display a notification here, prompting | 318 // TODO(armansito): Chrome should display a notification here, prompting |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
501 | 503 |
502 void ShowNetworkSettings(const std::string& service_path) { | 504 void ShowNetworkSettings(const std::string& service_path) { |
503 if (!ash::Shell::HasInstance()) | 505 if (!ash::Shell::HasInstance()) |
504 return; | 506 return; |
505 ash::Shell::GetInstance()->system_tray_delegate()->ShowNetworkSettings( | 507 ash::Shell::GetInstance()->system_tray_delegate()->ShowNetworkSettings( |
506 service_path); | 508 service_path); |
507 } | 509 } |
508 | 510 |
509 } // network_connect | 511 } // network_connect |
510 } // ash | 512 } // ash |
OLD | NEW |