Commit 6a00a7e3 authored by Leo Lai's avatar Leo Lai Committed by Commit Bot

clean up tpm password fetching logic of EULA screen.

Since chromium:1109629, eula screen doesn't show the owner password but
it still tryies to fetch the password before showing the security system
settings.

Thus, cleaning it up for sake of security as well as for product
excellence. Also, it is part of steps getting rid of `TpmGetPassword()`
D-Bus method.

BUG=b:172748724
BUG=b:168852740
BUG=chromium:1109629
TEST=browser_tests.

Change-Id: If5c0829658753aacadc1dfc3df7d054e6f458851
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2536657
Commit-Queue: Leo Lai <cylai@google.com>
Reviewed-by: default avatarAchuith Bhandarkar <achuith@chromium.org>
Reviewed-by: default avatarAlexander Alekseev <alemate@chromium.org>
Cr-Commit-Position: refs/heads/master@{#828063}
parent 8c28f33e
......@@ -95,8 +95,7 @@ std::string EulaScreen::GetResultString(Result result) {
EulaScreen::EulaScreen(EulaView* view, const ScreenExitCallback& exit_callback)
: BaseScreen(EulaView::kScreenId, OobeScreenPriority::DEFAULT),
view_(view),
exit_callback_(exit_callback),
password_fetcher_(this) {
exit_callback_(exit_callback) {
DCHECK(view_);
if (view_)
view_->Bind(this);
......@@ -107,15 +106,6 @@ EulaScreen::~EulaScreen() {
view_->Unbind();
}
void EulaScreen::InitiatePasswordFetch() {
if (tpm_password_.empty()) {
password_fetcher_.Fetch();
// Will call view after password has been fetched.
} else if (view_) {
view_->OnPasswordFetched(tpm_password_);
}
}
void EulaScreen::SetUsageStatsEnabled(bool enabled) {
g_usage_statistics_reporting_enabled = enabled;
}
......@@ -154,7 +144,7 @@ void EulaScreen::OnUserAction(const std::string& action_id) {
} else if (action_id == kUserActionShowAdditionalTos) {
ShowAdditionalTosDialog();
} else if (action_id == kUserActionShowSecuritySettings) {
InitiatePasswordFetch();
ShowSecuritySettingsDialog();
} else if (action_id == kUserActionSelectStatsUsage) {
SetUsageStatsEnabled(true);
} else if (action_id == kUserActionUnselectStatsUsage) {
......@@ -176,12 +166,6 @@ bool EulaScreen::HandleAccelerator(ash::LoginAcceleratorAction action) {
return false;
}
void EulaScreen::OnPasswordFetched(const std::string& tpm_password) {
tpm_password_ = tpm_password;
if (view_)
view_->OnPasswordFetched(tpm_password_);
}
void EulaScreen::ShowStatsUsageLearnMore() {
if (view_)
view_->ShowStatsUsageLearnMore();
......@@ -192,4 +176,9 @@ void EulaScreen::ShowAdditionalTosDialog() {
view_->ShowAdditionalTosDialog();
}
void EulaScreen::ShowSecuritySettingsDialog() {
if (view_)
view_->ShowSecuritySettingsDialog();
}
} // namespace chromeos
......@@ -11,7 +11,6 @@
#include "base/compiler_specific.h"
#include "base/macros.h"
#include "chrome/browser/chromeos/login/screens/base_screen.h"
#include "chromeos/tpm/tpm_password_fetcher.h"
#include "url/gurl.h"
namespace chromeos {
......@@ -20,10 +19,7 @@ class EulaView;
// Representation independent class that controls OOBE screen showing EULA
// to users.
//
// TODO(b/168852740): Clean up the password-related logic with the removal of
// `TpmGetPassword` D-Bus method.
class EulaScreen : public BaseScreen, public TpmPasswordFetcherDelegate {
class EulaScreen : public BaseScreen {
public:
enum class Result {
// The user accepted EULA, and enabled usage stats reporting.
......@@ -59,10 +55,6 @@ class EulaScreen : public BaseScreen, public TpmPasswordFetcherDelegate {
// locale and manifest. Returns empty URL otherwise.
GURL GetOemEulaUrl() const;
// Initiate TPM password fetch. Will call view's OnPasswordFetched() when
// done.
void InitiatePasswordFetch();
void SetUsageStatsEnabled(bool enabled);
// Returns true if usage statistics reporting is enabled.
......@@ -82,10 +74,10 @@ class EulaScreen : public BaseScreen, public TpmPasswordFetcherDelegate {
void OnUserAction(const std::string& action_id) override;
bool HandleAccelerator(ash::LoginAcceleratorAction action) override;
// TpmPasswordFetcherDelegate implementation:
void OnPasswordFetched(const std::string& tpm_password) override;
// EulaView:
void ShowStatsUsageLearnMore();
void ShowAdditionalTosDialog();
void ShowSecuritySettingsDialog();
// URL of the OEM EULA page (on disk).
GURL oem_eula_page_;
......@@ -101,8 +93,6 @@ class EulaScreen : public BaseScreen, public TpmPasswordFetcherDelegate {
ScreenExitCallback exit_callback_;
TpmPasswordFetcher password_fetcher_;
DISALLOW_COPY_AND_ASSIGN(EulaScreen);
};
......
......@@ -35,9 +35,9 @@ class MockEulaView : public EulaView {
MOCK_METHOD(void, MockBind, (EulaScreen * screen));
MOCK_METHOD(void, MockUnbind, ());
MOCK_METHOD(void, OnPasswordFetched, (const std::string& tpm_password));
MOCK_METHOD(void, ShowStatsUsageLearnMore, ());
MOCK_METHOD(void, ShowAdditionalTosDialog, ());
MOCK_METHOD(void, ShowSecuritySettingsDialog, ());
private:
EulaScreen* screen_ = nullptr;
......
......@@ -139,10 +139,6 @@ void EulaScreenHandler::Initialize() {
}
}
void EulaScreenHandler::OnPasswordFetched(const std::string& tpm_password) {
CallJS("login.EulaScreen.showSecuritySettingsDialog");
}
void EulaScreenHandler::ShowStatsUsageLearnMore() {
if (!help_app_.get())
help_app_ = new HelpAppLauncher(
......@@ -154,6 +150,10 @@ void EulaScreenHandler::ShowAdditionalTosDialog() {
CallJS("login.EulaScreen.showAdditionalTosDialog");
}
void EulaScreenHandler::ShowSecuritySettingsDialog() {
CallJS("login.EulaScreen.showSecuritySettingsDialog");
}
void EulaScreenHandler::UpdateLocalizedValues(
::login::SecureModuleUsed secure_module_used) {
base::DictionaryValue updated_secure_module_strings;
......
......@@ -34,9 +34,9 @@ class EulaView {
virtual void Hide() = 0;
virtual void Bind(EulaScreen* screen) = 0;
virtual void Unbind() = 0;
virtual void OnPasswordFetched(const std::string& tpm_password) = 0;
virtual void ShowStatsUsageLearnMore() = 0;
virtual void ShowAdditionalTosDialog() = 0;
virtual void ShowSecuritySettingsDialog() = 0;
};
// WebUI implementation of EulaScreenView. It is used to interact
......@@ -54,9 +54,9 @@ class EulaScreenHandler : public EulaView, public BaseScreenHandler {
void Hide() override;
void Bind(EulaScreen* screen) override;
void Unbind() override;
void OnPasswordFetched(const std::string& tpm_password) override;
void ShowStatsUsageLearnMore() override;
void ShowAdditionalTosDialog() override;
void ShowSecuritySettingsDialog() override;
// BaseScreenHandler implementation:
void DeclareLocalizedValues(
......
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