Allow only one bookmark to be added for multiple fast starring
[chromium-blink-merge.git] / ash / system / system_notifier.cc
blob6ff6dcb8375086e73843ac4f52fbce47c7b95073
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.
5 #include "ash/system/system_notifier.h"
7 #include "base/logging.h"
9 #if defined(OS_CHROMEOS)
10 #include "ui/chromeos/network/network_state_notifier.h"
11 #endif
13 namespace ash {
14 namespace system_notifier {
16 namespace {
18 // See http://dev.chromium.org/chromium-os/chromiumos-design-docs/
19 // system-notifications for the reasoning.
21 // |kAlwaysShownSystemNotifierIds| is the list of system notification sources
22 // which can appear regardless of the situation, such like login screen or lock
23 // screen.
24 const char* kAlwaysShownSystemNotifierIds[] = {
25 kNotifierBattery,
26 kNotifierDisplay,
27 kNotifierDisplayError,
28 #if defined(OS_CHROMEOS)
29 ui::NetworkStateNotifier::kNotifierNetworkError,
30 #endif
31 kNotifierPower,
32 // Note: Order doesn't matter here, so keep this in alphabetic order, don't
33 // just add your stuff at the end!
34 NULL};
36 // |kAshSystemNotifiers| is the list of normal system notification sources for
37 // ash events. These notifications can be hidden in some context.
38 const char* kAshSystemNotifiers[] = {
39 kNotifierBluetooth,
40 kNotifierDisplayResolutionChange,
41 kNotifierLocale,
42 kNotifierMultiProfileFirstRun,
43 #if defined(OS_CHROMEOS)
44 ui::NetworkStateNotifier::kNotifierNetwork,
45 #endif
46 kNotifierNetworkPortalDetector,
47 kNotifierScreenshot,
48 kNotifierScreenCapture,
49 kNotifierScreenShare,
50 kNotifierSessionLengthTimeout,
51 kNotifierSupervisedUser,
52 // Note: Order doesn't matter here, so keep this in alphabetic order, don't
53 // just add your stuff at the end!
54 NULL
57 bool MatchSystemNotifierId(const message_center::NotifierId& notifier_id,
58 const char* id_list[]) {
59 if (notifier_id.type != message_center::NotifierId::SYSTEM_COMPONENT)
60 return false;
62 for (size_t i = 0; id_list[i] != NULL; ++i) {
63 if (notifier_id.id == id_list[i])
64 return true;
66 return false;
69 } // namespace
71 const char kNotifierBattery[] = "ash.battery";
72 const char kNotifierBluetooth[] = "ash.bluetooth";
73 const char kNotifierDisplay[] = "ash.display";
74 const char kNotifierDisplayError[] = "ash.display.error";
75 const char kNotifierDisplayResolutionChange[] = "ash.display.resolution-change";
76 const char kNotifierLocale[] = "ash.locale";
77 const char kNotifierMultiProfileFirstRun[] = "ash.multi-profile.first-run";
78 const char kNotifierNetworkPortalDetector[] = "ash.network.portal-detector";
79 const char kNotifierPower[] = "ash.power";
80 const char kNotifierScreenshot[] = "ash.screenshot";
81 const char kNotifierScreenCapture[] = "ash.screen-capture";
82 const char kNotifierScreenShare[] = "ash.screen-share";
83 const char kNotifierSessionLengthTimeout[] = "ash.session-length-timeout";
84 const char kNotifierSupervisedUser[] = "ash.locally-managed-user";
86 bool ShouldAlwaysShowPopups(const message_center::NotifierId& notifier_id) {
87 return MatchSystemNotifierId(notifier_id, kAlwaysShownSystemNotifierIds);
90 bool IsAshSystemNotifier(const message_center::NotifierId& notifier_id) {
91 return ShouldAlwaysShowPopups(notifier_id) ||
92 MatchSystemNotifierId(notifier_id, kAshSystemNotifiers);
95 } // namespace system_notifier
96 } // namespace ash