summaryrefslogtreecommitdiffstats
path: root/chrome/browser/app_mode/app_mode_utils.cc
blob: 25b68555ded26980db20956fd40d0c763740c735 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
// Copyright (c) 2013 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/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_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) ||
      IsRunningInForcedAppMode();
}

bool IsRunningInForcedAppMode() {
  CommandLine* command_line = CommandLine::ForCurrentProcess();
  return command_line->HasSwitch(switches::kForceAppMode) &&
      command_line->HasSwitch(switches::kAppId);
}

}  // namespace chrome