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

Side by Side Diff: ash/system/web_notification/popup_bubble.cc

Issue 11028134: Re-factor Ash Message Center code part 2/4 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 2 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/popup_bubble.h" 5 #include "ash/system/web_notification/popup_bubble.h"
6 6
7 #include "ash/system/tray/tray_bubble_view.h" 7 #include "ash/system/tray/tray_bubble_view.h"
8 #include "ash/system/tray/tray_constants.h" 8 #include "ash/system/tray/tray_constants.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 "ui/views/layout/box_layout.h" 12 #include "ui/views/layout/box_layout.h"
13 #include "ui/views/view.h" 13 #include "ui/views/view.h"
14 #include "ui/views/widget/widget.h" 14 #include "ui/views/widget/widget.h"
15 15
16 namespace ash { 16 namespace ash {
17 17
18 using internal::TrayBubbleView;
miket_OOO 2012/10/12 19:53:59 Great!
19
20 namespace message_center { 18 namespace message_center {
21 19
22 const int kAutocloseDelaySeconds = 5; 20 const int kAutocloseDelaySeconds = 5;
23 21
24 // Popup notifications contents. 22 // Popup notifications contents.
25 class PopupBubbleContentsView : public views::View { 23 class PopupBubbleContentsView : public views::View {
26 public: 24 public:
27 explicit PopupBubbleContentsView(WebNotificationTray* tray) 25 explicit PopupBubbleContentsView(WebNotificationTray* tray)
28 : tray_(tray) { 26 : tray_(tray) {
29 SetLayoutManager( 27 SetLayoutManager(
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 PopupBubble::PopupBubble(WebNotificationTray* tray) : 67 PopupBubble::PopupBubble(WebNotificationTray* tray) :
70 WebNotificationBubble(tray), 68 WebNotificationBubble(tray),
71 contents_view_(NULL), 69 contents_view_(NULL),
72 num_popups_(0), 70 num_popups_(0),
73 dirty_(false) { 71 dirty_(false) {
74 TrayBubbleView::InitParams init_params = GetInitParams(); 72 TrayBubbleView::InitParams init_params = GetInitParams();
75 init_params.top_color = kBackgroundColor; 73 init_params.top_color = kBackgroundColor;
76 init_params.arrow_color = kBackgroundColor; 74 init_params.arrow_color = kBackgroundColor;
77 init_params.close_on_deactivate = false; 75 init_params.close_on_deactivate = false;
78 views::View* anchor = tray_->tray_container(); 76 views::View* anchor = tray_->tray_container();
79 bubble_view_ = TrayBubbleView::Create(anchor, this, init_params); 77 bubble_view_ = TrayBubbleView::Create(
78 tray_->GetBubbleWindowContainer(), anchor, this, &init_params);
80 contents_view_ = new PopupBubbleContentsView(tray); 79 contents_view_ = new PopupBubbleContentsView(tray);
81 80
82 Initialize(contents_view_); 81 Initialize(contents_view_);
83 } 82 }
84 83
85 PopupBubble::~PopupBubble() {} 84 PopupBubble::~PopupBubble() {}
86 85
87 size_t PopupBubble::NumMessageViewsForTest() const { 86 size_t PopupBubble::NumMessageViewsForTest() const {
88 return contents_view_->NumMessageViewsForTest(); 87 return contents_view_->NumMessageViewsForTest();
89 } 88 }
(...skipping 10 matching lines...) Expand all
100 99
101 void PopupBubble::OnMouseExitedView() { 100 void PopupBubble::OnMouseExitedView() {
102 StartAutoCloseTimer(); 101 StartAutoCloseTimer();
103 WebNotificationBubble::OnMouseExitedView(); 102 WebNotificationBubble::OnMouseExitedView();
104 } 103 }
105 104
106 void PopupBubble::UpdateBubbleView() { 105 void PopupBubble::UpdateBubbleView() {
107 WebNotificationList::Notifications popup_notifications; 106 WebNotificationList::Notifications popup_notifications;
108 tray_->notification_list()->GetPopupNotifications(&popup_notifications); 107 tray_->notification_list()->GetPopupNotifications(&popup_notifications);
109 if (popup_notifications.size() == 0) { 108 if (popup_notifications.size() == 0) {
110 tray_->HideBubble(this); // deletes |this|! 109 tray_->HideBubble(bubble_view()); // deletes |this|
111 return; 110 return;
112 } 111 }
113 // Only update the popup tray if the number of visible popup notifications 112 // Only update the popup tray if the number of visible popup notifications
114 // has changed. 113 // has changed.
115 if (popup_notifications.size() != num_popups_ || dirty()) { 114 if (popup_notifications.size() != num_popups_ || dirty()) {
116 set_dirty(false); 115 set_dirty(false);
117 num_popups_ = popup_notifications.size(); 116 num_popups_ = popup_notifications.size();
118 contents_view_->Update(popup_notifications); 117 contents_view_->Update(popup_notifications);
119 bubble_view_->Show(); 118 bubble_view_->Show();
120 bubble_view_->UpdateBubble(); 119 bubble_view_->UpdateBubble();
(...skipping 14 matching lines...) Expand all
135 134
136 void PopupBubble::OnAutoClose() { 135 void PopupBubble::OnAutoClose() {
137 tray_->notification_list()->MarkPopupsAsShown(); 136 tray_->notification_list()->MarkPopupsAsShown();
138 num_popups_ = 0; 137 num_popups_ = 0;
139 UpdateBubbleView(); 138 UpdateBubbleView();
140 } 139 }
141 140
142 } // namespace message_center 141 } // namespace message_center
143 142
144 } // namespace ash 143 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698