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

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: 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.h » ('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"
14 #include "chromeos/chromeos_switches.h"
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 (CommandLine::ForCurrentProcess() ->
361 HasSwitch(chromeos::switches::kEnableStubPortalledWifi) &&
362 default_service_path_ == ShillServiceClientStub::kStubPortalledWifiPath) {
363 result = captive_portal::RESULT_BEHIND_CAPTIVE_PORTAL;
364 response_code = 200;
365 }
366
355 DCHECK(CalledOnValidThread()); 367 DCHECK(CalledOnValidThread());
356 DCHECK(IsCheckingForPortal()); 368 DCHECK(IsCheckingForPortal());
357 369
358 VLOG(1) << "Portal detection completed: " 370 VLOG(1) << "Portal detection completed: "
359 << "network=" << default_network_id_ << ", " 371 << "network=" << default_network_id_ << ", "
360 << "result=" << CaptivePortalDetector::CaptivePortalResultToString( 372 << "result=" << CaptivePortalDetector::CaptivePortalResultToString(
361 results.result) << ", " 373 results.result) << ", "
362 << "response_code=" << results.response_code; 374 << "response_code=" << results.response_code;
363 375
364 state_ = STATE_IDLE; 376 state_ = STATE_IDLE;
365 detection_timeout_.Cancel(); 377 detection_timeout_.Cancel();
366 378
367 const NetworkState* default_network = 379 const NetworkState* default_network =
368 NetworkHandler::Get()->network_state_handler()->DefaultNetwork(); 380 NetworkHandler::Get()->network_state_handler()->DefaultNetwork();
369 381
370 CaptivePortalState state; 382 CaptivePortalState state;
371 state.response_code = results.response_code; 383 state.response_code = response_code;
372 switch (results.result) { 384 switch (result) {
373 case captive_portal::RESULT_NO_RESPONSE: 385 case captive_portal::RESULT_NO_RESPONSE:
374 if (attempt_count_ >= kMaxRequestAttempts) { 386 if (attempt_count_ >= kMaxRequestAttempts) {
375 if (state.response_code == net::HTTP_PROXY_AUTHENTICATION_REQUIRED) { 387 if (state.response_code == net::HTTP_PROXY_AUTHENTICATION_REQUIRED) {
376 state.status = CAPTIVE_PORTAL_STATUS_PROXY_AUTH_REQUIRED; 388 state.status = CAPTIVE_PORTAL_STATUS_PROXY_AUTH_REQUIRED;
377 } else if (default_network && (default_network->connection_state() == 389 } else if (default_network && (default_network->connection_state() ==
378 flimflam::kStatePortal)) { 390 flimflam::kStatePortal)) {
379 // Take into account shill's detection results. 391 // Take into account shill's detection results.
380 state.status = CAPTIVE_PORTAL_STATUS_PORTAL; 392 state.status = CAPTIVE_PORTAL_STATUS_PORTAL;
381 LOG(WARNING) << "Network " << default_network->guid() << " " 393 LOG(WARNING) << "Network " << default_network->guid() << " "
382 << "is marked as " 394 << "is marked as "
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
486 const NetworkState* network = 498 const NetworkState* network =
487 NetworkHandler::Get()->network_state_handler()->DefaultNetwork(); 499 NetworkHandler::Get()->network_state_handler()->DefaultNetwork();
488 if (!network) 500 if (!network)
489 return kBaseRequestTimeoutSec; 501 return kBaseRequestTimeoutSec;
490 if (lazy_detection_enabled_) 502 if (lazy_detection_enabled_)
491 return kLazyRequestTimeoutSec; 503 return kLazyRequestTimeoutSec;
492 return attempt_count_ * kBaseRequestTimeoutSec; 504 return attempt_count_ * kBaseRequestTimeoutSec;
493 } 505 }
494 506
495 } // namespace chromeos 507 } // namespace chromeos
OLDNEW
« no previous file with comments | « no previous file | chromeos/chromeos_switches.h » ('j') | chromeos/dbus/shill_service_client_stub.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698