1424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)// Copyright 2013 The Chromium Authors. All rights reserved.
2424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be
3424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)// found in the LICENSE file.
4424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)
5424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)#include "ash/system/system_notifier.h"
6424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)
7424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)#include "base/logging.h"
8424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)
9424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)namespace ash {
1058537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)namespace system_notifier {
1158537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)
1258537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)namespace {
1358537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)
1458537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)// See http://dev.chromium.org/chromium-os/chromiumos-design-docs/
1558537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)// system-notifications for the reasoning.
16a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)const char* kAlwaysShownNotifierIds[] = {
17a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  kNotifierDisplay,
18a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  kNotifierDisplayError,
19a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  kNotifierNetworkError,
20a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  kNotifierPower,
215f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)  // Note: Order doesn't matter here, so keep this in alphabetic order, don't
225f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)  // just add your stuff at the end!
23a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  NULL
2458537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)};
2558537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)
26a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)const char* kAshSystemNotifiers[] = {
275f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)  kNotifierBluetooth,
28a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  kNotifierDisplay,
29a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  kNotifierDisplayError,
305f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)  kNotifierDisplayResolutionChange,
31a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  kNotifierLocale,
32a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  kNotifierMultiProfileFirstRun,
33a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  kNotifierNetwork,
34a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  kNotifierNetworkError,
35a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  kNotifierNetworkPortalDetector,
365f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)  kNotifierPower,
37a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  kNotifierScreenshot,
38a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  kNotifierScreenCapture,
39a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  kNotifierScreenShare,
40a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  kNotifierSessionLengthTimeout,
415f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)  kNotifierSupervisedUser,
425f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)  // Note: Order doesn't matter here, so keep this in alphabetic order, don't
435f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)  // just add your stuff at the end!
44a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  NULL
45a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)};
46424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)
47a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)bool MatchSystemNotifierId(const message_center::NotifierId& notifier_id,
48a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)                           const char* id_list[]) {
4958537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)  if (notifier_id.type != message_center::NotifierId::SYSTEM_COMPONENT)
5058537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)    return false;
5158537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)
52a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  for (size_t i = 0; id_list[i] != NULL; ++i) {
53a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)    if (notifier_id.id == id_list[i])
5458537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)      return true;
5558537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)  }
5658537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)  return false;
5758537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)}
5858537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)
59a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)}  // namespace
60a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)
61a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)const char kNotifierBluetooth[] = "ash.bluetooth";
62a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)const char kNotifierDisplay[] = "ash.display";
63a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)const char kNotifierDisplayError[] = "ash.display.error";
645f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)const char kNotifierDisplayResolutionChange[] = "ash.display.resolution-change";
65a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)const char kNotifierLocale[] = "ash.locale";
66a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)const char kNotifierMultiProfileFirstRun[] = "ash.multi-profile.first-run";
67a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)const char kNotifierNetwork[] = "ash.network";
68a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)const char kNotifierNetworkError[] = "ash.network.error";
69a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)const char kNotifierNetworkPortalDetector[] = "ash.network.portal-detector";
70a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)const char kNotifierPower[] = "ash.power";
71a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)const char kNotifierScreenshot[] = "ash.screenshot";
72a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)const char kNotifierScreenCapture[] = "ash.screen-capture";
73a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)const char kNotifierScreenShare[] = "ash.screen-share";
74a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)const char kNotifierSessionLengthTimeout[] = "ash.session-length-timeout";
755f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)const char kNotifierSupervisedUser[] = "ash.locally-managed-user";
76a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)
77a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)bool ShouldAlwaysShowPopups(const message_center::NotifierId& notifier_id) {
78a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  return MatchSystemNotifierId(notifier_id, kAlwaysShownNotifierIds);
79a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)}
80a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)
81a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)bool IsAshSystemNotifier(const message_center::NotifierId& notifier_id) {
82a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  return MatchSystemNotifierId(notifier_id, kAshSystemNotifiers);
83a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)}
84a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)
8558537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)}  // namespace system_notifier
8658537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)}  // namespace ash
87