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

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

Issue 12667018: Switch Windows to use the MessagePopupCollection (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Rebase. Created 7 years, 9 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
« no previous file with comments | « ui/message_center/message_center.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/timer.h" 10 #include "base/timer.h"
(...skipping 29 matching lines...) Expand all
40 int seconds = kAutocloseDefaultDelaySeconds; 40 int seconds = kAutocloseDefaultDelaySeconds;
41 if (notification->priority() > DEFAULT_PRIORITY) 41 if (notification->priority() > DEFAULT_PRIORITY)
42 seconds = kAutocloseHighPriorityDelaySeconds; 42 seconds = kAutocloseHighPriorityDelaySeconds;
43 delay_ = base::TimeDelta::FromSeconds(seconds); 43 delay_ = base::TimeDelta::FromSeconds(seconds);
44 } 44 }
45 45
46 views::Widget* CreateWidget(gfx::NativeView context) { 46 views::Widget* CreateWidget(gfx::NativeView context) {
47 views::Widget::InitParams params( 47 views::Widget::InitParams params(
48 views::Widget::InitParams::TYPE_WINDOW_FRAMELESS); 48 views::Widget::InitParams::TYPE_WINDOW_FRAMELESS);
49 params.keep_on_top = true; 49 params.keep_on_top = true;
50 params.context = context; 50 if (context)
51 params.context = context;
52 else
53 params.top_level = true;
51 params.transparent = true; 54 params.transparent = true;
52 // The origin of the initial bounds are set to (0, 0). It'll then moved by 55 // The origin of the initial bounds are set to (0, 0). It'll then moved by
53 // MessagePopupCollection. 56 // MessagePopupCollection.
54 params.bounds = gfx::Rect( 57 params.bounds = gfx::Rect(
55 gfx::Size(kWebNotificationWidth, 58 gfx::Size(kWebNotificationWidth,
56 GetHeightForWidth(kWebNotificationWidth))); 59 GetHeightForWidth(kWebNotificationWidth)));
57 params.delegate = this; 60 params.delegate = this;
58 views::Widget* widget = new views::Widget(); 61 views::Widget* widget = new views::Widget();
59 widget->set_focus_on_creation(false); 62 widget->set_focus_on_creation(false);
60 widget->Init(params); 63 widget->Init(params);
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 143
141 void MessagePopupCollection::UpdatePopups() { 144 void MessagePopupCollection::UpdatePopups() {
142 NotificationList::PopupNotifications popups = 145 NotificationList::PopupNotifications popups =
143 message_center_->notification_list()->GetPopupNotifications(); 146 message_center_->notification_list()->GetPopupNotifications();
144 147
145 if (popups.empty()) { 148 if (popups.empty()) {
146 CloseAllWidgets(); 149 CloseAllWidgets();
147 return; 150 return;
148 } 151 }
149 152
150 gfx::Screen* screen = gfx::Screen::GetScreenFor(context_); 153 gfx::Rect work_area;
151 gfx::Rect work_area = screen->GetDisplayNearestWindow(context_).work_area(); 154 if (!context_) {
155 // On Win+Aura, we don't have a context since the popups currently show up
156 // on the Windows desktop, not in the Aura/Ash desktop. This code will
157 // display the popups on the primary display.
158 gfx::Screen* screen = gfx::Screen::GetNativeScreen();
159 work_area = screen->GetPrimaryDisplay().work_area();
160 } else {
161 gfx::Screen* screen = gfx::Screen::GetScreenFor(context_);
162 work_area = screen->GetDisplayNearestWindow(context_).work_area();
163 }
152 164
153 std::set<std::string> old_toast_ids; 165 std::set<std::string> old_toast_ids;
154 for (ToastContainer::iterator iter = toasts_.begin(); iter != toasts_.end(); 166 for (ToastContainer::iterator iter = toasts_.begin(); iter != toasts_.end();
155 ++iter) { 167 ++iter) {
156 old_toast_ids.insert(iter->first); 168 old_toast_ids.insert(iter->first);
157 } 169 }
158 170
159 int bottom = work_area.bottom() - kMarginBetweenItems; 171 int bottom = work_area.bottom() - kMarginBetweenItems;
160 int left = work_area.right() - kWebNotificationWidth - kMarginBetweenItems; 172 int left = work_area.right() - kWebNotificationWidth - kMarginBetweenItems;
161 // Iterate in the reverse order to keep the oldest toasts on screen. Newer 173 // Iterate in the reverse order to keep the oldest toasts on screen. Newer
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 message_center_->notification_list()->MarkSinglePopupAsShown( 259 message_center_->notification_list()->MarkSinglePopupAsShown(
248 iter->first, false); 260 iter->first, false);
249 toasts_.erase(iter); 261 toasts_.erase(iter);
250 break; 262 break;
251 } 263 }
252 } 264 }
253 UpdatePopups(); 265 UpdatePopups();
254 } 266 }
255 267
256 } // namespace message_center 268 } // namespace message_center
OLDNEW
« no previous file with comments | « ui/message_center/message_center.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698