OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "ash/system/chromeos/screen_layout_observer.h" | 5 #include "ash/system/chromeos/screen_layout_observer.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 #include <utility> | 8 #include <utility> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "ash/common/metrics/user_metrics_action.h" | 11 #include "ash/common/metrics/user_metrics_action.h" |
12 #include "ash/common/system/chromeos/devicetype_utils.h" | 12 #include "ash/common/system/chromeos/devicetype_utils.h" |
13 #include "ash/common/system/system_notifier.h" | 13 #include "ash/common/system/system_notifier.h" |
14 #include "ash/common/system/tray/fixed_sized_image_view.h" | 14 #include "ash/common/system/tray/fixed_sized_image_view.h" |
15 #include "ash/common/system/tray/system_tray_controller.h" | 15 #include "ash/common/system/tray/system_tray_controller.h" |
16 #include "ash/common/system/tray/system_tray_delegate.h" | 16 #include "ash/common/system/tray/system_tray_delegate.h" |
17 #include "ash/common/system/tray/tray_constants.h" | 17 #include "ash/common/system/tray/tray_constants.h" |
18 #include "ash/common/system/tray/tray_notification_view.h" | 18 #include "ash/common/system/tray/tray_notification_view.h" |
19 #include "ash/common/wm_shell.h" | 19 #include "ash/common/wm_shell.h" |
20 #include "ash/display/display_manager.h" | |
21 #include "ash/display/screen_orientation_controller_chromeos.h" | 20 #include "ash/display/screen_orientation_controller_chromeos.h" |
22 #include "ash/shell.h" | 21 #include "ash/shell.h" |
23 #include "base/bind.h" | 22 #include "base/bind.h" |
24 #include "base/strings/string_util.h" | 23 #include "base/strings/string_util.h" |
25 #include "base/strings/utf_string_conversions.h" | 24 #include "base/strings/utf_string_conversions.h" |
26 #include "grit/ash_resources.h" | 25 #include "grit/ash_resources.h" |
27 #include "grit/ash_strings.h" | 26 #include "grit/ash_strings.h" |
28 #include "ui/base/l10n/l10n_util.h" | 27 #include "ui/base/l10n/l10n_util.h" |
29 #include "ui/base/resource/resource_bundle.h" | 28 #include "ui/base/resource/resource_bundle.h" |
30 #include "ui/display/display.h" | 29 #include "ui/display/display.h" |
| 30 #include "ui/display/manager/display_manager.h" |
31 #include "ui/message_center/message_center.h" | 31 #include "ui/message_center/message_center.h" |
32 #include "ui/message_center/notification.h" | 32 #include "ui/message_center/notification.h" |
33 #include "ui/message_center/notification_delegate.h" | 33 #include "ui/message_center/notification_delegate.h" |
34 | 34 |
35 using message_center::Notification; | 35 using message_center::Notification; |
36 | 36 |
37 namespace ash { | 37 namespace ash { |
38 namespace { | 38 namespace { |
39 | 39 |
40 DisplayManager* GetDisplayManager() { | 40 display::DisplayManager* GetDisplayManager() { |
41 return Shell::GetInstance()->display_manager(); | 41 return Shell::GetInstance()->display_manager(); |
42 } | 42 } |
43 | 43 |
44 base::string16 GetDisplayName(int64_t display_id) { | 44 base::string16 GetDisplayName(int64_t display_id) { |
45 return base::UTF8ToUTF16( | 45 return base::UTF8ToUTF16( |
46 GetDisplayManager()->GetDisplayNameForId(display_id)); | 46 GetDisplayManager()->GetDisplayNameForId(display_id)); |
47 } | 47 } |
48 | 48 |
49 base::string16 GetDisplaySize(int64_t display_id) { | 49 base::string16 GetDisplaySize(int64_t display_id) { |
50 DisplayManager* display_manager = GetDisplayManager(); | 50 display::DisplayManager* display_manager = GetDisplayManager(); |
51 | 51 |
52 const display::Display* display = | 52 const display::Display* display = |
53 &display_manager->GetDisplayForId(display_id); | 53 &display_manager->GetDisplayForId(display_id); |
54 | 54 |
55 // We don't show display size for mirrored display. Fallback | 55 // We don't show display size for mirrored display. Fallback |
56 // to empty string if this happens on release build. | 56 // to empty string if this happens on release build. |
57 bool mirroring = display_manager->mirroring_display_id() == display_id; | 57 bool mirroring = display_manager->mirroring_display_id() == display_id; |
58 DCHECK(!mirroring); | 58 DCHECK(!mirroring); |
59 if (mirroring) | 59 if (mirroring) |
60 return base::string16(); | 60 return base::string16(); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 UMA_STATUS_AREA_DISPLAY_NOTIFICATION_SELECTED); | 94 UMA_STATUS_AREA_DISPLAY_NOTIFICATION_SELECTED); |
95 if (OpenSettings()) { | 95 if (OpenSettings()) { |
96 WmShell::Get()->RecordUserMetricsAction( | 96 WmShell::Get()->RecordUserMetricsAction( |
97 UMA_STATUS_AREA_DISPLAY_NOTIFICATION_SHOW_SETTINGS); | 97 UMA_STATUS_AREA_DISPLAY_NOTIFICATION_SHOW_SETTINGS); |
98 } | 98 } |
99 } | 99 } |
100 | 100 |
101 // Returns the name of the currently connected external display. This should not | 101 // Returns the name of the currently connected external display. This should not |
102 // be used when the external display is used for mirroring. | 102 // be used when the external display is used for mirroring. |
103 base::string16 GetExternalDisplayName() { | 103 base::string16 GetExternalDisplayName() { |
104 DisplayManager* display_manager = GetDisplayManager(); | 104 display::DisplayManager* display_manager = GetDisplayManager(); |
105 DCHECK(!display_manager->IsInMirrorMode()); | 105 DCHECK(!display_manager->IsInMirrorMode()); |
106 | 106 |
107 int64_t external_id = display::Display::kInvalidDisplayID; | 107 int64_t external_id = display::Display::kInvalidDisplayID; |
108 for (size_t i = 0; i < display_manager->GetNumDisplays(); ++i) { | 108 for (size_t i = 0; i < display_manager->GetNumDisplays(); ++i) { |
109 int64_t id = display_manager->GetDisplayAt(i).id(); | 109 int64_t id = display_manager->GetDisplayAt(i).id(); |
110 if (!display::Display::IsInternalDisplayId(id)) { | 110 if (!display::Display::IsInternalDisplayId(id)) { |
111 external_id = id; | 111 external_id = id; |
112 break; | 112 break; |
113 } | 113 } |
114 } | 114 } |
(...skipping 17 matching lines...) Expand all Loading... |
132 name = l10n_util::GetStringFUTF16( | 132 name = l10n_util::GetStringFUTF16( |
133 IDS_ASH_STATUS_TRAY_DISPLAY_ANNOTATED_NAME, name, | 133 IDS_ASH_STATUS_TRAY_DISPLAY_ANNOTATED_NAME, name, |
134 l10n_util::GetStringUTF16( | 134 l10n_util::GetStringUTF16( |
135 IDS_ASH_STATUS_TRAY_DISPLAY_ANNOTATION_OVERSCAN)); | 135 IDS_ASH_STATUS_TRAY_DISPLAY_ANNOTATION_OVERSCAN)); |
136 } | 136 } |
137 | 137 |
138 return name; | 138 return name; |
139 } | 139 } |
140 | 140 |
141 base::string16 GetDisplayMessage(base::string16* additional_message_out) { | 141 base::string16 GetDisplayMessage(base::string16* additional_message_out) { |
142 DisplayManager* display_manager = GetDisplayManager(); | 142 display::DisplayManager* display_manager = GetDisplayManager(); |
143 if (display_manager->GetNumDisplays() > 1) { | 143 if (display_manager->GetNumDisplays() > 1) { |
144 if (display::Display::HasInternalDisplay()) { | 144 if (display::Display::HasInternalDisplay()) { |
145 return l10n_util::GetStringFUTF16(IDS_ASH_STATUS_TRAY_DISPLAY_EXTENDED, | 145 return l10n_util::GetStringFUTF16(IDS_ASH_STATUS_TRAY_DISPLAY_EXTENDED, |
146 GetExternalDisplayName()); | 146 GetExternalDisplayName()); |
147 } | 147 } |
148 return l10n_util::GetStringUTF16( | 148 return l10n_util::GetStringUTF16( |
149 IDS_ASH_STATUS_TRAY_DISPLAY_EXTENDED_NO_INTERNAL); | 149 IDS_ASH_STATUS_TRAY_DISPLAY_EXTENDED_NO_INTERNAL); |
150 } | 150 } |
151 | 151 |
152 if (display_manager->IsInMirrorMode()) { | 152 if (display_manager->IsInMirrorMode()) { |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
188 ScreenLayoutObserver::~ScreenLayoutObserver() { | 188 ScreenLayoutObserver::~ScreenLayoutObserver() { |
189 WmShell::Get()->RemoveDisplayObserver(this); | 189 WmShell::Get()->RemoveDisplayObserver(this); |
190 } | 190 } |
191 | 191 |
192 void ScreenLayoutObserver::UpdateDisplayInfo( | 192 void ScreenLayoutObserver::UpdateDisplayInfo( |
193 ScreenLayoutObserver::DisplayInfoMap* old_info) { | 193 ScreenLayoutObserver::DisplayInfoMap* old_info) { |
194 if (old_info) | 194 if (old_info) |
195 old_info->swap(display_info_); | 195 old_info->swap(display_info_); |
196 display_info_.clear(); | 196 display_info_.clear(); |
197 | 197 |
198 DisplayManager* display_manager = GetDisplayManager(); | 198 display::DisplayManager* display_manager = GetDisplayManager(); |
199 for (size_t i = 0; i < display_manager->GetNumDisplays(); ++i) { | 199 for (size_t i = 0; i < display_manager->GetNumDisplays(); ++i) { |
200 int64_t id = display_manager->GetDisplayAt(i).id(); | 200 int64_t id = display_manager->GetDisplayAt(i).id(); |
201 display_info_[id] = display_manager->GetDisplayInfo(id); | 201 display_info_[id] = display_manager->GetDisplayInfo(id); |
202 } | 202 } |
203 } | 203 } |
204 | 204 |
205 bool ScreenLayoutObserver::GetDisplayMessageForNotification( | 205 bool ScreenLayoutObserver::GetDisplayMessageForNotification( |
206 const ScreenLayoutObserver::DisplayInfoMap& old_info, | 206 const ScreenLayoutObserver::DisplayInfoMap& old_info, |
207 base::string16* message_out, | 207 base::string16* message_out, |
208 base::string16* additional_message_out) { | 208 base::string16* additional_message_out) { |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
303 if (!show_notifications_for_testing) | 303 if (!show_notifications_for_testing) |
304 return; | 304 return; |
305 | 305 |
306 base::string16 message; | 306 base::string16 message; |
307 base::string16 additional_message; | 307 base::string16 additional_message; |
308 if (GetDisplayMessageForNotification(old_info, &message, &additional_message)) | 308 if (GetDisplayMessageForNotification(old_info, &message, &additional_message)) |
309 CreateOrUpdateNotification(message, additional_message); | 309 CreateOrUpdateNotification(message, additional_message); |
310 } | 310 } |
311 | 311 |
312 } // namespace ash | 312 } // namespace ash |
OLD | NEW |