namespace chromeos {
ControllerPairingScreen::ControllerPairingScreen(
- ScreenObserver* observer,
+ BaseScreenDelegate* base_screen_delegate,
+ Delegate* delegate,
ControllerPairingScreenActor* actor,
- ControllerPairingController* controller)
- : WizardScreen(observer),
+ ControllerPairingController* shark_controller)
+ : BaseScreen(base_screen_delegate),
+ delegate_(delegate),
actor_(actor),
- controller_(controller),
+ shark_controller_(shark_controller),
current_stage_(ControllerPairingController::STAGE_NONE),
device_preselected_(false) {
actor_->SetDelegate(this);
- controller_->AddObserver(this);
+ shark_controller_->AddObserver(this);
}
ControllerPairingScreen::~ControllerPairingScreen() {
if (actor_)
actor_->SetDelegate(NULL);
- controller_->RemoveObserver(this);
+ shark_controller_->RemoveObserver(this);
}
void ControllerPairingScreen::CommitContextChanges() {
void ControllerPairingScreen::Show() {
if (actor_)
actor_->Show();
- controller_->StartPairing();
+ shark_controller_->StartPairing();
}
void ControllerPairingScreen::Hide() {
return WizardController::kControllerPairingScreenName;
}
-// Overridden from ControllerPairingController::Observer:
void ControllerPairingScreen::PairingStageChanged(Stage new_stage) {
DCHECK(new_stage != current_stage_);
switch (new_stage) {
case ControllerPairingController::STAGE_DEVICES_DISCOVERY: {
desired_page = kPageDevicesDiscovery;
- context_.SetStringList(kContextKeyDevices, StringList());
+ context_.SetStringList(kContextKeyDevices, ::login::StringList());
context_.SetString(kContextKeySelectedDevice, std::string());
device_preselected_ = false;
break;
case ControllerPairingController::STAGE_WAITING_FOR_CODE_CONFIRMATION: {
desired_page = kPageCodeConfirmation;
context_.SetString(kContextKeyConfirmationCode,
- controller_->GetConfirmationCode());
+ shark_controller_->GetConfirmationCode());
+ break;
+ }
+ case ControllerPairingController::STAGE_PAIRING_DONE: {
+ if (delegate_)
+ delegate_->SetHostConfiguration();
break;
}
case ControllerPairingController::STAGE_HOST_UPDATE_IN_PROGRESS: {
break;
}
case ControllerPairingController::STAGE_WAITING_FOR_CREDENTIALS: {
- controller_->RemoveObserver(this);
- get_screen_observer()->OnExit(
+ shark_controller_->RemoveObserver(this);
+ get_base_screen_delegate()->OnExit(
WizardController::CONTROLLER_PAIRING_FINISHED);
- // TODO: Move the rest of the stages to the proper location.
desired_page = kPageEnrollmentIntroduction;
break;
}
- case ControllerPairingController::STAGE_HOST_ENROLLMENT_IN_PROGRESS: {
- desired_page = kPageHostEnrollment;
- break;
- }
- case ControllerPairingController::STAGE_HOST_ENROLLMENT_ERROR: {
- desired_page = kPageHostEnrollmentError;
- break;
- }
- case ControllerPairingController::STAGE_PAIRING_DONE: {
- desired_page = kPagePairingDone;
- break;
- }
- case ControllerPairingController::STAGE_FINISHED: {
- get_screen_observer()->OnExit(
- WizardController::CONTROLLER_PAIRING_FINISHED);
+ case ControllerPairingController::STAGE_INITIALIZATION_ERROR: {
+ // TODO(achuith, dzhioev, zork): Handle this better.
+ LOG(WARNING) << "Bluetooth initialization error";
break;
}
default:
context_.SetString(kContextKeyPage, desired_page);
context_.SetBoolean(kContextKeyControlsDisabled, false);
CommitContextChanges();
+ VLOG(1) << "PairingStageChanged " << desired_page
+ << ", current stage " << current_stage_;
}
void ControllerPairingScreen::DiscoveredDevicesListChanged() {
if (!ExpectStageIs(ControllerPairingController::STAGE_DEVICES_DISCOVERY))
return;
ControllerPairingController::DeviceIdList devices =
- controller_->GetDiscoveredDevices();
+ shark_controller_->GetDiscoveredDevices();
std::sort(devices.begin(), devices.end());
context_.SetStringList(kContextKeyDevices, devices);
context_.SetString(
if (selectedDevice.empty())
LOG(ERROR) << "Device was not selected.";
else
- controller_->ChooseDeviceForPairing(selectedDevice);
+ shark_controller_->ChooseDeviceForPairing(selectedDevice);
} else if (action == kActionRepeatDiscovery) {
- controller_->RepeatDiscovery();
+ shark_controller_->RepeatDiscovery();
} else if (action == kActionAcceptCode) {
- controller_->SetConfirmationCodeIsCorrect(true);
+ shark_controller_->SetConfirmationCodeIsCorrect(true);
} else if (action == kActionRejectCode) {
- controller_->SetConfirmationCodeIsCorrect(false);
+ shark_controller_->SetConfirmationCodeIsCorrect(false);
} else if (action == kActionProceedToAuthentication) {
context_.SetString(kContextKeyPage, kPageAuthentication);
disable_controls = false;
const std::string domain(gaia::ExtractDomainName(account_id));
context_.SetString(kContextKeyEnrollmentDomain, domain);
} else if (action == kActionStartSession) {
- controller_->StartSession();
+ shark_controller_->StartSession();
}
context_.SetBoolean(kContextKeyControlsDisabled, disable_controls);
CommitContextChanges();