Commit 411b8d24 authored by ygorshenin's avatar ygorshenin Committed by Commit bot

ScreenObserver::(Set|Get)UsageStatisticsReporting() are extracted into EulaScreen::Delegate.

BUG=405876
TEST=existing unit_tests and browser_tests

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

Cr-Commit-Position: refs/heads/master@{#301121}
parent d425521f
......@@ -47,8 +47,6 @@ class DeviceDisabledScreenTest : public testing::Test, public ScreenObserver {
void ShowCurrentScreen() override;
void OnSetUserNamePassword(const std::string& username,
const std::string& password) override;
void SetUsageStatisticsReporting(bool val) override;
bool GetUsageStatisticsReporting() const override;
void SetHostConfiguration() override;
void ConfigureHost(bool accepted_eula,
const std::string& lang,
......@@ -104,13 +102,6 @@ void DeviceDisabledScreenTest::OnSetUserNamePassword(
const std::string& password) {
}
void DeviceDisabledScreenTest::SetUsageStatisticsReporting(bool val) {
}
bool DeviceDisabledScreenTest::GetUsageStatisticsReporting() const {
return false;
}
void DeviceDisabledScreenTest::SetHostConfiguration() {
}
......
......@@ -27,6 +27,11 @@ EulaScreen::~EulaScreen() {
actor_->SetDelegate(NULL);
}
void EulaScreen::SetDelegate(Delegate* delegate) {
DCHECK(delegate);
delegate_ = delegate;
}
void EulaScreen::PrepareToShow() {
if (actor_)
actor_->PrepareToShow();
......@@ -68,7 +73,8 @@ GURL EulaScreen::GetOemEulaUrl() const {
}
void EulaScreen::OnExit(bool accepted, bool usage_stats_enabled) {
get_screen_observer()->SetUsageStatisticsReporting(usage_stats_enabled);
if (delegate_)
delegate_->SetUsageStatisticsReporting(usage_stats_enabled);
get_screen_observer()->OnExit(accepted
? ScreenObserver::EULA_ACCEPTED
: ScreenObserver::EULA_BACK);
......@@ -90,7 +96,7 @@ void EulaScreen::OnPasswordFetched(const std::string& tpm_password) {
}
bool EulaScreen::IsUsageStatsEnabled() const {
return get_screen_observer()->GetUsageStatisticsReporting();
return delegate_ && delegate_->GetUsageStatisticsReporting();
}
void EulaScreen::OnActorDestroyed(EulaScreenActor* actor) {
......
......@@ -21,9 +21,20 @@ class EulaScreen : public BaseScreen,
public EulaScreenActor::Delegate,
public TpmPasswordFetcherDelegate {
public:
class Delegate {
public:
virtual ~Delegate() {}
// Whether usage statistics reporting is enabled on EULA screen.
virtual void SetUsageStatisticsReporting(bool val) = 0;
virtual bool GetUsageStatisticsReporting() const = 0;
};
EulaScreen(ScreenObserver* observer, EulaScreenActor* actor);
virtual ~EulaScreen();
void SetDelegate(Delegate* delegate);
// BaseScreen implementation:
virtual void PrepareToShow() override;
virtual void Show() override;
......@@ -53,6 +64,8 @@ class EulaScreen : public BaseScreen,
EulaScreenActor* actor_;
Delegate* delegate_;
TpmPasswordFetcher password_fetcher_;
DISALLOW_COPY_AND_ASSIGN(EulaScreen);
......
......@@ -64,10 +64,6 @@ class ScreenObserver {
virtual void OnSetUserNamePassword(const std::string& username,
const std::string& password) = 0;
// Whether usage statistics reporting is enabled on EULA screen.
virtual void SetUsageStatisticsReporting(bool val) = 0;
virtual bool GetUsageStatisticsReporting() const = 0;
// Set remora configuration from shark.
virtual void SetHostConfiguration() = 0;
virtual void ConfigureHost(bool accepted_eula,
......
......@@ -304,7 +304,10 @@ BaseScreen* WizardController::CreateScreen(const std::string& screen_name) {
return new chromeos::UserImageScreen(
this, oobe_display_->GetUserImageScreenActor());
} else if (screen_name == kEulaScreenName) {
return new chromeos::EulaScreen(this, oobe_display_->GetEulaScreenActor());
scoped_ptr<chromeos::EulaScreen> screen(
new chromeos::EulaScreen(this, oobe_display_->GetEulaScreenActor()));
screen->SetDelegate(this);
return screen.release();
} else if (screen_name == kEnrollmentScreenName) {
return new chromeos::EnrollmentScreen(
this, oobe_display_->GetEnrollmentScreenActor());
......@@ -1022,14 +1025,6 @@ void WizardController::OnSetUserNamePassword(const std::string& username,
password_ = password;
}
void WizardController::SetUsageStatisticsReporting(bool val) {
usage_statistics_reporting_ = val;
}
bool WizardController::GetUsageStatisticsReporting() const {
return usage_statistics_reporting_;
}
void WizardController::ShowErrorScreen() {
VLOG(1) << "Showing error screen.";
SetCurrentScreen(GetScreen(kErrorScreenName));
......@@ -1041,6 +1036,14 @@ void WizardController::HideErrorScreen(BaseScreen* parent_screen) {
SetCurrentScreen(parent_screen);
}
void WizardController::SetUsageStatisticsReporting(bool val) {
usage_statistics_reporting_ = val;
}
bool WizardController::GetUsageStatisticsReporting() const {
return usage_statistics_reporting_;
}
void WizardController::OnAccessibilityStatusChanged(
const AccessibilityStatusEventDetails& details) {
enum AccessibilityNotificationType type = details.notification_type;
......
......@@ -20,6 +20,7 @@
#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/eula_screen.h"
#include "chrome/browser/chromeos/login/screens/screen_observer.h"
class PrefRegistrySimple;
......@@ -54,7 +55,9 @@ class UserImageScreen;
// Class that manages control flow between wizard screens. Wizard controller
// interacts with screen controllers to move the user between screens.
class WizardController : public ScreenObserver, public ScreenManager {
class WizardController : public ScreenObserver,
public ScreenManager,
public EulaScreen::Delegate {
public:
// Observes screen changes.
class Observer {
......@@ -239,8 +242,6 @@ class WizardController : public ScreenObserver, public ScreenManager {
virtual void ShowCurrentScreen() override;
virtual void OnSetUserNamePassword(const std::string& username,
const std::string& password) override;
virtual void SetUsageStatisticsReporting(bool val) override;
virtual bool GetUsageStatisticsReporting() const override;
virtual void SetHostConfiguration() override;
virtual void ConfigureHost(bool accepted_eula,
const std::string& lang,
......@@ -251,6 +252,10 @@ class WizardController : public ScreenObserver, public ScreenManager {
virtual void ShowErrorScreen() override;
virtual void HideErrorScreen(BaseScreen* parent_screen) override;
// Overridden from EulaScreen::Delegate:
virtual void SetUsageStatisticsReporting(bool val) override;
virtual bool GetUsageStatisticsReporting() const 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