| 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/web_notification/message_center_bubble.h" | 5 #include "ash/system/web_notification/message_center_bubble.h" |
| 6 | 6 |
| 7 #include "ash/system/tray/tray_constants.h" | 7 #include "ash/system/tray/tray_constants.h" |
| 8 #include "ash/system/tray/tray_views.h" | 8 #include "ash/system/tray/tray_views.h" |
| 9 #include "ash/system/web_notification/web_notification_list.h" | 9 #include "ash/system/web_notification/web_notification_list.h" |
| 10 #include "ash/system/web_notification/web_notification_tray.h" | 10 #include "ash/system/web_notification/web_notification_tray.h" |
| 11 #include "ash/system/web_notification/web_notification_view.h" | 11 #include "ash/system/web_notification/web_notification_view.h" |
| 12 #include "grit/ash_strings.h" | 12 #include "grit/ash_strings.h" |
| 13 #include "ui/base/l10n/l10n_util.h" | 13 #include "ui/base/l10n/l10n_util.h" |
| 14 #include "ui/base/resource/resource_bundle.h" | 14 #include "ui/base/resource/resource_bundle.h" |
| 15 #include "ui/gfx/size.h" | 15 #include "ui/gfx/size.h" |
| 16 #include "ui/views/controls/label.h" | 16 #include "ui/views/controls/label.h" |
| 17 #include "ui/views/layout/box_layout.h" | 17 #include "ui/views/layout/box_layout.h" |
| 18 #include "ui/views/layout/grid_layout.h" | 18 #include "ui/views/layout/grid_layout.h" |
| 19 #include "ui/views/painter.h" | 19 #include "ui/views/painter.h" |
| 20 #include "ui/views/view.h" | 20 #include "ui/views/view.h" |
| 21 #include "ui/views/widget/widget.h" | 21 #include "ui/views/widget/widget.h" |
| 22 | 22 |
| 23 namespace ash { | 23 namespace ash { |
| 24 | 24 |
| 25 using internal::TrayBubbleView; | |
| 26 using internal::TrayPopupTextButton; | 25 using internal::TrayPopupTextButton; |
| 27 | 26 |
| 28 namespace message_center { | 27 namespace message_center { |
| 29 | 28 |
| 30 // Web Notification Bubble constants | 29 // Web Notification Bubble constants |
| 31 const int kWebNotificationBubbleMinHeight = 80; | 30 const int kWebNotificationBubbleMinHeight = 80; |
| 32 const int kWebNotificationBubbleMaxHeight = 400; | 31 const int kWebNotificationBubbleMaxHeight = 400; |
| 33 | 32 |
| 34 // The view for the buttons at the bottom of the web notification tray. | 33 // The view for the buttons at the bottom of the web notification tray. |
| 35 class WebNotificationButtonView : public views::View, | 34 class WebNotificationButtonView : public views::View, |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 190 }; | 189 }; |
| 191 | 190 |
| 192 // Message Center Bubble. | 191 // Message Center Bubble. |
| 193 MessageCenterBubble::MessageCenterBubble(WebNotificationTray* tray) : | 192 MessageCenterBubble::MessageCenterBubble(WebNotificationTray* tray) : |
| 194 WebNotificationBubble(tray), | 193 WebNotificationBubble(tray), |
| 195 contents_view_(NULL) { | 194 contents_view_(NULL) { |
| 196 TrayBubbleView::InitParams init_params = GetInitParams(); | 195 TrayBubbleView::InitParams init_params = GetInitParams(); |
| 197 init_params.max_height = message_center::kWebNotificationBubbleMaxHeight; | 196 init_params.max_height = message_center::kWebNotificationBubbleMaxHeight; |
| 198 init_params.can_activate = true; | 197 init_params.can_activate = true; |
| 199 views::View* anchor = tray_->tray_container(); | 198 views::View* anchor = tray_->tray_container(); |
| 200 bubble_view_ = TrayBubbleView::Create(anchor, this, init_params); | 199 bubble_view_ = TrayBubbleView::Create( |
| 200 tray_->GetBubbleWindowContainer(), anchor, this, &init_params); |
| 201 contents_view_ = new MessageCenterContentsView(tray); | 201 contents_view_ = new MessageCenterContentsView(tray); |
| 202 | 202 |
| 203 Initialize(contents_view_); | 203 Initialize(contents_view_); |
| 204 } | 204 } |
| 205 | 205 |
| 206 MessageCenterBubble::~MessageCenterBubble() {} | 206 MessageCenterBubble::~MessageCenterBubble() {} |
| 207 | 207 |
| 208 size_t MessageCenterBubble::NumMessageViewsForTest() const { | 208 size_t MessageCenterBubble::NumMessageViewsForTest() const { |
| 209 return contents_view_->NumMessageViewsForTest(); | 209 return contents_view_->NumMessageViewsForTest(); |
| 210 } | 210 } |
| 211 | 211 |
| 212 void MessageCenterBubble::BubbleViewDestroyed() { | 212 void MessageCenterBubble::BubbleViewDestroyed() { |
| 213 contents_view_ = NULL; | 213 contents_view_ = NULL; |
| 214 WebNotificationBubble::BubbleViewDestroyed(); | 214 WebNotificationBubble::BubbleViewDestroyed(); |
| 215 } | 215 } |
| 216 | 216 |
| 217 void MessageCenterBubble::UpdateBubbleView() { | 217 void MessageCenterBubble::UpdateBubbleView() { |
| 218 contents_view_->Update(tray_->notification_list()->notifications()); | 218 contents_view_->Update(tray_->notification_list()->notifications()); |
| 219 bubble_view_->Show(); | 219 bubble_view_->Show(); |
| 220 bubble_view_->UpdateBubble(); | 220 bubble_view_->UpdateBubble(); |
| 221 } | 221 } |
| 222 | 222 |
| 223 void MessageCenterBubble::OnClickedOutsideView() { | |
| 224 // May delete |this|. | |
| 225 tray_->HideMessageCenterBubble(); | |
| 226 } | |
| 227 | |
| 228 } // namespace message_center | 223 } // namespace message_center |
| 229 | 224 |
| 230 } // namespace ash | 225 } // namespace ash |
| OLD | NEW |