Commit bb51338b authored by ygorshenin's avatar ygorshenin Committed by Commit bot

SetHostConfiguration() and ConfigureHost() are moved from ScreenObserver.

BUG=405876,  426651
TEST=none

Review URL: https://codereview.chromium.org/673813003

Cr-Commit-Position: refs/heads/master@{#301363}
parent 9593f321
......@@ -21,6 +21,7 @@ ControllerPairingScreen::ControllerPairingScreen(
: BaseScreen(observer),
actor_(actor),
shark_controller_(shark_controller),
delegate_(nullptr),
current_stage_(ControllerPairingController::STAGE_NONE),
device_preselected_(false) {
actor_->SetDelegate(this);
......@@ -33,6 +34,10 @@ ControllerPairingScreen::~ControllerPairingScreen() {
shark_controller_->RemoveObserver(this);
}
void ControllerPairingScreen::SetDelegate(Delegate* delegate) {
delegate_ = delegate;
}
void ControllerPairingScreen::CommitContextChanges() {
if (!context_.HasChanges())
return;
......@@ -99,7 +104,8 @@ void ControllerPairingScreen::PairingStageChanged(Stage new_stage) {
break;
}
case ControllerPairingController::STAGE_PAIRING_DONE: {
get_screen_observer()->SetHostConfiguration();
if (delegate_)
delegate_->SetHostConfiguration();
break;
}
case ControllerPairingController::STAGE_HOST_UPDATE_IN_PROGRESS: {
......
......@@ -19,12 +19,22 @@ class ControllerPairingScreen
public pairing_chromeos::ControllerPairingController::Observer,
public ControllerPairingScreenActor::Delegate {
public:
class Delegate {
public:
virtual ~Delegate() {}
// Set remora configuration from shark.
virtual void SetHostConfiguration() = 0;
};
ControllerPairingScreen(
ScreenObserver* observer,
ControllerPairingScreenActor* actor,
pairing_chromeos::ControllerPairingController* shark_controller);
virtual ~ControllerPairingScreen();
void SetDelegate(Delegate* delegate);
private:
typedef pairing_chromeos::ControllerPairingController::Stage Stage;
......@@ -56,6 +66,8 @@ class ControllerPairingScreen
// Controller performing pairing. Owned by the wizard controller.
pairing_chromeos::ControllerPairingController* shark_controller_;
Delegate* delegate_;
// Current stage of pairing process.
Stage current_stage_;
......
......@@ -45,12 +45,6 @@ class DeviceDisabledScreenTest : public testing::Test, public ScreenObserver {
// ScreenObserver:
MOCK_METHOD1(OnExit, void(ExitCodes));
void ShowCurrentScreen() override;
void SetHostConfiguration() override;
void ConfigureHost(bool accepted_eula,
const std::string& lang,
const std::string& timezone,
bool send_reports,
const std::string& keyboard_layout) override;
ErrorScreen* GetErrorScreen() override;
void ShowErrorScreen() override;
void HideErrorScreen(BaseScreen* parent_screen) override;
......@@ -95,17 +89,6 @@ void DeviceDisabledScreenTest::TearDown() {
void DeviceDisabledScreenTest::ShowCurrentScreen() {
}
void DeviceDisabledScreenTest::SetHostConfiguration() {
}
void DeviceDisabledScreenTest::ConfigureHost(
bool accepted_eula,
const std::string& lang,
const std::string& timezone,
bool send_reports,
const std::string& keyboard_layout) {
}
ErrorScreen* DeviceDisabledScreenTest::GetErrorScreen() {
return nullptr;
}
......
......@@ -20,6 +20,7 @@ HostPairingScreen::HostPairingScreen(
: BaseScreen(observer),
actor_(actor),
remora_controller_(remora_controller),
delegate_(nullptr),
current_stage_(HostPairingController::STAGE_NONE) {
actor_->SetDelegate(this);
remora_controller_->AddObserver(this);
......@@ -31,6 +32,10 @@ HostPairingScreen::~HostPairingScreen() {
remora_controller_->RemoveObserver(this);
}
void HostPairingScreen::SetDelegate(Delegate* delegate) {
delegate_ = delegate;
}
void HostPairingScreen::CommitContextChanges() {
if (!context_.HasChanges())
return;
......@@ -92,8 +97,10 @@ void HostPairingScreen::ConfigureHost(bool accepted_eula,
<< ", keyboard_layout=" << keyboard_layout;
remora_controller_->RemoveObserver(this);
get_screen_observer()->ConfigureHost(accepted_eula, lang, timezone,
send_reports, keyboard_layout);
if (delegate_) {
delegate_->ConfigureHost(
accepted_eula, lang, timezone, send_reports, keyboard_layout);
}
get_screen_observer()->OnExit(WizardController::HOST_PAIRING_FINISHED);
}
......
......@@ -18,10 +18,22 @@ class HostPairingScreen
public pairing_chromeos::HostPairingController::Observer,
public HostPairingScreenActor::Delegate {
public:
class Delegate {
public:
virtual ~Delegate() {}
virtual void ConfigureHost(bool accepted_eula,
const std::string& lang,
const std::string& timezone,
bool send_reports,
const std::string& keyboard_layout) = 0;
};
HostPairingScreen(ScreenObserver* observer, HostPairingScreenActor* actor,
pairing_chromeos::HostPairingController* remora_controller);
virtual ~HostPairingScreen();
void SetDelegate(Delegate* delegate);
private:
typedef pairing_chromeos::HostPairingController::Stage Stage;
......@@ -54,6 +66,8 @@ class HostPairingScreen
// Controller performing pairing. Owned by the wizard controller.
pairing_chromeos::HostPairingController* remora_controller_;
Delegate* delegate_;
// Current stage of pairing process.
Stage current_stage_;
......
......@@ -59,14 +59,6 @@ class ScreenObserver {
// Forces current screen showing.
virtual void ShowCurrentScreen() = 0;
// Set remora configuration from shark.
virtual void SetHostConfiguration() = 0;
virtual void ConfigureHost(bool accepted_eula,
const std::string& lang,
const std::string& timezone,
bool send_reports,
const std::string& keyboard_layout) = 0;
virtual ErrorScreen* GetErrorScreen() = 0;
virtual void ShowErrorScreen() = 0;
virtual void HideErrorScreen(BaseScreen* parent_screen) = 0;
......
......@@ -32,12 +32,10 @@
#include "chrome/browser/chromeos/login/helper.h"
#include "chrome/browser/chromeos/login/hwid_checker.h"
#include "chrome/browser/chromeos/login/login_utils.h"
#include "chrome/browser/chromeos/login/screens/controller_pairing_screen.h"
#include "chrome/browser/chromeos/login/screens/device_disabled_screen.h"
#include "chrome/browser/chromeos/login/screens/error_screen.h"
#include "chrome/browser/chromeos/login/screens/eula_screen.h"
#include "chrome/browser/chromeos/login/screens/hid_detection_screen.h"
#include "chrome/browser/chromeos/login/screens/host_pairing_screen.h"
#include "chrome/browser/chromeos/login/screens/kiosk_autolaunch_screen.h"
#include "chrome/browser/chromeos/login/screens/kiosk_enable_screen.h"
#include "chrome/browser/chromeos/login/screens/network_screen.h"
......@@ -340,18 +338,25 @@ BaseScreen* WizardController::CreateScreen(const std::string& screen_name) {
shark_controller_.reset(
new pairing_chromeos::BluetoothControllerPairingController());
}
return new ControllerPairingScreen(
this, oobe_display_->GetControllerPairingScreenActor(),
shark_controller_.get());
scoped_ptr<chromeos::ControllerPairingScreen> screen(
new ControllerPairingScreen(
this,
oobe_display_->GetControllerPairingScreenActor(),
shark_controller_.get()));
screen->SetDelegate(this);
return screen.release();
} else if (screen_name == kHostPairingScreenName) {
if (!remora_controller_) {
remora_controller_.reset(
new pairing_chromeos::BluetoothHostPairingController());
remora_controller_->StartPairing();
}
return new HostPairingScreen(this,
oobe_display_->GetHostPairingScreenActor(),
remora_controller_.get());
scoped_ptr<HostPairingScreen> screen(
new HostPairingScreen(this,
oobe_display_->GetHostPairingScreenActor(),
remora_controller_.get()));
screen->SetDelegate(this);
return screen.release();
} else if (screen_name == kDeviceDisabledScreenName) {
return new chromeos::DeviceDisabledScreen(
this, oobe_display_->GetDeviceDisabledScreenActor());
......@@ -1038,6 +1043,34 @@ bool WizardController::GetUsageStatisticsReporting() const {
return usage_statistics_reporting_;
}
void WizardController::SetHostConfiguration() {
if (shark_controller_) {
NetworkScreenActor* network_actor = oobe_display_->GetNetworkScreenActor();
shark_controller_->SetHostConfiguration(
true, // Eula must be accepted before we get this far.
network_actor->GetApplicationLocale(),
network_actor->GetTimezone(),
GetUsageStatisticsReporting(),
network_actor->GetInputMethod());
}
}
void WizardController::ConfigureHost(bool accepted_eula,
const std::string& lang,
const std::string& timezone,
bool send_reports,
const std::string& keyboard_layout) {
VLOG(1) << "ConfigureHost locale=" << lang << ", timezone=" << timezone
<< ", keyboard_layout=" << keyboard_layout;
if (accepted_eula) // Always true.
StartupUtils::MarkEulaAccepted();
SetUsageStatisticsReporting(send_reports);
NetworkScreenActor* network_actor = oobe_display_->GetNetworkScreenActor();
network_actor->SetApplicationLocale(lang);
network_actor->SetTimezone(timezone);
network_actor->SetInputMethod(keyboard_layout);
}
void WizardController::OnAccessibilityStatusChanged(
const AccessibilityStatusEventDetails& details) {
enum AccessibilityNotificationType type = details.notification_type;
......@@ -1273,33 +1306,4 @@ void WizardController::OnSharkConnected(
ShowHostPairingScreen();
}
void WizardController::SetHostConfiguration() {
if (shark_controller_) {
NetworkScreenActor* network_actor = oobe_display_->GetNetworkScreenActor();
shark_controller_->SetHostConfiguration(
true, // Eula must be accepted before we get this far.
network_actor->GetApplicationLocale(),
network_actor->GetTimezone(),
GetUsageStatisticsReporting(),
network_actor->GetInputMethod());
}
}
void WizardController::ConfigureHost(bool accepted_eula,
const std::string& lang,
const std::string& timezone,
bool send_reports,
const std::string& keyboard_layout) {
VLOG(1) << "ConfigureHost locale=" << lang
<< ", timezone=" << timezone
<< ", keyboard_layout=" << keyboard_layout;
if (accepted_eula) // Always true.
StartupUtils::MarkEulaAccepted();
SetUsageStatisticsReporting(send_reports);
NetworkScreenActor* network_actor = oobe_display_->GetNetworkScreenActor();
network_actor->SetApplicationLocale(lang);
network_actor->SetTimezone(timezone);
network_actor->SetInputMethod(keyboard_layout);
}
} // namespace chromeos
......@@ -20,7 +20,9 @@
#include "base/timer/timer.h"
#include "chrome/browser/chromeos/accessibility/accessibility_manager.h"
#include "chrome/browser/chromeos/login/screen_manager.h"
#include "chrome/browser/chromeos/login/screens/controller_pairing_screen.h"
#include "chrome/browser/chromeos/login/screens/eula_screen.h"
#include "chrome/browser/chromeos/login/screens/host_pairing_screen.h"
#include "chrome/browser/chromeos/login/screens/screen_observer.h"
class PrefRegistrySimple;
......@@ -57,7 +59,9 @@ class UserImageScreen;
// interacts with screen controllers to move the user between screens.
class WizardController : public ScreenObserver,
public ScreenManager,
public EulaScreen::Delegate {
public EulaScreen::Delegate,
public ControllerPairingScreen::Delegate,
public HostPairingScreen::Delegate {
public:
// Observes screen changes.
class Observer {
......@@ -240,12 +244,6 @@ class WizardController : public ScreenObserver,
// Overridden from ScreenObserver:
virtual void OnExit(ExitCodes exit_code) override;
virtual void ShowCurrentScreen() override;
virtual void SetHostConfiguration() override;
virtual void ConfigureHost(bool accepted_eula,
const std::string& lang,
const std::string& timezone,
bool send_reports,
const std::string& keyboard_layout) override;
virtual ErrorScreen* GetErrorScreen() override;
virtual void ShowErrorScreen() override;
virtual void HideErrorScreen(BaseScreen* parent_screen) override;
......@@ -254,6 +252,16 @@ class WizardController : public ScreenObserver,
virtual void SetUsageStatisticsReporting(bool val) override;
virtual bool GetUsageStatisticsReporting() const override;
// Override from ControllerPairingScreen::Delegate:
virtual void SetHostConfiguration() override;
// Override from HostPairingScreen::Delegate:
virtual void ConfigureHost(bool accepted_eula,
const std::string& lang,
const std::string& timezone,
bool send_reports,
const std::string& keyboard_layout) override;
// Notification of a change in the state of an accessibility setting.
void OnAccessibilityStatusChanged(
const AccessibilityStatusEventDetails& details);
......
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