summaryrefslogtreecommitdiffstats
path: root/ash
diff options
context:
space:
mode:
authorderat@chromium.org <derat@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-01-20 22:20:39 +0000
committerderat@chromium.org <derat@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-01-20 22:20:39 +0000
commiteaae8b461225ee3733f642143c3bf728d8763655 (patch)
tree757f2e89f13010eba83e9446c4b40aef2e7f67d2 /ash
parent70b5ecaf5554037b5470b3ca64896eaa1b369063 (diff)
downloadchromium_src-eaae8b461225ee3733f642143c3bf728d8763655.zip
chromium_src-eaae8b461225ee3733f642143c3bf728d8763655.tar.gz
chromium_src-eaae8b461225ee3733f642143c3bf728d8763655.tar.bz2
aura: Replace UI-feature GYP flags with switches.
This replaces the aura_show_about_flag_window_mode and chromeos_legacy_power_button GYP flags with --aura-force-compact-window-mode and --aura-legacy-power-button command-line switches. There is concern that using compile-time flags to control these features will greatly increase the workload on the Chrome OS builders; we apparently currently share Chrome binaries across all Chrome OS boards with the same architecture. BUG=109209,109052,chrome-os-partner:7570 TEST=manual Review URL: https://chromiumcodereview.appspot.com/9264025 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@118522 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash')
-rw-r--r--ash/ash_switches.cc11
-rw-r--r--ash/ash_switches.h2
-rw-r--r--ash/shell.cc3
-rw-r--r--ash/wm/power_button_controller.cc95
-rw-r--r--ash/wm/power_button_controller.h8
-rw-r--r--ash/wm/power_button_controller_unittest.cc14
6 files changed, 84 insertions, 49 deletions
diff --git a/ash/ash_switches.cc b/ash/ash_switches.cc
index 10b71ad..f7ef7d1 100644
--- a/ash/ash_switches.cc
+++ b/ash/ash_switches.cc
@@ -11,9 +11,20 @@
namespace ash {
namespace switches {
+// Force the "compact" window mode regardless of the value of kAuraWindowMode.
+// This can be used to override a value set in chrome://flags.
+// TODO(derat): Remove this once the normal mode is usable on all platforms.
+const char kAuraForceCompactWindowMode[] = "aura-force-compact-window-mode";
+
// Use Google-style dialog box frames.
const char kAuraGoogleDialogFrames[] = "aura-google-dialog-frames";
+// (Most) Chrome OS hardware reports ACPI power button releases correctly.
+// Standard hardware reports releases immediately after presses. If set, we
+// lock the screen or shutdown the system immediately in response to a press
+// instead of displaying an interactive animation.
+const char kAuraLegacyPowerButton[] = "aura-legacy-power-button";
+
// Avoid drawing drop shadows under windows.
const char kAuraNoShadows[] = "aura-no-shadows";
diff --git a/ash/ash_switches.h b/ash/ash_switches.h
index 2b5d8ad..f086173 100644
--- a/ash/ash_switches.h
+++ b/ash/ash_switches.h
@@ -12,7 +12,9 @@ namespace ash {
namespace switches {
// Please keep alphabetized.
+ASH_EXPORT extern const char kAuraForceCompactWindowMode[];
ASH_EXPORT extern const char kAuraGoogleDialogFrames[];
+ASH_EXPORT extern const char kAuraLegacyPowerButton[];
ASH_EXPORT extern const char kAuraNoShadows[];
ASH_EXPORT extern const char kAuraTranslucentFrames[];
ASH_EXPORT extern const char kAuraWindowMode[];
diff --git a/ash/shell.cc b/ash/shell.cc
index 0e9a14c..9480898 100644
--- a/ash/shell.cc
+++ b/ash/shell.cc
@@ -273,6 +273,9 @@ void Shell::Init() {
Shell::WindowMode Shell::ComputeWindowMode(const gfx::Size& monitor_size,
CommandLine* command_line) const {
+ if (command_line->HasSwitch(switches::kAuraForceCompactWindowMode))
+ return COMPACT_MODE;
+
// If user set the flag, use their desired behavior.
if (command_line->HasSwitch(switches::kAuraWindowMode)) {
std::string mode =
diff --git a/ash/wm/power_button_controller.cc b/ash/wm/power_button_controller.cc
index d8ce2be1..47d0aa4 100644
--- a/ash/wm/power_button_controller.cc
+++ b/ash/wm/power_button_controller.cc
@@ -4,8 +4,10 @@
#include "ash/wm/power_button_controller.h"
+#include "ash/ash_switches.h"
#include "ash/shell.h"
#include "ash/shell_window_ids.h"
+#include "base/command_line.h"
#include "base/logging.h"
#include "base/time.h"
#include "third_party/skia/include/core/SkColor.h"
@@ -320,7 +322,10 @@ PowerButtonController::PowerButtonController()
locked_(false),
power_button_down_(false),
lock_button_down_(false),
- shutting_down_(false) {
+ shutting_down_(false),
+ has_legacy_power_button_(
+ CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kAuraLegacyPowerButton)) {
}
PowerButtonController::~PowerButtonController() {
@@ -340,15 +345,13 @@ void PowerButtonController::OnLockStateChange(bool locked) {
lock_timer_.Stop();
lock_fail_timer_.Stop();
-#if !defined(CHROMEOS_LEGACY_POWER_BUTTON)
- if (power_button_down_) {
+ if (!has_legacy_power_button_ && power_button_down_) {
lock_to_shutdown_timer_.Stop();
lock_to_shutdown_timer_.Start(
FROM_HERE,
base::TimeDelta::FromMilliseconds(kLockToShutdownTimeoutMs),
this, &PowerButtonController::OnLockToShutdownTimeout);
}
-#endif
} else {
StartAnimation(ALL_BUT_SCREEN_LOCKER_AND_RELATED_CONTAINERS,
ANIMATION_RESTORE);
@@ -374,51 +377,51 @@ void PowerButtonController::OnPowerButtonEvent(
if (shutting_down_)
return;
-#if defined(CHROMEOS_LEGACY_POWER_BUTTON)
- // If power button releases won't get reported correctly because we're not
- // running on official hardware, just lock the screen or shut down
- // immediately.
- if (down) {
- ShowBackgroundLayer();
- if (logged_in_as_non_guest_ && !locked_) {
- StartAnimation(ALL_BUT_SCREEN_LOCKER_AND_RELATED_CONTAINERS,
- ANIMATION_SLOW_CLOSE);
- OnLockTimeout();
- } else {
- OnShutdownTimeout();
- }
- }
-#else
- if (down) {
- // If we already have a pending request to lock the screen, wait.
- if (lock_fail_timer_.IsRunning())
- return;
-
- if (logged_in_as_non_guest_ && !locked_)
- StartLockTimer();
- else
- StartShutdownTimer();
- } else { // Button is up.
- if (lock_timer_.IsRunning() || shutdown_timer_.IsRunning())
- StartAnimation(
- locked_ ? SCREEN_LOCKER_AND_RELATED_CONTAINERS : ALL_CONTAINERS,
- ANIMATION_UNDO_SLOW_CLOSE);
-
- // Drop the background layer after the undo animation finishes.
- if (lock_timer_.IsRunning() ||
- (shutdown_timer_.IsRunning() && !logged_in_as_non_guest_)) {
- hide_background_layer_timer_.Stop();
- hide_background_layer_timer_.Start(
- FROM_HERE,
- base::TimeDelta::FromMilliseconds(kUndoSlowCloseAnimMs),
- this, &PowerButtonController::HideBackgroundLayer);
+ if (has_legacy_power_button_) {
+ // If power button releases won't get reported correctly because we're not
+ // running on official hardware, just lock the screen or shut down
+ // immediately.
+ if (down) {
+ ShowBackgroundLayer();
+ if (logged_in_as_non_guest_ && !locked_) {
+ StartAnimation(ALL_BUT_SCREEN_LOCKER_AND_RELATED_CONTAINERS,
+ ANIMATION_SLOW_CLOSE);
+ OnLockTimeout();
+ } else {
+ OnShutdownTimeout();
+ }
}
+ } else { // !has_legacy_power_button_
+ if (down) {
+ // If we already have a pending request to lock the screen, wait.
+ if (lock_fail_timer_.IsRunning())
+ return;
+
+ if (logged_in_as_non_guest_ && !locked_)
+ StartLockTimer();
+ else
+ StartShutdownTimer();
+ } else { // Button is up.
+ if (lock_timer_.IsRunning() || shutdown_timer_.IsRunning())
+ StartAnimation(
+ locked_ ? SCREEN_LOCKER_AND_RELATED_CONTAINERS : ALL_CONTAINERS,
+ ANIMATION_UNDO_SLOW_CLOSE);
+
+ // Drop the background layer after the undo animation finishes.
+ if (lock_timer_.IsRunning() ||
+ (shutdown_timer_.IsRunning() && !logged_in_as_non_guest_)) {
+ hide_background_layer_timer_.Stop();
+ hide_background_layer_timer_.Start(
+ FROM_HERE,
+ base::TimeDelta::FromMilliseconds(kUndoSlowCloseAnimMs),
+ this, &PowerButtonController::HideBackgroundLayer);
+ }
- lock_timer_.Stop();
- shutdown_timer_.Stop();
- lock_to_shutdown_timer_.Stop();
+ lock_timer_.Stop();
+ shutdown_timer_.Stop();
+ lock_to_shutdown_timer_.Stop();
+ }
}
-#endif
}
void PowerButtonController::OnLockButtonEvent(
diff --git a/ash/wm/power_button_controller.h b/ash/wm/power_button_controller.h
index 00a1507..b25f0a1 100644
--- a/ash/wm/power_button_controller.h
+++ b/ash/wm/power_button_controller.h
@@ -132,6 +132,10 @@ class ASH_EXPORT PowerButtonController : public aura::RootWindowObserver {
delegate_.reset(delegate);
}
+ void set_has_legacy_power_button_for_test(bool legacy) {
+ has_legacy_power_button_ = legacy;
+ }
+
// Called when the user logs in.
void OnLoginStateChange(bool logged_in, bool is_guest);
@@ -195,6 +199,10 @@ class ASH_EXPORT PowerButtonController : public aura::RootWindowObserver {
// screen has been locked?
bool should_start_shutdown_timer_after_lock_;
+ // Was a command-line switch set telling us that we're running on hardware
+ // that misreports power button releases?
+ bool has_legacy_power_button_;
+
// Responsible for painting |background_layer_|.
scoped_ptr<BackgroundLayerDelegate> background_layer_delegate_;
diff --git a/ash/wm/power_button_controller_unittest.cc b/ash/wm/power_button_controller_unittest.cc
index 658ed98..18b08e5 100644
--- a/ash/wm/power_button_controller_unittest.cc
+++ b/ash/wm/power_button_controller_unittest.cc
@@ -61,12 +61,12 @@ class PowerButtonControllerTest : public AuraShellTestBase {
DISALLOW_COPY_AND_ASSIGN(PowerButtonControllerTest);
};
-#if defined(CHROMEOS_LEGACY_POWER_BUTTON)
// Test the lock-to-shutdown flow for non-Chrome-OS hardware that doesn't
// correctly report power button releases. We should lock immediately the first
// time the button is pressed and shut down when it's pressed from the locked
// state.
TEST_F(PowerButtonControllerTest, LegacyLockAndShutDown) {
+ controller_->set_has_legacy_power_button_for_test(true);
controller_->OnLoginStateChange(true /*logged_in*/, false /*is_guest*/);
controller_->OnLockStateChange(false);
@@ -120,6 +120,7 @@ TEST_F(PowerButtonControllerTest, LegacyLockAndShutDown) {
// Test that we start shutting down immediately if the power button is pressed
// while we're not logged in on an unofficial system.
TEST_F(PowerButtonControllerTest, LegacyNotLoggedIn) {
+ controller_->set_has_legacy_power_button_for_test(true);
controller_->OnLoginStateChange(false /*logged_in*/, false /*is_guest*/);
controller_->OnLockStateChange(false);
controller_->OnPowerButtonEvent(true, base::TimeTicks::Now());
@@ -129,15 +130,17 @@ TEST_F(PowerButtonControllerTest, LegacyNotLoggedIn) {
// Test that we start shutting down immediately if the power button is pressed
// while we're logged in as a guest on an unofficial system.
TEST_F(PowerButtonControllerTest, LegacyGuest) {
+ controller_->set_has_legacy_power_button_for_test(true);
controller_->OnLoginStateChange(true /*logged_in*/, true /*is_guest*/);
controller_->OnLockStateChange(false);
controller_->OnPowerButtonEvent(true, base::TimeTicks::Now());
EXPECT_TRUE(test_api_->real_shutdown_timer_is_running());
}
-#else
+
// When we hold the power button while the user isn't logged in, we should shut
// down the machine directly.
TEST_F(PowerButtonControllerTest, ShutdownWhenNotLoggedIn) {
+ controller_->set_has_legacy_power_button_for_test(false);
controller_->OnLoginStateChange(false /*logged_in*/, false /*is_guest*/);
controller_->OnLockStateChange(false);
EXPECT_FALSE(test_api_->BackgroundLayerIsVisible());
@@ -186,6 +189,7 @@ TEST_F(PowerButtonControllerTest, ShutdownWhenNotLoggedIn) {
// Test that we lock the screen and deal with unlocking correctly.
TEST_F(PowerButtonControllerTest, LockAndUnlock) {
+ controller_->set_has_legacy_power_button_for_test(false);
controller_->OnLoginStateChange(true /*logged_in*/, false /*is_guest*/);
controller_->OnLockStateChange(false);
EXPECT_FALSE(test_api_->BackgroundLayerIsVisible());
@@ -270,6 +274,7 @@ TEST_F(PowerButtonControllerTest, LockAndUnlock) {
// Hold the power button down from the unlocked state to eventual shutdown.
TEST_F(PowerButtonControllerTest, LockToShutdown) {
+ controller_->set_has_legacy_power_button_for_test(false);
controller_->OnLoginStateChange(true /*logged_in*/, false /*is_guest*/);
controller_->OnLockStateChange(false);
@@ -302,6 +307,7 @@ TEST_F(PowerButtonControllerTest, LockToShutdown) {
// Test that we handle the case where lock requests are ignored.
TEST_F(PowerButtonControllerTest, LockFail) {
+ controller_->set_has_legacy_power_button_for_test(false);
controller_->OnLoginStateChange(true /*logged_in*/, false /*is_guest*/);
controller_->OnLockStateChange(false);
@@ -334,6 +340,7 @@ TEST_F(PowerButtonControllerTest, LockFail) {
// button is released, but that we cancel the timer if the button is pressed
// again before the timer has fired.
TEST_F(PowerButtonControllerTest, CancelHideBackground) {
+ controller_->set_has_legacy_power_button_for_test(false);
controller_->OnLoginStateChange(false /*logged_in*/, false /*is_guest*/);
controller_->OnLockStateChange(false);
@@ -348,6 +355,7 @@ TEST_F(PowerButtonControllerTest, CancelHideBackground) {
// Test the basic operation of the lock button.
TEST_F(PowerButtonControllerTest, LockButtonBasic) {
+ controller_->set_has_legacy_power_button_for_test(false);
// The lock button shouldn't do anything if we aren't logged in.
controller_->OnLoginStateChange(false /*logged_in*/, false /*is_guest*/);
controller_->OnLockStateChange(false);
@@ -411,6 +419,7 @@ TEST_F(PowerButtonControllerTest, LockButtonBasic) {
// Test that the power button takes priority over the lock button.
TEST_F(PowerButtonControllerTest, PowerButtonPreemptsLockButton) {
+ controller_->set_has_legacy_power_button_for_test(false);
controller_->OnLoginStateChange(true /*logged_in*/, false /*is_guest*/);
controller_->OnLockStateChange(false);
@@ -438,7 +447,6 @@ TEST_F(PowerButtonControllerTest, PowerButtonPreemptsLockButton) {
controller_->OnLockButtonEvent(false, base::TimeTicks::Now());
EXPECT_FALSE(test_api_->lock_timer_is_running());
}
-#endif
} // namespace test
} // namespace ash