Chromium Code Reviews| Index: ash/system/tray/system_tray_bubble.cc |
| diff --git a/ash/system/tray/system_tray_bubble.cc b/ash/system/tray/system_tray_bubble.cc |
| index c45f608ea5ca006229d7e5061beca8f9a6dd2a02..e5d43bcf9a8293376704781a600bb680a6beffe7 100644 |
| --- a/ash/system/tray/system_tray_bubble.cc |
| +++ b/ash/system/tray/system_tray_bubble.cc |
| @@ -9,7 +9,6 @@ |
| #include "ash/system/tray/system_tray_delegate.h" |
| #include "ash/system/tray/system_tray_item.h" |
| #include "ash/system/tray/tray_constants.h" |
| -#include "ash/wm/window_animations.h" |
| #include "base/message_loop.h" |
| #include "ui/aura/window.h" |
| #include "ui/compositor/layer.h" |
| @@ -23,8 +22,6 @@ namespace ash { |
| namespace { |
| -const int kAnimationDurationForPopupMS = 200; |
| - |
| // Normally a detailed view is the same size as the default view. However, |
| // when showing a detailed view directly (e.g. clicking on a notification), |
| // we may not know the height of the default view, or the default view may |
| @@ -158,18 +155,6 @@ class AnimationObserverDeleteLayer : public ui::ImplicitAnimationObserver { |
| namespace internal { |
| -// SystemTrayBubble::InitParams |
| -SystemTrayBubble::InitParams::InitParams( |
| - SystemTrayBubble::AnchorType anchor_type, |
| - ShelfAlignment shelf_alignment) |
| - : anchor(NULL), |
| - anchor_type(anchor_type), |
| - can_activate(false), |
| - login_status(ash::user::LOGGED_IN_NONE), |
| - arrow_offset(0), |
| - max_height(0) { |
| -} |
| - |
| // SystemTrayBubble |
| SystemTrayBubble::SystemTrayBubble( |
| @@ -181,7 +166,6 @@ SystemTrayBubble::SystemTrayBubble( |
| bubble_widget_(NULL), |
| items_(items), |
| bubble_type_(bubble_type), |
| - anchor_type_(ANCHOR_TYPE_TRAY), |
| autoclose_delay_(0) { |
| } |
| @@ -286,60 +270,28 @@ void SystemTrayBubble::UpdateView( |
| } |
| } |
| -void SystemTrayBubble::InitView(const InitParams& init_params) { |
| +void SystemTrayBubble::InitView(views::View* anchor, |
| + TrayBubbleView::InitParams init_params, |
| + user::LoginStatus login_status) { |
| DCHECK(bubble_view_ == NULL); |
| - anchor_type_ = init_params.anchor_type; |
| - views::BubbleBorder::ArrowLocation arrow_location; |
| - if (anchor_type_ == ANCHOR_TYPE_TRAY) { |
| - if (tray_->shelf_alignment() == SHELF_ALIGNMENT_BOTTOM) { |
| - arrow_location = base::i18n::IsRTL() ? |
| - views::BubbleBorder::BOTTOM_LEFT : |
| - views::BubbleBorder::BOTTOM_RIGHT; |
| - } else if (tray_->shelf_alignment() == SHELF_ALIGNMENT_LEFT) { |
| - arrow_location = views::BubbleBorder::LEFT_BOTTOM; |
| - } else { |
| - arrow_location = views::BubbleBorder::RIGHT_BOTTOM; |
| - } |
| - } else { |
| - arrow_location = views::BubbleBorder::NONE; |
| + |
| + if (bubble_type_ == BUBBLE_TYPE_DETAILED && |
| + init_params.max_height < kDetailedBubbleMaxHeight) { |
| + init_params.max_height = kDetailedBubbleMaxHeight; |
|
jennyz
2012/07/31 02:29:47
I don't see bubble_view_ called SetMaxHeight(init_
stevenjb
2012/07/31 16:35:28
It still gets called from SystemTrayBubble::Update
|
| } |
| - bubble_view_ = new TrayBubbleView( |
| - init_params.anchor, arrow_location, |
| - this, init_params.can_activate, kTrayPopupWidth); |
| + |
| + bubble_view_ = TrayBubbleView::Create(anchor, this, init_params); |
| + |
| if (bubble_type_ == BUBBLE_TYPE_NOTIFICATION) |
| bubble_view_->set_close_on_deactivate(false); |
| - int max_height = init_params.max_height; |
| - if (bubble_type_ == BUBBLE_TYPE_DETAILED && |
| - max_height < kDetailedBubbleMaxHeight) |
| - max_height = kDetailedBubbleMaxHeight; |
| - bubble_view_->SetMaxHeight(max_height); |
| - CreateItemViews(init_params.login_status); |
| + CreateItemViews(login_status); |
| DCHECK(bubble_widget_ == NULL); |
| bubble_widget_ = views::BubbleDelegateView::CreateBubble(bubble_view_); |
| - |
| - // Must occur after call to CreateBubble() |
| - bubble_view_->SetAlignment(views::BubbleBorder::ALIGN_EDGE_TO_ANCHOR_EDGE); |
| - bubble_widget_->non_client_view()->frame_view()->set_background(NULL); |
| - bubble_view_->SetBubbleBorder(init_params.arrow_offset); |
| - |
| bubble_widget_->AddObserver(this); |
| - // Setup animation. |
| - ash::SetWindowVisibilityAnimationType( |
| - bubble_widget_->GetNativeWindow(), |
| - ash::WINDOW_VISIBILITY_ANIMATION_TYPE_FADE); |
| - ash::SetWindowVisibilityAnimationTransition( |
| - bubble_widget_->GetNativeWindow(), |
| - ash::ANIMATE_BOTH); |
| - ash::SetWindowVisibilityAnimationDuration( |
| - bubble_widget_->GetNativeWindow(), |
| - base::TimeDelta::FromMilliseconds(kAnimationDurationForPopupMS)); |
| - |
| - InitializeHost(bubble_widget_, tray_); |
| - |
| - bubble_view_->Show(); |
| + InitializeAndShowBubble(bubble_widget_, bubble_view_, tray_); |
| } |
| void SystemTrayBubble::BubbleViewDestroyed() { |
| @@ -347,40 +299,6 @@ void SystemTrayBubble::BubbleViewDestroyed() { |
| bubble_view_ = NULL; |
| } |
| -gfx::Rect SystemTrayBubble::GetAnchorRect() const { |
| - gfx::Rect rect; |
| - views::Widget* widget = bubble_view()->anchor_widget(); |
| - if (widget->IsVisible()) { |
| - rect = widget->GetWindowBoundsInScreen(); |
| - if (anchor_type_ == ANCHOR_TYPE_TRAY) { |
| - if (tray_->shelf_alignment() == SHELF_ALIGNMENT_BOTTOM) { |
| - rect.Inset( |
| - base::i18n::IsRTL() ? |
| - kPaddingFromRightEdgeOfScreenBottomAlignment : 0, |
| - 0, |
| - base::i18n::IsRTL() ? |
| - 0 : kPaddingFromRightEdgeOfScreenBottomAlignment, |
| - kPaddingFromBottomOfScreenBottomAlignment); |
| - } else if (tray_->shelf_alignment() == SHELF_ALIGNMENT_LEFT) { |
| - rect.Inset(0, 0, kPaddingFromInnerEdgeOfLauncherVerticalAlignment, |
| - kPaddingFromBottomOfScreenVerticalAlignment); |
| - } else { |
| - rect.Inset(kPaddingFromInnerEdgeOfLauncherVerticalAlignment, |
| - 0, 0, kPaddingFromBottomOfScreenVerticalAlignment); |
| - } |
| - } else if (anchor_type_ == ANCHOR_TYPE_BUBBLE) { |
| - // For notification bubble to be anchored with uber tray bubble, |
| - // the anchor can include arrow on left or right, which should |
| - // be deducted out from the anchor rect. |
| - views::View* anchor_view = bubble_view()->anchor_view(); |
| - rect = anchor_view->GetBoundsInScreen(); |
| - gfx::Insets insets = anchor_view->GetInsets(); |
| - rect.Inset(insets); |
| - } |
| - } |
| - return rect; |
| -} |
| - |
| void SystemTrayBubble::OnMouseEnteredView() { |
| StopAutoCloseTimer(); |
| } |