Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(510)

Side by Side Diff: chromeos/dbus/fake_shill_manager_client.cc

Issue 954293003: Support badges and connecting animation in cr-network-icon element (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 state == shill::kStateReady; 98 state == shill::kStateReady;
99 } 99 }
100 100
101 void UpdatePortaledWifiState(const std::string& service_path) { 101 void UpdatePortaledWifiState(const std::string& service_path) {
102 DBusThreadManager::Get()->GetShillServiceClient()->GetTestInterface() 102 DBusThreadManager::Get()->GetShillServiceClient()->GetTestInterface()
103 ->SetServiceProperty(service_path, 103 ->SetServiceProperty(service_path,
104 shill::kStateProperty, 104 shill::kStateProperty,
105 base::StringValue(shill::kStatePortal)); 105 base::StringValue(shill::kStatePortal));
106 } 106 }
107 107
108 bool IsCellularTechnology(const std::string& type) {
109 return (type == shill::kNetworkTechnology1Xrtt ||
110 type == shill::kNetworkTechnologyEvdo ||
111 type == shill::kNetworkTechnologyGsm ||
112 type == shill::kNetworkTechnologyGprs ||
113 type == shill::kNetworkTechnologyEdge ||
114 type == shill::kNetworkTechnologyUmts ||
115 type == shill::kNetworkTechnologyHspa ||
116 type == shill::kNetworkTechnologyHspaPlus ||
117 type == shill::kNetworkTechnologyLte ||
118 type == shill::kNetworkTechnologyLteAdvanced);
119 }
120
108 const char* kTechnologyUnavailable = "unavailable"; 121 const char* kTechnologyUnavailable = "unavailable";
109 const char* kNetworkActivated = "activated"; 122 const char* kNetworkActivated = "activated";
110 const char* kNetworkDisabled = "disabled"; 123 const char* kNetworkDisabled = "disabled";
111 const char* kCellularServicePath = "/service/cellular1"; 124 const char* kCellularServicePath = "/service/cellular1";
112 const char* kRoamingRequired = "required"; 125 const char* kRoamingRequired = "required";
113 126
114 } // namespace 127 } // namespace
115 128
116 // static 129 // static
117 const char FakeShillManagerClient::kFakeEthernetNetworkGuid[] = "eth1_guid"; 130 const char FakeShillManagerClient::kFakeEthernetNetworkGuid[] = "eth1_guid";
118 131
119 FakeShillManagerClient::FakeShillManagerClient() 132 FakeShillManagerClient::FakeShillManagerClient()
120 : interactive_delay_(0), 133 : interactive_delay_(0),
134 cellular_technology_(shill::kNetworkTechnologyGsm),
121 weak_ptr_factory_(this) { 135 weak_ptr_factory_(this) {
122 ParseCommandLineSwitch(); 136 ParseCommandLineSwitch();
123 } 137 }
124 138
125 FakeShillManagerClient::~FakeShillManagerClient() {} 139 FakeShillManagerClient::~FakeShillManagerClient() {}
126 140
127 // ShillManagerClient overrides. 141 // ShillManagerClient overrides.
128 142
129 void FakeShillManagerClient::Init(dbus::Bus* bus) {} 143 void FakeShillManagerClient::Init(dbus::Bus* bus) {}
130 144
(...skipping 644 matching lines...) Expand 10 before | Expand all | Expand 10 after
775 shill::kProviderRequiresRoamingProperty, 789 shill::kProviderRequiresRoamingProperty,
776 base::FundamentalValue(true)); 790 base::FundamentalValue(true));
777 } 791 }
778 792
779 services->AddService(kCellularServicePath, 793 services->AddService(kCellularServicePath,
780 "cellular1_guid", 794 "cellular1_guid",
781 "cellular1" /* name */, 795 "cellular1" /* name */,
782 shill::kTypeCellular, 796 shill::kTypeCellular,
783 state, 797 state,
784 add_to_visible); 798 add_to_visible);
785 base::StringValue technology_value(shill::kNetworkTechnologyGsm); 799 base::StringValue technology_value(cellular_technology_);
786 devices->SetDeviceProperty("/device/cellular1", 800 devices->SetDeviceProperty("/device/cellular1",
787 shill::kTechnologyFamilyProperty, 801 shill::kTechnologyFamilyProperty,
788 technology_value); 802 technology_value);
789 services->SetServiceProperty(kCellularServicePath, 803 services->SetServiceProperty(kCellularServicePath,
790 shill::kNetworkTechnologyProperty, 804 shill::kNetworkTechnologyProperty,
791 technology_value); 805 technology_value);
792 806
793 if (activated) { 807 if (activated) {
794 services->SetServiceProperty( 808 services->SetServiceProperty(
795 kCellularServicePath, 809 kCellularServicePath,
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after
1065 // "home", "roaming", or "required" 1079 // "home", "roaming", or "required"
1066 roaming_state_ = arg1; 1080 roaming_state_ = arg1;
1067 return true; 1081 return true;
1068 } 1082 }
1069 return SetInitialNetworkState(arg0, arg1); 1083 return SetInitialNetworkState(arg0, arg1);
1070 } 1084 }
1071 1085
1072 bool FakeShillManagerClient::SetInitialNetworkState(std::string type_arg, 1086 bool FakeShillManagerClient::SetInitialNetworkState(std::string type_arg,
1073 std::string state_arg) { 1087 std::string state_arg) {
1074 std::string state; 1088 std::string state;
1075 state_arg = base::StringToLowerASCII(state_arg);
1076 if (state_arg.empty() || state_arg == "1" || state_arg == "on" || 1089 if (state_arg.empty() || state_arg == "1" || state_arg == "on" ||
1077 state_arg == "enabled" || state_arg == "connected" || 1090 state_arg == "enabled" || state_arg == "connected" ||
1078 state_arg == "online") { 1091 state_arg == "online") {
1079 // Enabled and connected (default value) 1092 // Enabled and connected (default value)
1080 state = shill::kStateOnline; 1093 state = shill::kStateOnline;
1081 } else if (state_arg == "0" || state_arg == "off" || 1094 } else if (state_arg == "0" || state_arg == "off" ||
1082 state_arg == "inactive" || state_arg == shill::kStateIdle) { 1095 state_arg == "inactive" || state_arg == shill::kStateIdle) {
1083 // Technology enabled, services are created but are not connected. 1096 // Technology enabled, services are created but are not connected.
1084 state = shill::kStateIdle; 1097 state = shill::kStateIdle;
1085 } else if (state_arg == "disabled" || state_arg == "disconnect") { 1098 } else if (state_arg == "disabled" || state_arg == "disconnect") {
1086 // Technology disabled but available, services created but not connected. 1099 // Technology disabled but available, services created but not connected.
1087 state = kNetworkDisabled; 1100 state = kNetworkDisabled;
1088 } else if (state_arg == "none" || state_arg == "offline") { 1101 } else if (state_arg == "none" || state_arg == "offline") {
1089 // Technology not available, do not create services. 1102 // Technology not available, do not create services.
1090 state = kTechnologyUnavailable; 1103 state = kTechnologyUnavailable;
1091 } else if (state_arg == "portal") { 1104 } else if (state_arg == "portal") {
1092 // Technology is enabled, a service is connected and in Portal state. 1105 // Technology is enabled, a service is connected and in Portal state.
1093 state = shill::kStatePortal; 1106 state = shill::kStatePortal;
1094 } else if (state_arg == "active" || state_arg == "activated") { 1107 } else if (state_arg == "active" || state_arg == "activated") {
1095 // Technology is enabled, a service is connected and Activated. 1108 // Technology is enabled, a service is connected and Activated.
1096 state = kNetworkActivated; 1109 state = kNetworkActivated;
1110 } else if (type_arg == shill::kTypeCellular &&
1111 IsCellularTechnology(state_arg)) {
1112 state = shill::kStateOnline;
1113 cellular_technology_ = state_arg;
1114 } else if (type_arg == shill::kTypeCellular && state_arg == "LTEAdvanced") {
1115 // Special case, Shill name contains a ' '.
1116 state = shill::kStateOnline;
1117 cellular_technology_ = shill::kNetworkTechnologyLteAdvanced;
1097 } else { 1118 } else {
1098 LOG(ERROR) << "Unrecognized initial state: " << state_arg; 1119 LOG(ERROR) << "Unrecognized initial state: " << type_arg << "="
1120 << state_arg;
1099 return false; 1121 return false;
1100 } 1122 }
1101 1123
1102 type_arg = base::StringToLowerASCII(type_arg);
1103 // Special cases 1124 // Special cases
1104 if (type_arg == "wireless") { 1125 if (type_arg == "wireless") {
1105 shill_initial_state_map_[shill::kTypeWifi] = state; 1126 shill_initial_state_map_[shill::kTypeWifi] = state;
1106 shill_initial_state_map_[shill::kTypeCellular] = state; 1127 shill_initial_state_map_[shill::kTypeCellular] = state;
1107 return true; 1128 return true;
1108 } 1129 }
1109 // Convenience synonyms. 1130 // Convenience synonyms.
1110 if (type_arg == "eth") 1131 if (type_arg == "eth")
1111 type_arg = shill::kTypeEthernet; 1132 type_arg = shill::kTypeEthernet;
1112 1133
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
1146 *enabled = true; 1167 *enabled = true;
1147 if ((state == shill::kStatePortal && type != shill::kTypeWifi) || 1168 if ((state == shill::kStatePortal && type != shill::kTypeWifi) ||
1148 (state == kNetworkActivated && type != shill::kTypeCellular)) { 1169 (state == kNetworkActivated && type != shill::kTypeCellular)) {
1149 LOG(WARNING) << "Invalid state: " << state << " for " << type; 1170 LOG(WARNING) << "Invalid state: " << state << " for " << type;
1150 return shill::kStateIdle; 1171 return shill::kStateIdle;
1151 } 1172 }
1152 return state; 1173 return state;
1153 } 1174 }
1154 1175
1155 } // namespace chromeos 1176 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698