Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(688)

Unified Diff: ash/system/tray/system_tray_bubble.cc

Issue 10808066: Fix position of web notification bubble and arrow (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Rebase Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ash/system/tray/system_tray_bubble.h ('k') | ash/system/tray/tray_bubble_view.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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;
}
- 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();
}
« no previous file with comments | « ash/system/tray/system_tray_bubble.h ('k') | ash/system/tray/tray_bubble_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698