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

Side by Side Diff: chrome/browser/chromeos/cros/network_library_impl_stub.cc

Issue 10829249: Merge 150607 - Fix logic for VPN badges and network menu order (Closed) Base URL: svn://svn.chromium.org/chrome/branches/1229/src/
Patch Set: Created 8 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/chromeos/status/network_menu_icon.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 device_map_["cellular_gsm"] = cellular_gsm; 66 device_map_["cellular_gsm"] = cellular_gsm;
67 67
68 // Profiles 68 // Profiles
69 AddProfile("default", PROFILE_SHARED); 69 AddProfile("default", PROFILE_SHARED);
70 AddProfile("user", PROFILE_USER); 70 AddProfile("user", PROFILE_USER);
71 71
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.
77 network_priority_order_ = 0;
78
79 Network* ethernet = new EthernetNetwork("eth1"); 76 Network* ethernet = new EthernetNetwork("eth1");
80 ethernet->set_name("Fake Ethernet"); 77 ethernet->set_name("Fake Ethernet");
81 ethernet->set_is_active(true);
82 ethernet->set_connected(); 78 ethernet->set_connected();
83 AddStubNetwork(ethernet, PROFILE_SHARED); 79 AddStubNetwork(ethernet, PROFILE_SHARED);
80 ethernet->set_is_active(ethernet->connected());
84 81
85 WifiNetwork* wifi1 = new WifiNetwork("wifi1"); 82 WifiNetwork* wifi1 = new WifiNetwork("wifi1");
86 wifi1->set_name("Fake WiFi1"); 83 wifi1->set_name("Fake WiFi1");
87 wifi1->set_strength(100); 84 wifi1->set_strength(100);
88 wifi1->set_connected(); 85 wifi1->set_connected();
89 wifi1->set_encryption(SECURITY_NONE); 86 wifi1->set_encryption(SECURITY_NONE);
90 AddStubNetwork(wifi1, PROFILE_SHARED); 87 AddStubNetwork(wifi1, PROFILE_SHARED);
91 88
92 WifiNetwork* wifi2 = new WifiNetwork("wifi2"); 89 WifiNetwork* wifi2 = new WifiNetwork("wifi2");
93 wifi2->set_name("Fake WiFi2"); 90 wifi2->set_name("Fake WiFi2");
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 NetworkUIData vpn4_ui_data; 277 NetworkUIData vpn4_ui_data;
281 vpn4_ui_data.set_onc_source(NetworkUIData::ONC_SOURCE_DEVICE_POLICY); 278 vpn4_ui_data.set_onc_source(NetworkUIData::ONC_SOURCE_DEVICE_POLICY);
282 vpn4->set_ui_data(vpn4_ui_data); 279 vpn4->set_ui_data(vpn4_ui_data);
283 AddStubNetwork(vpn4, PROFILE_USER); 280 AddStubNetwork(vpn4, PROFILE_USER);
284 281
285 wifi_scanning_ = false; 282 wifi_scanning_ = false;
286 offline_mode_ = false; 283 offline_mode_ = false;
287 284
288 // Ensure our active network is connected and vice versa, otherwise our 285 // Ensure our active network is connected and vice versa, otherwise our
289 // autotest browser_tests sometimes conclude the device is offline. 286 // autotest browser_tests sometimes conclude the device is offline.
290 CHECK(active_network()->connected()); 287 CHECK(active_network()->connected())
288 << "Active: " << active_network()->name();
291 CHECK(connected_network()->is_active()); 289 CHECK(connected_network()->is_active());
292 290
293 std::string test_blob( 291 std::string test_blob(
294 "{" 292 "{"
295 " \"NetworkConfigurations\": [" 293 " \"NetworkConfigurations\": ["
296 " {" 294 " {"
297 " \"GUID\": \"guid\"," 295 " \"GUID\": \"guid\","
298 " \"Type\": \"VPN\"," 296 " \"Type\": \"VPN\","
299 " \"Name\": \"VPNtest\"," 297 " \"Name\": \"VPNtest\","
300 " \"VPN\": {" 298 " \"VPN\": {"
(...skipping 17 matching lines...) Expand all
318 316
319 bool NetworkLibraryImplStub::IsCros() const { 317 bool NetworkLibraryImplStub::IsCros() const {
320 return false; 318 return false;
321 } 319 }
322 320
323 //////////////////////////////////////////////////////////////////////////// 321 ////////////////////////////////////////////////////////////////////////////
324 // NetworkLibraryImplStub private methods. 322 // NetworkLibraryImplStub private methods.
325 323
326 void NetworkLibraryImplStub::AddStubNetwork( 324 void NetworkLibraryImplStub::AddStubNetwork(
327 Network* network, NetworkProfileType profile_type) { 325 Network* network, NetworkProfileType profile_type) {
328 network->priority_order_ = network_priority_order_++; 326 // Currently we don't prioritize networks in Shill so don't do so in the stub.
327 // network->priority_order_ = network_priority_order_++;
329 network->CalculateUniqueId(); 328 network->CalculateUniqueId();
330 if (!network->unique_id().empty()) 329 if (!network->unique_id().empty())
331 network_unique_id_map_[network->unique_id()] = network; 330 network_unique_id_map_[network->unique_id()] = network;
332 AddNetwork(network); 331 AddNetwork(network);
333 UpdateActiveNetwork(network); 332 UpdateActiveNetwork(network);
334 SetProfileType(network, profile_type); 333 SetProfileType(network, profile_type);
335 AddStubRememberedNetwork(network); 334 AddStubRememberedNetwork(network);
336 } 335 }
337 336
338 // Add a remembered network to the appropriate profile if specified. 337 // Add a remembered network to the appropriate profile if specified.
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
400 if (!passphrase.empty()) { 399 if (!passphrase.empty()) {
401 if (passphrase.find("bad") == 0) { 400 if (passphrase.find("bad") == 0) {
402 NetworkConnectCompleted(network, CONNECT_BAD_PASSPHRASE); 401 NetworkConnectCompleted(network, CONNECT_BAD_PASSPHRASE);
403 return; 402 return;
404 } else if (passphrase.find("error") == 0) { 403 } else if (passphrase.find("error") == 0) {
405 NetworkConnectCompleted(network, CONNECT_FAILED); 404 NetworkConnectCompleted(network, CONNECT_FAILED);
406 return; 405 return;
407 } 406 }
408 } 407 }
409 408
409 // Disconnect ethernet when connecting to a new network (for UI testing).
410 if (network->type() != TYPE_VPN) {
411 ethernet_->set_is_active(false);
412 ethernet_->set_disconnected();
413 }
414
410 // Set connected state. 415 // Set connected state.
411 network->set_connected(); 416 network->set_connected();
412 network->set_connection_started(false); 417 network->set_connection_started(false);
413 418
414 // Make the connected network the highest priority network. 419 // Make the connected network the highest priority network.
415 // Set all other networks of the same type to disconnected + inactive; 420 // Set all other networks of the same type to disconnected + inactive;
416 int old_priority_order = network->priority_order_; 421 int old_priority_order = network->priority_order_;
417 network->priority_order_ = 0; 422 network->priority_order_ = 0;
418 for (NetworkMap::iterator iter = network_map_.begin(); 423 for (NetworkMap::iterator iter = network_map_.begin();
419 iter != network_map_.end(); ++iter) { 424 iter != network_map_.end(); ++iter) {
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
665 HardwareAddressFormat format) { 670 HardwareAddressFormat format) {
666 *hardware_address = hardware_address_; 671 *hardware_address = hardware_address_;
667 return ip_configs_; 672 return ip_configs_;
668 } 673 }
669 674
670 void NetworkLibraryImplStub::SetIPConfig(const NetworkIPConfig& ipconfig) { 675 void NetworkLibraryImplStub::SetIPConfig(const NetworkIPConfig& ipconfig) {
671 ip_configs_.push_back(ipconfig); 676 ip_configs_.push_back(ipconfig);
672 } 677 }
673 678
674 } // namespace chromeos 679 } // namespace chromeos
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/chromeos/status/network_menu_icon.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698