| 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/common/system/tray/system_tray.h" | 5 #include "ash/common/system/tray/system_tray.h" |
| 6 | 6 |
| 7 #include "ash/common/key_event_watcher.h" | 7 #include "ash/common/key_event_watcher.h" |
| 8 #include "ash/common/login_status.h" | 8 #include "ash/common/login_status.h" |
| 9 #include "ash/common/material_design/material_design_controller.h" | 9 #include "ash/common/material_design/material_design_controller.h" |
| 10 #include "ash/common/session/session_state_delegate.h" | 10 #include "ash/common/session/session_state_delegate.h" |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 #include "ash/common/system/chromeos/tray_caps_lock.h" | 68 #include "ash/common/system/chromeos/tray_caps_lock.h" |
| 69 #include "ash/common/system/chromeos/tray_tracing.h" | 69 #include "ash/common/system/chromeos/tray_tracing.h" |
| 70 #include "ash/common/system/ime/tray_ime_chromeos.h" | 70 #include "ash/common/system/ime/tray_ime_chromeos.h" |
| 71 #include "ui/message_center/message_center.h" | 71 #include "ui/message_center/message_center.h" |
| 72 #endif | 72 #endif |
| 73 | 73 |
| 74 using views::TrayBubbleView; | 74 using views::TrayBubbleView; |
| 75 | 75 |
| 76 namespace ash { | 76 namespace ash { |
| 77 | 77 |
| 78 namespace { |
| 79 |
| 80 // A tray item that just reserves space in the tray. |
| 81 class PaddingTrayItem : public SystemTrayItem { |
| 82 public: |
| 83 PaddingTrayItem() : SystemTrayItem(nullptr, UMA_NOT_RECORDED) {} |
| 84 ~PaddingTrayItem() override {} |
| 85 |
| 86 // SystemTrayItem: |
| 87 views::View* CreateTrayView(LoginStatus status) override { |
| 88 return new PaddingView(); |
| 89 } |
| 90 |
| 91 private: |
| 92 class PaddingView : public views::View { |
| 93 public: |
| 94 PaddingView() {} |
| 95 ~PaddingView() override {} |
| 96 |
| 97 private: |
| 98 gfx::Size GetPreferredSize() const override { |
| 99 return gfx::Size(GetTrayConstant(TRAY_IMAGE_ITEM_PADDING), |
| 100 GetTrayConstant(TRAY_IMAGE_ITEM_PADDING)); |
| 101 } |
| 102 |
| 103 DISALLOW_COPY_AND_ASSIGN(PaddingView); |
| 104 }; |
| 105 |
| 106 DISALLOW_COPY_AND_ASSIGN(PaddingTrayItem); |
| 107 }; |
| 108 |
| 109 } // namespace |
| 110 |
| 78 // The minimum width of the system tray menu. | 111 // The minimum width of the system tray menu. |
| 79 const int kMinimumSystemTrayMenuWidth = 300; | 112 const int kMinimumSystemTrayMenuWidth = 300; |
| 80 const int kMinimumSystemTrayMenuWidthMd = 332; | 113 const int kMinimumSystemTrayMenuWidthMd = 332; |
| 81 | 114 |
| 82 // Class to initialize and manage the SystemTrayBubble and TrayBubbleWrapper | 115 // Class to initialize and manage the SystemTrayBubble and TrayBubbleWrapper |
| 83 // instances for a bubble. | 116 // instances for a bubble. |
| 84 | 117 |
| 85 class SystemBubbleWrapper { | 118 class SystemBubbleWrapper { |
| 86 public: | 119 public: |
| 87 // Takes ownership of |bubble|. | 120 // Takes ownership of |bubble|. |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 full_system_tray_menu_(false), | 210 full_system_tray_menu_(false), |
| 178 tray_accessibility_(nullptr), | 211 tray_accessibility_(nullptr), |
| 179 tray_audio_(nullptr), | 212 tray_audio_(nullptr), |
| 180 tray_cast_(nullptr), | 213 tray_cast_(nullptr), |
| 181 tray_date_(nullptr), | 214 tray_date_(nullptr), |
| 182 tray_tiles_(nullptr), | 215 tray_tiles_(nullptr), |
| 183 tray_update_(nullptr), | 216 tray_update_(nullptr), |
| 184 screen_capture_tray_item_(nullptr), | 217 screen_capture_tray_item_(nullptr), |
| 185 screen_share_tray_item_(nullptr) { | 218 screen_share_tray_item_(nullptr) { |
| 186 SetContentsBackground(); | 219 SetContentsBackground(); |
| 187 if (MaterialDesignController::IsSystemTrayMenuMaterial()) | |
| 188 tray_container()->SetMargin(GetTrayConstant(TRAY_IMAGE_ITEM_PADDING), 0); | |
| 189 } | 220 } |
| 190 | 221 |
| 191 SystemTray::~SystemTray() { | 222 SystemTray::~SystemTray() { |
| 192 // Destroy any child views that might have back pointers before ~View(). | 223 // Destroy any child views that might have back pointers before ~View(). |
| 193 activation_observer_.reset(); | 224 activation_observer_.reset(); |
| 194 key_event_watcher_.reset(); | 225 key_event_watcher_.reset(); |
| 195 system_bubble_.reset(); | 226 system_bubble_.reset(); |
| 196 notification_bubble_.reset(); | 227 notification_bubble_.reset(); |
| 197 for (std::vector<SystemTrayItem*>::iterator it = items_.begin(); | 228 for (std::vector<SystemTrayItem*>::iterator it = items_.begin(); |
| 198 it != items_.end(); ++it) { | 229 it != items_.end(); ++it) { |
| (...skipping 17 matching lines...) Expand all Loading... |
| 216 | 247 |
| 217 void SystemTray::CreateItems(SystemTrayDelegate* delegate) { | 248 void SystemTray::CreateItems(SystemTrayDelegate* delegate) { |
| 218 #if !defined(OS_WIN) | 249 #if !defined(OS_WIN) |
| 219 // Create user items for each possible user. | 250 // Create user items for each possible user. |
| 220 int maximum_user_profiles = WmShell::Get() | 251 int maximum_user_profiles = WmShell::Get() |
| 221 ->GetSessionStateDelegate() | 252 ->GetSessionStateDelegate() |
| 222 ->GetMaximumNumberOfLoggedInUsers(); | 253 ->GetMaximumNumberOfLoggedInUsers(); |
| 223 for (int i = 0; i < maximum_user_profiles; i++) | 254 for (int i = 0; i < maximum_user_profiles; i++) |
| 224 AddTrayItem(new TrayUser(this, i)); | 255 AddTrayItem(new TrayUser(this, i)); |
| 225 | 256 |
| 257 // Crucially, this trailing padding has to be inside the user item(s). |
| 258 // Otherwise it could be a main axis margin on the tray's box layout. |
| 259 if (MaterialDesignController::IsSystemTrayMenuMaterial()) |
| 260 AddTrayItem(new PaddingTrayItem()); |
| 261 |
| 226 if (maximum_user_profiles > 1) { | 262 if (maximum_user_profiles > 1) { |
| 227 // Add a special double line separator between users and the rest of the | 263 // Add a special double line separator between users and the rest of the |
| 228 // menu if more than one user is logged in. | 264 // menu if more than one user is logged in. |
| 229 AddTrayItem(new TrayUserSeparator(this)); | 265 AddTrayItem(new TrayUserSeparator(this)); |
| 230 } | 266 } |
| 231 #endif | 267 #endif |
| 232 | 268 |
| 233 const bool use_material_design = | 269 const bool use_material_design = |
| 234 MaterialDesignController::IsSystemTrayMenuMaterial(); | 270 MaterialDesignController::IsSystemTrayMenuMaterial(); |
| 235 tray_accessibility_ = new TrayAccessibility(this); | 271 tray_accessibility_ = new TrayAccessibility(this); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 275 AddTrayItem(new TraySystemInfo(this)); | 311 AddTrayItem(new TraySystemInfo(this)); |
| 276 } else { | 312 } else { |
| 277 AddTrayItem(tray_date_); | 313 AddTrayItem(tray_date_); |
| 278 } | 314 } |
| 279 #elif defined(OS_WIN) | 315 #elif defined(OS_WIN) |
| 280 AddTrayItem(tray_accessibility_); | 316 AddTrayItem(tray_accessibility_); |
| 281 AddTrayItem(tray_update_); | 317 AddTrayItem(tray_update_); |
| 282 if (!use_material_design) | 318 if (!use_material_design) |
| 283 AddTrayItem(tray_date_); | 319 AddTrayItem(tray_date_); |
| 284 #endif | 320 #endif |
| 321 // Leading padding. |
| 322 if (MaterialDesignController::IsSystemTrayMenuMaterial()) |
| 323 AddTrayItem(new PaddingTrayItem()); |
| 285 } | 324 } |
| 286 | 325 |
| 287 void SystemTray::AddTrayItem(SystemTrayItem* item) { | 326 void SystemTray::AddTrayItem(SystemTrayItem* item) { |
| 288 items_.push_back(item); | 327 items_.push_back(item); |
| 289 | 328 |
| 290 SystemTrayDelegate* delegate = WmShell::Get()->system_tray_delegate(); | 329 SystemTrayDelegate* delegate = WmShell::Get()->system_tray_delegate(); |
| 291 views::View* tray_item = item->CreateTrayView(delegate->GetUserLoginStatus()); | 330 views::View* tray_item = item->CreateTrayView(delegate->GetUserLoginStatus()); |
| 292 item->UpdateAfterShelfAlignmentChange(shelf_alignment()); | 331 item->UpdateAfterShelfAlignmentChange(shelf_alignment()); |
| 293 | 332 |
| 294 if (tray_item) { | 333 if (tray_item) { |
| (...skipping 608 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 903 .work_area() | 942 .work_area() |
| 904 .height(); | 943 .height(); |
| 905 if (work_area_height > 0) { | 944 if (work_area_height > 0) { |
| 906 UMA_HISTOGRAM_CUSTOM_COUNTS( | 945 UMA_HISTOGRAM_CUSTOM_COUNTS( |
| 907 "Ash.SystemMenu.PercentageOfWorkAreaHeightCoveredByMenu", | 946 "Ash.SystemMenu.PercentageOfWorkAreaHeightCoveredByMenu", |
| 908 100 * bubble_view->height() / work_area_height, 1, 300, 100); | 947 100 * bubble_view->height() / work_area_height, 1, 300, 100); |
| 909 } | 948 } |
| 910 } | 949 } |
| 911 | 950 |
| 912 } // namespace ash | 951 } // namespace ash |
| OLD | NEW |