OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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_detector_impl.h" | 5 #include "chrome/browser/chromeos/net/network_portal_detector_impl.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
11 #include "base/metrics/histogram.h" | 11 #include "base/metrics/histogram.h" |
12 #include "chrome/browser/chrome_notification_types.h" | 12 #include "chrome/browser/chrome_notification_types.h" |
13 #include "chrome/common/chrome_switches.h" | 13 #include "chromeos/dbus/shill_service_client_stub.h" |
14 #include "chromeos/network/network_state.h" | 14 #include "chromeos/network/network_state.h" |
15 #include "chromeos/network/network_state_handler.h" | 15 #include "chromeos/network/network_state_handler.h" |
16 #include "content/public/browser/notification_service.h" | 16 #include "content/public/browser/notification_service.h" |
17 #include "grit/generated_resources.h" | 17 #include "grit/generated_resources.h" |
18 #include "net/http/http_status_code.h" | 18 #include "net/http/http_status_code.h" |
19 #include "third_party/cros_system_api/dbus/service_constants.h" | 19 #include "third_party/cros_system_api/dbus/service_constants.h" |
20 #include "ui/base/l10n/l10n_util.h" | 20 #include "ui/base/l10n/l10n_util.h" |
21 | 21 |
22 using captive_portal::CaptivePortalDetector; | 22 using captive_portal::CaptivePortalDetector; |
23 | 23 |
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
345 if (IsPortalCheckPending()) | 345 if (IsPortalCheckPending()) |
346 detection_task_.Cancel(); | 346 detection_task_.Cancel(); |
347 else if (IsCheckingForPortal()) | 347 else if (IsCheckingForPortal()) |
348 captive_portal_detector_->Cancel(); | 348 captive_portal_detector_->Cancel(); |
349 detection_timeout_.Cancel(); | 349 detection_timeout_.Cancel(); |
350 state_ = STATE_IDLE; | 350 state_ = STATE_IDLE; |
351 } | 351 } |
352 | 352 |
353 void NetworkPortalDetectorImpl::OnPortalDetectionCompleted( | 353 void NetworkPortalDetectorImpl::OnPortalDetectionCompleted( |
354 const CaptivePortalDetector::Results& results) { | 354 const CaptivePortalDetector::Results& results) { |
| 355 captive_portal::Result result = results.result; |
| 356 int response_code = results.response_code; |
| 357 |
| 358 if (ShillServiceClientStub::IsStubPortalledWifiEnabled( |
| 359 default_service_path_)) { |
| 360 result = captive_portal::RESULT_BEHIND_CAPTIVE_PORTAL; |
| 361 response_code = 200; |
| 362 } |
| 363 |
355 DCHECK(CalledOnValidThread()); | 364 DCHECK(CalledOnValidThread()); |
356 DCHECK(IsCheckingForPortal()); | 365 DCHECK(IsCheckingForPortal()); |
357 | 366 |
358 VLOG(1) << "Portal detection completed: " | 367 VLOG(1) << "Portal detection completed: " |
359 << "network=" << default_network_id_ << ", " | 368 << "network=" << default_network_id_ << ", " |
360 << "result=" << CaptivePortalDetector::CaptivePortalResultToString( | 369 << "result=" << CaptivePortalDetector::CaptivePortalResultToString( |
361 results.result) << ", " | 370 results.result) << ", " |
362 << "response_code=" << results.response_code; | 371 << "response_code=" << results.response_code; |
363 | 372 |
364 state_ = STATE_IDLE; | 373 state_ = STATE_IDLE; |
365 detection_timeout_.Cancel(); | 374 detection_timeout_.Cancel(); |
366 | 375 |
367 const NetworkState* default_network = | 376 const NetworkState* default_network = |
368 NetworkHandler::Get()->network_state_handler()->DefaultNetwork(); | 377 NetworkHandler::Get()->network_state_handler()->DefaultNetwork(); |
369 | 378 |
370 CaptivePortalState state; | 379 CaptivePortalState state; |
371 state.response_code = results.response_code; | 380 state.response_code = response_code; |
372 switch (results.result) { | 381 switch (result) { |
373 case captive_portal::RESULT_NO_RESPONSE: | 382 case captive_portal::RESULT_NO_RESPONSE: |
374 if (attempt_count_ >= kMaxRequestAttempts) { | 383 if (attempt_count_ >= kMaxRequestAttempts) { |
375 if (state.response_code == net::HTTP_PROXY_AUTHENTICATION_REQUIRED) { | 384 if (state.response_code == net::HTTP_PROXY_AUTHENTICATION_REQUIRED) { |
376 state.status = CAPTIVE_PORTAL_STATUS_PROXY_AUTH_REQUIRED; | 385 state.status = CAPTIVE_PORTAL_STATUS_PROXY_AUTH_REQUIRED; |
377 } else if (default_network && (default_network->connection_state() == | 386 } else if (default_network && (default_network->connection_state() == |
378 flimflam::kStatePortal)) { | 387 flimflam::kStatePortal)) { |
379 // Take into account shill's detection results. | 388 // Take into account shill's detection results. |
380 state.status = CAPTIVE_PORTAL_STATUS_PORTAL; | 389 state.status = CAPTIVE_PORTAL_STATUS_PORTAL; |
381 LOG(WARNING) << "Network " << default_network->guid() << " " | 390 LOG(WARNING) << "Network " << default_network->guid() << " " |
382 << "is marked as " | 391 << "is marked as " |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
486 const NetworkState* network = | 495 const NetworkState* network = |
487 NetworkHandler::Get()->network_state_handler()->DefaultNetwork(); | 496 NetworkHandler::Get()->network_state_handler()->DefaultNetwork(); |
488 if (!network) | 497 if (!network) |
489 return kBaseRequestTimeoutSec; | 498 return kBaseRequestTimeoutSec; |
490 if (lazy_detection_enabled_) | 499 if (lazy_detection_enabled_) |
491 return kLazyRequestTimeoutSec; | 500 return kLazyRequestTimeoutSec; |
492 return attempt_count_ * kBaseRequestTimeoutSec; | 501 return attempt_count_ * kBaseRequestTimeoutSec; |
493 } | 502 } |
494 | 503 |
495 } // namespace chromeos | 504 } // namespace chromeos |
OLD | NEW |