Added stub portalled wifi network.

Added stub portalled wifi network for testing captive portal UI on the
ChromeOS build. To use it one's need run chrome with the folliwing
switches:
--disable-stub-ethernet
--use-new-network-connection-handler
--default-stub-network-state-idle
--enable-stub-portalled-wifi

BUG=246391
TEST=manual tests on Lumpy

Review URL: https://chromiumcodereview.appspot.com/22364005

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@217099 0039d316-1c4b-4281-b951-d872f2087c98
parent 2f39055b
......@@ -10,7 +10,7 @@
#include "base/message_loop/message_loop.h"
#include "base/metrics/histogram.h"
#include "chrome/browser/chrome_notification_types.h"
#include "chrome/common/chrome_switches.h"
#include "chromeos/dbus/shill_service_client_stub.h"
#include "chromeos/network/network_state.h"
#include "chromeos/network/network_state_handler.h"
#include "content/public/browser/notification_service.h"
......@@ -352,6 +352,15 @@ void NetworkPortalDetectorImpl::CancelPortalDetection() {
void NetworkPortalDetectorImpl::OnPortalDetectionCompleted(
const CaptivePortalDetector::Results& results) {
captive_portal::Result result = results.result;
int response_code = results.response_code;
if (ShillServiceClientStub::IsStubPortalledWifiEnabled(
default_service_path_)) {
result = captive_portal::RESULT_BEHIND_CAPTIVE_PORTAL;
response_code = 200;
}
DCHECK(CalledOnValidThread());
DCHECK(IsCheckingForPortal());
......@@ -368,8 +377,8 @@ void NetworkPortalDetectorImpl::OnPortalDetectionCompleted(
NetworkHandler::Get()->network_state_handler()->DefaultNetwork();
CaptivePortalState state;
state.response_code = results.response_code;
switch (results.result) {
state.response_code = response_code;
switch (result) {
case captive_portal::RESULT_NO_RESPONSE:
if (attempt_count_ >= kMaxRequestAttempts) {
if (state.response_code == net::HTTP_PROXY_AUTHENTICATION_REQUIRED) {
......
......@@ -24,6 +24,9 @@ const char kChromeOSReleaseBoard[] = "chromeos-release-board";
// Forces the stub implementation of dbus clients.
const char kDbusStub[] = "dbus-stub";
// All stub networks are idle by default.
const char kDefaultStubNetworkStateIdle[] = "default-stub-network-state-idle";
// Disables wallpaper boot animation (except of OOBE case).
const char kDisableBootAnimation[] = "disable-boot-animation";
......@@ -88,6 +91,9 @@ const char kEnableScreensaverExtensions[] = "enable-screensaver-extensions";
// Enable "interactive" mode for stub implemenations (e.g. NetworkStateHandler)
const char kEnableStubInteractive[] = "enable-stub-interactive";
// Enable stub portalled wifi network for testing.
const char kEnableStubPortalledWifi[] = "enable-stub-portalled-wifi";
// Enables touchpad three-finger-click as middle button.
const char kEnableTouchpadThreeFingerClick[]
= "enable-touchpad-three-finger-click";
......
......@@ -25,6 +25,7 @@ CHROMEOS_EXPORT extern const char kAshWebUIInit[];
CHROMEOS_EXPORT extern const char kAuthExtensionPath[];
CHROMEOS_EXPORT extern const char kChromeOSReleaseBoard[];
CHROMEOS_EXPORT extern const char kDbusStub[];
CHROMEOS_EXPORT extern const char kDefaultStubNetworkStateIdle[];
CHROMEOS_EXPORT extern const char kDisableBootAnimation[];
CHROMEOS_EXPORT extern const char kDisableChromeCaptivePortalDetector[];
CHROMEOS_EXPORT extern const char kDisableDrive[];
......@@ -46,6 +47,7 @@ CHROMEOS_EXPORT extern const char kEnableRequestTabletSite[];
CHROMEOS_EXPORT extern const char kEnableScreensaverExtensions[];
CHROMEOS_EXPORT extern const char kEnableStaticIPConfig[];
CHROMEOS_EXPORT extern const char kEnableStubInteractive[];
CHROMEOS_EXPORT extern const char kEnableStubPortalledWifi[];
CHROMEOS_EXPORT extern const char kEnableTouchpadThreeFingerClick[];
CHROMEOS_EXPORT extern const char kEnterpriseEnrollmentInitialModulus[];
CHROMEOS_EXPORT extern const char kEnterpriseEnrollmentModulusLimit[];
......
......@@ -24,6 +24,9 @@ namespace chromeos {
namespace {
const char kStubPortalledWifiPath[] = "portalled_wifi";
const char kStubPortalledWifiName[] = "Portalled Wifi";
void ErrorFunction(const std::string& error_name,
const std::string& error_message) {
LOG(ERROR) << "Shill Error: " << error_name << " : " << error_message;
......@@ -51,6 +54,16 @@ ShillServiceClientStub::~ShillServiceClientStub() {
observer_list_.begin(), observer_list_.end());
}
// static
bool ShillServiceClientStub::IsStubPortalledWifiEnabled(
const std::string& path) {
if (!CommandLine::ForCurrentProcess()->HasSwitch(
chromeos::switches::kEnableStubPortalledWifi)) {
return false;
}
return path == kStubPortalledWifiPath;
}
// ShillServiceClient overrides.
void ShillServiceClientStub::AddPropertyChangedObserver(
......@@ -192,6 +205,8 @@ void ShillServiceClientStub::Connect(const dbus::ObjectPath& service_path,
delay = base::TimeDelta::FromSeconds(kConnectDelaySeconds);
}
base::StringValue online_value(flimflam::kStateOnline);
if (service_path.value() == kStubPortalledWifiPath)
online_value = base::StringValue(flimflam::kStatePortal);
std::string passphrase;
service_properties->GetStringWithoutPathExpansion(
flimflam::kPassphraseProperty, &passphrase);
......@@ -320,7 +335,12 @@ void ShillServiceClientStub::AddService(const std::string& service_path,
const std::string& state,
bool add_to_visible_list,
bool add_to_watch_list) {
AddServiceWithIPConfig(service_path, name, type, state, "",
std::string nstate = state;
if (CommandLine::ForCurrentProcess()->HasSwitch(
chromeos::switches::kDefaultStubNetworkStateIdle)) {
nstate = flimflam::kStateIdle;
}
AddServiceWithIPConfig(service_path, name, type, nstate, "",
add_to_visible_list, add_to_watch_list);
}
......@@ -454,6 +474,17 @@ void ShillServiceClientStub::AddDefaultServices() {
flimflam::kSignalStrengthProperty,
strength_value);
if (CommandLine::ForCurrentProcess()->HasSwitch(
chromeos::switches::kEnableStubPortalledWifi)) {
AddService(kStubPortalledWifiPath, kStubPortalledWifiName,
flimflam::kTypeWifi,
flimflam::kStatePortal,
add_to_visible, add_to_watchlist);
SetServiceProperty(kStubPortalledWifiPath,
flimflam::kSecurityProperty,
base::StringValue(flimflam::kSecurityNone));
}
// Wimax
AddService("wimax1", "wimax1",
......
......@@ -11,6 +11,7 @@
#include "base/basictypes.h"
#include "base/callback.h"
#include "base/memory/weak_ptr.h"
#include "chromeos/chromeos_export.h"
#include "chromeos/dbus/shill_service_client.h"
namespace chromeos {
......@@ -23,6 +24,11 @@ class ShillServiceClientStub : public ShillServiceClient,
ShillServiceClientStub();
virtual ~ShillServiceClientStub();
// Returns true when stub portalled wifi is enabled and it's service
// path equals to |path|.
CHROMEOS_EXPORT static bool IsStubPortalledWifiEnabled(
const std::string& path);
// ShillServiceClient overrides.
virtual void AddPropertyChangedObserver(
const dbus::ObjectPath& service_path,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment