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

Side by Side Diff: ui/message_center/views/message_popup_collection.cc

Issue 2834773002: Hide popup custom notifications on non-primary displays (Closed)
Patch Set: Created 3 years, 8 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
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 "ui/message_center/views/message_popup_collection.h" 5 #include "ui/message_center/views/message_popup_collection.h"
6 6
7 #include <set> 7 #include <set>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/i18n/rtl.h" 10 #include "base/i18n/rtl.h"
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 166
167 NotificationList::PopupNotifications popups = 167 NotificationList::PopupNotifications popups =
168 message_center_->GetPopupNotifications(); 168 message_center_->GetPopupNotifications();
169 if (popups.empty()) { 169 if (popups.empty()) {
170 CloseAllWidgets(); 170 CloseAllWidgets();
171 return; 171 return;
172 } 172 }
173 173
174 bool top_down = alignment_delegate_->IsTopDown(); 174 bool top_down = alignment_delegate_->IsTopDown();
175 int base = GetBaseLine(toasts_.empty() ? NULL : toasts_.back()); 175 int base = GetBaseLine(toasts_.empty() ? NULL : toasts_.back());
176 #if defined(OS_CHROMEOS)
177 bool isPrimaryDisplay =
178 alignment_delegate_->IsPrimaryDisplayForNotification();
179 #endif
176 180
177 // Iterate in the reverse order to keep the oldest toasts on screen. Newer 181 // Iterate in the reverse order to keep the oldest toasts on screen. Newer
178 // items may be ignored if there are no room to place them. 182 // items may be ignored if there are no room to place them.
179 for (NotificationList::PopupNotifications::const_reverse_iterator iter = 183 for (NotificationList::PopupNotifications::const_reverse_iterator iter =
180 popups.rbegin(); iter != popups.rend(); ++iter) { 184 popups.rbegin(); iter != popups.rend(); ++iter) {
181 if (FindToast((*iter)->id())) 185 if (FindToast((*iter)->id()))
182 continue; 186 continue;
183 187
188 #if defined(OS_CHROMEOS)
189 // Disables popup of custom notification on non-primary displays.
190 // Chrome OS shows popups on all displays but custom notification can be
191 // visible only on one display at the same time.
192 if (!isPrimaryDisplay && (*iter)->type() == NOTIFICATION_TYPE_CUSTOM)
193 continue;
194 #endif
195
184 MessageView* view; 196 MessageView* view;
185 // Create top-level notification. 197 // Create top-level notification.
186 #if defined(OS_CHROMEOS) 198 #if defined(OS_CHROMEOS)
187 if ((*iter)->pinned()) { 199 if ((*iter)->pinned()) {
188 Notification notification = *(*iter); 200 Notification notification = *(*iter);
189 // Override pinned status, since toasts should be closable even when it's 201 // Override pinned status, since toasts should be closable even when it's
190 // pinned. 202 // pinned.
191 notification.set_pinned(false); 203 notification.set_pinned(false);
192 view = MessageViewFactory::Create(NULL, notification, true); 204 view = MessageViewFactory::Create(NULL, notification, true);
193 } else 205 } else
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 if (top_down) 244 if (top_down)
233 base += view_height + kToastMarginY; 245 base += view_height + kToastMarginY;
234 else 246 else
235 base -= view_height + kToastMarginY; 247 base -= view_height + kToastMarginY;
236 248
237 if (views::ViewsDelegate::GetInstance()) { 249 if (views::ViewsDelegate::GetInstance()) {
238 views::ViewsDelegate::GetInstance()->NotifyAccessibilityEvent( 250 views::ViewsDelegate::GetInstance()->NotifyAccessibilityEvent(
239 toast, ui::AX_EVENT_ALERT); 251 toast, ui::AX_EVENT_ALERT);
240 } 252 }
241 253
254 LOG(ERROR) << "POPUP: " << (*iter)->id();
yhanada 2017/04/21 09:02:23 remove?
yoshiki 2017/04/21 09:58:05 Done.
242 message_center_->DisplayedNotification( 255 message_center_->DisplayedNotification(
243 (*iter)->id(), message_center::DISPLAY_SOURCE_POPUP); 256 (*iter)->id(), message_center::DISPLAY_SOURCE_POPUP);
244 } 257 }
245 } 258 }
246 259
247 void MessagePopupCollection::OnMouseEntered(ToastContentsView* toast_entered) { 260 void MessagePopupCollection::OnMouseEntered(ToastContentsView* toast_entered) {
248 // Sometimes we can get two MouseEntered/MouseExited in a row when animating 261 // Sometimes we can get two MouseEntered/MouseExited in a row when animating
249 // toasts. So we need to keep track of which one is the currently active one. 262 // toasts. So we need to keep track of which one is the currently active one.
250 latest_toast_entered_ = toast_entered; 263 latest_toast_entered_ = toast_entered;
251 264
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after
564 views::Widget* widget = (*iter)->GetWidget(); 577 views::Widget* widget = (*iter)->GetWidget();
565 if (widget) 578 if (widget)
566 return widget->GetWindowBoundsInScreen(); 579 return widget->GetWindowBoundsInScreen();
567 break; 580 break;
568 } 581 }
569 } 582 }
570 return gfx::Rect(); 583 return gfx::Rect();
571 } 584 }
572 585
573 } // namespace message_center 586 } // namespace message_center
OLDNEW
« no previous file with comments | « ui/message_center/views/desktop_popup_alignment_delegate.cc ('k') | ui/message_center/views/popup_alignment_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698