| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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_impl.h" | 5 #include "chrome/browser/chromeos/net/network_portal_detector_impl.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 535 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 546 ++no_response_result_count_; | 546 ++no_response_result_count_; |
| 547 else | 547 else |
| 548 no_response_result_count_ = 0; | 548 no_response_result_count_ = 0; |
| 549 | 549 |
| 550 if (state.status != CAPTIVE_PORTAL_STATUS_OFFLINE || | 550 if (state.status != CAPTIVE_PORTAL_STATUS_OFFLINE || |
| 551 same_detection_result_count_ >= kMaxOfflineResultsBeforeReport) { | 551 same_detection_result_count_ >= kMaxOfflineResultsBeforeReport) { |
| 552 OnDetectionCompleted(network, state); | 552 OnDetectionCompleted(network, state); |
| 553 } | 553 } |
| 554 | 554 |
| 555 // Observers (via OnDetectionCompleted) may already schedule new attempt. | 555 // Observers (via OnDetectionCompleted) may already schedule new attempt. |
| 556 if (!is_idle()) | 556 if (is_idle()) |
| 557 return; | 557 ScheduleAttempt(results.retry_after_delta); |
| 558 | |
| 559 // If behind a captive portal and the response code was 200 (OK), do not | |
| 560 // schedule a new attempt. | |
| 561 if (state.status == CAPTIVE_PORTAL_STATUS_PORTAL && response_code == 200) | |
| 562 return; | |
| 563 | |
| 564 ScheduleAttempt(results.retry_after_delta); | |
| 565 } | 558 } |
| 566 | 559 |
| 567 void NetworkPortalDetectorImpl::Observe( | 560 void NetworkPortalDetectorImpl::Observe( |
| 568 int type, | 561 int type, |
| 569 const content::NotificationSource& source, | 562 const content::NotificationSource& source, |
| 570 const content::NotificationDetails& details) { | 563 const content::NotificationDetails& details) { |
| 571 if (type == chrome::NOTIFICATION_LOGIN_PROXY_CHANGED || | 564 if (type == chrome::NOTIFICATION_LOGIN_PROXY_CHANGED || |
| 572 type == chrome::NOTIFICATION_AUTH_SUPPLIED || | 565 type == chrome::NOTIFICATION_AUTH_SUPPLIED || |
| 573 type == chrome::NOTIFICATION_AUTH_CANCELLED) { | 566 type == chrome::NOTIFICATION_AUTH_CANCELLED) { |
| 574 NET_LOG(EVENT) << "Restarting portal detection due to proxy change" | 567 NET_LOG(EVENT) << "Restarting portal detection due to proxy change" |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 654 } | 647 } |
| 655 | 648 |
| 656 void NetworkPortalDetectorImpl::ResetStrategyAndCounters() { | 649 void NetworkPortalDetectorImpl::ResetStrategyAndCounters() { |
| 657 last_detection_result_ = CAPTIVE_PORTAL_STATUS_UNKNOWN; | 650 last_detection_result_ = CAPTIVE_PORTAL_STATUS_UNKNOWN; |
| 658 same_detection_result_count_ = 0; | 651 same_detection_result_count_ = 0; |
| 659 no_response_result_count_ = 0; | 652 no_response_result_count_ = 0; |
| 660 strategy_->Reset(); | 653 strategy_->Reset(); |
| 661 } | 654 } |
| 662 | 655 |
| 663 } // namespace chromeos | 656 } // namespace chromeos |
| OLD | NEW |