| 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/cros/network_library_impl_stub.h" | 5 #include "chrome/browser/chromeos/cros/network_library_impl_stub.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "content/public/browser/browser_thread.h" | 8 #include "content/public/browser/browser_thread.h" |
| 9 | 9 |
| 10 using content::BrowserThread; | 10 using content::BrowserThread; |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 // Networks | 72 // Networks |
| 73 // If these change, the expectations in network_library_unittest and | 73 // If these change, the expectations in network_library_unittest and |
| 74 // network_menu_icon_unittest need to be changed also. | 74 // network_menu_icon_unittest need to be changed also. |
| 75 | 75 |
| 76 // Networks are added in priority order. | 76 // Networks are added in priority order. |
| 77 network_priority_order_ = 0; | 77 network_priority_order_ = 0; |
| 78 | 78 |
| 79 Network* ethernet = new EthernetNetwork("eth1"); | 79 Network* ethernet = new EthernetNetwork("eth1"); |
| 80 ethernet->set_name("Fake Ethernet"); | 80 ethernet->set_name("Fake Ethernet"); |
| 81 ethernet->set_is_active(true); | 81 ethernet->set_is_active(true); |
| 82 ethernet->set_connected(true); | 82 ethernet->set_connected(); |
| 83 AddStubNetwork(ethernet, PROFILE_SHARED); | 83 AddStubNetwork(ethernet, PROFILE_SHARED); |
| 84 | 84 |
| 85 WifiNetwork* wifi1 = new WifiNetwork("wifi1"); | 85 WifiNetwork* wifi1 = new WifiNetwork("wifi1"); |
| 86 wifi1->set_name("Fake WiFi1"); | 86 wifi1->set_name("Fake WiFi1"); |
| 87 wifi1->set_strength(100); | 87 wifi1->set_strength(100); |
| 88 wifi1->set_connected(true); | 88 wifi1->set_connected(); |
| 89 wifi1->set_encryption(SECURITY_NONE); | 89 wifi1->set_encryption(SECURITY_NONE); |
| 90 AddStubNetwork(wifi1, PROFILE_SHARED); | 90 AddStubNetwork(wifi1, PROFILE_SHARED); |
| 91 | 91 |
| 92 WifiNetwork* wifi2 = new WifiNetwork("wifi2"); | 92 WifiNetwork* wifi2 = new WifiNetwork("wifi2"); |
| 93 wifi2->set_name("Fake WiFi2"); | 93 wifi2->set_name("Fake WiFi2"); |
| 94 wifi2->set_strength(70); | 94 wifi2->set_strength(70); |
| 95 wifi2->set_encryption(SECURITY_NONE); | 95 wifi2->set_encryption(SECURITY_NONE); |
| 96 AddStubNetwork(wifi2, PROFILE_SHARED); | 96 AddStubNetwork(wifi2, PROFILE_SHARED); |
| 97 | 97 |
| 98 WifiNetwork* wifi3 = new WifiNetwork("wifi3"); | 98 WifiNetwork* wifi3 = new WifiNetwork("wifi3"); |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 wifi7->SetEAPIdentity("enterprise@example.com"); | 156 wifi7->SetEAPIdentity("enterprise@example.com"); |
| 157 wifi7->SetEAPPassphrase("password"); | 157 wifi7->SetEAPPassphrase("password"); |
| 158 NetworkUIData wifi7_ui_data; | 158 NetworkUIData wifi7_ui_data; |
| 159 wifi7_ui_data.set_onc_source(NetworkUIData::ONC_SOURCE_DEVICE_POLICY); | 159 wifi7_ui_data.set_onc_source(NetworkUIData::ONC_SOURCE_DEVICE_POLICY); |
| 160 wifi7->set_ui_data(wifi7_ui_data); | 160 wifi7->set_ui_data(wifi7_ui_data); |
| 161 AddStubNetwork(wifi7, PROFILE_USER); | 161 AddStubNetwork(wifi7, PROFILE_USER); |
| 162 | 162 |
| 163 CellularNetwork* cellular1 = new CellularNetwork("cellular1"); | 163 CellularNetwork* cellular1 = new CellularNetwork("cellular1"); |
| 164 cellular1->set_name("Fake Cellular 1"); | 164 cellular1->set_name("Fake Cellular 1"); |
| 165 cellular1->set_strength(100); | 165 cellular1->set_strength(100); |
| 166 cellular1->set_connected(true); | 166 cellular1->set_connected(); |
| 167 cellular1->set_activation_state(ACTIVATION_STATE_ACTIVATED); | 167 cellular1->set_activation_state(ACTIVATION_STATE_ACTIVATED); |
| 168 cellular1->set_payment_url(std::string("http://www.google.com")); | 168 cellular1->set_payment_url(std::string("http://www.google.com")); |
| 169 cellular1->set_usage_url(std::string("http://www.google.com")); | 169 cellular1->set_usage_url(std::string("http://www.google.com")); |
| 170 cellular1->set_network_technology(NETWORK_TECHNOLOGY_EVDO); | 170 cellular1->set_network_technology(NETWORK_TECHNOLOGY_EVDO); |
| 171 AddStubNetwork(cellular1, PROFILE_NONE); | 171 AddStubNetwork(cellular1, PROFILE_NONE); |
| 172 | 172 |
| 173 CellularNetwork* cellular2 = new CellularNetwork("/cellular2"); | 173 CellularNetwork* cellular2 = new CellularNetwork("/cellular2"); |
| 174 cellular2->set_name("Fake Cellular 2"); | 174 cellular2->set_name("Fake Cellular 2"); |
| 175 cellular2->set_strength(50); | 175 cellular2->set_strength(50); |
| 176 cellular2->set_activation_state(ACTIVATION_STATE_NOT_ACTIVATED); | 176 cellular2->set_activation_state(ACTIVATION_STATE_NOT_ACTIVATED); |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 242 wimax1->set_name("Fake WiMAX Protected"); | 242 wimax1->set_name("Fake WiMAX Protected"); |
| 243 wimax1->set_strength(75); | 243 wimax1->set_strength(75); |
| 244 wimax1->set_connectable(true); | 244 wimax1->set_connectable(true); |
| 245 wimax1->set_eap_identity("WiMAX User 1"); | 245 wimax1->set_eap_identity("WiMAX User 1"); |
| 246 wimax1->set_passphrase_required(true); | 246 wimax1->set_passphrase_required(true); |
| 247 AddStubNetwork(wimax1, PROFILE_NONE); | 247 AddStubNetwork(wimax1, PROFILE_NONE); |
| 248 | 248 |
| 249 WimaxNetwork* wimax2 = new WimaxNetwork("wimax2"); | 249 WimaxNetwork* wimax2 = new WimaxNetwork("wimax2"); |
| 250 wimax2->set_name("Fake WiMAX Open"); | 250 wimax2->set_name("Fake WiMAX Open"); |
| 251 wimax2->set_strength(50); | 251 wimax2->set_strength(50); |
| 252 wimax2->set_connected(true); | 252 wimax2->set_connected(); |
| 253 wimax2->set_passphrase_required(false); | 253 wimax2->set_passphrase_required(false); |
| 254 AddStubNetwork(wimax2, PROFILE_NONE); | 254 AddStubNetwork(wimax2, PROFILE_NONE); |
| 255 | 255 |
| 256 VirtualNetwork* vpn1 = new VirtualNetwork("vpn1"); | 256 VirtualNetwork* vpn1 = new VirtualNetwork("vpn1"); |
| 257 vpn1->set_name("Fake VPN1"); | 257 vpn1->set_name("Fake VPN1"); |
| 258 vpn1->set_server_hostname("vpn1server.fake.com"); | 258 vpn1->set_server_hostname("vpn1server.fake.com"); |
| 259 vpn1->set_provider_type(PROVIDER_TYPE_L2TP_IPSEC_PSK); | 259 vpn1->set_provider_type(PROVIDER_TYPE_L2TP_IPSEC_PSK); |
| 260 vpn1->set_username("VPN User 1"); | 260 vpn1->set_username("VPN User 1"); |
| 261 AddStubNetwork(vpn1, PROFILE_USER); | 261 AddStubNetwork(vpn1, PROFILE_USER); |
| 262 | 262 |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 401 if (passphrase.find("bad") == 0) { | 401 if (passphrase.find("bad") == 0) { |
| 402 NetworkConnectCompleted(network, CONNECT_BAD_PASSPHRASE); | 402 NetworkConnectCompleted(network, CONNECT_BAD_PASSPHRASE); |
| 403 return; | 403 return; |
| 404 } else if (passphrase.find("error") == 0) { | 404 } else if (passphrase.find("error") == 0) { |
| 405 NetworkConnectCompleted(network, CONNECT_FAILED); | 405 NetworkConnectCompleted(network, CONNECT_FAILED); |
| 406 return; | 406 return; |
| 407 } | 407 } |
| 408 } | 408 } |
| 409 | 409 |
| 410 // Set connected state. | 410 // Set connected state. |
| 411 network->set_connected(true); | 411 network->set_connected(); |
| 412 network->set_connection_started(false); | 412 network->set_connection_started(false); |
| 413 | 413 |
| 414 // Make the connected network the highest priority network. | 414 // Make the connected network the highest priority network. |
| 415 // Set all other networks of the same type to disconnected + inactive; | 415 // Set all other networks of the same type to disconnected + inactive; |
| 416 int old_priority_order = network->priority_order_; | 416 int old_priority_order = network->priority_order_; |
| 417 network->priority_order_ = 0; | 417 network->priority_order_ = 0; |
| 418 for (NetworkMap::iterator iter = network_map_.begin(); | 418 for (NetworkMap::iterator iter = network_map_.begin(); |
| 419 iter != network_map_.end(); ++iter) { | 419 iter != network_map_.end(); ++iter) { |
| 420 Network* other = iter->second; | 420 Network* other = iter->second; |
| 421 if (other == network) | 421 if (other == network) |
| 422 continue; | 422 continue; |
| 423 if (other->priority_order_ < old_priority_order) | 423 if (other->priority_order_ < old_priority_order) |
| 424 other->priority_order_++; | 424 other->priority_order_++; |
| 425 if (other->type() == network->type()) { | 425 if (other->type() == network->type()) { |
| 426 other->set_is_active(false); | 426 other->set_is_active(false); |
| 427 other->set_connected(false); | 427 other->set_idle(); |
| 428 } | 428 } |
| 429 } | 429 } |
| 430 | 430 |
| 431 // Cycle data left to trigger notifications. | 431 // Cycle data left to trigger notifications. |
| 432 if (network->type() == TYPE_CELLULAR) { | 432 if (network->type() == TYPE_CELLULAR) { |
| 433 if (network->name().find("Low Data") != std::string::npos) { | 433 if (network->name().find("Low Data") != std::string::npos) { |
| 434 CellularNetwork* cellular = static_cast<CellularNetwork*>(network); | 434 CellularNetwork* cellular = static_cast<CellularNetwork*>(network); |
| 435 // Simulate a transition to very low data. | 435 // Simulate a transition to very low data. |
| 436 cellular->set_data_left(CellularNetwork::DATA_LOW); | 436 cellular->set_data_left(CellularNetwork::DATA_LOW); |
| 437 NotifyCellularDataPlanChanged(); | 437 NotifyCellularDataPlanChanged(); |
| (...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 633 bool NetworkLibraryImplStub::GetWifiAccessPoints( | 633 bool NetworkLibraryImplStub::GetWifiAccessPoints( |
| 634 WifiAccessPointVector* result) { | 634 WifiAccessPointVector* result) { |
| 635 *result = WifiAccessPointVector(); | 635 *result = WifiAccessPointVector(); |
| 636 return true; | 636 return true; |
| 637 } | 637 } |
| 638 | 638 |
| 639 void NetworkLibraryImplStub::DisconnectFromNetwork(const Network* network) { | 639 void NetworkLibraryImplStub::DisconnectFromNetwork(const Network* network) { |
| 640 // Update the network state here since no network manager in stub impl. | 640 // Update the network state here since no network manager in stub impl. |
| 641 Network* modify_network = const_cast<Network*>(network); | 641 Network* modify_network = const_cast<Network*>(network); |
| 642 modify_network->set_is_active(false); | 642 modify_network->set_is_active(false); |
| 643 modify_network->set_connected(false); | 643 modify_network->set_idle(); |
| 644 if (network == active_wifi_) | 644 if (network == active_wifi_) |
| 645 active_wifi_ = NULL; | 645 active_wifi_ = NULL; |
| 646 else if (network == active_cellular_) | 646 else if (network == active_cellular_) |
| 647 active_cellular_ = NULL; | 647 active_cellular_ = NULL; |
| 648 else if (network == active_virtual_) | 648 else if (network == active_virtual_) |
| 649 active_virtual_ = NULL; | 649 active_virtual_ = NULL; |
| 650 SignalNetworkManagerObservers(); | 650 SignalNetworkManagerObservers(); |
| 651 NotifyNetworkChanged(network); | 651 NotifyNetworkChanged(network); |
| 652 } | 652 } |
| 653 | 653 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 665 HardwareAddressFormat format) { | 665 HardwareAddressFormat format) { |
| 666 *hardware_address = hardware_address_; | 666 *hardware_address = hardware_address_; |
| 667 return ip_configs_; | 667 return ip_configs_; |
| 668 } | 668 } |
| 669 | 669 |
| 670 void NetworkLibraryImplStub::SetIPConfig(const NetworkIPConfig& ipconfig) { | 670 void NetworkLibraryImplStub::SetIPConfig(const NetworkIPConfig& ipconfig) { |
| 671 ip_configs_.push_back(ipconfig); | 671 ip_configs_.push_back(ipconfig); |
| 672 } | 672 } |
| 673 | 673 |
| 674 } // namespace chromeos | 674 } // namespace chromeos |
| OLD | NEW |