summaryrefslogtreecommitdiffstats
path: root/ash/system/system_notifier.cc
blob: aedd2be47f7c58adc5621bbb0c0a62f82bab2be1 (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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
// Copyright 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 "ash/system/system_notifier.h"

#include "base/logging.h"

#if defined(OS_CHROMEOS)
#include "ui/chromeos/network/network_state_notifier.h"
#endif

namespace ash {
namespace system_notifier {

namespace {

// See http://dev.chromium.org/chromium-os/chromiumos-design-docs/
// system-notifications for the reasoning.
const char* kAlwaysShownNotifierIds[] = {
    kNotifierBattery,
    kNotifierDisplay,
    kNotifierDisplayError,
#if defined(OS_CHROMEOS)
    ui::NetworkStateNotifier::kNotifierNetworkError,
#endif
    kNotifierPower,
    // Note: Order doesn't matter here, so keep this in alphabetic order, don't
    // just add your stuff at the end!
    NULL};

const char* kAshSystemNotifiers[] = {
  kNotifierBluetooth,
  kNotifierDisplay,
  kNotifierDisplayError,
  kNotifierDisplayResolutionChange,
  kNotifierLocale,
  kNotifierMultiProfileFirstRun,
#if defined(OS_CHROMEOS)
  ui::NetworkStateNotifier::kNotifierNetwork,
  ui::NetworkStateNotifier::kNotifierNetworkError,
#endif
  kNotifierNetworkPortalDetector,
  kNotifierPower,
  kNotifierScreenshot,
  kNotifierScreenCapture,
  kNotifierScreenShare,
  kNotifierSessionLengthTimeout,
  kNotifierSupervisedUser,
  // Note: Order doesn't matter here, so keep this in alphabetic order, don't
  // just add your stuff at the end!
  NULL
};

bool MatchSystemNotifierId(const message_center::NotifierId& notifier_id,
                           const char* id_list[]) {
  if (notifier_id.type != message_center::NotifierId::SYSTEM_COMPONENT)
    return false;

  for (size_t i = 0; id_list[i] != NULL; ++i) {
    if (notifier_id.id == id_list[i])
      return true;
  }
  return false;
}

}  // namespace

const char kNotifierBattery[] = "ash.battery";
const char kNotifierBluetooth[] = "ash.bluetooth";
const char kNotifierDisplay[] = "ash.display";
const char kNotifierDisplayError[] = "ash.display.error";
const char kNotifierDisplayResolutionChange[] = "ash.display.resolution-change";
const char kNotifierLocale[] = "ash.locale";
const char kNotifierMultiProfileFirstRun[] = "ash.multi-profile.first-run";
const char kNotifierNetworkPortalDetector[] = "ash.network.portal-detector";
const char kNotifierPower[] = "ash.power";
const char kNotifierScreenshot[] = "ash.screenshot";
const char kNotifierScreenCapture[] = "ash.screen-capture";
const char kNotifierScreenShare[] = "ash.screen-share";
const char kNotifierSessionLengthTimeout[] = "ash.session-length-timeout";
const char kNotifierSupervisedUser[] = "ash.locally-managed-user";

bool ShouldAlwaysShowPopups(const message_center::NotifierId& notifier_id) {
  return MatchSystemNotifierId(notifier_id, kAlwaysShownNotifierIds);
}

bool IsAshSystemNotifier(const message_center::NotifierId& notifier_id) {
  return MatchSystemNotifierId(notifier_id, kAshSystemNotifiers);
}

}  // namespace system_notifier
}  // namespace ash