system_notifier.cc revision 5f1c94371a64b3196d4be9466099bb892df9b88e
1// Copyright 2013 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#include "ash/system/system_notifier.h"
6
7#include "base/logging.h"
8
9namespace ash {
10namespace system_notifier {
11
12namespace {
13
14// See http://dev.chromium.org/chromium-os/chromiumos-design-docs/
15// system-notifications for the reasoning.
16const char* kAlwaysShownNotifierIds[] = {
17  kNotifierDisplay,
18  kNotifierDisplayError,
19  kNotifierNetworkError,
20  kNotifierPower,
21  // Note: Order doesn't matter here, so keep this in alphabetic order, don't
22  // just add your stuff at the end!
23  NULL
24};
25
26const char* kAshSystemNotifiers[] = {
27  kNotifierBluetooth,
28  kNotifierDisplay,
29  kNotifierDisplayError,
30  kNotifierDisplayResolutionChange,
31  kNotifierLocale,
32  kNotifierMultiProfileFirstRun,
33  kNotifierNetwork,
34  kNotifierNetworkError,
35  kNotifierNetworkPortalDetector,
36  kNotifierPower,
37  kNotifierScreenshot,
38  kNotifierScreenCapture,
39  kNotifierScreenShare,
40  kNotifierSessionLengthTimeout,
41  kNotifierSupervisedUser,
42  // Note: Order doesn't matter here, so keep this in alphabetic order, don't
43  // just add your stuff at the end!
44  NULL
45};
46
47bool MatchSystemNotifierId(const message_center::NotifierId& notifier_id,
48                           const char* id_list[]) {
49  if (notifier_id.type != message_center::NotifierId::SYSTEM_COMPONENT)
50    return false;
51
52  for (size_t i = 0; id_list[i] != NULL; ++i) {
53    if (notifier_id.id == id_list[i])
54      return true;
55  }
56  return false;
57}
58
59}  // namespace
60
61const char kNotifierBluetooth[] = "ash.bluetooth";
62const char kNotifierDisplay[] = "ash.display";
63const char kNotifierDisplayError[] = "ash.display.error";
64const char kNotifierDisplayResolutionChange[] = "ash.display.resolution-change";
65const char kNotifierLocale[] = "ash.locale";
66const char kNotifierMultiProfileFirstRun[] = "ash.multi-profile.first-run";
67const char kNotifierNetwork[] = "ash.network";
68const char kNotifierNetworkError[] = "ash.network.error";
69const char kNotifierNetworkPortalDetector[] = "ash.network.portal-detector";
70const char kNotifierPower[] = "ash.power";
71const char kNotifierScreenshot[] = "ash.screenshot";
72const char kNotifierScreenCapture[] = "ash.screen-capture";
73const char kNotifierScreenShare[] = "ash.screen-share";
74const char kNotifierSessionLengthTimeout[] = "ash.session-length-timeout";
75const char kNotifierSupervisedUser[] = "ash.locally-managed-user";
76
77bool ShouldAlwaysShowPopups(const message_center::NotifierId& notifier_id) {
78  return MatchSystemNotifierId(notifier_id, kAlwaysShownNotifierIds);
79}
80
81bool IsAshSystemNotifier(const message_center::NotifierId& notifier_id) {
82  return MatchSystemNotifierId(notifier_id, kAshSystemNotifiers);
83}
84
85}  // namespace system_notifier
86}  // namespace ash
87