Chromium Code Reviews| 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/tray_display.h" | 5 #include "ash/system/chromeos/tray_display.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/system/chromeos/devicetype_utils.h" | 12 #include "ash/common/system/chromeos/devicetype_utils.h" |
| 12 #include "ash/common/system/system_notifier.h" | 13 #include "ash/common/system/system_notifier.h" |
| 13 #include "ash/common/system/tray/actionable_view.h" | 14 #include "ash/common/system/tray/actionable_view.h" |
| 14 #include "ash/common/system/tray/fixed_sized_image_view.h" | 15 #include "ash/common/system/tray/fixed_sized_image_view.h" |
| 15 #include "ash/common/system/tray/system_tray_delegate.h" | 16 #include "ash/common/system/tray/system_tray_delegate.h" |
| 16 #include "ash/common/system/tray/tray_constants.h" | 17 #include "ash/common/system/tray/tray_constants.h" |
| 17 #include "ash/common/system/tray/tray_notification_view.h" | 18 #include "ash/common/system/tray/tray_notification_view.h" |
| 18 #include "ash/common/wm_shell.h" | 19 #include "ash/common/wm_shell.h" |
| 19 #include "ash/display/display_manager.h" | 20 #include "ash/display/display_manager.h" |
| 20 #include "ash/display/screen_orientation_controller_chromeos.h" | 21 #include "ash/display/screen_orientation_controller_chromeos.h" |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 105 for (size_t i = 0; i < display_manager->GetNumDisplays(); ++i) { | 106 for (size_t i = 0; i < display_manager->GetNumDisplays(); ++i) { |
| 106 int64_t id = display_manager->GetDisplayAt(i).id(); | 107 int64_t id = display_manager->GetDisplayAt(i).id(); |
| 107 if (id == internal_id) | 108 if (id == internal_id) |
| 108 continue; | 109 continue; |
| 109 lines.push_back(GetDisplayInfoLine(id)); | 110 lines.push_back(GetDisplayInfoLine(id)); |
| 110 } | 111 } |
| 111 | 112 |
| 112 return base::JoinString(lines, base::ASCIIToUTF16("\n")); | 113 return base::JoinString(lines, base::ASCIIToUTF16("\n")); |
| 113 } | 114 } |
| 114 | 115 |
| 115 void OpenSettings() { | 116 void OpenSettings(UserMetricsAction action) { |
|
tdanderson
2016/07/07 21:41:39
nit: Add a brief explanation to the documentation
bruthig
2016/07/08 17:12:51
This got reworked a little bit.
| |
| 116 // switch is intentionally introduced without default, to cause an error when | 117 // switch is intentionally introduced without default, to cause an error when |
| 117 // a new type of login status is introduced. | 118 // a new type of login status is introduced. |
| 118 switch (WmShell::Get()->system_tray_delegate()->GetUserLoginStatus()) { | 119 switch (WmShell::Get()->system_tray_delegate()->GetUserLoginStatus()) { |
| 119 case LoginStatus::NOT_LOGGED_IN: | 120 case LoginStatus::NOT_LOGGED_IN: |
| 120 case LoginStatus::LOCKED: | 121 case LoginStatus::LOCKED: |
| 121 return; | 122 return; |
| 122 | 123 |
| 123 case LoginStatus::USER: | 124 case LoginStatus::USER: |
| 124 case LoginStatus::OWNER: | 125 case LoginStatus::OWNER: |
| 125 case LoginStatus::GUEST: | 126 case LoginStatus::GUEST: |
| 126 case LoginStatus::PUBLIC: | 127 case LoginStatus::PUBLIC: |
| 127 case LoginStatus::SUPERVISED: | 128 case LoginStatus::SUPERVISED: |
| 128 case LoginStatus::KIOSK_APP: | 129 case LoginStatus::KIOSK_APP: |
| 129 SystemTrayDelegate* delegate = WmShell::Get()->system_tray_delegate(); | 130 SystemTrayDelegate* delegate = WmShell::Get()->system_tray_delegate(); |
| 130 if (delegate->ShouldShowSettings()) | 131 if (delegate->ShouldShowSettings()) |
| 131 delegate->ShowDisplaySettings(); | 132 delegate->ShowDisplaySettings(); |
| 132 } | 133 } |
| 134 | |
| 135 WmShell::Get()->RecordUserMetricsAction(action); | |
| 133 } | 136 } |
| 134 | 137 |
| 135 } // namespace | 138 } // namespace |
| 136 | 139 |
| 137 const char TrayDisplay::kNotificationId[] = "chrome://settings/display"; | 140 const char TrayDisplay::kNotificationId[] = "chrome://settings/display"; |
| 138 | 141 |
| 139 class DisplayView : public ActionableView { | 142 class DisplayView : public ActionableView { |
| 140 public: | 143 public: |
| 141 explicit DisplayView() { | 144 explicit DisplayView() { |
| 142 SetLayoutManager(new views::BoxLayout(views::BoxLayout::kHorizontal, | 145 SetLayoutManager(new views::BoxLayout(views::BoxLayout::kHorizontal, |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 273 (display_info.active_rotation_source() != | 276 (display_info.active_rotation_source() != |
| 274 display::Display::ROTATION_SOURCE_ACCELEROMETER || | 277 display::Display::ROTATION_SOURCE_ACCELEROMETER || |
| 275 !display::Display::IsInternalDisplayId(first_display_id))) || | 278 !display::Display::IsInternalDisplayId(first_display_id))) || |
| 276 display_info.configured_ui_scale() != 1.0f || | 279 display_info.configured_ui_scale() != 1.0f || |
| 277 !display_info.overscan_insets_in_dip().IsEmpty() || | 280 !display_info.overscan_insets_in_dip().IsEmpty() || |
| 278 display_info.has_overscan(); | 281 display_info.has_overscan(); |
| 279 } | 282 } |
| 280 | 283 |
| 281 // Overridden from ActionableView. | 284 // Overridden from ActionableView. |
| 282 bool PerformAction(const ui::Event& event) override { | 285 bool PerformAction(const ui::Event& event) override { |
| 283 OpenSettings(); | 286 OpenSettings(UMA_STATUS_AREA_DISPLAY_DEFAULT_CLICKED); |
| 284 return true; | 287 return true; |
| 285 } | 288 } |
| 286 | 289 |
| 287 void OnBoundsChanged(const gfx::Rect& previous_bounds) override { | 290 void OnBoundsChanged(const gfx::Rect& previous_bounds) override { |
| 288 int label_max_width = bounds().width() - kTrayPopupPaddingHorizontal * 2 - | 291 int label_max_width = bounds().width() - kTrayPopupPaddingHorizontal * 2 - |
| 289 kTrayPopupPaddingBetweenItems - | 292 kTrayPopupPaddingBetweenItems - |
| 290 image_->GetPreferredSize().width(); | 293 image_->GetPreferredSize().width(); |
| 291 label_->SizeToFit(label_max_width); | 294 label_->SizeToFit(label_max_width); |
| 292 } | 295 } |
| 293 | 296 |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 397 | 400 |
| 398 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance(); | 401 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance(); |
| 399 std::unique_ptr<Notification> notification(new Notification( | 402 std::unique_ptr<Notification> notification(new Notification( |
| 400 message_center::NOTIFICATION_TYPE_SIMPLE, kNotificationId, message, | 403 message_center::NOTIFICATION_TYPE_SIMPLE, kNotificationId, message, |
| 401 additional_message, bundle.GetImageNamed(IDR_AURA_NOTIFICATION_DISPLAY), | 404 additional_message, bundle.GetImageNamed(IDR_AURA_NOTIFICATION_DISPLAY), |
| 402 base::string16(), // display_source | 405 base::string16(), // display_source |
| 403 GURL(), | 406 GURL(), |
| 404 message_center::NotifierId(message_center::NotifierId::SYSTEM_COMPONENT, | 407 message_center::NotifierId(message_center::NotifierId::SYSTEM_COMPONENT, |
| 405 system_notifier::kNotifierDisplay), | 408 system_notifier::kNotifierDisplay), |
| 406 message_center::RichNotificationData(), | 409 message_center::RichNotificationData(), |
| 407 new message_center::HandleNotificationClickedDelegate( | 410 new message_center::HandleNotificationClickedDelegate(base::Bind( |
| 408 base::Bind(&OpenSettings)))); | 411 &OpenSettings, UMA_STATUS_AREA_DISPLAY_NOTIFICATION_CLICKED)))); |
| 409 | 412 |
| 410 message_center::MessageCenter::Get()->AddNotification( | 413 message_center::MessageCenter::Get()->AddNotification( |
| 411 std::move(notification)); | 414 std::move(notification)); |
| 412 } | 415 } |
| 413 | 416 |
| 414 views::View* TrayDisplay::CreateDefaultView(LoginStatus status) { | 417 views::View* TrayDisplay::CreateDefaultView(LoginStatus status) { |
| 415 DCHECK(default_ == NULL); | 418 DCHECK(default_ == NULL); |
| 416 default_ = new DisplayView(); | 419 default_ = new DisplayView(); |
| 417 return default_; | 420 return default_; |
| 418 } | 421 } |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 450 bool TrayDisplay::GetAccessibleStateForTesting(ui::AXViewState* state) { | 453 bool TrayDisplay::GetAccessibleStateForTesting(ui::AXViewState* state) { |
| 451 views::View* view = default_; | 454 views::View* view = default_; |
| 452 if (view) { | 455 if (view) { |
| 453 view->GetAccessibleState(state); | 456 view->GetAccessibleState(state); |
| 454 return true; | 457 return true; |
| 455 } | 458 } |
| 456 return false; | 459 return false; |
| 457 } | 460 } |
| 458 | 461 |
| 459 } // namespace ash | 462 } // namespace ash |
| OLD | NEW |