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.
Let Chrome app handle Ash accelerators first if the app is launched a…
…s a window. Currently, Ash accelerators are handled at a very early stage, right after a native key event is received by aura::RootWindowHost. This CL change the way of handling Ash accelerators as follows to make it more App friendly: 1. If no window is focused, handle an Ash accelerator immediately in ash/accelerators/accelerator_filter.cc in the same way as before. 2. Otherwise, do not handle it in ash/accelerators/accelerator_filter.cc but let a custom views::FocusManager handle it (see ash/shell.cc). There are 3 types of scenarios here depending on the type of the focused window: 2-a. If the focused window is a browser, and the browser is not for an app, let the custom focus manager pre-handle Ash accelerators before passing it to the browser (see PreHandleKeyboardEvent() in chrome/browser/ui/views/frame/browser_view.cc). 2-b. If the focused window is a browser, and the browser is for an app, let the app handle Ash accelerators first (see chrome/browser/ui/views/frame/browser_view.cc). If the accelerator is not consumed by the app, let the custom focus manager handle it. 2-c. If the focused window is not a browser, let the window handle Ash accelerators first. If the accelerator is not consumed by the window, then let the custom focus manager handle it. This means a WebView without the chrome/browser/ui/ layer can handle Ash accelerators first whenever needed. Other changes: chrome/browser/ui/views/frame/browser_view.cc: Support ET_KEY_RELEASED accelerators in BrowserView::PreHandleKeyboardEvent(). ui/views/focus/focus_manager.cc: Support ET_KEY_RELEASED accelerators. Also fix code for handing VKEY_MENU so that the Shift+Alt+ET_KEY_RELEASED accelerator for Ash could be handled correctly. This CL depends on http://codereview.chromium.org/10377158/ (by jochen), https://chromiumcodereview.appspot.com/10388023, http://codereview.chromium.org/10389035/, and https://chromiumcodereview.appspot.com/10332051/, and should not be submitted until the 4 CLs are landed. BUG=123856 TEST=ran aura_shell_unittests TEST=manual; launch Chromoting app as a window, connect to a Chromoting server, focus Chrome on the remote machine, press Ctrl-n, confirm a new window is opened on the remote machine. Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=135791 Review URL: https://chromiumcodereview.appspot.com/10134036 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@137629 0039d316-1c4b-4281-b951-d872f2087c98
- Loading branch information
yusukes@chromium.org
committed
May 17, 2012
1 parent
12ba80a
commit e7293fa
Showing
17 changed files
with
284 additions
and
96 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// 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 "ash/accelerators/focus_manager_factory.h" | ||
|
||
#include "ash/accelerators/accelerator_controller.h" | ||
#include "ash/shell.h" | ||
#include "ui/views/focus/focus_manager.h" | ||
|
||
namespace ash { | ||
|
||
AshFocusManagerFactory::AshFocusManagerFactory() {} | ||
AshFocusManagerFactory::~AshFocusManagerFactory() {} | ||
|
||
views::FocusManager* AshFocusManagerFactory::CreateFocusManager( | ||
views::Widget* widget) { | ||
return new views::FocusManager(widget, new Delegate); | ||
} | ||
|
||
bool AshFocusManagerFactory::Delegate::ProcessAccelerator( | ||
const ui::Accelerator& accelerator) { | ||
AcceleratorController* controller = | ||
Shell::GetInstance()->accelerator_controller(); | ||
if (controller) | ||
return controller->Process(accelerator); | ||
return false; | ||
} | ||
|
||
ui::AcceleratorTarget* | ||
AshFocusManagerFactory::Delegate::GetCurrentTargetForAccelerator( | ||
const ui::Accelerator& accelerator) const { | ||
AcceleratorController* controller = | ||
Shell::GetInstance()->accelerator_controller(); | ||
if (controller && controller->IsRegistered(accelerator)) | ||
return controller; | ||
return NULL; | ||
} | ||
|
||
} // 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,43 @@ | ||
// 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. | ||
|
||
#ifndef ASH_ACCELERATORS_FOCUS_MANAGER_FACTORY_H_ | ||
#define ASH_ACCELERATORS_FOCUS_MANAGER_FACTORY_H_ | ||
#pragma once | ||
|
||
#include "base/basictypes.h" | ||
#include "base/compiler_specific.h" | ||
#include "ui/views/focus/focus_manager_delegate.h" | ||
#include "ui/views/focus/focus_manager_factory.h" | ||
|
||
namespace ash { | ||
|
||
// A factory class for creating a custom views::FocusManager object which | ||
// supports Ash shortcuts. | ||
class AshFocusManagerFactory : public views::FocusManagerFactory { | ||
public: | ||
AshFocusManagerFactory(); | ||
virtual ~AshFocusManagerFactory(); | ||
|
||
protected: | ||
// views::FocusManagerFactory overrides: | ||
virtual views::FocusManager* CreateFocusManager( | ||
views::Widget* widget) OVERRIDE; | ||
|
||
private: | ||
class Delegate : public views::FocusManagerDelegate { | ||
public: | ||
// views::FocusManagerDelegate overrides: | ||
virtual bool ProcessAccelerator( | ||
const ui::Accelerator& accelerator) OVERRIDE; | ||
virtual ui::AcceleratorTarget* GetCurrentTargetForAccelerator( | ||
const ui::Accelerator& accelerator) const OVERRIDE; | ||
}; | ||
|
||
DISALLOW_COPY_AND_ASSIGN(AshFocusManagerFactory); | ||
}; | ||
|
||
} // namespace ash | ||
|
||
#endif // ASH_ACCELERATORS_FOCUS_MANAGER_FACTORY_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
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
Oops, something went wrong.