Home | History | Annotate | Download | only in system
      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 
      9 namespace ash {
     10 namespace system_notifier {
     11 
     12 namespace {
     13 
     14 // See http://dev.chromium.org/chromium-os/chromiumos-design-docs/
     15 // system-notifications for the reasoning.
     16 const char* kAlwaysShownNotifierIds[] = {
     17   kNotifierDisplay,
     18   kNotifierDisplayError,
     19   kNotifierPower,
     20   NULL
     21 };
     22 
     23 const char* kAshSystemNotifiers[] = {
     24   kNotifierDisplay,
     25   kNotifierDisplayResolutionChange,
     26   kNotifierDisplayError,
     27   kNotifierInputMethod,
     28   kNotifierLocale,
     29   kNotifierLocallyManagedUser,
     30   kNotifierMultiProfileFirstRun,
     31   kNotifierNetwork,
     32   kNotifierNetworkError,
     33   kNotifierScreenshot,
     34   kNotifierScreenCapture,
     35   kNotifierScreenShare,
     36   kNotifierSessionLengthTimeout,
     37   kNotifierPower,
     38   NULL
     39 };
     40 
     41 bool MatchSystemNotifierId(const message_center::NotifierId& notifier_id,
     42                            const char* id_list[]) {
     43   if (notifier_id.type != message_center::NotifierId::SYSTEM_COMPONENT)
     44     return false;
     45 
     46   for (size_t i = 0; id_list[i] != NULL; ++i) {
     47     if (notifier_id.id == id_list[i])
     48       return true;
     49   }
     50   return false;
     51 }
     52 
     53 }  // namespace
     54 
     55 const char kNotifierDisplay[] = "ash.display";
     56 const char kNotifierDisplayResolutionChange[] = "ash.display.resolution-change";
     57 const char kNotifierDisplayError[] = "ash.display.error";
     58 const char kNotifierInputMethod[] = "ash.input-method";
     59 const char kNotifierLocale[] = "ash.locale";
     60 const char kNotifierLocallyManagedUser[] = "ash.locally-managed-user";
     61 const char kNotifierMultiProfileFirstRun[] = "ash.multi-profile.first-run";
     62 const char kNotifierNetwork[] = "ash.network";
     63 const char kNotifierNetworkError[] = "ash.network.error";
     64 const char kNotifierScreenshot[] = "ash.screenshot";
     65 const char kNotifierScreenCapture[] = "ash.screen-capture";
     66 const char kNotifierScreenShare[] = "ash.screen-share";
     67 const char kNotifierSessionLengthTimeout[] = "ash.session-length-timeout";
     68 const char kNotifierPower[] = "ash.power";
     69 
     70 bool ShouldAlwaysShowPopups(const message_center::NotifierId& notifier_id) {
     71   return MatchSystemNotifierId(notifier_id, kAlwaysShownNotifierIds);
     72 }
     73 
     74 bool IsAshSystemNotifier(const message_center::NotifierId& notifier_id) {
     75   return MatchSystemNotifierId(notifier_id, kAshSystemNotifiers);
     76 }
     77 
     78 }  // namespace system_notifier
     79 }  // namespace ash
     80