| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_notification_controller.h" | 5 #include "chrome/browser/chromeos/net/network_portal_notification_controller.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "ash/shell.h" | 9 #include "ash/shell.h" |
| 10 #include "ash/system/system_notifier.h" | 10 #include "ash/system/system_notifier.h" |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 #include "chrome/browser/chromeos/profiles/profile_helper.h" | 29 #include "chrome/browser/chromeos/profiles/profile_helper.h" |
| 30 #include "chrome/browser/profiles/profile_manager.h" | 30 #include "chrome/browser/profiles/profile_manager.h" |
| 31 #include "chrome/browser/ui/browser_dialogs.h" | 31 #include "chrome/browser/ui/browser_dialogs.h" |
| 32 #include "chrome/browser/ui/scoped_tabbed_browser_displayer.h" | 32 #include "chrome/browser/ui/scoped_tabbed_browser_displayer.h" |
| 33 #include "chrome/browser/ui/singleton_tabs.h" | 33 #include "chrome/browser/ui/singleton_tabs.h" |
| 34 #include "chrome/common/pref_names.h" | 34 #include "chrome/common/pref_names.h" |
| 35 #include "chrome/grit/generated_resources.h" | 35 #include "chrome/grit/generated_resources.h" |
| 36 #include "chrome/grit/theme_resources.h" | 36 #include "chrome/grit/theme_resources.h" |
| 37 #include "chromeos/chromeos_switches.h" | 37 #include "chromeos/chromeos_switches.h" |
| 38 #include "chromeos/network/network_state.h" | 38 #include "chromeos/network/network_state.h" |
| 39 #include "chromeos/network/network_state_handler.h" |
| 39 #include "chromeos/network/network_type_pattern.h" | 40 #include "chromeos/network/network_type_pattern.h" |
| 40 #include "components/captive_portal/captive_portal_detector.h" | 41 #include "components/captive_portal/captive_portal_detector.h" |
| 41 #include "components/user_manager/user_manager.h" | 42 #include "components/user_manager/user_manager.h" |
| 42 #include "extensions/browser/api/networking_config/networking_config_service.h" | 43 #include "extensions/browser/api/networking_config/networking_config_service.h" |
| 43 #include "extensions/browser/api/networking_config/networking_config_service_fac
tory.h" | 44 #include "extensions/browser/api/networking_config/networking_config_service_fac
tory.h" |
| 44 #include "third_party/cros_system_api/dbus/service_constants.h" | 45 #include "third_party/cros_system_api/dbus/service_constants.h" |
| 45 #include "ui/base/l10n/l10n_util.h" | 46 #include "ui/base/l10n/l10n_util.h" |
| 46 #include "ui/base/resource/resource_bundle.h" | 47 #include "ui/base/resource/resource_bundle.h" |
| 47 #include "ui/message_center/message_center.h" | 48 #include "ui/message_center/message_center.h" |
| 48 #include "ui/message_center/notification.h" | 49 #include "ui/message_center/notification.h" |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 228 "chrome://net/network_portal_detector"; | 229 "chrome://net/network_portal_detector"; |
| 229 | 230 |
| 230 // static | 231 // static |
| 231 const char NetworkPortalNotificationController::kNotificationMetric[] = | 232 const char NetworkPortalNotificationController::kNotificationMetric[] = |
| 232 "CaptivePortal.Notification.Status"; | 233 "CaptivePortal.Notification.Status"; |
| 233 | 234 |
| 234 // static | 235 // static |
| 235 const char NetworkPortalNotificationController::kUserActionMetric[] = | 236 const char NetworkPortalNotificationController::kUserActionMetric[] = |
| 236 "CaptivePortal.Notification.UserAction"; | 237 "CaptivePortal.Notification.UserAction"; |
| 237 | 238 |
| 238 NetworkPortalNotificationController::NetworkPortalNotificationController() | 239 NetworkPortalNotificationController::NetworkPortalNotificationController( |
| 239 : dialog_(nullptr), | 240 NetworkPortalDetector* network_portal_detector) |
| 240 ignore_no_network_for_testing_(false), | 241 : network_portal_detector_(network_portal_detector), weak_factory_(this) { |
| 241 weak_factory_(this) {} | 242 if (NetworkHandler::IsInitialized()) { // NULL for unit tests. |
| 243 NetworkHandler::Get()->network_state_handler()->AddObserver(this, |
| 244 FROM_HERE); |
| 245 } |
| 246 if (network_portal_detector_) |
| 247 network_portal_detector_->AddObserver(this); |
| 248 } |
| 242 | 249 |
| 243 NetworkPortalNotificationController::~NetworkPortalNotificationController() { | 250 NetworkPortalNotificationController::~NetworkPortalNotificationController() { |
| 251 if (network_portal_detector_) |
| 252 network_portal_detector_->RemoveObserver(this); |
| 253 if (NetworkHandler::IsInitialized()) { |
| 254 NetworkHandler::Get()->network_state_handler()->RemoveObserver(this, |
| 255 FROM_HERE); |
| 256 } |
| 244 } | 257 } |
| 245 | 258 |
| 246 void NetworkPortalNotificationController::DefaultNetworkChanged( | 259 void NetworkPortalNotificationController::DefaultNetworkChanged( |
| 247 const NetworkState* network) { | 260 const NetworkState* network) { |
| 248 if (!network) | 261 if (!network) |
| 249 return; | 262 return; |
| 250 Profile* profile = GetProfileForPrimaryUser(); | 263 Profile* profile = GetProfileForPrimaryUser(); |
| 251 extensions::NetworkingConfigService* networking_config_service = | 264 extensions::NetworkingConfigService* networking_config_service = |
| 252 GetNetworkingConfigService(profile); | 265 GetNetworkingConfigService(profile); |
| 253 if (!networking_config_service) | 266 if (!networking_config_service) |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 427 if (dialog_) | 440 if (dialog_) |
| 428 dialog_->Close(); | 441 dialog_->Close(); |
| 429 } | 442 } |
| 430 | 443 |
| 431 const NetworkPortalWebDialog* | 444 const NetworkPortalWebDialog* |
| 432 NetworkPortalNotificationController::GetDialogForTesting() const { | 445 NetworkPortalNotificationController::GetDialogForTesting() const { |
| 433 return dialog_; | 446 return dialog_; |
| 434 } | 447 } |
| 435 | 448 |
| 436 } // namespace chromeos | 449 } // namespace chromeos |
| OLD | NEW |