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

Side by Side Diff: chrome/browser/chromeos/net/network_portal_notification_controller.cc

Issue 2906713002: Revert "cros: close dialog when shill detects captive portal network switched to online" (Closed)
Patch Set: Created 3 years, 7 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 unified diff | Download patch
« no previous file with comments | « chrome/browser/chromeos/net/network_portal_notification_controller.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 if (NetworkHandler::IsInitialized()) { 252 if (NetworkHandler::IsInitialized()) {
253 NetworkHandler::Get()->network_state_handler()->RemoveObserver(this, 253 NetworkHandler::Get()->network_state_handler()->RemoveObserver(this,
254 FROM_HERE); 254 FROM_HERE);
255 } 255 }
256 } 256 }
257 257
258 void NetworkPortalNotificationController::DefaultNetworkChanged( 258 void NetworkPortalNotificationController::DefaultNetworkChanged(
259 const NetworkState* network) { 259 const NetworkState* network) {
260 if (!network) 260 if (!network)
261 return; 261 return;
262
263 bool network_changed = (default_network_id_ != network->guid());
264 default_network_id_ = network->guid();
265 if (!network_changed && network->connection_state() == shill::kStateOnline &&
266 dialog_) {
267 dialog_->Close();
268 }
269
270 Profile* profile = GetProfileForPrimaryUser(); 262 Profile* profile = GetProfileForPrimaryUser();
271 extensions::NetworkingConfigService* networking_config_service = 263 extensions::NetworkingConfigService* networking_config_service =
272 GetNetworkingConfigService(profile); 264 GetNetworkingConfigService(profile);
273 if (!networking_config_service) 265 if (!networking_config_service)
274 return; 266 return;
275 networking_config_service->ResetAuthenticationResult(); 267 networking_config_service->ResetAuthenticationResult();
276 } 268 }
277 269
278 void NetworkPortalNotificationController::OnPortalDetectionCompleted( 270 void NetworkPortalNotificationController::OnPortalDetectionCompleted(
279 const NetworkState* network, 271 const NetworkState* network,
280 const NetworkPortalDetector::CaptivePortalState& state) { 272 const NetworkPortalDetector::CaptivePortalState& state) {
281 if (!IsPortalNotificationEnabled()) 273 if (!IsPortalNotificationEnabled())
282 return; 274 return;
283 275
284 if (!network || 276 if (!network ||
285 state.status != NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_PORTAL) { 277 state.status != NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_PORTAL) {
286 last_network_guid_.clear(); 278 last_network_guid_.clear();
279
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
282 // immediately closed. The testing check below prevents dialog from closing.
283 if (dialog_ &&
284 (!ignore_no_network_for_testing_ ||
285 state.status == NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_ONLINE)) {
286 dialog_->Close();
287 }
288
287 CloseNotification(); 289 CloseNotification();
288 return; 290 return;
289 } 291 }
290 292
291 // Don't do anything if we're currently activating the device. 293 // Don't do anything if we're currently activating the device.
292 if (MobileActivator::GetInstance()->RunningActivation()) 294 if (MobileActivator::GetInstance()->RunningActivation())
293 return; 295 return;
294 296
295 // Don't do anything if notification for |network| already was 297 // Don't do anything if notification for |network| already was
296 // displayed. 298 // displayed.
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
423 } else { 425 } else {
424 return CreateDefaultCaptivePortalNotification(network); 426 return CreateDefaultCaptivePortalNotification(network);
425 } 427 }
426 } 428 }
427 429
428 void NetworkPortalNotificationController::OnExtensionFinishedAuthentication() { 430 void NetworkPortalNotificationController::OnExtensionFinishedAuthentication() {
429 if (!retry_detection_callback_.is_null()) 431 if (!retry_detection_callback_.is_null())
430 retry_detection_callback_.Run(); 432 retry_detection_callback_.Run();
431 } 433 }
432 434
435 void NetworkPortalNotificationController::SetIgnoreNoNetworkForTesting() {
436 ignore_no_network_for_testing_ = true;
437 }
438
433 void NetworkPortalNotificationController::CloseDialog() { 439 void NetworkPortalNotificationController::CloseDialog() {
434 if (dialog_) 440 if (dialog_)
435 dialog_->Close(); 441 dialog_->Close();
436 } 442 }
437 443
438 const NetworkPortalWebDialog* 444 const NetworkPortalWebDialog*
439 NetworkPortalNotificationController::GetDialogForTesting() const { 445 NetworkPortalNotificationController::GetDialogForTesting() const {
440 return dialog_; 446 return dialog_;
441 } 447 }
442 448
443 } // namespace chromeos 449 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/net/network_portal_notification_controller.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698