| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/app_mode/app_mode_utils.h" | 5 #include "chrome/browser/app_mode/app_mode_utils.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 #include "base/macros.h" | 11 #include "base/macros.h" |
| 12 #include "chrome/app/chrome_command_ids.h" | 12 #include "chrome/app/chrome_command_ids.h" |
| 13 #include "chrome/common/chrome_switches.h" | 13 #include "chrome/common/chrome_switches.h" |
| 14 | 14 |
| 15 namespace chrome { | 15 namespace chrome { |
| 16 | 16 |
| 17 bool IsCommandAllowedInAppMode(int command_id) { | 17 bool IsCommandAllowedInAppMode(int command_id) { |
| 18 DCHECK(IsRunningInForcedAppMode()); | 18 DCHECK(IsRunningInForcedAppMode()); |
| 19 | 19 |
| 20 const int kAllowed[] = { | 20 const int kAllowed[] = { |
| 21 IDC_BACK, | 21 IDC_BACK, |
| 22 IDC_FORWARD, | 22 IDC_FORWARD, |
| 23 IDC_RELOAD, | 23 IDC_RELOAD, |
| 24 IDC_STOP, | 24 IDC_STOP, |
| 25 IDC_RELOAD_IGNORING_CACHE, | 25 IDC_RELOAD_BYPASSING_CACHE, |
| 26 IDC_RELOAD_CLEARING_CACHE, | 26 IDC_RELOAD_CLEARING_CACHE, |
| 27 IDC_CUT, | 27 IDC_CUT, |
| 28 IDC_COPY, | 28 IDC_COPY, |
| 29 IDC_PASTE, | 29 IDC_PASTE, |
| 30 IDC_ZOOM_PLUS, | 30 IDC_ZOOM_PLUS, |
| 31 IDC_ZOOM_NORMAL, | 31 IDC_ZOOM_NORMAL, |
| 32 IDC_ZOOM_MINUS, | 32 IDC_ZOOM_MINUS, |
| 33 }; | 33 }; |
| 34 | 34 |
| 35 for (size_t i = 0; i < arraysize(kAllowed); ++i) { | 35 for (size_t i = 0; i < arraysize(kAllowed); ++i) { |
| 36 if (kAllowed[i] == command_id) | 36 if (kAllowed[i] == command_id) |
| 37 return true; | 37 return true; |
| 38 } | 38 } |
| 39 | 39 |
| 40 return false; | 40 return false; |
| 41 } | 41 } |
| 42 | 42 |
| 43 bool IsRunningInAppMode() { | 43 bool IsRunningInAppMode() { |
| 44 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); | 44 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
| 45 return command_line->HasSwitch(switches::kKioskMode) || | 45 return command_line->HasSwitch(switches::kKioskMode) || |
| 46 IsRunningInForcedAppMode(); | 46 IsRunningInForcedAppMode(); |
| 47 } | 47 } |
| 48 | 48 |
| 49 bool IsRunningInForcedAppMode() { | 49 bool IsRunningInForcedAppMode() { |
| 50 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); | 50 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
| 51 return command_line->HasSwitch(switches::kForceAppMode) && | 51 return command_line->HasSwitch(switches::kForceAppMode) && |
| 52 command_line->HasSwitch(switches::kAppId); | 52 command_line->HasSwitch(switches::kAppId); |
| 53 } | 53 } |
| 54 | 54 |
| 55 } // namespace chrome | 55 } // namespace chrome |
| OLD | NEW |