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/common/system/tray/system_tray.h" | 5 #include "ash/common/system/tray/system_tray.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <map> | 8 #include <map> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 209 | 209 |
| 210 // SystemTray | 210 // SystemTray |
| 211 | 211 |
| 212 SystemTray::SystemTray(WmShelf* wm_shelf) | 212 SystemTray::SystemTray(WmShelf* wm_shelf) |
| 213 : TrayBackgroundView(wm_shelf), | 213 : TrayBackgroundView(wm_shelf), |
| 214 web_notification_tray_(nullptr), | 214 web_notification_tray_(nullptr), |
| 215 detailed_item_(nullptr), | 215 detailed_item_(nullptr), |
| 216 default_bubble_height_(0), | 216 default_bubble_height_(0), |
| 217 hide_notifications_(false), | 217 hide_notifications_(false), |
| 218 full_system_tray_menu_(false), | 218 full_system_tray_menu_(false), |
| 219 tray_user_active_(nullptr), | |
| 219 tray_accessibility_(nullptr), | 220 tray_accessibility_(nullptr), |
| 220 tray_audio_(nullptr), | 221 tray_audio_(nullptr), |
| 221 tray_cast_(nullptr), | 222 tray_cast_(nullptr), |
| 222 tray_date_(nullptr), | 223 tray_date_(nullptr), |
| 223 tray_tiles_(nullptr), | 224 tray_tiles_(nullptr), |
| 224 tray_system_info_(nullptr), | 225 tray_system_info_(nullptr), |
| 225 tray_update_(nullptr), | 226 tray_update_(nullptr), |
| 226 screen_capture_tray_item_(nullptr), | 227 screen_capture_tray_item_(nullptr), |
| 227 screen_share_tray_item_(nullptr) { | 228 screen_share_tray_item_(nullptr) { |
| 228 SetContentsBackground(true); | 229 if (MaterialDesignController::IsShelfMaterial()) { |
| 230 SetInkDropMode(InkDropMode::ON); | |
| 231 SetContentsBackground(false); | |
| 232 } else { | |
| 233 SetContentsBackground(true); | |
| 234 } | |
| 229 } | 235 } |
| 230 | 236 |
| 231 SystemTray::~SystemTray() { | 237 SystemTray::~SystemTray() { |
| 232 // Destroy any child views that might have back pointers before ~View(). | 238 // Destroy any child views that might have back pointers before ~View(). |
| 233 activation_observer_.reset(); | 239 activation_observer_.reset(); |
| 234 key_event_watcher_.reset(); | 240 key_event_watcher_.reset(); |
| 235 system_bubble_.reset(); | 241 system_bubble_.reset(); |
| 236 notification_bubble_.reset(); | 242 notification_bubble_.reset(); |
| 237 for (std::vector<SystemTrayItem*>::iterator it = items_.begin(); | 243 for (std::vector<SystemTrayItem*>::iterator it = items_.begin(); |
| 238 it != items_.end(); ++it) { | 244 it != items_.end(); ++it) { |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 253 DCHECK(web_notification_tray_); | 259 DCHECK(web_notification_tray_); |
| 254 web_notification_tray_ = nullptr; | 260 web_notification_tray_ = nullptr; |
| 255 } | 261 } |
| 256 | 262 |
| 257 void SystemTray::CreateItems(SystemTrayDelegate* delegate) { | 263 void SystemTray::CreateItems(SystemTrayDelegate* delegate) { |
| 258 #if !defined(OS_WIN) | 264 #if !defined(OS_WIN) |
| 259 // Create user items for each possible user. | 265 // Create user items for each possible user. |
| 260 int maximum_user_profiles = WmShell::Get() | 266 int maximum_user_profiles = WmShell::Get() |
| 261 ->GetSessionStateDelegate() | 267 ->GetSessionStateDelegate() |
| 262 ->GetMaximumNumberOfLoggedInUsers(); | 268 ->GetMaximumNumberOfLoggedInUsers(); |
| 263 for (int i = 0; i < maximum_user_profiles; i++) | 269 for (int i = 0; i < maximum_user_profiles; i++) { |
| 264 AddTrayItem(new TrayUser(this, i)); | 270 TrayUser* tray_user = new TrayUser(this, i); |
| 271 if (i == 0) | |
| 272 tray_user_active_ = tray_user; | |
| 273 AddTrayItem(tray_user); | |
| 274 } | |
| 265 | 275 |
| 266 // Crucially, this trailing padding has to be inside the user item(s). | 276 // Crucially, this trailing padding has to be inside the user item(s). |
| 267 // Otherwise it could be a main axis margin on the tray's box layout. | 277 // Otherwise it could be a main axis margin on the tray's box layout. |
| 268 if (MaterialDesignController::IsSystemTrayMenuMaterial()) | 278 if (MaterialDesignController::IsSystemTrayMenuMaterial()) |
| 269 AddTrayItem(new PaddingTrayItem()); | 279 AddTrayItem(new PaddingTrayItem()); |
| 270 | 280 |
| 271 if (maximum_user_profiles > 1) { | 281 if (maximum_user_profiles > 1) { |
| 272 // Add a special double line separator between users and the rest of the | 282 // Add a special double line separator between users and the rest of the |
| 273 // menu if more than one user is logged in. | 283 // menu if more than one user is logged in. |
| 274 AddTrayItem(new TrayUserSeparator(this)); | 284 AddTrayItem(new TrayUserSeparator(this)); |
| (...skipping 577 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 852 base::Bind(&SystemTray::ActivateAndStartNavigation, | 862 base::Bind(&SystemTray::ActivateAndStartNavigation, |
| 853 base::Unretained(this))); | 863 base::Unretained(this))); |
| 854 } | 864 } |
| 855 | 865 |
| 856 void SystemTray::ActivateBubble() { | 866 void SystemTray::ActivateBubble() { |
| 857 TrayBubbleView* bubble_view = GetSystemBubble()->bubble_view(); | 867 TrayBubbleView* bubble_view = GetSystemBubble()->bubble_view(); |
| 858 bubble_view->set_can_activate(true); | 868 bubble_view->set_can_activate(true); |
| 859 bubble_view->GetWidget()->Activate(); | 869 bubble_view->GetWidget()->Activate(); |
| 860 } | 870 } |
| 861 | 871 |
| 872 gfx::Insets SystemTray::GetBackgroundInsets() const { | |
|
bruthig
2016/11/17 06:31:20
Double check with Sebastien but I imagine we want
mohsen
2016/11/17 20:10:12
Sure. Done.
| |
| 873 gfx::Insets insets = TrayBackgroundView::GetBackgroundInsets(); | |
| 874 if (tray_user_active_ && tray_user_active_->is_avatar_visible()) { | |
| 875 if (IsHorizontalAlignment(shelf_alignment())) { | |
| 876 insets.Set(insets.top(), insets.left(), insets.bottom(), | |
| 877 insets.right() + kTrayItemSize); | |
| 878 } else { | |
| 879 insets.Set(insets.top(), insets.left(), insets.bottom() + kTrayItemSize, | |
| 880 insets.right()); | |
| 881 } | |
| 882 } | |
| 883 return insets; | |
| 884 } | |
| 885 | |
| 862 bool SystemTray::PerformAction(const ui::Event& event) { | 886 bool SystemTray::PerformAction(const ui::Event& event) { |
| 863 // If we're already showing the default view, hide it; otherwise, show it | 887 // If we're already showing the default view, hide it; otherwise, show it |
| 864 // (and hide any popup that's currently shown). | 888 // (and hide any popup that's currently shown). |
| 865 if (HasSystemBubbleType(SystemTrayBubble::BUBBLE_TYPE_DEFAULT)) { | 889 if (HasSystemBubbleType(SystemTrayBubble::BUBBLE_TYPE_DEFAULT)) { |
| 866 system_bubble_->bubble()->Close(); | 890 system_bubble_->bubble()->Close(); |
| 867 } else { | 891 } else { |
| 868 ShowDefaultView(BUBBLE_CREATE_NEW); | 892 ShowDefaultView(BUBBLE_CREATE_NEW); |
| 869 if (event.IsKeyEvent() || (event.flags() & ui::EF_TOUCH_ACCESSIBILITY)) | 893 if (event.IsKeyEvent() || (event.flags() & ui::EF_TOUCH_ACCESSIBILITY)) |
| 870 ActivateBubble(); | 894 ActivateBubble(); |
| 871 } | 895 } |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 906 .work_area() | 930 .work_area() |
| 907 .height(); | 931 .height(); |
| 908 if (work_area_height > 0) { | 932 if (work_area_height > 0) { |
| 909 UMA_HISTOGRAM_CUSTOM_COUNTS( | 933 UMA_HISTOGRAM_CUSTOM_COUNTS( |
| 910 "Ash.SystemMenu.PercentageOfWorkAreaHeightCoveredByMenu", | 934 "Ash.SystemMenu.PercentageOfWorkAreaHeightCoveredByMenu", |
| 911 100 * bubble_view->height() / work_area_height, 1, 300, 100); | 935 100 * bubble_view->height() / work_area_height, 1, 300, 100); |
| 912 } | 936 } |
| 913 } | 937 } |
| 914 | 938 |
| 915 } // namespace ash | 939 } // namespace ash |
| OLD | NEW |