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

Side by Side Diff: chrome/browser/chromeos/proxy_cros_settings_provider.cc

Issue 8496017: cros proxy: fix bug to use default port whenever its input field is empty. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 9 years, 1 month 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 | « chrome/browser/chromeos/proxy_cros_settings_provider.h ('k') | no next file » | 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/proxy_cros_settings_provider.h" 5 #include "chrome/browser/chromeos/proxy_cros_settings_provider.h"
6 6
7 #include "base/string_util.h" 7 #include "base/string_util.h"
8 #include "chrome/browser/browser_process.h" 8 #include "chrome/browser/browser_process.h"
9 #include "chrome/browser/chromeos/cros_settings.h" 9 #include "chrome/browser/chromeos/cros_settings.h"
10 #include "chrome/browser/profiles/profile.h" 10 #include "chrome/browser/profiles/profile.h"
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after
344 return profile_->GetProxyConfigTracker(); 344 return profile_->GetProxyConfigTracker();
345 } 345 }
346 346
347 net::ProxyServer ProxyCrosSettingsProvider::CreateProxyServerFromHost( 347 net::ProxyServer ProxyCrosSettingsProvider::CreateProxyServerFromHost(
348 const std::string& host, 348 const std::string& host,
349 const ProxyConfigServiceImpl::ProxyConfig::ManualProxy& proxy, 349 const ProxyConfigServiceImpl::ProxyConfig::ManualProxy& proxy,
350 net::ProxyServer::Scheme scheme) const { 350 net::ProxyServer::Scheme scheme) const {
351 uint16 port = 0; 351 uint16 port = 0;
352 if (proxy.server.is_valid()) 352 if (proxy.server.is_valid())
353 port = proxy.server.host_port_pair().port(); 353 port = proxy.server.host_port_pair().port();
354 if (host.length() == 0 && port == 0) 354 return CreateProxyServer(host, port, scheme);
355 return net::ProxyServer();
356 if (port == 0)
357 port = net::ProxyServer::GetDefaultPortForScheme(scheme);
358 net::HostPortPair host_port_pair(host, port);
359 return net::ProxyServer(scheme, host_port_pair);
360 } 355 }
361 356
362 net::ProxyServer ProxyCrosSettingsProvider::CreateProxyServerFromPort( 357 net::ProxyServer ProxyCrosSettingsProvider::CreateProxyServerFromPort(
363 uint16 port, 358 uint16 port,
364 const ProxyConfigServiceImpl::ProxyConfig::ManualProxy& proxy, 359 const ProxyConfigServiceImpl::ProxyConfig::ManualProxy& proxy,
365 net::ProxyServer::Scheme scheme) const { 360 net::ProxyServer::Scheme scheme) const {
366 std::string host; 361 std::string host;
367 if (proxy.server.is_valid()) 362 if (proxy.server.is_valid())
368 host = proxy.server.host_port_pair().host(); 363 host = proxy.server.host_port_pair().host();
364 return CreateProxyServer(host, port, scheme);
365 }
366
367 net::ProxyServer ProxyCrosSettingsProvider::CreateProxyServer(
368 std::string host,
369 uint16 port,
370 net::ProxyServer::Scheme scheme) const {
369 if (host.length() == 0 && port == 0) 371 if (host.length() == 0 && port == 0)
370 return net::ProxyServer(); 372 return net::ProxyServer();
373 if (port == 0)
374 port = net::ProxyServer::GetDefaultPortForScheme(scheme);
371 net::HostPortPair host_port_pair(host, port); 375 net::HostPortPair host_port_pair(host, port);
372 return net::ProxyServer(scheme, host_port_pair); 376 return net::ProxyServer(scheme, host_port_pair);
373 } 377 }
374 378
375 Value* ProxyCrosSettingsProvider::CreateServerHostValue( 379 Value* ProxyCrosSettingsProvider::CreateServerHostValue(
376 const ProxyConfigServiceImpl::ProxyConfig::ManualProxy& proxy) const { 380 const ProxyConfigServiceImpl::ProxyConfig::ManualProxy& proxy) const {
377 return proxy.server.is_valid() ? 381 return proxy.server.is_valid() ?
378 Value::CreateStringValue(proxy.server.host_port_pair().host()) : 382 Value::CreateStringValue(proxy.server.host_port_pair().host()) :
379 NULL; 383 NULL;
380 } 384 }
381 385
382 Value* ProxyCrosSettingsProvider::CreateServerPortValue( 386 Value* ProxyCrosSettingsProvider::CreateServerPortValue(
383 const ProxyConfigServiceImpl::ProxyConfig::ManualProxy& proxy) const { 387 const ProxyConfigServiceImpl::ProxyConfig::ManualProxy& proxy) const {
384 return proxy.server.is_valid() ? 388 return proxy.server.is_valid() ?
385 Value::CreateIntegerValue(proxy.server.host_port_pair().port()) : 389 Value::CreateIntegerValue(proxy.server.host_port_pair().port()) :
386 NULL; 390 NULL;
387 } 391 }
388 392
389 } // namespace chromeos 393 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/proxy_cros_settings_provider.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698