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

Side by Side Diff: chrome/browser/chromeos/net/network_portal_detector.cc

Issue 12263006: Fixed portal detector behaviour for proxied network. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 10 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/net/network_portal_detector_unittest.cc » ('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/net/network_portal_detector.h" 5 #include "chrome/browser/chromeos/net/network_portal_detector.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/logging.h" 9 #include "base/logging.h"
10 #include "base/message_loop.h" 10 #include "base/message_loop.h"
(...skipping 18 matching lines...) Expand all
29 const int kMaxRequestAttempts = 3; 29 const int kMaxRequestAttempts = 3;
30 30
31 // Minimum timeout between consecutive portal checks for the same 31 // Minimum timeout between consecutive portal checks for the same
32 // network. 32 // network.
33 const int kMinTimeBetweenAttemptsSec = 3; 33 const int kMinTimeBetweenAttemptsSec = 3;
34 34
35 // Timeout for a portal check. 35 // Timeout for a portal check.
36 const int kRequestTimeoutSec = 10; 36 const int kRequestTimeoutSec = 10;
37 37
38 // Delay before portal detection caused by changes in proxy settings. 38 // Delay before portal detection caused by changes in proxy settings.
39 const int kProxyChangeDelayMs = 500; 39 const int kProxyChangeDelayMs = 1000;
40 40
41 std::string CaptivePortalStatusString( 41 std::string CaptivePortalStatusString(
42 NetworkPortalDetector::CaptivePortalStatus status) { 42 NetworkPortalDetector::CaptivePortalStatus status) {
43 switch (status) { 43 switch (status) {
44 case NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_UNKNOWN: 44 case NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_UNKNOWN:
45 return l10n_util::GetStringUTF8( 45 return l10n_util::GetStringUTF8(
46 IDS_CHROMEOS_CAPTIVE_PORTAL_STATUS_UNKNOWN); 46 IDS_CHROMEOS_CAPTIVE_PORTAL_STATUS_UNKNOWN);
47 case NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_OFFLINE: 47 case NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_OFFLINE:
48 return l10n_util::GetStringUTF8( 48 return l10n_util::GetStringUTF8(
49 IDS_CHROMEOS_CAPTIVE_PORTAL_STATUS_OFFLINE); 49 IDS_CHROMEOS_CAPTIVE_PORTAL_STATUS_OFFLINE);
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 304
305 NetworkLibrary* cros = CrosLibrary::Get()->GetNetworkLibrary(); 305 NetworkLibrary* cros = CrosLibrary::Get()->GetNetworkLibrary();
306 const Network* active_network = cros->active_network(); 306 const Network* active_network = cros->active_network();
307 if (!active_network) 307 if (!active_network)
308 return; 308 return;
309 309
310 CaptivePortalState state; 310 CaptivePortalState state;
311 state.response_code = results.response_code; 311 state.response_code = results.response_code;
312 switch (results.result) { 312 switch (results.result) {
313 case captive_portal::RESULT_NO_RESPONSE: 313 case captive_portal::RESULT_NO_RESPONSE:
314 if (state.response_code == net::HTTP_PROXY_AUTHENTICATION_REQUIRED) { 314 if (attempt_count_ >= kMaxRequestAttempts) {
315 state.status = CAPTIVE_PORTAL_STATUS_PROXY_AUTH_REQUIRED; 315 if (state.response_code == net::HTTP_PROXY_AUTHENTICATION_REQUIRED) {
316 SetCaptivePortalState(active_network, state); 316 state.status = CAPTIVE_PORTAL_STATUS_PROXY_AUTH_REQUIRED;
317 } else if (attempt_count_ >= kMaxRequestAttempts) { 317 } else if (active_network->restricted_pool()) {
318 // Take into account shill's detection results. 318 // Take into account shill's detection results.
319 if (active_network->restricted_pool()) {
320 state.status = CAPTIVE_PORTAL_STATUS_PORTAL; 319 state.status = CAPTIVE_PORTAL_STATUS_PORTAL;
321 LOG(WARNING) << "Network " << active_network->unique_id() << " " 320 LOG(WARNING) << "Network " << active_network->unique_id() << " "
322 << "is marked as " 321 << "is marked as "
323 << CaptivePortalStatusString(state.status) << " " 322 << CaptivePortalStatusString(state.status) << " "
324 << "despite the fact that CaptivePortalDetector " 323 << "despite the fact that CaptivePortalDetector "
325 << "received no response"; 324 << "received no response";
326 } else { 325 } else {
327 state.status = CAPTIVE_PORTAL_STATUS_OFFLINE; 326 state.status = CAPTIVE_PORTAL_STATUS_OFFLINE;
328 } 327 }
329 SetCaptivePortalState(active_network, state); 328 SetCaptivePortalState(active_network, state);
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
397 } 396 }
398 397
399 base::TimeTicks NetworkPortalDetector::GetCurrentTimeTicks() const { 398 base::TimeTicks NetworkPortalDetector::GetCurrentTimeTicks() const {
400 if (time_ticks_for_testing_.is_null()) 399 if (time_ticks_for_testing_.is_null())
401 return base::TimeTicks::Now(); 400 return base::TimeTicks::Now();
402 else 401 else
403 return time_ticks_for_testing_; 402 return time_ticks_for_testing_;
404 } 403 }
405 404
406 } // namespace chromeos 405 } // namespace chromeos
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/chromeos/net/network_portal_detector_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698