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

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

Issue 22364005: Added stub portalled wifi network. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix, sync. Created 7 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | chromeos/chromeos_switches.h » ('j') | chromeos/dbus/shill_service_client_stub.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "chrome/common/chrome_switches.h"
oshima 2013/08/07 16:01:12 this looks unnecessary too. can you remove it?
ygorshenin1 2013/08/08 08:05:57 Done.
14 #include "chromeos/chromeos_switches.h"
oshima 2013/08/07 16:01:12 nit: this is no longer necessary?
ygorshenin1 2013/08/08 08:05:57 Done.
15 #include "chromeos/dbus/shill_service_client_stub.h"
14 #include "chromeos/network/network_state.h" 16 #include "chromeos/network/network_state.h"
15 #include "chromeos/network/network_state_handler.h" 17 #include "chromeos/network/network_state_handler.h"
16 #include "content/public/browser/notification_service.h" 18 #include "content/public/browser/notification_service.h"
17 #include "grit/generated_resources.h" 19 #include "grit/generated_resources.h"
18 #include "net/http/http_status_code.h" 20 #include "net/http/http_status_code.h"
19 #include "third_party/cros_system_api/dbus/service_constants.h" 21 #include "third_party/cros_system_api/dbus/service_constants.h"
20 #include "ui/base/l10n/l10n_util.h" 22 #include "ui/base/l10n/l10n_util.h"
21 23
22 using captive_portal::CaptivePortalDetector; 24 using captive_portal::CaptivePortalDetector;
23 25
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after
345 if (IsPortalCheckPending()) 347 if (IsPortalCheckPending())
346 detection_task_.Cancel(); 348 detection_task_.Cancel();
347 else if (IsCheckingForPortal()) 349 else if (IsCheckingForPortal())
348 captive_portal_detector_->Cancel(); 350 captive_portal_detector_->Cancel();
349 detection_timeout_.Cancel(); 351 detection_timeout_.Cancel();
350 state_ = STATE_IDLE; 352 state_ = STATE_IDLE;
351 } 353 }
352 354
353 void NetworkPortalDetectorImpl::OnPortalDetectionCompleted( 355 void NetworkPortalDetectorImpl::OnPortalDetectionCompleted(
354 const CaptivePortalDetector::Results& results) { 356 const CaptivePortalDetector::Results& results) {
357 captive_portal::Result result = results.result;
358 int response_code = results.response_code;
359
360 if (ShillServiceClientStub::IsStubPortalledWifiEnabled(
361 default_service_path_)) {
362 result = captive_portal::RESULT_BEHIND_CAPTIVE_PORTAL;
363 response_code = 200;
364 }
365
355 DCHECK(CalledOnValidThread()); 366 DCHECK(CalledOnValidThread());
356 DCHECK(IsCheckingForPortal()); 367 DCHECK(IsCheckingForPortal());
357 368
358 VLOG(1) << "Portal detection completed: " 369 VLOG(1) << "Portal detection completed: "
359 << "network=" << default_network_id_ << ", " 370 << "network=" << default_network_id_ << ", "
360 << "result=" << CaptivePortalDetector::CaptivePortalResultToString( 371 << "result=" << CaptivePortalDetector::CaptivePortalResultToString(
361 results.result) << ", " 372 results.result) << ", "
362 << "response_code=" << results.response_code; 373 << "response_code=" << results.response_code;
363 374
364 state_ = STATE_IDLE; 375 state_ = STATE_IDLE;
365 detection_timeout_.Cancel(); 376 detection_timeout_.Cancel();
366 377
367 const NetworkState* default_network = 378 const NetworkState* default_network =
368 NetworkHandler::Get()->network_state_handler()->DefaultNetwork(); 379 NetworkHandler::Get()->network_state_handler()->DefaultNetwork();
369 380
370 CaptivePortalState state; 381 CaptivePortalState state;
371 state.response_code = results.response_code; 382 state.response_code = response_code;
372 switch (results.result) { 383 switch (result) {
373 case captive_portal::RESULT_NO_RESPONSE: 384 case captive_portal::RESULT_NO_RESPONSE:
374 if (attempt_count_ >= kMaxRequestAttempts) { 385 if (attempt_count_ >= kMaxRequestAttempts) {
375 if (state.response_code == net::HTTP_PROXY_AUTHENTICATION_REQUIRED) { 386 if (state.response_code == net::HTTP_PROXY_AUTHENTICATION_REQUIRED) {
376 state.status = CAPTIVE_PORTAL_STATUS_PROXY_AUTH_REQUIRED; 387 state.status = CAPTIVE_PORTAL_STATUS_PROXY_AUTH_REQUIRED;
377 } else if (default_network && (default_network->connection_state() == 388 } else if (default_network && (default_network->connection_state() ==
378 flimflam::kStatePortal)) { 389 flimflam::kStatePortal)) {
379 // Take into account shill's detection results. 390 // Take into account shill's detection results.
380 state.status = CAPTIVE_PORTAL_STATUS_PORTAL; 391 state.status = CAPTIVE_PORTAL_STATUS_PORTAL;
381 LOG(WARNING) << "Network " << default_network->guid() << " " 392 LOG(WARNING) << "Network " << default_network->guid() << " "
382 << "is marked as " 393 << "is marked as "
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
486 const NetworkState* network = 497 const NetworkState* network =
487 NetworkHandler::Get()->network_state_handler()->DefaultNetwork(); 498 NetworkHandler::Get()->network_state_handler()->DefaultNetwork();
488 if (!network) 499 if (!network)
489 return kBaseRequestTimeoutSec; 500 return kBaseRequestTimeoutSec;
490 if (lazy_detection_enabled_) 501 if (lazy_detection_enabled_)
491 return kLazyRequestTimeoutSec; 502 return kLazyRequestTimeoutSec;
492 return attempt_count_ * kBaseRequestTimeoutSec; 503 return attempt_count_ * kBaseRequestTimeoutSec;
493 } 504 }
494 505
495 } // namespace chromeos 506 } // namespace chromeos
OLDNEW
« no previous file with comments | « no previous file | chromeos/chromeos_switches.h » ('j') | chromeos/dbus/shill_service_client_stub.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698