Commit 82051ed5 authored by Jacob Dufault's avatar Jacob Dufault Committed by Commit Bot

cros: Remove EnableDebuggingScreenView::Delegate

Change-Id: Ic56f86eee47d27077c07cf781dcae80f983020aa
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1562516
Commit-Queue: Jacob Dufault <jdufault@chromium.org>
Reviewed-by: default avatarAlexander Alekseev <alemate@chromium.org>
Cr-Commit-Position: refs/heads/master@{#650479}
parent 6e611251
......@@ -22,7 +22,16 @@ EnableDebuggingScreen::EnableDebuggingScreen(
EnableDebuggingScreen::~EnableDebuggingScreen() {
if (view_)
view_->SetDelegate(NULL);
view_->SetDelegate(nullptr);
}
void EnableDebuggingScreen::OnExit(bool success) {
exit_callback_.Run();
}
void EnableDebuggingScreen::OnViewDestroyed(EnableDebuggingScreenView* view) {
if (view_ == view)
view_ = nullptr;
}
void EnableDebuggingScreen::Show() {
......@@ -35,13 +44,4 @@ void EnableDebuggingScreen::Hide() {
view_->Hide();
}
void EnableDebuggingScreen::OnExit(bool success) {
exit_callback_.Run();
}
void EnableDebuggingScreen::OnViewDestroyed(EnableDebuggingScreenView* view) {
if (view_ == view)
view_ = NULL;
}
} // namespace chromeos
......@@ -16,21 +16,20 @@ namespace chromeos {
// Representation independent class that controls screen showing enable
// debugging screen to users.
class EnableDebuggingScreen : public BaseScreen,
public EnableDebuggingScreenView::Delegate {
class EnableDebuggingScreen : public BaseScreen {
public:
EnableDebuggingScreen(EnableDebuggingScreenView* view,
const base::RepeatingClosure& exit_callback);
~EnableDebuggingScreen() override;
// Called by EnableDebuggingScreenHandler.
void OnExit(bool success);
void OnViewDestroyed(EnableDebuggingScreenView* view);
// BaseScreen implementation:
void Show() override;
void Hide() override;
// EnableDebuggingScreenActor::Delegate implementation:
void OnExit(bool success) override;
void OnViewDestroyed(EnableDebuggingScreenView* view) override;
protected:
base::RepeatingClosure* exit_callback() { return &exit_callback_; }
......
......@@ -10,23 +10,12 @@
namespace chromeos {
class EnableDebuggingScreen;
// Interface between enable debugging screen and its representation.
// Note, do not forget to call OnViewDestroyed in the dtor.
class EnableDebuggingScreenView {
public:
// Allows us to get info from reset screen that we need.
class Delegate {
public:
virtual ~Delegate() {}
// Called when screen is exited.
virtual void OnExit(bool success) = 0;
// This method is called, when view is being destroyed. Note, if Delegate
// is destroyed earlier then it has to call SetDelegate(nullptr).
virtual void OnViewDestroyed(EnableDebuggingScreenView* view) = 0;
};
constexpr static OobeScreen kScreenId =
OobeScreen::SCREEN_OOBE_ENABLE_DEBUGGING;
......@@ -34,7 +23,7 @@ class EnableDebuggingScreenView {
virtual void Show() = 0;
virtual void Hide() = 0;
virtual void SetDelegate(Delegate* delegate) = 0;
virtual void SetDelegate(EnableDebuggingScreen* screen) = 0;
};
} // namespace chromeos
......
......@@ -20,14 +20,13 @@ void MockEnableDebuggingScreen::ExitScreen() {
MockEnableDebuggingScreenView::MockEnableDebuggingScreenView() = default;
MockEnableDebuggingScreenView::~MockEnableDebuggingScreenView() {
if (delegate_)
delegate_->OnViewDestroyed(this);
if (screen_)
screen_->OnViewDestroyed(this);
}
void MockEnableDebuggingScreenView::SetDelegate(
EnableDebuggingScreenView::Delegate* delegate) {
delegate_ = delegate;
MockSetDelegate(delegate);
void MockEnableDebuggingScreenView::SetDelegate(EnableDebuggingScreen* screen) {
screen_ = screen;
MockSetDelegate(screen_);
}
} // namespace chromeos
......@@ -31,12 +31,12 @@ class MockEnableDebuggingScreenView : public EnableDebuggingScreenView {
MOCK_METHOD0(Show, void());
MOCK_METHOD0(Hide, void());
MOCK_METHOD1(MockSetDelegate, void(Delegate* delegate));
MOCK_METHOD1(MockSetDelegate, void(EnableDebuggingScreen* screen));
void SetDelegate(EnableDebuggingScreenView::Delegate* delegate) override;
void SetDelegate(EnableDebuggingScreen* screen) override;
private:
Delegate* delegate_;
EnableDebuggingScreen* screen_;
};
} // namespace chromeos
......
......@@ -11,6 +11,8 @@
#include "base/values.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/chromeos/login/oobe_screen.h"
#include "chrome/browser/chromeos/login/screens/enable_debugging_screen.h"
#include "chrome/browser/chromeos/login/screens/enable_debugging_screen_view.h"
#include "chrome/browser/chromeos/login/ui/login_display_host.h"
#include "chrome/browser/chromeos/login/ui/login_web_dialog.h"
#include "chrome/browser/profiles/profile.h"
......@@ -38,8 +40,8 @@ EnableDebuggingScreenHandler::EnableDebuggingScreenHandler(
}
EnableDebuggingScreenHandler::~EnableDebuggingScreenHandler() {
if (delegate_)
delegate_->OnViewDestroyed(this);
if (screen_)
screen_->OnViewDestroyed(this);
}
void EnableDebuggingScreenHandler::ShowWithParams() {
......@@ -69,8 +71,8 @@ void EnableDebuggingScreenHandler::Hide() {
weak_ptr_factory_.InvalidateWeakPtrs();
}
void EnableDebuggingScreenHandler::SetDelegate(Delegate* delegate) {
delegate_ = delegate;
void EnableDebuggingScreenHandler::SetDelegate(EnableDebuggingScreen* screen) {
screen_ = screen;
if (page_is_ready())
Initialize();
}
......@@ -120,7 +122,7 @@ void EnableDebuggingScreenHandler::RegisterPrefs(PrefRegistrySimple* registry) {
}
void EnableDebuggingScreenHandler::Initialize() {
if (!page_is_ready() || !delegate_)
if (!page_is_ready() || !screen_)
return;
if (show_on_init_) {
......@@ -143,13 +145,13 @@ void EnableDebuggingScreenHandler::RegisterMessages() {
}
void EnableDebuggingScreenHandler::HandleOnCancel() {
if (delegate_)
delegate_->OnExit(false);
if (screen_)
screen_->OnExit(false);
}
void EnableDebuggingScreenHandler::HandleOnDone() {
if (delegate_)
delegate_->OnExit(true);
if (screen_)
screen_->OnExit(true);
}
void EnableDebuggingScreenHandler::HandleOnRemoveRootFSProtection() {
......
......@@ -27,7 +27,7 @@ class EnableDebuggingScreenHandler : public EnableDebuggingScreenView,
// EnableDebuggingScreenView implementation:
void Show() override;
void Hide() override;
void SetDelegate(Delegate* delegate) override;
void SetDelegate(EnableDebuggingScreen* screen) override;
// BaseScreenHandler implementation:
void DeclareLocalizedValues(
......@@ -76,7 +76,7 @@ class EnableDebuggingScreenHandler : public EnableDebuggingScreenView,
// Updates UI state.
void UpdateUIState(UIState state);
Delegate* delegate_ = nullptr;
EnableDebuggingScreen* screen_ = nullptr;
// Keeps whether screen should be shown right after initialization.
bool show_on_init_ = false;
......
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