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 /chrome/browser/app_mode | |
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 'chrome/browser/app_mode')
-rw-r--r-- | chrome/browser/app_mode/app_mode_utils.cc | 39 | ||||
-rw-r--r-- | chrome/browser/app_mode/app_mode_utils.h | 8 |
2 files changed, 44 insertions, 3 deletions
diff --git a/chrome/browser/app_mode/app_mode_utils.cc b/chrome/browser/app_mode/app_mode_utils.cc index ca3baa5..c4cdeb2 100644 --- a/chrome/browser/app_mode/app_mode_utils.cc +++ b/chrome/browser/app_mode/app_mode_utils.cc @@ -4,16 +4,51 @@ #include "chrome/browser/app_mode/app_mode_utils.h" +#include "base/basictypes.h" #include "base/command_line.h" +#include "base/logging.h" +#include "chrome/app/chrome_command_ids.h" #include "chrome/common/chrome_switches.h" namespace chrome { +bool IsCommandAllowedInAppMode(int command_id) { + DCHECK(IsRunningInForcedAppMode()); + + const int kAllowed[] = { + IDC_BACK, + IDC_FORWARD, + IDC_RELOAD, + IDC_STOP, + IDC_RELOAD_IGNORING_CACHE, + IDC_RELOAD_CLEARING_CACHE, + IDC_CUT, + IDC_COPY, + IDC_COPY_URL, + IDC_PASTE, + IDC_ZOOM_PLUS, + IDC_ZOOM_NORMAL, + IDC_ZOOM_MINUS, + }; + + for (size_t i = 0; i < arraysize(kAllowed); ++i) { + if (kAllowed[i] == command_id) + return true; + } + + return false; +} + bool IsRunningInAppMode() { CommandLine* command_line = CommandLine::ForCurrentProcess(); return command_line->HasSwitch(switches::kKioskMode) || - (command_line->HasSwitch(switches::kForceAppMode) && - command_line->HasSwitch(switches::kAppId)); + IsRunningInForcedAppMode(); +} + +bool IsRunningInForcedAppMode() { + CommandLine* command_line = CommandLine::ForCurrentProcess(); + return command_line->HasSwitch(switches::kForceAppMode) && + command_line->HasSwitch(switches::kAppId); } } // namespace switches diff --git a/chrome/browser/app_mode/app_mode_utils.h b/chrome/browser/app_mode/app_mode_utils.h index 1fe9605..487b454 100644 --- a/chrome/browser/app_mode/app_mode_utils.h +++ b/chrome/browser/app_mode/app_mode_utils.h @@ -7,9 +7,15 @@ namespace chrome { -// Return true if browser process is run in kiosk or forces app mode. +// Returns true if the given browser command is allowed in app mode. +bool IsCommandAllowedInAppMode(int command_id); + +// Return true if browser process is run in kiosk or forced app mode. bool IsRunningInAppMode(); +// Return true if browser process is run in forced app mode. +bool IsRunningInForcedAppMode(); + } // namespace switches #endif // CHROME_BROWSER_APP_MODE_APP_MODE_UTILS_H_ |