Skip to content

Commit

Permalink
Mash: elim ShellDelegate::Exit
Browse files Browse the repository at this point in the history
Instead call SessionController::RequestSignOut which does
the same thing.

Bug: 758365
Change-Id: I138b58a05a10a4cdc748896746a5acf14f9bb980
Reviewed-on: https://chromium-review.googlesource.com/699430
Commit-Queue: Steven Bennetts <stevenjb@chromium.org>
Reviewed-by: James Cook <jamescook@chromium.org>
Reviewed-by: Michael Wasserman <msw@chromium.org>
Cr-Commit-Position: refs/heads/master@{#506776}
  • Loading branch information
stevenjb authored and Commit Bot committed Oct 5, 2017
1 parent 2fc0ffd commit d1b937b
Show file tree
Hide file tree
Showing 16 changed files with 15 additions and 49 deletions.
4 changes: 2 additions & 2 deletions ash/accelerators/exit_warning_handler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
#include "ash/accelerators/exit_warning_handler.h"

#include "ash/public/cpp/shell_window_ids.h"
#include "ash/session/session_controller.h"
#include "ash/shell.h"
#include "ash/shell_delegate.h"
#include "ash/strings/grit/ash_strings.h"
#include "base/memory/ptr_util.h"
#include "base/metrics/user_metrics.h"
Expand Down Expand Up @@ -107,7 +107,7 @@ void ExitWarningHandler::HandleAccelerator() {
CancelTimer();
Hide();
base::RecordAction(base::UserMetricsAction("Accel_Exit_Second_Q"));
Shell::Get()->shell_delegate()->Exit();
Shell::Get()->session_controller()->RequestSignOut();
break;
case EXITING:
break;
Expand Down
4 changes: 0 additions & 4 deletions ash/mus/shell_delegate_mus.cc
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,6 @@ void ShellDelegateMus::PreShutdown() {
NOTIMPLEMENTED();
}

void ShellDelegateMus::Exit() {
NOTIMPLEMENTED();
}

std::unique_ptr<keyboard::KeyboardUI> ShellDelegateMus::CreateKeyboardUI() {
NOTIMPLEMENTED();
return nullptr;
Expand Down
1 change: 0 additions & 1 deletion ash/mus/shell_delegate_mus.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ class ShellDelegateMus : public ShellDelegate {
bool IsForceMaximizeOnFirstRun() const override;
void PreInit() override;
void PreShutdown() override;
void Exit() override;
std::unique_ptr<keyboard::KeyboardUI> CreateKeyboardUI() override;
void OpenUrlFromArc(const GURL& url) override;
NetworkingConfigDelegate* GetNetworkingConfigDelegate() override;
Expand Down
4 changes: 2 additions & 2 deletions ash/session/session_aborted_dialog.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
#include "ash/session/session_aborted_dialog.h"

#include "ash/root_window_controller.h"
#include "ash/session/session_controller.h"
#include "ash/shelf/shelf.h"
#include "ash/shell.h"
#include "ash/shell_delegate.h"
#include "ash/strings/grit/ash_strings.h"
#include "base/macros.h"
#include "base/strings/utf_string_conversions.h"
Expand Down Expand Up @@ -52,7 +52,7 @@ void SessionAbortedDialog::Show(const std::string& user_email) {
}

bool SessionAbortedDialog::Accept() {
Shell::Get()->shell_delegate()->Exit();
Shell::Get()->session_controller()->RequestSignOut();
return true;
}

Expand Down
3 changes: 1 addition & 2 deletions ash/shelf/login_shelf_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
#include "ash/shelf/shelf_constants.h"
#include "ash/shelf/shelf_widget.h"
#include "ash/shell.h"
#include "ash/shell_delegate.h"
#include "ash/shutdown_controller.h"
#include "ash/strings/grit/ash_strings.h"
#include "ash/system/status_area_widget.h"
Expand Down Expand Up @@ -161,7 +160,7 @@ void LoginShelfView::ButtonPressed(views::Button* sender,
break;
case kSignOut:
base::RecordAction(base::UserMetricsAction("ScreenLocker_Signout"));
Shell::Get()->shell_delegate()->Exit();
Shell::Get()->session_controller()->RequestSignOut();
break;
case kCloseNote:
Shell::Get()->tray_action()->CloseLockScreenNote(
Expand Down
11 changes: 6 additions & 5 deletions ash/shelf/login_shelf_view_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@
#include "ash/login/ui/login_test_base.h"
#include "ash/root_window_controller.h"
#include "ash/session/session_controller.h"
#include "ash/session/test_session_controller_client.h"
#include "ash/shelf/shelf.h"
#include "ash/shelf/shelf_widget.h"
#include "ash/shell.h"
#include "ash/shutdown_controller.h"
#include "ash/system/tray/system_tray.h"
#include "ash/test/ash_test_base.h"
#include "ash/test/ash_test_helper.h"
#include "ash/test_shell_delegate.h"
#include "ash/tray_action/test_tray_action_client.h"
#include "ash/tray_action/tray_action.h"
#include "ash/wm/lock_state_controller.h"
Expand Down Expand Up @@ -210,11 +210,12 @@ TEST_F(LoginShelfViewTest, ClickRestartButton) {
}

TEST_F(LoginShelfViewTest, ClickSignOutButton) {
TestShellDelegate* shell_delegate_ =
static_cast<TestShellDelegate*>(Shell::Get()->shell_delegate());
EXPECT_EQ(shell_delegate_->num_exit_requests(), 0);
NotifySessionStateChanged(SessionState::ACTIVE);
EXPECT_EQ(session_manager::SessionState::ACTIVE,
Shell::Get()->session_controller()->GetSessionState());
Click(LoginShelfView::kSignOut);
EXPECT_EQ(shell_delegate_->num_exit_requests(), 1);
EXPECT_EQ(session_manager::SessionState::LOGIN_PRIMARY,
Shell::Get()->session_controller()->GetSessionState());
}

TEST_F(LoginShelfViewTest, ClickUnlockButton) {
Expand Down
5 changes: 0 additions & 5 deletions ash/shell/shell_delegate_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
#include "ash/shell/toplevel_window.h"
#include "ash/wm/window_state.h"
#include "base/memory/ptr_util.h"
#include "base/run_loop.h"
#include "base/strings/utf_string_conversions.h"
#include "components/user_manager/user_info_impl.h"
#include "ui/aura/window.h"
Expand Down Expand Up @@ -81,10 +80,6 @@ void ShellDelegateImpl::PreInit() {}

void ShellDelegateImpl::PreShutdown() {}

void ShellDelegateImpl::Exit() {
base::RunLoop::QuitCurrentWhenIdleDeprecated();
}

std::unique_ptr<keyboard::KeyboardUI> ShellDelegateImpl::CreateKeyboardUI() {
return base::MakeUnique<TestKeyboardUI>();
}
Expand Down
1 change: 0 additions & 1 deletion ash/shell/shell_delegate_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ class ShellDelegateImpl : public ShellDelegate {
bool IsForceMaximizeOnFirstRun() const override;
void PreInit() override;
void PreShutdown() override;
void Exit() override;
std::unique_ptr<keyboard::KeyboardUI> CreateKeyboardUI() override;
void OpenUrlFromArc(const GURL& url) override;
NetworkingConfigDelegate* GetNetworkingConfigDelegate() override;
Expand Down
3 changes: 0 additions & 3 deletions ash/shell_delegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,6 @@ class ASH_EXPORT ShellDelegate {
// delegate can use Shell instance to perform cleanup tasks.
virtual void PreShutdown() = 0;

// Invoked when the user uses Ctrl-Shift-Q to close chrome.
virtual void Exit() = 0;

// Create a shell-specific keyboard::KeyboardUI.
virtual std::unique_ptr<keyboard::KeyboardUI> CreateKeyboardUI() = 0;

Expand Down
4 changes: 2 additions & 2 deletions ash/shutdown_controller.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

#include <utility>

#include "ash/session/session_controller.h"
#include "ash/shell.h"
#include "ash/shell_delegate.h"
#include "ash/shutdown_reason.h"
#include "ash/wm/lock_state_controller.h"
#include "base/metrics/user_metrics.h"
Expand All @@ -33,7 +33,7 @@ void ShutdownController::RemoveObserver(Observer* observer) {
void ShutdownController::ShutDownOrReboot(ShutdownReason reason) {
// For developers on Linux desktop just exit the app.
if (!base::SysInfo::IsRunningOnChromeOS()) {
Shell::Get()->shell_delegate()->Exit();
Shell::Get()->session_controller()->RequestSignOut();
return;
}

Expand Down
4 changes: 0 additions & 4 deletions ash/test_shell_delegate.cc
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,6 @@ void TestShellDelegate::PreInit() {}

void TestShellDelegate::PreShutdown() {}

void TestShellDelegate::Exit() {
num_exit_requests_++;
}

std::unique_ptr<keyboard::KeyboardUI> TestShellDelegate::CreateKeyboardUI() {
return std::make_unique<TestKeyboardUI>();
}
Expand Down
4 changes: 0 additions & 4 deletions ash/test_shell_delegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ class TestShellDelegate : public ShellDelegate {
bool IsForceMaximizeOnFirstRun() const override;
void PreInit() override;
void PreShutdown() override;
void Exit() override;
std::unique_ptr<keyboard::KeyboardUI> CreateKeyboardUI() override;
void OpenUrlFromArc(const GURL& url) override;
NetworkingConfigDelegate* GetNetworkingConfigDelegate() override;
Expand All @@ -36,14 +35,11 @@ class TestShellDelegate : public ShellDelegate {
gfx::Image GetDeprecatedAcceleratorImage() const override;
ui::InputDeviceControllerClient* GetInputDeviceControllerClient() override;

int num_exit_requests() const { return num_exit_requests_; }

void SetForceMaximizeOnFirstRun(bool maximize) {
force_maximize_on_first_run_ = maximize;
}

private:
int num_exit_requests_ = 0;
bool force_maximize_on_first_run_ = false;

DISALLOW_COPY_AND_ASSIGN(TestShellDelegate);
Expand Down
2 changes: 1 addition & 1 deletion ash/wm/lock_state_controller.cc
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ void LockStateController::SetLockScreenDisplayedCallback(
}

void LockStateController::OnHostCloseRequested(aura::WindowTreeHost* host) {
Shell::Get()->shell_delegate()->Exit();
Shell::Get()->session_controller()->RequestSignOut();
}

void LockStateController::OnChromeTerminating() {
Expand Down
8 changes: 1 addition & 7 deletions ash/wm/lock_state_controller_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
#include "ash/system/tray/system_tray.h"
#include "ash/test/ash_test_base.h"
#include "ash/test_screenshot_delegate.h"
#include "ash/test_shell_delegate.h"
#include "ash/wm/lock_state_controller_test_api.h"
#include "ash/wm/power_button_controller.h"
#include "ash/wm/session_state_animator.h"
Expand Down Expand Up @@ -92,9 +91,6 @@ class LockStateControllerTest : public AshTestBase {
test_api_->set_shutdown_controller(&test_shutdown_controller_);

power_button_controller_ = Shell::Get()->power_button_controller();

shell_delegate_ =
static_cast<TestShellDelegate*>(Shell::Get()->shell_delegate());
}

void TearDown() override {
Expand All @@ -121,8 +117,7 @@ class LockStateControllerTest : public AshTestBase {
}

int NumShutdownRequests() {
return test_shutdown_controller_.num_shutdown_requests() +
shell_delegate_->num_exit_requests();
return test_shutdown_controller_.num_shutdown_requests();
}

void Advance(SessionStateAnimator::AnimationSpeed speed) {
Expand Down Expand Up @@ -361,7 +356,6 @@ class LockStateControllerTest : public AshTestBase {

TestSessionStateAnimator* test_animator_ = nullptr; // not owned
std::unique_ptr<LockStateControllerTestApi> test_api_;
TestShellDelegate* shell_delegate_ = nullptr; // not owned

private:
DISALLOW_COPY_AND_ASSIGN(LockStateControllerTest);
Expand Down
5 changes: 0 additions & 5 deletions chrome/browser/ui/ash/chrome_shell_delegate.cc
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
#include "chrome/browser/chromeos/display/display_preferences.h"
#include "chrome/browser/chromeos/policy/display_rotation_default_handler.h"
#include "chrome/browser/chromeos/profiles/profile_helper.h"
#include "chrome/browser/lifetime/application_lifetime.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/signin/signin_error_notifier_factory_ash.h"
Expand Down Expand Up @@ -403,10 +402,6 @@ void ChromeShellDelegate::PreShutdown() {
display_configuration_observer_.reset();
}

void ChromeShellDelegate::Exit() {
chrome::AttemptUserExit();
}

void ChromeShellDelegate::OpenUrlFromArc(const GURL& url) {
if (!url.is_valid())
return;
Expand Down
1 change: 0 additions & 1 deletion chrome/browser/ui/ash/chrome_shell_delegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ class ChromeShellDelegate : public ash::ShellDelegate,
bool IsForceMaximizeOnFirstRun() const override;
void PreInit() override;
void PreShutdown() override;
void Exit() override;
std::unique_ptr<keyboard::KeyboardUI> CreateKeyboardUI() override;
void OpenUrlFromArc(const GURL& url) override;
ash::NetworkingConfigDelegate* GetNetworkingConfigDelegate() override;
Expand Down

0 comments on commit d1b937b

Please sign in to comment.