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