OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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 "chromeos/dbus/fake_shill_manager_client.h" | 5 #include "chromeos/dbus/fake_shill_manager_client.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
(...skipping 984 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
995 [shill::kTypeCellular][shill::kTechnologyFamilyProperty] = | 995 [shill::kTypeCellular][shill::kTechnologyFamilyProperty] = |
996 new base::StringValue(shill::kNetworkTechnologyGsm); | 996 new base::StringValue(shill::kNetworkTechnologyGsm); |
997 return true; | 997 return true; |
998 } | 998 } |
999 return SetInitialNetworkState(arg0, arg1); | 999 return SetInitialNetworkState(arg0, arg1); |
1000 } | 1000 } |
1001 | 1001 |
1002 bool FakeShillManagerClient::SetInitialNetworkState(std::string type_arg, | 1002 bool FakeShillManagerClient::SetInitialNetworkState(std::string type_arg, |
1003 std::string state_arg) { | 1003 std::string state_arg) { |
1004 std::string state; | 1004 std::string state; |
1005 state_arg = StringToLowerASCII(state_arg); | 1005 state_arg = base::StringToLowerASCII(state_arg); |
1006 if (state_arg.empty() || state_arg == "1" || state_arg == "on" || | 1006 if (state_arg.empty() || state_arg == "1" || state_arg == "on" || |
1007 state_arg == "enabled" || state_arg == "connected" || | 1007 state_arg == "enabled" || state_arg == "connected" || |
1008 state_arg == "online") { | 1008 state_arg == "online") { |
1009 // Enabled and connected (default value) | 1009 // Enabled and connected (default value) |
1010 state = shill::kStateOnline; | 1010 state = shill::kStateOnline; |
1011 } else if (state_arg == "0" || state_arg == "off" || | 1011 } else if (state_arg == "0" || state_arg == "off" || |
1012 state_arg == "inactive" || state_arg == shill::kStateIdle) { | 1012 state_arg == "inactive" || state_arg == shill::kStateIdle) { |
1013 // Technology enabled, services are created but are not connected. | 1013 // Technology enabled, services are created but are not connected. |
1014 state = shill::kStateIdle; | 1014 state = shill::kStateIdle; |
1015 } else if (state_arg == "disabled" || state_arg == "disconnect") { | 1015 } else if (state_arg == "disabled" || state_arg == "disconnect") { |
1016 // Technology disabled but available, services created but not connected. | 1016 // Technology disabled but available, services created but not connected. |
1017 state = kNetworkDisabled; | 1017 state = kNetworkDisabled; |
1018 } else if (state_arg == "none" || state_arg == "offline") { | 1018 } else if (state_arg == "none" || state_arg == "offline") { |
1019 // Technology not available, do not create services. | 1019 // Technology not available, do not create services. |
1020 state = kTechnologyUnavailable; | 1020 state = kTechnologyUnavailable; |
1021 } else if (state_arg == "portal") { | 1021 } else if (state_arg == "portal") { |
1022 // Technology is enabled, a service is connected and in Portal state. | 1022 // Technology is enabled, a service is connected and in Portal state. |
1023 state = shill::kStatePortal; | 1023 state = shill::kStatePortal; |
1024 } else if (state_arg == "active" || state_arg == "activated") { | 1024 } else if (state_arg == "active" || state_arg == "activated") { |
1025 // Technology is enabled, a service is connected and Activated. | 1025 // Technology is enabled, a service is connected and Activated. |
1026 state = kNetworkActivated; | 1026 state = kNetworkActivated; |
1027 } else { | 1027 } else { |
1028 LOG(ERROR) << "Unrecognized initial state: " << state_arg; | 1028 LOG(ERROR) << "Unrecognized initial state: " << state_arg; |
1029 return false; | 1029 return false; |
1030 } | 1030 } |
1031 | 1031 |
1032 type_arg = StringToLowerASCII(type_arg); | 1032 type_arg = base::StringToLowerASCII(type_arg); |
1033 // Special cases | 1033 // Special cases |
1034 if (type_arg == "wireless") { | 1034 if (type_arg == "wireless") { |
1035 shill_initial_state_map_[shill::kTypeWifi] = state; | 1035 shill_initial_state_map_[shill::kTypeWifi] = state; |
1036 shill_initial_state_map_[shill::kTypeCellular] = state; | 1036 shill_initial_state_map_[shill::kTypeCellular] = state; |
1037 return true; | 1037 return true; |
1038 } | 1038 } |
1039 // Convenience synonyms. | 1039 // Convenience synonyms. |
1040 if (type_arg == "eth") | 1040 if (type_arg == "eth") |
1041 type_arg = shill::kTypeEthernet; | 1041 type_arg = shill::kTypeEthernet; |
1042 | 1042 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1076 *enabled = true; | 1076 *enabled = true; |
1077 if ((state == shill::kStatePortal && type != shill::kTypeWifi) || | 1077 if ((state == shill::kStatePortal && type != shill::kTypeWifi) || |
1078 (state == kNetworkActivated && type != shill::kTypeCellular)) { | 1078 (state == kNetworkActivated && type != shill::kTypeCellular)) { |
1079 LOG(WARNING) << "Invalid state: " << state << " for " << type; | 1079 LOG(WARNING) << "Invalid state: " << state << " for " << type; |
1080 return shill::kStateIdle; | 1080 return shill::kStateIdle; |
1081 } | 1081 } |
1082 return state; | 1082 return state; |
1083 } | 1083 } |
1084 | 1084 |
1085 } // namespace chromeos | 1085 } // namespace chromeos |
OLD | NEW |