Commit 5fbb90a0 authored by harrym@chromium.org's avatar harrym@chromium.org

Allow closing root window, or pressing the power button to shutdown ash_shell,...

Allow closing root window, or pressing the power button to shutdown ash_shell, and chrome /w chromeos flag (not running on chromeos) to exit the application


BUG=113123


Review URL: https://chromiumcodereview.appspot.com/10825191

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@151815 0039d316-1c4b-4281-b951-d872f2087c98
parent da4c7f4f
...@@ -131,7 +131,9 @@ class DummySystemTrayDelegate : public SystemTrayDelegate { ...@@ -131,7 +131,9 @@ class DummySystemTrayDelegate : public SystemTrayDelegate {
caps_lock_enabled_ = enabled; caps_lock_enabled_ = enabled;
} }
virtual void ShutDown() OVERRIDE {} virtual void ShutDown() OVERRIDE {
MessageLoop::current()->Quit();
}
virtual void SignOut() OVERRIDE { virtual void SignOut() OVERRIDE {
MessageLoop::current()->Quit(); MessageLoop::current()->Quit();
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#include "ash/ash_switches.h" #include "ash/ash_switches.h"
#include "ash/shell.h" #include "ash/shell.h"
#include "ash/shell_delegate.h"
#include "ash/shell_window_ids.h" #include "ash/shell_window_ids.h"
#include "ash/wm/cursor_manager.h" #include "ash/wm/cursor_manager.h"
#include "base/command_line.h" #include "base/command_line.h"
...@@ -472,6 +473,12 @@ void PowerButtonController::OnRootWindowResized(const aura::RootWindow* root, ...@@ -472,6 +473,12 @@ void PowerButtonController::OnRootWindowResized(const aura::RootWindow* root,
background_layer_->SetBounds(gfx::Rect(root->bounds().size())); background_layer_->SetBounds(gfx::Rect(root->bounds().size()));
} }
void PowerButtonController::OnRootWindowHostCloseRequested(
const aura::RootWindow*) {
if(Shell::GetInstance() && Shell::GetInstance()->delegate())
Shell::GetInstance()->delegate()->Exit();
}
bool PowerButtonController::LoggedInAsNonGuest() const { bool PowerButtonController::LoggedInAsNonGuest() const {
if (login_status_ == user::LOGGED_IN_NONE) if (login_status_ == user::LOGGED_IN_NONE)
return false; return false;
......
...@@ -157,6 +157,8 @@ class ASH_EXPORT PowerButtonController : public aura::RootWindowObserver, ...@@ -157,6 +157,8 @@ class ASH_EXPORT PowerButtonController : public aura::RootWindowObserver,
// aura::RootWindowObserver overrides: // aura::RootWindowObserver overrides:
virtual void OnRootWindowResized(const aura::RootWindow* root, virtual void OnRootWindowResized(const aura::RootWindow* root,
const gfx::Size& old_size) OVERRIDE; const gfx::Size& old_size) OVERRIDE;
virtual void OnRootWindowHostCloseRequested(
const aura::RootWindow* root) OVERRIDE;
// ShellObserver overrides: // ShellObserver overrides:
virtual void OnLoginStateChanged(user::LoginStatus status) OVERRIDE; virtual void OnLoginStateChanged(user::LoginStatus status) OVERRIDE;
......
...@@ -355,6 +355,8 @@ class SystemTrayDelegate : public ash::SystemTrayDelegate, ...@@ -355,6 +355,8 @@ class SystemTrayDelegate : public ash::SystemTrayDelegate,
virtual void ShutDown() OVERRIDE { virtual void ShutDown() OVERRIDE {
DBusThreadManager::Get()->GetPowerManagerClient()->RequestShutdown(); DBusThreadManager::Get()->GetPowerManagerClient()->RequestShutdown();
if (!base::chromeos::IsRunningOnChromeOS())
browser::AttemptUserExit();
} }
virtual void SignOut() OVERRIDE { virtual void SignOut() OVERRIDE {
......
...@@ -338,9 +338,9 @@ void RootWindow::OnKeyboardMappingChanged() { ...@@ -338,9 +338,9 @@ void RootWindow::OnKeyboardMappingChanged() {
OnKeyboardMappingChanged(this)); OnKeyboardMappingChanged(this));
} }
void RootWindow::OnRootWindowHostClosed() { void RootWindow::OnRootWindowHostCloseRequested() {
FOR_EACH_OBSERVER(RootWindowObserver, observers_, FOR_EACH_OBSERVER(RootWindowObserver, observers_,
OnRootWindowHostClosed(this)); OnRootWindowHostCloseRequested(this));
} }
void RootWindow::AddRootWindowObserver(RootWindowObserver* observer) { void RootWindow::AddRootWindowObserver(RootWindowObserver* observer) {
......
...@@ -167,7 +167,7 @@ class AURA_EXPORT RootWindow : public ui::CompositorDelegate, ...@@ -167,7 +167,7 @@ class AURA_EXPORT RootWindow : public ui::CompositorDelegate,
void OnKeyboardMappingChanged(); void OnKeyboardMappingChanged();
// The system windowing system has sent a request that we close our window. // The system windowing system has sent a request that we close our window.
void OnRootWindowHostClosed(); void OnRootWindowHostCloseRequested();
// Add/remove observer. There is no need to remove the observer if // Add/remove observer. There is no need to remove the observer if
// the root window is being deleted. In particular, you SHOULD NOT remove // the root window is being deleted. In particular, you SHOULD NOT remove
......
...@@ -714,7 +714,7 @@ bool RootWindowHostLinux::Dispatch(const base::NativeEvent& event) { ...@@ -714,7 +714,7 @@ bool RootWindowHostLinux::Dispatch(const base::NativeEvent& event) {
Atom message_type = static_cast<Atom>(xev->xclient.data.l[0]); Atom message_type = static_cast<Atom>(xev->xclient.data.l[0]);
if (message_type == atom_cache_.GetAtom("WM_DELETE_WINDOW")) { if (message_type == atom_cache_.GetAtom("WM_DELETE_WINDOW")) {
// We have received a close message from the window manager. // We have received a close message from the window manager.
delegate_->AsRootWindow()->OnRootWindowHostClosed(); delegate_->AsRootWindow()->OnRootWindowHostCloseRequested();
} else if (message_type == atom_cache_.GetAtom("_NET_WM_PING")) { } else if (message_type == atom_cache_.GetAtom("_NET_WM_PING")) {
XEvent reply_event = *xev; XEvent reply_event = *xev;
reply_event.xclient.window = x_root_window_; reply_event.xclient.window = x_root_window_;
......
...@@ -23,7 +23,7 @@ class AURA_EXPORT RootWindowObserver { ...@@ -23,7 +23,7 @@ class AURA_EXPORT RootWindowObserver {
// Invoked when the native windowing system sends us a request to close our // Invoked when the native windowing system sends us a request to close our
// window. // window.
virtual void OnRootWindowHostClosed(const RootWindow* root) {} virtual void OnRootWindowHostCloseRequested(const RootWindow* root) {}
// Invoked when the keyboard mapping has changed. // Invoked when the keyboard mapping has changed.
virtual void OnKeyboardMappingChanged(const RootWindow* root) {} virtual void OnKeyboardMappingChanged(const RootWindow* root) {}
......
...@@ -242,7 +242,7 @@ void DesktopNativeWidgetHelperAura::OnRootWindowResized( ...@@ -242,7 +242,7 @@ void DesktopNativeWidgetHelperAura::OnRootWindowResized(
root->GetHostSize())); root->GetHostSize()));
} }
void DesktopNativeWidgetHelperAura::OnRootWindowHostClosed( void DesktopNativeWidgetHelperAura::OnRootWindowHostCloseRequested(
const aura::RootWindow* root) { const aura::RootWindow* root) {
DCHECK_EQ(root, root_window_.get()); DCHECK_EQ(root, root_window_.get());
widget_->GetWidget()->Close(); widget_->GetWidget()->Close();
......
...@@ -62,7 +62,8 @@ class VIEWS_EXPORT DesktopNativeWidgetHelperAura ...@@ -62,7 +62,8 @@ class VIEWS_EXPORT DesktopNativeWidgetHelperAura
// Overridden from aura::RootWindowObserver: // Overridden from aura::RootWindowObserver:
virtual void OnRootWindowResized(const aura::RootWindow* root, virtual void OnRootWindowResized(const aura::RootWindow* root,
const gfx::Size& old_size) OVERRIDE; const gfx::Size& old_size) OVERRIDE;
virtual void OnRootWindowHostClosed(const aura::RootWindow* root) OVERRIDE; virtual void OnRootWindowHostCloseRequested(
const aura::RootWindow* root) OVERRIDE;
private: private:
// A weak pointer back to our owning widget. // A weak pointer back to our owning widget.
......
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