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

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

Issue 7101013: Fix issue with static ipconfig not creating dhcp ip configs properly. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 6 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/resources/options/chromeos/internet_detail.html » ('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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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.h" 5 #include "chrome/browser/chromeos/cros/network_library.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <map> 8 #include <map>
9 9
10 #include "base/i18n/icu_encoding_detection.h" 10 #include "base/i18n/icu_encoding_detection.h"
(...skipping 3370 matching lines...) Expand 10 before | Expand all | Expand 10 after
3381 chromeos::ListIPConfigs(ipconfig.device_path.c_str()); 3381 chromeos::ListIPConfigs(ipconfig.device_path.c_str());
3382 if (ipconfig_status) { 3382 if (ipconfig_status) {
3383 for (int i = 0; i < ipconfig_status->size; i++) { 3383 for (int i = 0; i < ipconfig_status->size; i++) {
3384 if (ipconfig_status->ips[i].type == chromeos::IPCONFIG_TYPE_DHCP) 3384 if (ipconfig_status->ips[i].type == chromeos::IPCONFIG_TYPE_DHCP)
3385 ipconfig_dhcp = &ipconfig_status->ips[i]; 3385 ipconfig_dhcp = &ipconfig_status->ips[i];
3386 else if (ipconfig_status->ips[i].type == chromeos::IPCONFIG_TYPE_IPV4) 3386 else if (ipconfig_status->ips[i].type == chromeos::IPCONFIG_TYPE_IPV4)
3387 ipconfig_static = &ipconfig_status->ips[i]; 3387 ipconfig_static = &ipconfig_status->ips[i];
3388 } 3388 }
3389 } 3389 }
3390 3390
3391 // If switching from dhcp to static, then create new static ip config.
3392 IPConfigStatus* ipconfig_status2 = NULL; 3391 IPConfigStatus* ipconfig_status2 = NULL;
3393 if (ipconfig.type == chromeos::IPCONFIG_TYPE_IPV4 && !ipconfig_static) { 3392 if (ipconfig.type == chromeos::IPCONFIG_TYPE_DHCP) {
3394 // Create new static ip config. 3393 // If switching from static to dhcp, create new dhcp ip config.
3395 chromeos::AddIPConfig(ipconfig.device_path.c_str(), 3394 if (!ipconfig_dhcp)
3396 chromeos::IPCONFIG_TYPE_IPV4); 3395 chromeos::AddIPConfig(ipconfig.device_path.c_str(),
3397 // Now find the newly created IP config. 3396 chromeos::IPCONFIG_TYPE_DHCP);
3398 ipconfig_status2 = chromeos::ListIPConfigs(ipconfig.device_path.c_str()); 3397 // User wants DHCP now. So delete the static ip config.
3399 if (ipconfig_status2) { 3398 if (ipconfig_static)
3400 for (int i = 0; i < ipconfig_status2->size; i++) { 3399 chromeos::RemoveIPConfig(ipconfig_static);
3401 if (ipconfig_status2->ips[i].type == chromeos::IPCONFIG_TYPE_IPV4) 3400 } else if (ipconfig.type == chromeos::IPCONFIG_TYPE_IPV4) {
3402 ipconfig_static = &ipconfig_status2->ips[i]; 3401 // If switching from dhcp to static, create new static ip config.
3402 if (!ipconfig_static) {
3403 chromeos::AddIPConfig(ipconfig.device_path.c_str(),
3404 chromeos::IPCONFIG_TYPE_IPV4);
3405 // Now find the newly created IP config.
3406 ipconfig_status2 =
3407 chromeos::ListIPConfigs(ipconfig.device_path.c_str());
3408 if (ipconfig_status2) {
3409 for (int i = 0; i < ipconfig_status2->size; i++) {
3410 if (ipconfig_status2->ips[i].type == chromeos::IPCONFIG_TYPE_IPV4)
3411 ipconfig_static = &ipconfig_status2->ips[i];
3412 }
3403 } 3413 }
3404 } 3414 }
3405 }
3406
3407 if (ipconfig.type == chromeos::IPCONFIG_TYPE_DHCP) {
3408 if (ipconfig_static) {
3409 // User wants DHCP now. So delete the static ip config.
3410 chromeos::RemoveIPConfig(ipconfig_static);
3411 }
3412 } else if (ipconfig.type == chromeos::IPCONFIG_TYPE_IPV4) {
3413 if (ipconfig_static) { 3415 if (ipconfig_static) {
3414 // Save any changed details. 3416 // Save any changed details.
3415 if (ipconfig.address != ipconfig_static->address) { 3417 if (ipconfig.address != ipconfig_static->address) {
3416 scoped_ptr<Value> value(Value::CreateStringValue(ipconfig.address)); 3418 scoped_ptr<Value> value(Value::CreateStringValue(ipconfig.address));
3417 chromeos::SetNetworkIPConfigProperty(ipconfig_static->path, 3419 chromeos::SetNetworkIPConfigProperty(ipconfig_static->path,
3418 kAddressProperty, 3420 kAddressProperty,
3419 value.get()); 3421 value.get());
3420 } 3422 }
3421 if (ipconfig.netmask != ipconfig_static->netmask) { 3423 if (ipconfig.netmask != ipconfig_static->netmask) {
3422 int32 prefixlen = ipconfig.GetPrefixLength(); 3424 int32 prefixlen = ipconfig.GetPrefixLength();
(...skipping 14 matching lines...) Expand all
3437 value.get()); 3439 value.get());
3438 } 3440 }
3439 if (ipconfig.name_servers != ipconfig_static->name_servers) { 3441 if (ipconfig.name_servers != ipconfig_static->name_servers) {
3440 scoped_ptr<Value> value( 3442 scoped_ptr<Value> value(
3441 Value::CreateStringValue(ipconfig.name_servers)); 3443 Value::CreateStringValue(ipconfig.name_servers));
3442 chromeos::SetNetworkIPConfigProperty(ipconfig_static->path, 3444 chromeos::SetNetworkIPConfigProperty(ipconfig_static->path,
3443 kNameServersProperty, 3445 kNameServersProperty,
3444 value.get()); 3446 value.get());
3445 } 3447 }
3446 // Remove dhcp ip config if there is one. 3448 // Remove dhcp ip config if there is one.
3447 if (ipconfig_dhcp) { 3449 if (ipconfig_dhcp)
3448 chromeos::RemoveIPConfig(ipconfig_dhcp); 3450 chromeos::RemoveIPConfig(ipconfig_dhcp);
3449 }
3450 } 3451 }
3451 } 3452 }
3452 3453
3453 if (ipconfig_status) 3454 if (ipconfig_status)
3454 chromeos::FreeIPConfigStatus(ipconfig_status); 3455 chromeos::FreeIPConfigStatus(ipconfig_status);
3455 if (ipconfig_status2) 3456 if (ipconfig_status2)
3456 chromeos::FreeIPConfigStatus(ipconfig_status2); 3457 chromeos::FreeIPConfigStatus(ipconfig_status2);
3457 } 3458 }
3458 3459
3459 private: 3460 private:
(...skipping 1625 matching lines...) Expand 10 before | Expand all | Expand 10 after
5085 return new NetworkLibraryStubImpl(); 5086 return new NetworkLibraryStubImpl();
5086 else 5087 else
5087 return new NetworkLibraryImpl(); 5088 return new NetworkLibraryImpl();
5088 } 5089 }
5089 5090
5090 } // namespace chromeos 5091 } // namespace chromeos
5091 5092
5092 // Allows InvokeLater without adding refcounting. This class is a Singleton and 5093 // Allows InvokeLater without adding refcounting. This class is a Singleton and
5093 // won't be deleted until it's last InvokeLater is run. 5094 // won't be deleted until it's last InvokeLater is run.
5094 DISABLE_RUNNABLE_METHOD_REFCOUNT(chromeos::NetworkLibraryImpl); 5095 DISABLE_RUNNABLE_METHOD_REFCOUNT(chromeos::NetworkLibraryImpl);
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/resources/options/chromeos/internet_detail.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698