Index: chrome/browser/chromeos/net/network_portal_notification_controller.cc |
diff --git a/chrome/browser/chromeos/net/network_portal_notification_controller.cc b/chrome/browser/chromeos/net/network_portal_notification_controller.cc |
index 92a7278272799db59b96266c5ca47e3cf07c1503..b65686e7f5609dbe0d089c4ecd5ed26b71b341d2 100644 |
--- a/chrome/browser/chromeos/net/network_portal_notification_controller.cc |
+++ b/chrome/browser/chromeos/net/network_portal_notification_controller.cc |
@@ -36,6 +36,7 @@ |
#include "chrome/grit/theme_resources.h" |
#include "chromeos/chromeos_switches.h" |
#include "chromeos/network/network_state.h" |
+#include "chromeos/network/network_state_handler.h" |
#include "chromeos/network/network_type_pattern.h" |
#include "components/captive_portal/captive_portal_detector.h" |
#include "components/user_manager/user_manager.h" |
@@ -235,12 +236,24 @@ const char NetworkPortalNotificationController::kNotificationMetric[] = |
const char NetworkPortalNotificationController::kUserActionMetric[] = |
"CaptivePortal.Notification.UserAction"; |
-NetworkPortalNotificationController::NetworkPortalNotificationController() |
- : dialog_(nullptr), |
- ignore_no_network_for_testing_(false), |
- weak_factory_(this) {} |
+NetworkPortalNotificationController::NetworkPortalNotificationController( |
+ NetworkPortalDetector* network_portal_detector) |
+ : network_portal_detector_(network_portal_detector), weak_factory_(this) { |
+ if (NetworkHandler::IsInitialized()) { |
stevenjb
2015/09/17 20:45:53
This should probably be a DCHECK, it would be bad
achuithb
2015/09/17 22:03:33
It's NULL for unit tests. I've added a comment.
|
+ NetworkHandler::Get()->network_state_handler()->AddObserver(this, |
+ FROM_HERE); |
+ } |
+ if (network_portal_detector_) |
+ network_portal_detector_->AddObserver(this); |
+} |
NetworkPortalNotificationController::~NetworkPortalNotificationController() { |
+ if (network_portal_detector_) |
+ network_portal_detector_->RemoveObserver(this); |
+ if (NetworkHandler::IsInitialized()) { |
+ NetworkHandler::Get()->network_state_handler()->RemoveObserver(this, |
+ FROM_HERE); |
+ } |
} |
void NetworkPortalNotificationController::DefaultNetworkChanged( |