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/tray/system_tray.h" | 5 #include "ash/system/tray/system_tray.h" |
6 | 6 |
7 #include "ash/ash_switches.h" | 7 #include "ash/ash_switches.h" |
8 #include "ash/metrics/user_metrics_recorder.h" | 8 #include "ash/metrics/user_metrics_recorder.h" |
9 #include "ash/shelf/shelf_layout_manager.h" | 9 #include "ash/shelf/shelf_layout_manager.h" |
10 #include "ash/shell.h" | 10 #include "ash/shell.h" |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 void InitView(TrayBackgroundView* tray, | 87 void InitView(TrayBackgroundView* tray, |
88 views::View* anchor, | 88 views::View* anchor, |
89 TrayBubbleView::InitParams* init_params, | 89 TrayBubbleView::InitParams* init_params, |
90 bool is_persistent) { | 90 bool is_persistent) { |
91 DCHECK(anchor); | 91 DCHECK(anchor); |
92 user::LoginStatus login_status = | 92 user::LoginStatus login_status = |
93 Shell::GetInstance()->system_tray_delegate()->GetUserLoginStatus(); | 93 Shell::GetInstance()->system_tray_delegate()->GetUserLoginStatus(); |
94 bubble_->InitView(anchor, login_status, init_params); | 94 bubble_->InitView(anchor, login_status, init_params); |
95 bubble_wrapper_.reset( | 95 bubble_wrapper_.reset( |
96 new internal::TrayBubbleWrapper(tray, bubble_->bubble_view())); | 96 new internal::TrayBubbleWrapper(tray, bubble_->bubble_view())); |
97 // The system bubble should not have an arrow. | 97 if (ash::switches::UseAlternateShelfLayout()) { |
98 bubble_->bubble_view()->SetArrowPaintType( | 98 // The system bubble should not have an arrow. |
99 views::BubbleBorder::PAINT_NONE); | 99 bubble_->bubble_view()->SetArrowPaintType( |
| 100 views::BubbleBorder::PAINT_NONE); |
| 101 } |
100 is_persistent_ = is_persistent; | 102 is_persistent_ = is_persistent; |
101 | 103 |
102 // If ChromeVox is enabled, focus the default item if no item is focused. | 104 // If ChromeVox is enabled, focus the default item if no item is focused. |
103 if (Shell::GetInstance()->accessibility_delegate()-> | 105 if (Shell::GetInstance()->accessibility_delegate()-> |
104 IsSpokenFeedbackEnabled()) { | 106 IsSpokenFeedbackEnabled()) { |
105 bubble_->FocusDefaultIfNeeded(); | 107 bubble_->FocusDefaultIfNeeded(); |
106 } | 108 } |
107 } | 109 } |
108 | 110 |
109 // Convenience accessors: | 111 // Convenience accessors: |
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
467 full_system_tray_menu_ = items.size() > 1; | 469 full_system_tray_menu_ = items.size() > 1; |
468 // The menu width is fixed, and it is a per language setting. | 470 // The menu width is fixed, and it is a per language setting. |
469 int menu_width = std::max(kMinimumSystemTrayMenuWidth, | 471 int menu_width = std::max(kMinimumSystemTrayMenuWidth, |
470 Shell::GetInstance()->system_tray_delegate()->GetSystemTrayMenuWidth()); | 472 Shell::GetInstance()->system_tray_delegate()->GetSystemTrayMenuWidth()); |
471 | 473 |
472 TrayBubbleView::InitParams init_params(TrayBubbleView::ANCHOR_TYPE_TRAY, | 474 TrayBubbleView::InitParams init_params(TrayBubbleView::ANCHOR_TYPE_TRAY, |
473 GetAnchorAlignment(), | 475 GetAnchorAlignment(), |
474 menu_width, | 476 menu_width, |
475 kTrayPopupMaxWidth); | 477 kTrayPopupMaxWidth); |
476 init_params.can_activate = can_activate; | 478 init_params.can_activate = can_activate; |
477 init_params.first_item_has_no_margin = true; | 479 init_params.first_item_has_no_margin = |
| 480 ash::switches::UseAlternateShelfLayout(); |
478 if (detailed) { | 481 if (detailed) { |
479 // This is the case where a volume control or brightness control bubble | 482 // This is the case where a volume control or brightness control bubble |
480 // is created. | 483 // is created. |
481 init_params.max_height = default_bubble_height_; | 484 init_params.max_height = default_bubble_height_; |
482 init_params.arrow_color = kBackgroundColor; | 485 init_params.arrow_color = kBackgroundColor; |
483 } else { | 486 } else { |
484 init_params.arrow_color = kHeaderBackgroundColor; | 487 init_params.arrow_color = kHeaderBackgroundColor; |
485 } | 488 } |
486 init_params.arrow_offset = arrow_offset; | 489 init_params.arrow_offset = arrow_offset; |
487 if (bubble_type == SystemTrayBubble::BUBBLE_TYPE_DEFAULT) | 490 if (bubble_type == SystemTrayBubble::BUBBLE_TYPE_DEFAULT) |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
538 anchor = system_bubble_->bubble_view(); | 541 anchor = system_bubble_->bubble_view(); |
539 anchor_type = TrayBubbleView::ANCHOR_TYPE_BUBBLE; | 542 anchor_type = TrayBubbleView::ANCHOR_TYPE_BUBBLE; |
540 } else { | 543 } else { |
541 anchor = tray_container(); | 544 anchor = tray_container(); |
542 anchor_type = TrayBubbleView::ANCHOR_TYPE_TRAY; | 545 anchor_type = TrayBubbleView::ANCHOR_TYPE_TRAY; |
543 } | 546 } |
544 TrayBubbleView::InitParams init_params(anchor_type, | 547 TrayBubbleView::InitParams init_params(anchor_type, |
545 GetAnchorAlignment(), | 548 GetAnchorAlignment(), |
546 kTrayPopupMinWidth, | 549 kTrayPopupMinWidth, |
547 kTrayPopupMaxWidth); | 550 kTrayPopupMaxWidth); |
548 init_params.first_item_has_no_margin = true; | 551 init_params.first_item_has_no_margin = |
| 552 ash::switches::UseAlternateShelfLayout(); |
549 init_params.arrow_color = kBackgroundColor; | 553 init_params.arrow_color = kBackgroundColor; |
550 init_params.arrow_offset = GetTrayXOffset(notification_items_[0]); | 554 init_params.arrow_offset = GetTrayXOffset(notification_items_[0]); |
551 notification_bubble_.reset( | 555 notification_bubble_.reset( |
552 new internal::SystemBubbleWrapper(notification_bubble)); | 556 new internal::SystemBubbleWrapper(notification_bubble)); |
553 notification_bubble_->InitView(this, anchor, &init_params, false); | 557 notification_bubble_->InitView(this, anchor, &init_params, false); |
554 | 558 |
555 if (notification_bubble->bubble_view()->child_count() == 0) { | 559 if (notification_bubble->bubble_view()->child_count() == 0) { |
556 // It is possible that none of the items generated actual notifications. | 560 // It is possible that none of the items generated actual notifications. |
557 DestroyNotificationBubble(); | 561 DestroyNotificationBubble(); |
558 return; | 562 return; |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
706 system_bubble_.reset(); | 710 system_bubble_.reset(); |
707 // When closing a system bubble with the alternate shelf layout, we need to | 711 // When closing a system bubble with the alternate shelf layout, we need to |
708 // turn off the active tinting of the shelf. | 712 // turn off the active tinting of the shelf. |
709 if (full_system_tray_menu_) { | 713 if (full_system_tray_menu_) { |
710 SetDrawBackgroundAsActive(false); | 714 SetDrawBackgroundAsActive(false); |
711 full_system_tray_menu_ = false; | 715 full_system_tray_menu_ = false; |
712 } | 716 } |
713 } | 717 } |
714 | 718 |
715 } // namespace ash | 719 } // namespace ash |
OLD | NEW |