diff options
author | xiyuan@chromium.org <xiyuan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-03-05 18:51:48 +0000 |
---|---|---|
committer | xiyuan@chromium.org <xiyuan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-03-05 18:51:48 +0000 |
commit | 565f32fc0ffca7ca992aca1a5b43c35e8c96d064 (patch) | |
tree | 79b69dcdf42fc4ef890f4f4f7a67ca41f87175fd /ash | |
parent | f8d5a5e7651d3a1abcb43ece43ef7bf6fbe49790 (diff) | |
download | chromium_src-565f32fc0ffca7ca992aca1a5b43c35e8c96d064.zip chromium_src-565f32fc0ffca7ca992aca1a5b43c35e8c96d064.tar.gz chromium_src-565f32fc0ffca7ca992aca1a5b43c35e8c96d064.tar.bz2 |
cros: Add app mode restrictions.
- White list ash accelerator actions;
- White list browser accelerators;
- Use a limited render view context menu;
BUG=178469
TEST=Verify Ctrl-N etc is disabled and no accelerator/menu to get a browser
window in app mode.
R=zelidrag@chromium.org,sky@chromium.org
Review URL: https://chromiumcodereview.appspot.com/12389083
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@186214 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash')
-rw-r--r-- | ash/accelerators/accelerator_controller.cc | 8 | ||||
-rw-r--r-- | ash/accelerators/accelerator_controller.h | 2 | ||||
-rw-r--r-- | ash/accelerators/accelerator_table.cc | 39 | ||||
-rw-r--r-- | ash/accelerators/accelerator_table.h | 6 | ||||
-rw-r--r-- | ash/shell/shell_delegate_impl.cc | 8 | ||||
-rw-r--r-- | ash/shell/shell_delegate_impl.h | 3 | ||||
-rw-r--r-- | ash/shell_delegate.h | 5 | ||||
-rw-r--r-- | ash/test/test_shell_delegate.cc | 6 | ||||
-rw-r--r-- | ash/test/test_shell_delegate.h | 4 |
9 files changed, 78 insertions, 3 deletions
diff --git a/ash/accelerators/accelerator_controller.cc b/ash/accelerators/accelerator_controller.cc index b9e12bb..6829148 100644 --- a/ash/accelerators/accelerator_controller.cc +++ b/ash/accelerators/accelerator_controller.cc @@ -337,6 +337,8 @@ void AcceleratorController::Init() { reserved_actions_.insert(kReservedActions[i]); for (size_t i = 0; i < kNonrepeatableActionsLength; ++i) nonrepeatable_actions_.insert(kNonrepeatableActions[i]); + for (size_t i = 0; i < kActionsAllowedInAppModeLength; ++i) + actions_allowed_in_app_mode_.insert(kActionsAllowedInAppMode[i]); RegisterAccelerators(kAcceleratorData, kAcceleratorDataLength); @@ -417,6 +419,12 @@ bool AcceleratorController::PerformAction(int action, // in the modal window by cycling through its window elements. return true; } + if (shell->delegate()->IsRunningInForcedAppMode() && + actions_allowed_in_app_mode_.find(action) == + actions_allowed_in_app_mode_.end()) { + return false; + } + const ui::KeyboardCode key_code = accelerator.key_code(); // PerformAction() is performed from gesture controllers and passes // empty Accelerator() instance as the second argument. Such events diff --git a/ash/accelerators/accelerator_controller.h b/ash/accelerators/accelerator_controller.h index 468a5bf..53ed723 100644 --- a/ash/accelerators/accelerator_controller.h +++ b/ash/accelerators/accelerator_controller.h @@ -156,6 +156,8 @@ class ASH_EXPORT AcceleratorController : public ui::AcceleratorTarget { std::set<int> reserved_actions_; // Actions which will not be repeated while holding the accelerator key. std::set<int> nonrepeatable_actions_; + // Actions allowed in app mode. + std::set<int> actions_allowed_in_app_mode_; DISALLOW_COPY_AND_ASSIGN(AcceleratorController); }; diff --git a/ash/accelerators/accelerator_table.cc b/ash/accelerators/accelerator_table.cc index eb97242..afb8eaa 100644 --- a/ash/accelerators/accelerator_table.cc +++ b/ash/accelerators/accelerator_table.cc @@ -297,4 +297,43 @@ const AcceleratorAction kNonrepeatableActions[] = { const size_t kNonrepeatableActionsLength = arraysize(kNonrepeatableActions); +const AcceleratorAction kActionsAllowedInAppMode[] = { + BRIGHTNESS_DOWN, + BRIGHTNESS_UP, +#if defined(OS_CHROMEOS) + CYCLE_DISPLAY_MODE, + DISABLE_GPU_WATCHDOG, +#endif // defined(OS_CHROMEOS) + DISABLE_CAPS_LOCK, + KEYBOARD_BRIGHTNESS_DOWN, + KEYBOARD_BRIGHTNESS_UP, + MAGNIFY_SCREEN_ZOOM_IN, // Control+F7 + MAGNIFY_SCREEN_ZOOM_OUT, // Control+F6 + MEDIA_NEXT_TRACK, + MEDIA_PLAY_PAUSE, + MEDIA_PREV_TRACK, + NEXT_IME, + POWER_PRESSED, + POWER_RELEASED, + PREVIOUS_IME, + SWAP_PRIMARY_DISPLAY, + SWITCH_IME, // Switch to another IME depending on the accelerator. + TOGGLE_CAPS_LOCK, + TOGGLE_SPOKEN_FEEDBACK, + TOGGLE_WIFI, + TOUCH_HUD_CLEAR, + VOLUME_DOWN, + VOLUME_MUTE, + VOLUME_UP, +#if !defined(NDEBUG) + PRINT_LAYER_HIERARCHY, + PRINT_VIEW_HIERARCHY, + PRINT_WINDOW_HIERARCHY, + ROTATE_SCREEN, +#endif +}; + +const size_t kActionsAllowedInAppModeLength = + arraysize(kActionsAllowedInAppMode); + } // namespace ash diff --git a/ash/accelerators/accelerator_table.h b/ash/accelerators/accelerator_table.h index 4410997..f8d99ac 100644 --- a/ash/accelerators/accelerator_table.h +++ b/ash/accelerators/accelerator_table.h @@ -149,6 +149,12 @@ ASH_EXPORT extern const AcceleratorAction kNonrepeatableActions[]; // The number of elements in kNonrepeatableActions. ASH_EXPORT extern const size_t kNonrepeatableActionsLength; +// Actions allowed in app mode. +ASH_EXPORT extern const AcceleratorAction kActionsAllowedInAppMode[]; + +// The number of elements in kActionsAllowedInAppMode. +ASH_EXPORT extern const size_t kActionsAllowedInAppModeLength; + } // namespace ash #endif // ASH_ACCELERATORS_ACCELERATOR_TABLE_H_ diff --git a/ash/shell/shell_delegate_impl.cc b/ash/shell/shell_delegate_impl.cc index 8054963..6b57e1e 100644 --- a/ash/shell/shell_delegate_impl.cc +++ b/ash/shell/shell_delegate_impl.cc @@ -4,11 +4,13 @@ #include "ash/shell/shell_delegate_impl.h" +#include <limits> + #include "ash/caps_lock_delegate_stub.h" #include "ash/host/root_window_host_factory.h" +#include "ash/shell/context_menu.h" #include "ash/shell/example_factory.h" #include "ash/shell/launcher_delegate_impl.h" -#include "ash/shell/context_menu.h" #include "ash/shell/toplevel_window.h" #include "ash/shell_window_ids.h" #include "ash/wm/window_util.h" @@ -49,6 +51,10 @@ bool ShellDelegateImpl::IsFirstRunAfterBoot() const { return false; } +bool ShellDelegateImpl::IsRunningInForcedAppMode() const { + return false; +} + bool ShellDelegateImpl::CanLockScreen() const { return true; } diff --git a/ash/shell/shell_delegate_impl.h b/ash/shell/shell_delegate_impl.h index 311ebef..9ac2f78 100644 --- a/ash/shell/shell_delegate_impl.h +++ b/ash/shell/shell_delegate_impl.h @@ -5,6 +5,8 @@ #ifndef ASH_SHELL_SHELL_DELEGATE_IMPL_H_ #define ASH_SHELL_SHELL_DELEGATE_IMPL_H_ +#include <string> + #include "ash/shell_delegate.h" #include "base/compiler_specific.h" @@ -24,6 +26,7 @@ class ShellDelegateImpl : public ash::ShellDelegate { virtual bool IsUserLoggedIn() const OVERRIDE; virtual bool IsSessionStarted() const OVERRIDE; virtual bool IsFirstRunAfterBoot() const OVERRIDE; + virtual bool IsRunningInForcedAppMode() const OVERRIDE; virtual bool CanLockScreen() const OVERRIDE; virtual void LockScreen() OVERRIDE; virtual void UnlockScreen() OVERRIDE; diff --git a/ash/shell_delegate.h b/ash/shell_delegate.h index cd7c10a..8fbfeb3 100644 --- a/ash/shell_delegate.h +++ b/ash/shell_delegate.h @@ -5,7 +5,7 @@ #ifndef ASH_SHELL_DELEGATE_H_ #define ASH_SHELL_DELEGATE_H_ -#include <vector> +#include <string> #include "ash/ash_export.h" #include "ash/magnifier/magnifier_constants.h" @@ -90,6 +90,9 @@ class ASH_EXPORT ShellDelegate { // restarted, typically due to logging in as a guest or logging out. virtual bool IsFirstRunAfterBoot() const = 0; + // Returns true if we're running in forced app mode. + virtual bool IsRunningInForcedAppMode() const = 0; + // Returns true if a user is logged in whose session can be locked (i.e. the // user has a password with which to unlock the session). virtual bool CanLockScreen() const = 0; diff --git a/ash/test/test_shell_delegate.cc b/ash/test/test_shell_delegate.cc index eb0d823..63af2e5 100644 --- a/ash/test/test_shell_delegate.cc +++ b/ash/test/test_shell_delegate.cc @@ -4,7 +4,7 @@ #include "ash/test/test_shell_delegate.h" -#include <algorithm> +#include <limits> #include "ash/caps_lock_delegate_stub.h" #include "ash/host/root_window_host_factory.h" @@ -45,6 +45,10 @@ bool TestShellDelegate::IsFirstRunAfterBoot() const { return false; } +bool TestShellDelegate::IsRunningInForcedAppMode() const { + return false; +} + bool TestShellDelegate::CanLockScreen() const { return user_logged_in_ && can_lock_screen_; } diff --git a/ash/test/test_shell_delegate.h b/ash/test/test_shell_delegate.h index ce6415a..862d6ae 100644 --- a/ash/test/test_shell_delegate.h +++ b/ash/test/test_shell_delegate.h @@ -5,6 +5,8 @@ #ifndef ASH_TEST_TEST_SHELL_DELEGATE_H_ #define ASH_TEST_TEST_SHELL_DELEGATE_H_ +#include <string> + #include "ash/shell_delegate.h" #include "base/compiler_specific.h" #include "base/memory/scoped_ptr.h" @@ -23,6 +25,7 @@ class TestShellDelegate : public ShellDelegate { virtual bool IsUserLoggedIn() const OVERRIDE; virtual bool IsSessionStarted() const OVERRIDE; virtual bool IsFirstRunAfterBoot() const OVERRIDE; + virtual bool IsRunningInForcedAppMode() const OVERRIDE; virtual bool CanLockScreen() const OVERRIDE; virtual void LockScreen() OVERRIDE; virtual void UnlockScreen() OVERRIDE; @@ -71,6 +74,7 @@ class TestShellDelegate : public ShellDelegate { virtual string16 GetProductName() const OVERRIDE; int num_exit_requests() const { return num_exit_requests_; } + private: friend class ash::test::AshTestBase; |