forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ash: Allow web pages to use the Ctrl-M minimize shortcut
The active window is minimized only if the active web page or app does not handle the key first. BUG=284522 TEST=manual, ash_unittests AcceleratorCommandsTest.* Review URL: https://chromiumcodereview.appspot.com/23611005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@221294 0039d316-1c4b-4281-b951-d872f2087c98
- Loading branch information
jamescook@chromium.org
committed
Sep 4, 2013
1 parent
9e2cf27
commit fa94127
Showing
9 changed files
with
135 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// Copyright 2013 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#include "ash/accelerators/accelerator_commands.h" | ||
|
||
#include "ash/shell.h" | ||
#include "ash/shell_delegate.h" | ||
#include "ash/wm/window_cycle_controller.h" | ||
#include "ash/wm/window_util.h" | ||
|
||
namespace ash { | ||
namespace accelerators { | ||
|
||
bool ToggleMinimized() { | ||
aura::Window* window = wm::GetActiveWindow(); | ||
// Attempt to restore the window that would be cycled through next from | ||
// the launcher when there is no active window. | ||
if (!window) { | ||
ash::Shell::GetInstance()->window_cycle_controller()-> | ||
HandleCycleWindow(WindowCycleController::FORWARD, false); | ||
return true; | ||
} | ||
// Disable the shortcut for minimizing full screen window due to | ||
// crbug.com/131709, which is a crashing issue related to minimizing | ||
// full screen pepper window. | ||
if (wm::IsWindowFullscreen(window) || !wm::CanMinimizeWindow(window)) | ||
return false; | ||
ash::Shell::GetInstance()->delegate()->RecordUserMetricsAction( | ||
ash::UMA_MINIMIZE_PER_KEY); | ||
wm::MinimizeWindow(window); | ||
return true; | ||
} | ||
|
||
} // namespace accelerators | ||
} // namespace ash |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// Copyright 2013 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#ifndef ASH_ACCELERATORS_ACCELERATOR_COMMANDS_H_ | ||
#define ASH_ACCELERATORS_ACCELERATOR_COMMANDS_H_ | ||
|
||
#include "ash/ash_export.h" | ||
|
||
// This file contains implementations of commands that are bound to keyboard | ||
// shortcuts in Ash or in the embedding application (e.g. Chrome). | ||
namespace ash { | ||
namespace accelerators { | ||
|
||
// Minimizes the active window, if present. If no windows are active, restores | ||
// the first unminimized window. Returns true if a window was minimized or | ||
// restored. | ||
ASH_EXPORT bool ToggleMinimized(); | ||
|
||
} // namespace accelerators | ||
} // namespace ash | ||
|
||
#endif // ASH_ACCELERATORS_ACCELERATOR_COMMANDS_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// Copyright 2013 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#include "ash/accelerators/accelerator_commands.h" | ||
|
||
#include "ash/test/ash_test_base.h" | ||
#include "ash/wm/window_util.h" | ||
#include "ui/aura/window.h" | ||
|
||
namespace ash { | ||
namespace accelerators { | ||
|
||
typedef test::AshTestBase AcceleratorCommandsTest; | ||
|
||
TEST_F(AcceleratorCommandsTest, ToggleMinimized) { | ||
scoped_ptr<aura::Window> window( | ||
CreateTestWindowInShellWithBounds(gfx::Rect(5, 5, 20, 20))); | ||
wm::ActivateWindow(window.get()); | ||
|
||
ToggleMinimized(); | ||
EXPECT_TRUE(wm::IsWindowMinimized(window.get())); | ||
EXPECT_FALSE(wm::IsWindowNormal(window.get())); | ||
|
||
ToggleMinimized(); | ||
EXPECT_FALSE(wm::IsWindowMinimized(window.get())); | ||
EXPECT_TRUE(wm::IsWindowNormal(window.get())); | ||
} | ||
|
||
} // namespace accelerators | ||
} // namespace ash |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters