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

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

Issue 11578052: Replace OncNetworkParser by the new ONC translator. (Closed) Base URL: http://git.chromium.org/chromium/src.git@extend_onc_to_shill
Patch Set: Rebased. Created 7 years, 11 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 (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 "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/stl_util.h"
9 #include "chrome/browser/chromeos/cros/native_network_constants.h" 10 #include "chrome/browser/chromeos/cros/native_network_constants.h"
10 #include "chrome/common/chrome_switches.h" 11 #include "chrome/common/chrome_switches.h"
11 #include "content/public/browser/browser_thread.h" 12 #include "content/public/browser/browser_thread.h"
12 #include "third_party/cros_system_api/dbus/service_constants.h" 13 #include "third_party/cros_system_api/dbus/service_constants.h"
13 14
14 using content::BrowserThread; 15 using content::BrowserThread;
15 16
16 namespace { 17 namespace {
17 18
18 bool IsEthernetEnabled() { 19 bool IsEthernetEnabled() {
(...skipping 17 matching lines...) Expand all
36 if (IsEthernetEnabled()) 37 if (IsEthernetEnabled())
37 check_portal_list_ = "ethernet,wifi,cellular"; 38 check_portal_list_ = "ethernet,wifi,cellular";
38 else 39 else
39 check_portal_list_ = "wifi,cellular"; 40 check_portal_list_ = "wifi,cellular";
40 } 41 }
41 42
42 NetworkLibraryImplStub::~NetworkLibraryImplStub() { 43 NetworkLibraryImplStub::~NetworkLibraryImplStub() {
43 disabled_wifi_networks_.clear(); 44 disabled_wifi_networks_.clear();
44 disabled_cellular_networks_.clear(); 45 disabled_cellular_networks_.clear();
45 disabled_wimax_networks_.clear(); 46 disabled_wimax_networks_.clear();
47 STLDeleteValues(&service_configurations_);
46 } 48 }
47 49
48 void NetworkLibraryImplStub::Init() { 50 void NetworkLibraryImplStub::Init() {
49 is_locked_ = false; 51 is_locked_ = false;
50 52
51 // Devices 53 // Devices
52 int devices = (1 << TYPE_WIFI) | (1 << TYPE_CELLULAR) | (1 << TYPE_WIMAX); 54 int devices = (1 << TYPE_WIFI) | (1 << TYPE_CELLULAR) | (1 << TYPE_WIMAX);
53 if (IsEthernetEnabled()) 55 if (IsEthernetEnabled())
54 devices |= 1 << TYPE_ETHERNET; 56 devices |= 1 << TYPE_ETHERNET;
55 available_devices_ = devices; 57 available_devices_ = devices;
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 wifi2->set_encryption(SECURITY_NONE); 122 wifi2->set_encryption(SECURITY_NONE);
121 AddStubNetwork(wifi2, PROFILE_SHARED); 123 AddStubNetwork(wifi2, PROFILE_SHARED);
122 124
123 WifiNetwork* wifi3 = new WifiNetwork("wifi3"); 125 WifiNetwork* wifi3 = new WifiNetwork("wifi3");
124 wifi3->set_name("Fake WiFi3 Encrypted with a long name"); 126 wifi3->set_name("Fake WiFi3 Encrypted with a long name");
125 wifi3->set_strength(60); 127 wifi3->set_strength(60);
126 wifi3->set_encryption(SECURITY_WEP); 128 wifi3->set_encryption(SECURITY_WEP);
127 wifi3->set_passphrase_required(true); 129 wifi3->set_passphrase_required(true);
128 AddStubNetwork(wifi3, PROFILE_USER); 130 AddStubNetwork(wifi3, PROFILE_USER);
129 131
132 CertificatePattern pattern;
133 IssuerSubjectPattern issuer;
134 issuer.set_organization("Google, Inc.");
135 pattern.set_issuer(issuer);
136 std::vector<std::string> enrollment_uris;
137 enrollment_uris.push_back("http://youtu.be/dQw4w9WgXcQ");
138 enrollment_uris.push_back("chrome-extension://abc/keygen-cert.html");
139 pattern.set_enrollment_uri_list(enrollment_uris);
140
130 WifiNetwork* wifi_cert_pattern = new WifiNetwork("wifi_cert_pattern"); 141 WifiNetwork* wifi_cert_pattern = new WifiNetwork("wifi_cert_pattern");
131 wifi_cert_pattern->set_name("Fake WiFi CertPattern 802.1x"); 142 wifi_cert_pattern->set_name("Fake WiFi CertPattern 802.1x");
132 wifi_cert_pattern->set_strength(50); 143 wifi_cert_pattern->set_strength(50);
133 wifi_cert_pattern->set_connectable(false); 144 wifi_cert_pattern->set_connectable(false);
134 wifi_cert_pattern->set_encryption(SECURITY_8021X); 145 wifi_cert_pattern->set_encryption(SECURITY_8021X);
135 wifi_cert_pattern->SetEAPMethod(EAP_METHOD_TLS); 146 wifi_cert_pattern->SetEAPMethod(EAP_METHOD_TLS);
136 wifi_cert_pattern->SetEAPUseSystemCAs(true); 147 wifi_cert_pattern->SetEAPUseSystemCAs(true);
137 wifi_cert_pattern->SetEAPIdentity("user@example.com"); 148 wifi_cert_pattern->SetEAPIdentity("user@example.com");
138 wifi_cert_pattern->SetEAPPhase2Auth(EAP_PHASE_2_AUTH_AUTO); 149 wifi_cert_pattern->SetEAPPhase2Auth(EAP_PHASE_2_AUTH_AUTO);
139 wifi_cert_pattern->set_client_cert_type(CLIENT_CERT_TYPE_PATTERN); 150 wifi_cert_pattern->set_client_cert_type(CLIENT_CERT_TYPE_PATTERN);
140 CertificatePattern pattern;
141 IssuerSubjectPattern subject;
142 subject.set_organization("Google Inc");
143 pattern.set_subject(subject);
144 std::vector<std::string> enrollment_uris;
145 enrollment_uris.push_back("http://www.google.com/chromebook");
146 pattern.set_enrollment_uri_list(enrollment_uris);
147 wifi_cert_pattern->set_client_cert_pattern(pattern); 151 wifi_cert_pattern->set_client_cert_pattern(pattern);
148 wifi_cert_pattern->set_eap_save_credentials(true); 152 wifi_cert_pattern->set_eap_save_credentials(true);
149 153
150 AddStubNetwork(wifi_cert_pattern, PROFILE_USER); 154 AddStubNetwork(wifi_cert_pattern, PROFILE_USER);
151 155
152 WifiNetwork* wifi4 = new WifiNetwork("wifi4"); 156 WifiNetwork* wifi4 = new WifiNetwork("wifi4");
153 wifi4->set_name("Fake WiFi4 802.1x"); 157 wifi4->set_name("Fake WiFi4 802.1x");
154 wifi4->set_strength(50); 158 wifi4->set_strength(50);
155 wifi4->set_connectable(false); 159 wifi4->set_connectable(false);
156 wifi4->set_encryption(SECURITY_8021X); 160 wifi4->set_encryption(SECURITY_8021X);
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 268
265 VirtualNetwork* vpn4 = new VirtualNetwork("vpn4"); 269 VirtualNetwork* vpn4 = new VirtualNetwork("vpn4");
266 vpn4->set_name("Fake VPN4 (policy-managed)"); 270 vpn4->set_name("Fake VPN4 (policy-managed)");
267 vpn4->set_server_hostname("vpn4server.fake.com"); 271 vpn4->set_server_hostname("vpn4server.fake.com");
268 vpn4->set_provider_type(PROVIDER_TYPE_OPEN_VPN); 272 vpn4->set_provider_type(PROVIDER_TYPE_OPEN_VPN);
269 NetworkUIData vpn4_ui_data; 273 NetworkUIData vpn4_ui_data;
270 vpn4_ui_data.set_onc_source(onc::ONC_SOURCE_DEVICE_POLICY); 274 vpn4_ui_data.set_onc_source(onc::ONC_SOURCE_DEVICE_POLICY);
271 vpn4->set_ui_data(vpn4_ui_data); 275 vpn4->set_ui_data(vpn4_ui_data);
272 AddStubNetwork(vpn4, PROFILE_USER); 276 AddStubNetwork(vpn4, PROFILE_USER);
273 277
278 VirtualNetwork* vpn_cert_pattern = new VirtualNetwork("vpn_cert_pattern");
279 vpn_cert_pattern->set_name("Fake VPN CertPattern");
280 vpn_cert_pattern->set_server_hostname("vpn4server.fake.com");
281 vpn_cert_pattern->set_provider_type(PROVIDER_TYPE_OPEN_VPN);
282 vpn_cert_pattern->set_client_cert_type(CLIENT_CERT_TYPE_PATTERN);
283 vpn_cert_pattern->set_client_cert_pattern(pattern);
284
285 AddStubNetwork(vpn_cert_pattern, PROFILE_USER);
286
274 wifi_scanning_ = false; 287 wifi_scanning_ = false;
275 offline_mode_ = false; 288 offline_mode_ = false;
276 289
277 // Ensure our active network is connected and vice versa, otherwise our 290 // Ensure our active network is connected and vice versa, otherwise our
278 // autotest browser_tests sometimes conclude the device is offline. 291 // autotest browser_tests sometimes conclude the device is offline.
279 CHECK(active_network()->connected()) 292 CHECK(active_network()->connected())
280 << "Active: " << active_network()->name(); 293 << "Active: " << active_network()->name();
281 CHECK(connected_network()->is_active()); 294 CHECK(connected_network()->is_active());
282 295
283 std::string test_blob( 296 std::string test_blob(
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
367 remembered_vpn->set_ui_data(vpn_ui_data); 380 remembered_vpn->set_ui_data(vpn_ui_data);
368 remembered = remembered_vpn; 381 remembered = remembered_vpn;
369 } 382 }
370 if (remembered) { 383 if (remembered) {
371 remembered->set_name(network->name()); 384 remembered->set_name(network->name());
372 remembered->set_unique_id(network->unique_id()); 385 remembered->set_unique_id(network->unique_id());
373 // ValidateAndAddRememberedNetwork will insert the network into the right 386 // ValidateAndAddRememberedNetwork will insert the network into the right
374 // remembered_*_networks_ list and the remembered_network_map_. 387 // remembered_*_networks_ list and the remembered_network_map_.
375 if (!ValidateAndAddRememberedNetwork(remembered)) 388 if (!ValidateAndAddRememberedNetwork(remembered))
376 NOTREACHED(); 389 NOTREACHED();
390 remembered->set_profile_path(profile->path);
391 remembered->set_profile_type(profile->type);
377 } 392 }
378 } 393 }
379 394
380 void NetworkLibraryImplStub::ConnectToNetwork(Network* network) { 395 void NetworkLibraryImplStub::ConnectToNetwork(Network* network) {
381 std::string passphrase; 396 std::string passphrase;
382 if (network->type() == TYPE_WIFI) { 397 if (network->type() == TYPE_WIFI) {
383 WifiNetwork* wifi = static_cast<WifiNetwork*>(network); 398 WifiNetwork* wifi = static_cast<WifiNetwork*>(network);
384 if (wifi->passphrase_required()) 399 if (wifi->passphrase_required())
385 passphrase = wifi->passphrase(); 400 passphrase = wifi->passphrase();
386 } else if (network->type() == TYPE_WIMAX) { 401 } else if (network->type() == TYPE_WIMAX) {
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
456 const std::string& service_path) {} 471 const std::string& service_path) {}
457 472
458 void NetworkLibraryImplStub::MonitorNetworkDeviceStart( 473 void NetworkLibraryImplStub::MonitorNetworkDeviceStart(
459 const std::string& device_path) {} 474 const std::string& device_path) {}
460 475
461 void NetworkLibraryImplStub::MonitorNetworkDeviceStop( 476 void NetworkLibraryImplStub::MonitorNetworkDeviceStop(
462 const std::string& device_path) {} 477 const std::string& device_path) {}
463 478
464 void NetworkLibraryImplStub::CallConfigureService( 479 void NetworkLibraryImplStub::CallConfigureService(
465 const std::string& identifier, 480 const std::string& identifier,
466 const DictionaryValue* info) {} 481 const DictionaryValue* info) {
482 DictionaryValue*& config_entry = service_configurations_[identifier];
483 delete config_entry;
484 config_entry = info->DeepCopy();
485 }
467 486
468 void NetworkLibraryImplStub::CallConnectToNetwork(Network* network) { 487 void NetworkLibraryImplStub::CallConnectToNetwork(Network* network) {
469 // Immediately set the network to active to mimic shill's behavior. 488 // Immediately set the network to active to mimic shill's behavior.
470 SetActiveNetwork(network->type(), network->service_path()); 489 SetActiveNetwork(network->type(), network->service_path());
471 // If a delay has been set (i.e. we are interactive), delay the call to 490 // If a delay has been set (i.e. we are interactive), delay the call to
472 // ConnectToNetwork (but signal observers since we changed connecting state). 491 // ConnectToNetwork (but signal observers since we changed connecting state).
473 if (connect_delay_ms_) { 492 if (connect_delay_ms_) {
474 // This class is a Singleton and won't be deleted until this callbacks has 493 // This class is a Singleton and won't be deleted until this callbacks has
475 // run. 494 // run.
476 BrowserThread::PostDelayedTask( 495 BrowserThread::PostDelayedTask(
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after
739 dictionary->SetString(flimflam::kTypeProperty, 758 dictionary->SetString(flimflam::kTypeProperty,
740 ConnectionTypeToString(network->type())); 759 ConnectionTypeToString(network->type()));
741 dictionary->SetString(flimflam::kNameProperty, network->name()); 760 dictionary->SetString(flimflam::kNameProperty, network->name());
742 dictionary->SetString(flimflam::kGuidProperty, network->unique_id()); 761 dictionary->SetString(flimflam::kGuidProperty, network->unique_id());
743 dictionary->SetString(flimflam::kStateProperty, 762 dictionary->SetString(flimflam::kStateProperty,
744 ConnectionStateToString(network->state())); 763 ConnectionStateToString(network->state()));
745 } 764 }
746 callback.Run(service_path, dictionary.get()); 765 callback.Run(service_path, dictionary.get());
747 } 766 }
748 767
768 const std::map<std::string, base::DictionaryValue*>&
769 NetworkLibraryImplStub::GetConfigurations() {
770 return service_configurations_;
771 }
772
749 } // namespace chromeos 773 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/cros/network_library_impl_stub.h ('k') | chrome/browser/chromeos/cros/network_library_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698