| 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 <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 268 } | 268 } |
| 269 | 269 |
| 270 void NetworkPortalNotificationController::OnPortalDetectionCompleted( | 270 void NetworkPortalNotificationController::OnPortalDetectionCompleted( |
| 271 const NetworkState* network, | 271 const NetworkState* network, |
| 272 const NetworkPortalDetector::CaptivePortalState& state) { | 272 const NetworkPortalDetector::CaptivePortalState& state) { |
| 273 if (!IsPortalNotificationEnabled()) | 273 if (!IsPortalNotificationEnabled()) |
| 274 return; | 274 return; |
| 275 | 275 |
| 276 if (!network || | 276 if (!network || |
| 277 state.status != NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_PORTAL) { | 277 state.status != NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_PORTAL) { |
| 278 last_network_path_.clear(); | 278 last_network_guid_.clear(); |
| 279 | 279 |
| 280 // In browser tests we initiate fake network portal detection, but network | 280 // In browser tests we initiate fake network portal detection, but network |
| 281 // state usually stays connected. This way, after dialog is shown, it is | 281 // state usually stays connected. This way, after dialog is shown, it is |
| 282 // immediately closed. The testing check below prevents dialog from closing. | 282 // immediately closed. The testing check below prevents dialog from closing. |
| 283 if (dialog_ && | 283 if (dialog_ && |
| 284 (!ignore_no_network_for_testing_ || | 284 (!ignore_no_network_for_testing_ || |
| 285 state.status == NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_ONLINE)) { | 285 state.status == NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_ONLINE)) { |
| 286 dialog_->Close(); | 286 dialog_->Close(); |
| 287 } | 287 } |
| 288 | 288 |
| 289 CloseNotification(); | 289 CloseNotification(); |
| 290 return; | 290 return; |
| 291 } | 291 } |
| 292 | 292 |
| 293 // Don't do anything if we're currently activating the device. | 293 // Don't do anything if we're currently activating the device. |
| 294 if (MobileActivator::GetInstance()->RunningActivation()) | 294 if (MobileActivator::GetInstance()->RunningActivation()) |
| 295 return; | 295 return; |
| 296 | 296 |
| 297 // Don't do anything if notification for |network| already was | 297 // Don't do anything if notification for |network| already was |
| 298 // displayed. | 298 // displayed. |
| 299 if (network->path() == last_network_path_) | 299 if (network->guid() == last_network_guid_) |
| 300 return; | 300 return; |
| 301 last_network_path_ = network->path(); | 301 last_network_guid_ = network->guid(); |
| 302 | 302 |
| 303 if (ash::WmShell::HasInstance()) { | 303 if (ash::WmShell::HasInstance()) { |
| 304 ash::WmShell::Get()->system_tray_notifier()->NotifyOnCaptivePortalDetected( | 304 ash::WmShell::Get()->system_tray_notifier()->NotifyOnCaptivePortalDetected( |
| 305 network->path()); | 305 network->guid()); |
| 306 } | 306 } |
| 307 | 307 |
| 308 message_center::MessageCenter::Get()->AddNotification( | 308 message_center::MessageCenter::Get()->AddNotification( |
| 309 GetNotification(network, state)); | 309 GetNotification(network, state)); |
| 310 } | 310 } |
| 311 | 311 |
| 312 void NetworkPortalNotificationController::ShowDialog() { | 312 void NetworkPortalNotificationController::ShowDialog() { |
| 313 if (dialog_) | 313 if (dialog_) |
| 314 return; | 314 return; |
| 315 | 315 |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 440 if (dialog_) | 440 if (dialog_) |
| 441 dialog_->Close(); | 441 dialog_->Close(); |
| 442 } | 442 } |
| 443 | 443 |
| 444 const NetworkPortalWebDialog* | 444 const NetworkPortalWebDialog* |
| 445 NetworkPortalNotificationController::GetDialogForTesting() const { | 445 NetworkPortalNotificationController::GetDialogForTesting() const { |
| 446 return dialog_; | 446 return dialog_; |
| 447 } | 447 } |
| 448 | 448 |
| 449 } // namespace chromeos | 449 } // namespace chromeos |
| OLD | NEW |