| 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/shell_port.h" |
| 16 #include "ash/strings/grit/ash_strings.h" | 16 #include "ash/strings/grit/ash_strings.h" |
| 17 #include "ash/system/devicetype_utils.h" | 17 #include "ash/system/devicetype_utils.h" |
| 18 #include "ash/system/system_notifier.h" | 18 #include "ash/system/system_notifier.h" |
| 19 #include "ash/system/tray/fixed_sized_image_view.h" | 19 #include "ash/system/tray/fixed_sized_image_view.h" |
| 20 #include "ash/system/tray/system_tray_controller.h" | 20 #include "ash/system/tray/system_tray_controller.h" |
| 21 #include "ash/system/tray/system_tray_delegate.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 "ash/wm/maximize_mode/maximize_mode_controller.h" |
| 23 #include "base/bind.h" | 24 #include "base/bind.h" |
| 24 #include "base/strings/string_util.h" | 25 #include "base/strings/string_util.h" |
| 25 #include "base/strings/utf_string_conversions.h" | 26 #include "base/strings/utf_string_conversions.h" |
| 26 #include "ui/base/l10n/l10n_util.h" | 27 #include "ui/base/l10n/l10n_util.h" |
| 27 #include "ui/base/resource/resource_bundle.h" | 28 #include "ui/base/resource/resource_bundle.h" |
| 28 #include "ui/display/display.h" | 29 #include "ui/display/display.h" |
| 29 #include "ui/display/manager/display_manager.h" | 30 #include "ui/display/manager/display_manager.h" |
| 30 #include "ui/display/types/display_constants.h" | 31 #include "ui/display/types/display_constants.h" |
| 31 #include "ui/message_center/message_center.h" | 32 #include "ui/message_center/message_center.h" |
| 32 #include "ui/message_center/notification.h" | 33 #include "ui/message_center/notification.h" |
| (...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 289 return false; | 290 return false; |
| 290 } | 291 } |
| 291 | 292 |
| 292 if (iter.second.configured_ui_scale() != | 293 if (iter.second.configured_ui_scale() != |
| 293 old_iter->second.configured_ui_scale()) { | 294 old_iter->second.configured_ui_scale()) { |
| 294 *out_additional_message = l10n_util::GetStringFUTF16( | 295 *out_additional_message = l10n_util::GetStringFUTF16( |
| 295 IDS_ASH_STATUS_TRAY_DISPLAY_RESOLUTION_CHANGED, | 296 IDS_ASH_STATUS_TRAY_DISPLAY_RESOLUTION_CHANGED, |
| 296 GetDisplayName(iter.first), GetDisplaySize(iter.first)); | 297 GetDisplayName(iter.first), GetDisplaySize(iter.first)); |
| 297 return true; | 298 return true; |
| 298 } | 299 } |
| 299 // We don't show rotation change notification when the rotation source is | 300 // Don't show rotation change notification if |
| 300 // the accelerometer. | 301 // a) no rotation change |
| 301 if (iter.second.active_rotation_source() != | 302 if (iter.second.GetActiveRotation() == old_iter->second.GetActiveRotation()) |
| 302 display::Display::ROTATION_SOURCE_ACCELEROMETER && | 303 continue; |
| 303 iter.second.GetActiveRotation() != | 304 // b) the source is accelerometer. |
| 304 old_iter->second.GetActiveRotation()) { | 305 if (iter.second.active_rotation_source() == |
| 305 int rotation_text_id = 0; | 306 display::Display::ROTATION_SOURCE_ACCELEROMETER) { |
| 306 switch (iter.second.GetActiveRotation()) { | 307 continue; |
| 307 case display::Display::ROTATE_0: | |
| 308 rotation_text_id = IDS_ASH_STATUS_TRAY_DISPLAY_STANDARD_ORIENTATION; | |
| 309 break; | |
| 310 case display::Display::ROTATE_90: | |
| 311 rotation_text_id = IDS_ASH_STATUS_TRAY_DISPLAY_ORIENTATION_90; | |
| 312 break; | |
| 313 case display::Display::ROTATE_180: | |
| 314 rotation_text_id = IDS_ASH_STATUS_TRAY_DISPLAY_ORIENTATION_180; | |
| 315 break; | |
| 316 case display::Display::ROTATE_270: | |
| 317 rotation_text_id = IDS_ASH_STATUS_TRAY_DISPLAY_ORIENTATION_270; | |
| 318 break; | |
| 319 } | |
| 320 *out_additional_message = l10n_util::GetStringFUTF16( | |
| 321 IDS_ASH_STATUS_TRAY_DISPLAY_ROTATED, GetDisplayName(iter.first), | |
| 322 l10n_util::GetStringUTF16(rotation_text_id)); | |
| 323 return true; | |
| 324 } | 308 } |
| 309 // c) if the device is in tablet mode, and source is not user. |
| 310 if (Shell::Get() |
| 311 ->maximize_mode_controller() |
| 312 ->IsMaximizeModeWindowManagerEnabled() && |
| 313 iter.second.active_rotation_source() != |
| 314 display::Display::ROTATION_SOURCE_USER) { |
| 315 continue; |
| 316 } |
| 317 |
| 318 int rotation_text_id = 0; |
| 319 switch (iter.second.GetActiveRotation()) { |
| 320 case display::Display::ROTATE_0: |
| 321 rotation_text_id = IDS_ASH_STATUS_TRAY_DISPLAY_STANDARD_ORIENTATION; |
| 322 break; |
| 323 case display::Display::ROTATE_90: |
| 324 rotation_text_id = IDS_ASH_STATUS_TRAY_DISPLAY_ORIENTATION_90; |
| 325 break; |
| 326 case display::Display::ROTATE_180: |
| 327 rotation_text_id = IDS_ASH_STATUS_TRAY_DISPLAY_ORIENTATION_180; |
| 328 break; |
| 329 case display::Display::ROTATE_270: |
| 330 rotation_text_id = IDS_ASH_STATUS_TRAY_DISPLAY_ORIENTATION_270; |
| 331 break; |
| 332 } |
| 333 *out_additional_message = l10n_util::GetStringFUTF16( |
| 334 IDS_ASH_STATUS_TRAY_DISPLAY_ROTATED, GetDisplayName(iter.first), |
| 335 l10n_util::GetStringUTF16(rotation_text_id)); |
| 336 return true; |
| 325 } | 337 } |
| 326 | 338 |
| 327 // Found nothing special | 339 // Found nothing special |
| 328 return false; | 340 return false; |
| 329 } | 341 } |
| 330 | 342 |
| 331 void ScreenLayoutObserver::CreateOrUpdateNotification( | 343 void ScreenLayoutObserver::CreateOrUpdateNotification( |
| 332 const base::string16& message, | 344 const base::string16& message, |
| 333 const base::string16& additional_message) { | 345 const base::string16& additional_message) { |
| 334 // Always remove the notification to make sure the notification appears | 346 // Always remove the notification to make sure the notification appears |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 419 return true; | 431 return true; |
| 420 | 432 |
| 421 default: | 433 default: |
| 422 // Mirror mode was turned off; other messages should be shown e.g. | 434 // Mirror mode was turned off; other messages should be shown e.g. |
| 423 // extended mode is on, ... etc. | 435 // extended mode is on, ... etc. |
| 424 return false; | 436 return false; |
| 425 } | 437 } |
| 426 } | 438 } |
| 427 | 439 |
| 428 } // namespace ash | 440 } // namespace ash |
| OLD | NEW |