Remove TOGGLE_MAXIMIZED_* from Ash reserved actions list.
The following changes are for removing TOGGLE_MAXIMIZED_* from Ash reserved actions list. - Add ShellDelegate::ToggleMaximized - Remove VKEY_F4 from browser accelerators list Also added a browser test for ChromeShellDelegate::ToggleMaximized. BUG=152265 TEST=Manual Review URL: https://chromiumcodereview.appspot.com/11082002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@161015 0039d316-1c4b-4281-b951-d872f2087c98
This commit is contained in:
@ -719,19 +719,7 @@ bool AcceleratorController::PerformAction(int action,
|
||||
shell->delegate()->RecordUserMetricsAction(
|
||||
UMA_ACCEL_MAXIMIZE_RESTORE_F4);
|
||||
}
|
||||
aura::Window* window = wm::GetActiveWindow();
|
||||
if (!window)
|
||||
return true;
|
||||
if (wm::IsWindowFullscreen(window)) {
|
||||
// Chrome also uses VKEY_F4 as a shortcut. Its action is to toggle
|
||||
// fullscreen. We return false below so Chrome will process the
|
||||
// shortcut again and, in case of VKEY_F4, exit fullscreen.
|
||||
return false;
|
||||
}
|
||||
if (wm::IsWindowMaximized(window))
|
||||
wm::RestoreWindow(window);
|
||||
else if (wm::CanMaximizeWindow(window))
|
||||
wm::MaximizeWindow(window);
|
||||
shell->delegate()->ToggleMaximized();
|
||||
return true;
|
||||
}
|
||||
case TOGGLE_MAXIMIZED_RELEASED: {
|
||||
|
@ -197,8 +197,6 @@ const AcceleratorAction kReservedActions[] = {
|
||||
#if defined(OS_CHROMEOS)
|
||||
POWER_PRESSED,
|
||||
POWER_RELEASED,
|
||||
TOGGLE_MAXIMIZED_PRESSED,
|
||||
TOGGLE_MAXIMIZED_RELEASED,
|
||||
#endif
|
||||
};
|
||||
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include "ash/shell/launcher_delegate_impl.h"
|
||||
#include "ash/shell/toplevel_window.h"
|
||||
#include "ash/shell_window_ids.h"
|
||||
#include "ash/wm/window_util.h"
|
||||
#include "base/message_loop.h"
|
||||
#include "ui/aura/window.h"
|
||||
|
||||
@ -75,6 +76,12 @@ void ShellDelegateImpl::NewWindow(bool incognito) {
|
||||
ash::shell::ToplevelWindow::CreateToplevelWindow(create_params);
|
||||
}
|
||||
|
||||
void ShellDelegateImpl::ToggleMaximized() {
|
||||
aura::Window* window = ash::wm::GetActiveWindow();
|
||||
if (window)
|
||||
ash::wm::ToggleMaximizedWindow(window);
|
||||
}
|
||||
|
||||
void ShellDelegateImpl::OpenFileManager(bool as_dialog) {
|
||||
}
|
||||
|
||||
|
@ -31,6 +31,7 @@ class ShellDelegateImpl : public ash::ShellDelegate {
|
||||
virtual void Exit() OVERRIDE;
|
||||
virtual void NewTab() OVERRIDE;
|
||||
virtual void NewWindow(bool incognito) OVERRIDE;
|
||||
virtual void ToggleMaximized() OVERRIDE;
|
||||
virtual void OpenFileManager(bool as_dialog) OVERRIDE;
|
||||
virtual void OpenCrosh() OVERRIDE;
|
||||
virtual void OpenMobileSetup(const std::string& service_path) OVERRIDE;
|
||||
|
@ -90,6 +90,9 @@ class ASH_EXPORT ShellDelegate {
|
||||
// Invoked when the user uses Ctrl-N or Ctrl-Shift-N to open a new window.
|
||||
virtual void NewWindow(bool incognito) = 0;
|
||||
|
||||
// Invoked when the user uses F4 to toggle window maximized state.
|
||||
virtual void ToggleMaximized() = 0;
|
||||
|
||||
// Invoked when the user uses Ctrl-M or Ctrl-O to open file manager.
|
||||
virtual void OpenFileManager(bool as_dialog) = 0;
|
||||
|
||||
|
@ -10,6 +10,7 @@
|
||||
#include "ash/shell.h"
|
||||
#include "ash/shell_window_ids.h"
|
||||
#include "ash/test/test_launcher_delegate.h"
|
||||
#include "ash/wm/window_util.h"
|
||||
#include "content/public/test/test_browser_context.h"
|
||||
#include "ui/aura/window.h"
|
||||
|
||||
@ -60,6 +61,12 @@ void TestShellDelegate::NewTab() {
|
||||
void TestShellDelegate::NewWindow(bool incognito) {
|
||||
}
|
||||
|
||||
void TestShellDelegate::ToggleMaximized() {
|
||||
aura::Window* window = ash::wm::GetActiveWindow();
|
||||
if (window)
|
||||
ash::wm::ToggleMaximizedWindow(window);
|
||||
}
|
||||
|
||||
void TestShellDelegate::OpenFileManager(bool as_dialog) {
|
||||
}
|
||||
|
||||
|
@ -28,6 +28,7 @@ class TestShellDelegate : public ShellDelegate {
|
||||
virtual void Exit() OVERRIDE;
|
||||
virtual void NewTab() OVERRIDE;
|
||||
virtual void NewWindow(bool incognito) OVERRIDE;
|
||||
virtual void ToggleMaximized() OVERRIDE;
|
||||
virtual void OpenFileManager(bool as_dialog) OVERRIDE;
|
||||
virtual void OpenCrosh() OVERRIDE;
|
||||
virtual void OpenMobileSetup(const std::string& service_path) OVERRIDE;
|
||||
|
@ -100,6 +100,13 @@ void RestoreWindow(aura::Window* window) {
|
||||
window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL);
|
||||
}
|
||||
|
||||
void ToggleMaximizedWindow(aura::Window* window) {
|
||||
if (ash::wm::IsWindowMaximized(window))
|
||||
ash::wm::RestoreWindow(window);
|
||||
else if (ash::wm::CanMaximizeWindow(window))
|
||||
ash::wm::MaximizeWindow(window);
|
||||
}
|
||||
|
||||
void CenterWindow(aura::Window* window) {
|
||||
const gfx::Display display = gfx::Screen::GetDisplayNearestWindow(window);
|
||||
gfx::Rect center = display.work_area().Center(window->bounds().size());
|
||||
|
@ -62,6 +62,9 @@ ASH_EXPORT void MinimizeWindow(aura::Window* window);
|
||||
// Restores |window|, which must not be NULL.
|
||||
ASH_EXPORT void RestoreWindow(aura::Window* window);
|
||||
|
||||
// Maximizes or restores |window| based on its state. |window| must not be NULL.
|
||||
ASH_EXPORT void ToggleMaximizedWindow(aura::Window* window);
|
||||
|
||||
// Moves the window to the center of the display.
|
||||
ASH_EXPORT void CenterWindow(aura::Window* window);
|
||||
|
||||
|
@ -182,6 +182,18 @@ void ChromeShellDelegate::NewWindow(bool is_incognito) {
|
||||
is_incognito ? profile->GetOffTheRecordProfile() : profile);
|
||||
}
|
||||
|
||||
void ChromeShellDelegate::ToggleMaximized() {
|
||||
aura::Window* window = ash::wm::GetActiveWindow();
|
||||
if (!window)
|
||||
return;
|
||||
// Get out of fullscreen when in fullscreen mode.
|
||||
if (ash::wm::IsWindowFullscreen(window)) {
|
||||
chrome::ToggleFullscreenMode(GetTargetBrowser());
|
||||
return;
|
||||
}
|
||||
ash::wm::ToggleMaximizedWindow(window);
|
||||
}
|
||||
|
||||
void ChromeShellDelegate::OpenFileManager(bool as_dialog) {
|
||||
#if defined(OS_CHROMEOS)
|
||||
if (as_dialog) {
|
||||
|
@ -44,6 +44,7 @@ class ChromeShellDelegate : public ash::ShellDelegate,
|
||||
virtual void Exit() OVERRIDE;
|
||||
virtual void NewTab() OVERRIDE;
|
||||
virtual void NewWindow(bool is_incognito) OVERRIDE;
|
||||
virtual void ToggleMaximized() OVERRIDE;
|
||||
virtual void OpenFileManager(bool as_dialog) OVERRIDE;
|
||||
virtual void OpenCrosh() OVERRIDE;
|
||||
virtual void OpenMobileSetup(const std::string& service_path) OVERRIDE;
|
||||
|
42
chrome/browser/ui/ash/chrome_shell_delegate_browsertest.cc
Normal file
42
chrome/browser/ui/ash/chrome_shell_delegate_browsertest.cc
Normal file
@ -0,0 +1,42 @@
|
||||
// Copyright (c) 2012 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 "chrome/browser/ui/ash/chrome_shell_delegate.h"
|
||||
|
||||
#include "ash/shell.h"
|
||||
#include "ash/shell_delegate.h"
|
||||
#include "ash/wm/window_util.h"
|
||||
#include "chrome/browser/ui/browser.h"
|
||||
#include "chrome/browser/ui/browser_commands.h"
|
||||
#include "chrome/browser/ui/browser_finder.h"
|
||||
#include "chrome/test/base/in_process_browser_test.h"
|
||||
|
||||
typedef InProcessBrowserTest ChromeShellDelegateBrowserTest;
|
||||
|
||||
// Confirm that toggling window miximized works properly
|
||||
IN_PROC_BROWSER_TEST_F(ChromeShellDelegateBrowserTest, ToggleMaximized) {
|
||||
ash::ShellDelegate* shell_delegate = ash::Shell::GetInstance()->delegate();
|
||||
ASSERT_TRUE(shell_delegate);
|
||||
|
||||
// When not in fullscreen, ShellDelegate::ToggleMaximized toggles Maximized.
|
||||
aura::Window* window = ash::wm::GetActiveWindow();
|
||||
EXPECT_FALSE(ash::wm::IsWindowMaximized(window));
|
||||
shell_delegate->ToggleMaximized();
|
||||
EXPECT_TRUE(ash::wm::IsWindowMaximized(window));
|
||||
shell_delegate->ToggleMaximized();
|
||||
EXPECT_FALSE(ash::wm::IsWindowMaximized(window));
|
||||
|
||||
// When in fullscreen ShellDelegate::ToggleMaximized gets out of fullscreen.
|
||||
EXPECT_FALSE(ash::wm::IsWindowFullscreen(window));
|
||||
Browser* browser = browser::FindBrowserWithWindow(window);
|
||||
ASSERT_TRUE(browser);
|
||||
chrome::ToggleFullscreenMode(browser);
|
||||
EXPECT_TRUE(ash::wm::IsWindowFullscreen(window));
|
||||
shell_delegate->ToggleMaximized();
|
||||
EXPECT_FALSE(ash::wm::IsWindowFullscreen(window));
|
||||
EXPECT_FALSE(ash::wm::IsWindowMaximized(window));
|
||||
shell_delegate->ToggleMaximized();
|
||||
EXPECT_FALSE(ash::wm::IsWindowFullscreen(window));
|
||||
EXPECT_TRUE(ash::wm::IsWindowMaximized(window));
|
||||
}
|
@ -100,7 +100,6 @@ const AcceleratorMapping kAcceleratorMap[] = {
|
||||
IDC_CLEAR_BROWSING_DATA },
|
||||
{ ui::VKEY_BROWSER_FORWARD, ui::EF_NONE, IDC_FORWARD },
|
||||
{ ui::VKEY_F2, ui::EF_NONE, IDC_FORWARD },
|
||||
{ ui::VKEY_F4, ui::EF_NONE, IDC_FULLSCREEN },
|
||||
{ ui::VKEY_F4, ui::EF_SHIFT_DOWN, IDC_FULLSCREEN },
|
||||
{ ui::VKEY_OEM_2, ui::EF_CONTROL_DOWN, IDC_HELP_PAGE_VIA_KEYBOARD },
|
||||
{ ui::VKEY_OEM_2, ui::EF_SHIFT_DOWN | ui::EF_CONTROL_DOWN,
|
||||
|
@ -43,16 +43,6 @@ TEST(AcceleratorTableTest, CheckDuplicatedAccelerators) {
|
||||
|
||||
#if defined(USE_ASH)
|
||||
TEST(AcceleratorTableTest, CheckDuplicatedAcceleratorsAsh) {
|
||||
std::set<AcceleratorMapping, Cmp> allowed_duplicates;
|
||||
#if defined(OS_CHROMEOS)
|
||||
AcceleratorMapping exception_entry;
|
||||
// Both Chrome and Ash have a shortcut for F4
|
||||
exception_entry.keycode = ui::VKEY_F4;
|
||||
exception_entry.modifiers = ui::EF_NONE;
|
||||
exception_entry.command_id = 0; // dummy
|
||||
allowed_duplicates.insert(exception_entry);
|
||||
#endif
|
||||
|
||||
std::set<AcceleratorMapping, Cmp> acclerators;
|
||||
for (size_t i = 0; i < kAcceleratorMapLength; ++i) {
|
||||
const AcceleratorMapping& entry = kAcceleratorMap[i];
|
||||
@ -66,13 +56,11 @@ TEST(AcceleratorTableTest, CheckDuplicatedAcceleratorsAsh) {
|
||||
entry.keycode = ash_entry.keycode;
|
||||
entry.modifiers = ash_entry.modifiers;
|
||||
entry.command_id = 0; // dummy
|
||||
if (allowed_duplicates.find(entry) == allowed_duplicates.end()) {
|
||||
EXPECT_TRUE(acclerators.insert(entry).second)
|
||||
<< "Duplicated accelerator: " << entry.keycode << ", "
|
||||
<< (entry.modifiers & ui::EF_SHIFT_DOWN) << ", "
|
||||
<< (entry.modifiers & ui::EF_CONTROL_DOWN) << ", "
|
||||
<< (entry.modifiers & ui::EF_ALT_DOWN);
|
||||
}
|
||||
EXPECT_TRUE(acclerators.insert(entry).second)
|
||||
<< "Duplicated accelerator: " << entry.keycode << ", "
|
||||
<< (entry.modifiers & ui::EF_SHIFT_DOWN) << ", "
|
||||
<< (entry.modifiers & ui::EF_CONTROL_DOWN) << ", "
|
||||
<< (entry.modifiers & ui::EF_ALT_DOWN);
|
||||
}
|
||||
}
|
||||
#endif // USE_ASH
|
||||
|
@ -3033,6 +3033,7 @@
|
||||
'browser/task_manager/task_manager_notification_browsertest.cc',
|
||||
'browser/translate/translate_manager_browsertest.cc',
|
||||
'browser/ui/ash/caps_lock_handler_browsertest.cc',
|
||||
'browser/ui/ash/chrome_shell_delegate_browsertest.cc',
|
||||
'browser/ui/ash/launcher/chrome_launcher_controller_browsertest.cc',
|
||||
'browser/ui/ash/launcher/launcher_favicon_loader_browsertest.cc',
|
||||
'browser/ui/ash/shelf_browsertest.cc',
|
||||
|
Reference in New Issue
Block a user