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

Unified Diff: ash/system/web_notification/web_notification_tray.cc

Issue 10808066: Fix position of web notification bubble and arrow (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: . 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
Index: ash/system/web_notification/web_notification_tray.cc
diff --git a/ash/system/web_notification/web_notification_tray.cc b/ash/system/web_notification/web_notification_tray.cc
index ac0afdc0b0eb60507113252b79ee0dd99478c9da..2fa23e2c4eb838459ea88efe61f09200f8345c14 100644
--- a/ash/system/web_notification/web_notification_tray.cc
+++ b/ash/system/web_notification/web_notification_tray.cc
@@ -42,7 +42,7 @@ const int kNotificationImageIconInset = 4;
// Web Notification Bubble constants
const int kWebNotificationBubbleMinHeight = 80;
-const int kWebNotificationBubbleMaxHeight = 400;
+const int kWebNotificationBubbleMaxHeight = 480;
// Delay laying out the Bubble until all notifications have been added and icons
// have had a chance to load.
const int kUpdateDelayMs = 50;
@@ -50,7 +50,7 @@ const int kUpdateDelayMs = 50;
const int kMaxVisibleNotifications = 100;
// Individual notifications constants
-const int kWebNotificationWidth = 400;
+const int kWebNotificationWidth = 320;
const int kWebNotificationButtonWidth = 32;
const int kWebNotificationIconSize = 40;
@@ -483,6 +483,7 @@ class WebNotificationButtonView : public TrayPopupTextButtonContainer,
} // namespace internal
+using internal::TrayBubbleView;
using internal::WebNotificationList;
using internal::WebNotificationView;
@@ -567,7 +568,7 @@ class WebNotificationTray::BubbleContentsView : public views::View {
DISALLOW_COPY_AND_ASSIGN(BubbleContentsView);
};
-class WebNotificationTray::Bubble : public internal::TrayBubbleView::Host,
+class WebNotificationTray::Bubble : public TrayBubbleView::Host,
public views::Widget::Observer {
public:
explicit Bubble(WebNotificationTray* tray)
@@ -577,32 +578,24 @@ class WebNotificationTray::Bubble : public internal::TrayBubbleView::Host,
contents_view_(NULL),
ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)) {
views::View* anchor = tray->tray_container();
- views::BubbleBorder::ArrowLocation arrow_location;
- int arrow_offset = 0;
+ TrayBubbleView::InitParams init_params(TrayBubbleView::ANCHOR_TYPE_TRAY,
+ tray->shelf_alignment());
+ init_params.bubble_width = kWebNotificationWidth;
+ init_params.max_height = kWebNotificationBubbleMaxHeight;
if (tray_->shelf_alignment() == SHELF_ALIGNMENT_BOTTOM) {
- arrow_location = views::BubbleBorder::BOTTOM_RIGHT;
- arrow_offset = anchor->GetContentsBounds().width() / 2;
- } else if (tray_->shelf_alignment() == SHELF_ALIGNMENT_LEFT) {
- arrow_location = views::BubbleBorder::LEFT_BOTTOM;
- } else {
- arrow_location = views::BubbleBorder::RIGHT_BOTTOM;
+ gfx::Rect bounds(anchor->width() / 2, 0, 0, 0);
+ bounds = anchor->ConvertRectToWidget(bounds);
+ init_params.arrow_offset = bounds.x();
}
- bubble_view_ = new internal::TrayBubbleView(
- anchor, arrow_location, this, false, kWebNotificationWidth);
- bubble_view_->SetMaxHeight(kWebNotificationBubbleMaxHeight);
-
- bubble_widget_ = views::BubbleDelegateView::CreateBubble(bubble_view_);
-
- bubble_view_->SetAlignment(views::BubbleBorder::ALIGN_EDGE_TO_ANCHOR_EDGE);
- bubble_widget_->non_client_view()->frame_view()->set_background(NULL);
- bubble_view_->SetBubbleBorder(arrow_offset);
-
- bubble_widget_->AddObserver(this);
+ bubble_view_ = TrayBubbleView::Create(anchor, this, init_params);
contents_view_ = new BubbleContentsView(tray);
bubble_view_->AddChildView(contents_view_);
- InitializeHost(bubble_widget_, tray_);
+ bubble_widget_ = views::BubbleDelegateView::CreateBubble(bubble_view_);
+ bubble_widget_->AddObserver(this);
+
+ PostCreateBubble(bubble_widget_, bubble_view_, tray_);
ScheduleUpdate();
}
@@ -633,11 +626,6 @@ class WebNotificationTray::Bubble : public internal::TrayBubbleView::Host,
contents_view_ = NULL;
}
- virtual gfx::Rect GetAnchorRect() const OVERRIDE {
- gfx::Rect anchor_rect = tray_->tray_container()->GetBoundsInScreen();
- return anchor_rect;
- }
-
virtual void OnMouseEnteredView() OVERRIDE {
}
@@ -663,7 +651,7 @@ class WebNotificationTray::Bubble : public internal::TrayBubbleView::Host,
}
WebNotificationTray* tray_;
- internal::TrayBubbleView* bubble_view_;
+ TrayBubbleView* bubble_view_;
views::Widget* bubble_widget_;
BubbleContentsView* contents_view_;
base::WeakPtrFactory<Bubble> weak_ptr_factory_;
@@ -818,6 +806,8 @@ void WebNotificationTray::SetShelfAlignment(ShelfAlignment alignment) {
alignment == SHELF_ALIGNMENT_BOTTOM ?
views::BoxLayout::kHorizontal : views::BoxLayout::kVertical,
0, 0, 0));
+ // Destroy any existing bubble so that it will be rebuilt correctly.
+ bubble_.reset();
}
bool WebNotificationTray::PerformAction(const views::Event& event) {

Powered by Google App Engine
This is Rietveld 408576698