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