| 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/session/session_controller.h" |
| 14 #include "ash/shell.h" | 15 #include "ash/shell.h" |
| 15 #include "ash/shell_port.h" | 16 #include "ash/shell_port.h" |
| 16 #include "ash/strings/grit/ash_strings.h" | 17 #include "ash/strings/grit/ash_strings.h" |
| 17 #include "ash/system/devicetype_utils.h" | 18 #include "ash/system/devicetype_utils.h" |
| 18 #include "ash/system/system_notifier.h" | 19 #include "ash/system/system_notifier.h" |
| 19 #include "ash/system/tray/fixed_sized_image_view.h" | 20 #include "ash/system/tray/fixed_sized_image_view.h" |
| 20 #include "ash/system/tray/system_tray_controller.h" | 21 #include "ash/system/tray/system_tray_controller.h" |
| 21 #include "ash/system/tray/system_tray_delegate.h" | |
| 22 #include "ash/system/tray/tray_constants.h" | 22 #include "ash/system/tray/tray_constants.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" |
| (...skipping 25 matching lines...) Expand all Loading... |
| 57 // to empty string if this happens on release build. | 57 // to empty string if this happens on release build. |
| 58 bool mirroring = display_manager->mirroring_display_id() == display_id; | 58 bool mirroring = display_manager->mirroring_display_id() == display_id; |
| 59 DCHECK(!mirroring); | 59 DCHECK(!mirroring); |
| 60 if (mirroring) | 60 if (mirroring) |
| 61 return base::string16(); | 61 return base::string16(); |
| 62 | 62 |
| 63 DCHECK(display->is_valid()); | 63 DCHECK(display->is_valid()); |
| 64 return base::UTF8ToUTF16(display->size().ToString()); | 64 return base::UTF8ToUTF16(display->size().ToString()); |
| 65 } | 65 } |
| 66 | 66 |
| 67 // Attempts to open the display settings, returns true if successful. | |
| 68 bool OpenSettings() { | |
| 69 // switch is intentionally introduced without default, to cause an error when | |
| 70 // a new type of login status is introduced. | |
| 71 switch (Shell::Get()->system_tray_delegate()->GetUserLoginStatus()) { | |
| 72 case LoginStatus::NOT_LOGGED_IN: | |
| 73 case LoginStatus::LOCKED: | |
| 74 return false; | |
| 75 | |
| 76 case LoginStatus::USER: | |
| 77 case LoginStatus::OWNER: | |
| 78 case LoginStatus::GUEST: | |
| 79 case LoginStatus::PUBLIC: | |
| 80 case LoginStatus::SUPERVISED: | |
| 81 case LoginStatus::KIOSK_APP: | |
| 82 case LoginStatus::ARC_KIOSK_APP: | |
| 83 SystemTrayDelegate* delegate = Shell::Get()->system_tray_delegate(); | |
| 84 if (delegate->ShouldShowSettings()) { | |
| 85 Shell::Get()->system_tray_controller()->ShowDisplaySettings(); | |
| 86 return true; | |
| 87 } | |
| 88 break; | |
| 89 } | |
| 90 | |
| 91 return false; | |
| 92 } | |
| 93 | |
| 94 // Callback to handle a user selecting the notification view. | 67 // Callback to handle a user selecting the notification view. |
| 95 void OpenSettingsFromNotification() { | 68 void OpenSettingsFromNotification() { |
| 96 ShellPort::Get()->RecordUserMetricsAction( | 69 ShellPort::Get()->RecordUserMetricsAction( |
| 97 UMA_STATUS_AREA_DISPLAY_NOTIFICATION_SELECTED); | 70 UMA_STATUS_AREA_DISPLAY_NOTIFICATION_SELECTED); |
| 98 if (OpenSettings()) { | 71 // Settings may be blocked, e.g. at the lock screen. |
| 72 if (Shell::Get()->session_controller()->ShouldEnableSettings()) { |
| 73 Shell::Get()->system_tray_controller()->ShowDisplaySettings(); |
| 99 ShellPort::Get()->RecordUserMetricsAction( | 74 ShellPort::Get()->RecordUserMetricsAction( |
| 100 UMA_STATUS_AREA_DISPLAY_NOTIFICATION_SHOW_SETTINGS); | 75 UMA_STATUS_AREA_DISPLAY_NOTIFICATION_SHOW_SETTINGS); |
| 101 } | 76 } |
| 102 } | 77 } |
| 103 | 78 |
| 104 // Returns the name of the currently connected external display whose ID is | 79 // 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 | 80 // |external_display_id|. This should not be used when the external display is |
| 106 // used for mirroring. | 81 // used for mirroring. |
| 107 base::string16 GetExternalDisplayName(int64_t external_display_id) { | 82 base::string16 GetExternalDisplayName(int64_t external_display_id) { |
| 108 DCHECK(!display::Display::IsInternalDisplayId(external_display_id)); | 83 DCHECK(!display::Display::IsInternalDisplayId(external_display_id)); |
| (...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 415 return true; | 390 return true; |
| 416 | 391 |
| 417 default: | 392 default: |
| 418 // Mirror mode was turned off; other messages should be shown e.g. | 393 // Mirror mode was turned off; other messages should be shown e.g. |
| 419 // extended mode is on, ... etc. | 394 // extended mode is on, ... etc. |
| 420 return false; | 395 return false; |
| 421 } | 396 } |
| 422 } | 397 } |
| 423 | 398 |
| 424 } // namespace ash | 399 } // namespace ash |
| OLD | NEW |