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

Unified Diff: chrome/browser/chromeos/net/network_portal_detector_impl.cc

Issue 254263004: Revert of Removed dependency on the UI from the NetworkPortalDetector. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 8 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/chromeos/net/network_portal_detector_impl.cc
diff --git a/chrome/browser/chromeos/net/network_portal_detector_impl.cc b/chrome/browser/chromeos/net/network_portal_detector_impl.cc
index a94e559348bf44ddf9b1b1f247e1850a2fbb0b19..b05c74996c86933b579d015959d1cabe0f5ce230 100644
--- a/chrome/browser/chromeos/net/network_portal_detector_impl.cc
+++ b/chrome/browser/chromeos/net/network_portal_detector_impl.cc
@@ -156,7 +156,8 @@
weak_factory_(this),
attempt_count_(0),
strategy_(PortalDetectorStrategy::CreateById(
- PortalDetectorStrategy::STRATEGY_ID_COUNT)) {
+ PortalDetectorStrategy::STRATEGY_ID_LOGIN_SCREEN)),
+ error_screen_displayed_(false) {
captive_portal_detector_.reset(new CaptivePortalDetector(request_context));
strategy_->set_delegate(this);
@@ -169,9 +170,12 @@
registrar_.Add(this,
chrome::NOTIFICATION_AUTH_CANCELLED,
content::NotificationService::AllSources());
+ registrar_.Add(this,
+ chrome::NOTIFICATION_LOGIN_USER_CHANGED,
+ content::NotificationService::AllSources());
NetworkHandler::Get()->network_state_handler()->AddObserver(this, FROM_HERE);
- SetStrategy(PortalDetectorStrategy::STRATEGY_ID_LOGIN_SCREEN);
+ UpdateCurrentStrategy();
}
NetworkPortalDetectorImpl::~NetworkPortalDetectorImpl() {
@@ -246,16 +250,6 @@
return false;
StartDetection();
return true;
-}
-
-void NetworkPortalDetectorImpl::SetStrategy(
- PortalDetectorStrategy::StrategyId id) {
- if (id == strategy_->Id())
- return;
- strategy_.reset(PortalDetectorStrategy::CreateById(id).release());
- strategy_->set_delegate(this);
- StopDetection();
- StartDetectionIfIdle();
}
void NetworkPortalDetectorImpl::DefaultNetworkChanged(
@@ -313,6 +307,15 @@
return time_ticks_for_testing_;
}
+void NetworkPortalDetectorImpl::OnErrorScreenShow() {
+ error_screen_displayed_ = true;
+ UpdateCurrentStrategy();
+}
+
+void NetworkPortalDetectorImpl::OnErrorScreenHide() {
+ error_screen_displayed_ = false;
+ UpdateCurrentStrategy();
+}
////////////////////////////////////////////////////////////////////////////////
// NetworkPortalDetectorImpl, private:
@@ -469,6 +472,8 @@
return;
StopDetection();
ScheduleAttempt(base::TimeDelta::FromSeconds(kProxyChangeDelaySec));
+ } else if (type == chrome::NOTIFICATION_LOGIN_USER_CHANGED) {
+ UpdateCurrentStrategy();
}
}
@@ -556,4 +561,26 @@
}
}
+void NetworkPortalDetectorImpl::UpdateCurrentStrategy() {
+ if (InSession()) {
+ SetStrategy(PortalDetectorStrategy::STRATEGY_ID_SESSION);
+ return;
+ }
+ if (error_screen_displayed_) {
+ SetStrategy(PortalDetectorStrategy::STRATEGY_ID_ERROR_SCREEN);
+ return;
+ }
+ SetStrategy(PortalDetectorStrategy::STRATEGY_ID_LOGIN_SCREEN);
+}
+
+void NetworkPortalDetectorImpl::SetStrategy(
+ PortalDetectorStrategy::StrategyId id) {
+ if (id == strategy_->Id())
+ return;
+ strategy_.reset(PortalDetectorStrategy::CreateById(id).release());
+ strategy_->set_delegate(this);
+ StopDetection();
+ StartDetectionIfIdle();
+}
+
} // namespace chromeos

Powered by Google App Engine
This is Rietveld 408576698