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/screen_layout_observer.h" | 5 #include "ash/system/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/display/screen_orientation_controller_chromeos.h" | 11 #include "ash/display/screen_orientation_controller_chromeos.h" |
12 #include "ash/metrics/user_metrics_action.h" | 12 #include "ash/metrics/user_metrics_action.h" |
13 #include "ash/resources/grit/ash_resources.h" | 13 #include "ash/resources/grit/ash_resources.h" |
14 #include "ash/shell.h" | 14 #include "ash/shell.h" |
| 15 #include "ash/shell_port.h" |
15 #include "ash/strings/grit/ash_strings.h" | 16 #include "ash/strings/grit/ash_strings.h" |
16 #include "ash/system/devicetype_utils.h" | 17 #include "ash/system/devicetype_utils.h" |
17 #include "ash/system/system_notifier.h" | 18 #include "ash/system/system_notifier.h" |
18 #include "ash/system/tray/fixed_sized_image_view.h" | 19 #include "ash/system/tray/fixed_sized_image_view.h" |
19 #include "ash/system/tray/system_tray_controller.h" | 20 #include "ash/system/tray/system_tray_controller.h" |
20 #include "ash/system/tray/system_tray_delegate.h" | 21 #include "ash/system/tray/system_tray_delegate.h" |
21 #include "ash/system/tray/tray_constants.h" | 22 #include "ash/system/tray/tray_constants.h" |
22 #include "ash/wm_shell.h" | |
23 #include "base/bind.h" | 23 #include "base/bind.h" |
24 #include "base/strings/string_util.h" | 24 #include "base/strings/string_util.h" |
25 #include "base/strings/utf_string_conversions.h" | 25 #include "base/strings/utf_string_conversions.h" |
26 #include "ui/base/l10n/l10n_util.h" | 26 #include "ui/base/l10n/l10n_util.h" |
27 #include "ui/base/resource/resource_bundle.h" | 27 #include "ui/base/resource/resource_bundle.h" |
28 #include "ui/display/display.h" | 28 #include "ui/display/display.h" |
29 #include "ui/display/manager/display_manager.h" | 29 #include "ui/display/manager/display_manager.h" |
30 #include "ui/display/types/display_constants.h" | 30 #include "ui/display/types/display_constants.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" |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 return true; | 86 return true; |
87 } | 87 } |
88 break; | 88 break; |
89 } | 89 } |
90 | 90 |
91 return false; | 91 return false; |
92 } | 92 } |
93 | 93 |
94 // Callback to handle a user selecting the notification view. | 94 // Callback to handle a user selecting the notification view. |
95 void OpenSettingsFromNotification() { | 95 void OpenSettingsFromNotification() { |
96 WmShell::Get()->RecordUserMetricsAction( | 96 ShellPort::Get()->RecordUserMetricsAction( |
97 UMA_STATUS_AREA_DISPLAY_NOTIFICATION_SELECTED); | 97 UMA_STATUS_AREA_DISPLAY_NOTIFICATION_SELECTED); |
98 if (OpenSettings()) { | 98 if (OpenSettings()) { |
99 WmShell::Get()->RecordUserMetricsAction( | 99 ShellPort::Get()->RecordUserMetricsAction( |
100 UMA_STATUS_AREA_DISPLAY_NOTIFICATION_SHOW_SETTINGS); | 100 UMA_STATUS_AREA_DISPLAY_NOTIFICATION_SHOW_SETTINGS); |
101 } | 101 } |
102 } | 102 } |
103 | 103 |
104 // Returns the name of the currently connected external display whose ID is | 104 // Returns the name of the currently connected external display whose ID is |
105 // |external_display_id|. This should not be used when the external display is | 105 // |external_display_id|. This should not be used when the external display is |
106 // used for mirroring. | 106 // used for mirroring. |
107 base::string16 GetExternalDisplayName(int64_t external_display_id) { | 107 base::string16 GetExternalDisplayName(int64_t external_display_id) { |
108 DCHECK(!display::Display::IsInternalDisplayId(external_display_id)); | 108 DCHECK(!display::Display::IsInternalDisplayId(external_display_id)); |
109 | 109 |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
195 return l10n_util::GetStringFUTF16(IDS_ASH_STATUS_TRAY_DISPLAY_EXTENDED, | 195 return l10n_util::GetStringFUTF16(IDS_ASH_STATUS_TRAY_DISPLAY_EXTENDED, |
196 GetExternalDisplayName(added_display_id)); | 196 GetExternalDisplayName(added_display_id)); |
197 } | 197 } |
198 | 198 |
199 } // namespace | 199 } // namespace |
200 | 200 |
201 const char ScreenLayoutObserver::kNotificationId[] = | 201 const char ScreenLayoutObserver::kNotificationId[] = |
202 "chrome://settings/display"; | 202 "chrome://settings/display"; |
203 | 203 |
204 ScreenLayoutObserver::ScreenLayoutObserver() { | 204 ScreenLayoutObserver::ScreenLayoutObserver() { |
205 WmShell::Get()->AddDisplayObserver(this); | 205 ShellPort::Get()->AddDisplayObserver(this); |
206 UpdateDisplayInfo(NULL); | 206 UpdateDisplayInfo(NULL); |
207 } | 207 } |
208 | 208 |
209 ScreenLayoutObserver::~ScreenLayoutObserver() { | 209 ScreenLayoutObserver::~ScreenLayoutObserver() { |
210 WmShell::Get()->RemoveDisplayObserver(this); | 210 ShellPort::Get()->RemoveDisplayObserver(this); |
211 } | 211 } |
212 | 212 |
213 void ScreenLayoutObserver::UpdateDisplayInfo( | 213 void ScreenLayoutObserver::UpdateDisplayInfo( |
214 ScreenLayoutObserver::DisplayInfoMap* old_info) { | 214 ScreenLayoutObserver::DisplayInfoMap* old_info) { |
215 if (old_info) | 215 if (old_info) |
216 old_info->swap(display_info_); | 216 old_info->swap(display_info_); |
217 display_info_.clear(); | 217 display_info_.clear(); |
218 | 218 |
219 display::DisplayManager* display_manager = GetDisplayManager(); | 219 display::DisplayManager* display_manager = GetDisplayManager(); |
220 for (size_t i = 0; i < display_manager->GetNumDisplays(); ++i) { | 220 for (size_t i = 0; i < display_manager->GetNumDisplays(); ++i) { |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
348 message_center::NOTIFICATION_TYPE_SIMPLE, kNotificationId, message, | 348 message_center::NOTIFICATION_TYPE_SIMPLE, kNotificationId, message, |
349 additional_message, bundle.GetImageNamed(IDR_AURA_NOTIFICATION_DISPLAY), | 349 additional_message, bundle.GetImageNamed(IDR_AURA_NOTIFICATION_DISPLAY), |
350 base::string16(), // display_source | 350 base::string16(), // display_source |
351 GURL(), | 351 GURL(), |
352 message_center::NotifierId(message_center::NotifierId::SYSTEM_COMPONENT, | 352 message_center::NotifierId(message_center::NotifierId::SYSTEM_COMPONENT, |
353 system_notifier::kNotifierDisplay), | 353 system_notifier::kNotifierDisplay), |
354 message_center::RichNotificationData(), | 354 message_center::RichNotificationData(), |
355 new message_center::HandleNotificationClickedDelegate( | 355 new message_center::HandleNotificationClickedDelegate( |
356 base::Bind(&OpenSettingsFromNotification)))); | 356 base::Bind(&OpenSettingsFromNotification)))); |
357 | 357 |
358 WmShell::Get()->RecordUserMetricsAction( | 358 ShellPort::Get()->RecordUserMetricsAction( |
359 UMA_STATUS_AREA_DISPLAY_NOTIFICATION_CREATED); | 359 UMA_STATUS_AREA_DISPLAY_NOTIFICATION_CREATED); |
360 message_center::MessageCenter::Get()->AddNotification( | 360 message_center::MessageCenter::Get()->AddNotification( |
361 std::move(notification)); | 361 std::move(notification)); |
362 } | 362 } |
363 | 363 |
364 void ScreenLayoutObserver::OnDisplayConfigurationChanged() { | 364 void ScreenLayoutObserver::OnDisplayConfigurationChanged() { |
365 DisplayInfoMap old_info; | 365 DisplayInfoMap old_info; |
366 UpdateDisplayInfo(&old_info); | 366 UpdateDisplayInfo(&old_info); |
367 | 367 |
368 old_display_mode_ = current_display_mode_; | 368 old_display_mode_ = current_display_mode_; |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
415 return true; | 415 return true; |
416 | 416 |
417 default: | 417 default: |
418 // Mirror mode was turned off; other messages should be shown e.g. | 418 // Mirror mode was turned off; other messages should be shown e.g. |
419 // extended mode is on, ... etc. | 419 // extended mode is on, ... etc. |
420 return false; | 420 return false; |
421 } | 421 } |
422 } | 422 } |
423 | 423 |
424 } // namespace ash | 424 } // namespace ash |
OLD | NEW |