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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 UMA_STATUS_AREA_DISPLAY_NOTIFICATION_SELECTED); | 96 UMA_STATUS_AREA_DISPLAY_NOTIFICATION_SELECTED); |
97 if (OpenSettings()) { | 97 if (OpenSettings()) { |
98 WmShell::Get()->RecordUserMetricsAction( | 98 WmShell::Get()->RecordUserMetricsAction( |
99 UMA_STATUS_AREA_DISPLAY_NOTIFICATION_SHOW_SETTINGS); | 99 UMA_STATUS_AREA_DISPLAY_NOTIFICATION_SHOW_SETTINGS); |
100 } | 100 } |
101 } | 101 } |
102 | 102 |
103 // Returns the name of the currently connected external display. This should not | 103 // Returns the name of the currently connected external display. This should not |
104 // be used when the external display is used for mirroring. | 104 // be used when the external display is used for mirroring. |
105 base::string16 GetExternalDisplayName() { | 105 base::string16 GetExternalDisplayName() { |
106 DisplayManager* display_manager = GetDisplayManager(); | 106 display::DisplayManager* display_manager = GetDisplayManager(); |
107 DCHECK(!display_manager->IsInMirrorMode()); | 107 DCHECK(!display_manager->IsInMirrorMode()); |
108 | 108 |
109 int64_t external_id = display::Display::kInvalidDisplayID; | 109 int64_t external_id = display::Display::kInvalidDisplayID; |
110 for (size_t i = 0; i < display_manager->GetNumDisplays(); ++i) { | 110 for (size_t i = 0; i < display_manager->GetNumDisplays(); ++i) { |
111 int64_t id = display_manager->GetDisplayAt(i).id(); | 111 int64_t id = display_manager->GetDisplayAt(i).id(); |
112 if (!display::Display::IsInternalDisplayId(id)) { | 112 if (!display::Display::IsInternalDisplayId(id)) { |
113 external_id = id; | 113 external_id = id; |
114 break; | 114 break; |
115 } | 115 } |
116 } | 116 } |
(...skipping 17 matching lines...) Expand all Loading... |
134 name = l10n_util::GetStringFUTF16( | 134 name = l10n_util::GetStringFUTF16( |
135 IDS_ASH_STATUS_TRAY_DISPLAY_ANNOTATED_NAME, name, | 135 IDS_ASH_STATUS_TRAY_DISPLAY_ANNOTATED_NAME, name, |
136 l10n_util::GetStringUTF16( | 136 l10n_util::GetStringUTF16( |
137 IDS_ASH_STATUS_TRAY_DISPLAY_ANNOTATION_OVERSCAN)); | 137 IDS_ASH_STATUS_TRAY_DISPLAY_ANNOTATION_OVERSCAN)); |
138 } | 138 } |
139 | 139 |
140 return name; | 140 return name; |
141 } | 141 } |
142 | 142 |
143 base::string16 GetDisplayMessage(base::string16* additional_message_out) { | 143 base::string16 GetDisplayMessage(base::string16* additional_message_out) { |
144 DisplayManager* display_manager = GetDisplayManager(); | 144 display::DisplayManager* display_manager = GetDisplayManager(); |
145 if (display_manager->GetNumDisplays() > 1) { | 145 if (display_manager->GetNumDisplays() > 1) { |
146 if (display::Display::HasInternalDisplay()) { | 146 if (display::Display::HasInternalDisplay()) { |
147 return l10n_util::GetStringFUTF16(IDS_ASH_STATUS_TRAY_DISPLAY_EXTENDED, | 147 return l10n_util::GetStringFUTF16(IDS_ASH_STATUS_TRAY_DISPLAY_EXTENDED, |
148 GetExternalDisplayName()); | 148 GetExternalDisplayName()); |
149 } | 149 } |
150 return l10n_util::GetStringUTF16( | 150 return l10n_util::GetStringUTF16( |
151 IDS_ASH_STATUS_TRAY_DISPLAY_EXTENDED_NO_INTERNAL); | 151 IDS_ASH_STATUS_TRAY_DISPLAY_EXTENDED_NO_INTERNAL); |
152 } | 152 } |
153 | 153 |
154 if (display_manager->IsInMirrorMode()) { | 154 if (display_manager->IsInMirrorMode()) { |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
190 ScreenLayoutObserver::~ScreenLayoutObserver() { | 190 ScreenLayoutObserver::~ScreenLayoutObserver() { |
191 WmShell::Get()->RemoveDisplayObserver(this); | 191 WmShell::Get()->RemoveDisplayObserver(this); |
192 } | 192 } |
193 | 193 |
194 void ScreenLayoutObserver::UpdateDisplayInfo( | 194 void ScreenLayoutObserver::UpdateDisplayInfo( |
195 ScreenLayoutObserver::DisplayInfoMap* old_info) { | 195 ScreenLayoutObserver::DisplayInfoMap* old_info) { |
196 if (old_info) | 196 if (old_info) |
197 old_info->swap(display_info_); | 197 old_info->swap(display_info_); |
198 display_info_.clear(); | 198 display_info_.clear(); |
199 | 199 |
200 DisplayManager* display_manager = GetDisplayManager(); | 200 display::DisplayManager* display_manager = GetDisplayManager(); |
201 for (size_t i = 0; i < display_manager->GetNumDisplays(); ++i) { | 201 for (size_t i = 0; i < display_manager->GetNumDisplays(); ++i) { |
202 int64_t id = display_manager->GetDisplayAt(i).id(); | 202 int64_t id = display_manager->GetDisplayAt(i).id(); |
203 display_info_[id] = display_manager->GetDisplayInfo(id); | 203 display_info_[id] = display_manager->GetDisplayInfo(id); |
204 } | 204 } |
205 } | 205 } |
206 | 206 |
207 bool ScreenLayoutObserver::GetDisplayMessageForNotification( | 207 bool ScreenLayoutObserver::GetDisplayMessageForNotification( |
208 const ScreenLayoutObserver::DisplayInfoMap& old_info, | 208 const ScreenLayoutObserver::DisplayInfoMap& old_info, |
209 base::string16* message_out, | 209 base::string16* message_out, |
210 base::string16* additional_message_out) { | 210 base::string16* additional_message_out) { |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
305 if (!show_notifications_for_testing) | 305 if (!show_notifications_for_testing) |
306 return; | 306 return; |
307 | 307 |
308 base::string16 message; | 308 base::string16 message; |
309 base::string16 additional_message; | 309 base::string16 additional_message; |
310 if (GetDisplayMessageForNotification(old_info, &message, &additional_message)) | 310 if (GetDisplayMessageForNotification(old_info, &message, &additional_message)) |
311 CreateOrUpdateNotification(message, additional_message); | 311 CreateOrUpdateNotification(message, additional_message); |
312 } | 312 } |
313 | 313 |
314 } // namespace ash | 314 } // namespace ash |
OLD | NEW |