1 // Copyright (c) 2012 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 #ifndef ASH_SYSTEM_CHROMEOS_TRAY_DISPLAY_H_
6 #define ASH_SYSTEM_CHROMEOS_TRAY_DISPLAY_H_
10 #include "ash/ash_export.h"
11 #include "ash/display/display_controller.h"
12 #include "ash/display/display_info.h"
13 #include "ash/system/tray/system_tray_item.h"
14 #include "base/strings/string16.h"
15 #include "ui/views/view.h"
24 class ASH_EXPORT TrayDisplay
: public SystemTrayItem
,
25 public DisplayController::Observer
{
27 explicit TrayDisplay(SystemTray
* system_tray
);
28 ~TrayDisplay() override
;
30 // Overridden from DisplayControllerObserver:
31 void OnDisplayConfigurationChanged() override
;
34 friend class TrayDisplayTest
;
36 typedef std::map
<int64
, DisplayInfo
> DisplayInfoMap
;
38 static const char kNotificationId
[];
40 // Scans the current display info and updates |display_info_|. Sets the
41 // previous data to |old_info| if it's not NULL.
42 void UpdateDisplayInfo(DisplayInfoMap
* old_info
);
44 // Compares the current display settings with |old_info| and determine what
45 // message should be shown for notification. Returns true if there's a
46 // meaningful change. Note that it's possible to return true and set
47 // |message_out| to empty, which means the notification should be removed. It
48 // also sets |additional_message_out| which appears in the notification with
50 bool GetDisplayMessageForNotification(
51 const DisplayInfoMap
& old_info
,
52 base::string16
* message_out
,
53 base::string16
* additional_message_out
);
55 // Creates or updates the display notification.
56 void CreateOrUpdateNotification(const base::string16
& message
,
57 const base::string16
& additional_message
);
59 // Overridden from SystemTrayItem.
60 views::View
* CreateDefaultView(user::LoginStatus status
) override
;
61 void DestroyDefaultView() override
;
64 base::string16
GetDefaultViewMessage() const;
65 bool GetAccessibleStateForTesting(ui::AXViewState
* state
);
66 const views::View
* default_view() const {
67 return reinterpret_cast<views::View
*>(default_
);
70 DisplayView
* default_
;
71 DisplayInfoMap display_info_
;
73 DISALLOW_COPY_AND_ASSIGN(TrayDisplay
);
78 #endif // ASH_SYSTEM_CHROMEOS_TRAY_DISPLAY_H_