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

Side by Side Diff: chrome/browser/ui/views/message_center/web_notification_tray_win.cc

Issue 12667018: Switch Windows to use the MessagePopupCollection (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Better comments. 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
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 "chrome/browser/ui/views/message_center/web_notification_tray_win.h" 5 #include "chrome/browser/ui/views/message_center/web_notification_tray_win.h"
6 6
7 #include "base/i18n/number_formatting.h" 7 #include "base/i18n/number_formatting.h"
8 #include "base/string16.h" 8 #include "base/string16.h"
9 #include "base/utf_string_conversions.h" 9 #include "base/utf_string_conversions.h"
10 #include "chrome/browser/browser_process.h" 10 #include "chrome/browser/browser_process.h"
11 #include "chrome/browser/status_icons/status_icon.h" 11 #include "chrome/browser/status_icons/status_icon.h"
12 #include "chrome/browser/status_icons/status_tray.h" 12 #include "chrome/browser/status_icons/status_tray.h"
13 #include "chrome/browser/ui/views/message_center/notification_bubble_wrapper_win .h" 13 #include "chrome/browser/ui/views/message_center/notification_bubble_wrapper_win .h"
14 #include "chrome/browser/ui/views/status_icons/status_icon_win.h" 14 #include "chrome/browser/ui/views/status_icons/status_icon_win.h"
15 #include "grit/chromium_strings.h" 15 #include "grit/chromium_strings.h"
16 #include "grit/theme_resources.h" 16 #include "grit/theme_resources.h"
17 #include "grit/ui_strings.h" 17 #include "grit/ui_strings.h"
18 #include "ui/base/l10n/l10n_util.h" 18 #include "ui/base/l10n/l10n_util.h"
19 #include "ui/base/models/simple_menu_model.h" 19 #include "ui/base/models/simple_menu_model.h"
20 #include "ui/base/resource/resource_bundle.h" 20 #include "ui/base/resource/resource_bundle.h"
21 #include "ui/base/win/hwnd_util.h" 21 #include "ui/base/win/hwnd_util.h"
22 #include "ui/gfx/image/image_skia_operations.h" 22 #include "ui/gfx/image/image_skia_operations.h"
23 #include "ui/gfx/screen.h" 23 #include "ui/gfx/screen.h"
24 #include "ui/message_center/message_center_tray.h" 24 #include "ui/message_center/message_center_tray.h"
25 #include "ui/message_center/message_center_tray_delegate.h" 25 #include "ui/message_center/message_center_tray_delegate.h"
26 #include "ui/message_center/views/message_bubble_base.h" 26 #include "ui/message_center/views/message_bubble_base.h"
27 #include "ui/message_center/views/message_center_bubble.h" 27 #include "ui/message_center/views/message_center_bubble.h"
28 #include "ui/message_center/views/message_popup_bubble.h" 28 #include "ui/message_center/views/message_popup_collection.h"
29 #include "ui/views/widget/widget.h" 29 #include "ui/views/widget/widget.h"
30 30
31 namespace { 31 namespace {
32 32
33 // Tray constants 33 // Tray constants
34 const int kScreenEdgePadding = 2; 34 const int kScreenEdgePadding = 2;
35 35
36 gfx::Rect GetCornerAnchorRect() { 36 gfx::Rect GetCornerAnchorRect() {
37 // TODO(dewittj): Use the preference to determine which corner to anchor from. 37 // TODO(dewittj): Use the preference to determine which corner to anchor from.
38 gfx::Screen* screen = gfx::Screen::GetNativeScreen(); 38 gfx::Screen* screen = gfx::Screen::GetNativeScreen();
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 StatusTray* status_tray = g_browser_process->status_tray(); 113 StatusTray* status_tray = g_browser_process->status_tray();
114 status_tray->RemoveStatusIcon(status_icon_); 114 status_tray->RemoveStatusIcon(status_icon_);
115 status_icon_ = NULL; 115 status_icon_ = NULL;
116 } 116 }
117 117
118 message_center::MessageCenter* WebNotificationTrayWin::message_center() { 118 message_center::MessageCenter* WebNotificationTrayWin::message_center() {
119 return message_center_tray_->message_center(); 119 return message_center_tray_->message_center();
120 } 120 }
121 121
122 bool WebNotificationTrayWin::ShowPopups() { 122 bool WebNotificationTrayWin::ShowPopups() {
123 scoped_ptr<message_center::MessagePopupBubble> bubble( 123 popup_collection_.reset(
124 new message_center::MessagePopupBubble(message_center())); 124 new message_center::MessagePopupCollection(NULL, message_center()));
Jun Mukai 2013/03/12 00:49:54 You should specify the first argument, otherwise (
dewittj 2013/03/12 00:57:10 The #ifdef inside mesage_popup_collection.cc preve
Jun Mukai 2013/03/12 01:27:11 Hmm, I still don't get the point why win-aura is s
dewittj 2013/03/13 18:38:16 Elliot's feedback was that the comment is wrong -
125 popup_bubble_.reset(new internal::NotificationBubbleWrapperWin(
126 this,
127 bubble.Pass(),
128 internal::NotificationBubbleWrapperWin::BUBBLE_TYPE_POPUP));
129 return true; 125 return true;
130 } 126 }
131 127
132 void WebNotificationTrayWin::HidePopups() { 128 void WebNotificationTrayWin::HidePopups() {
133 popup_bubble_.reset(); 129 popup_collection_.reset();
134 } 130 }
135 131
136 bool WebNotificationTrayWin::ShowMessageCenter() { 132 bool WebNotificationTrayWin::ShowMessageCenter() {
137 scoped_ptr<message_center::MessageCenterBubble> bubble( 133 scoped_ptr<message_center::MessageCenterBubble> bubble(
138 new message_center::MessageCenterBubble(message_center())); 134 new message_center::MessageCenterBubble(message_center()));
139 gfx::Screen* screen = gfx::Screen::GetNativeScreen(); 135 gfx::Screen* screen = gfx::Screen::GetNativeScreen();
140 gfx::Rect work_area = screen->GetPrimaryDisplay().work_area(); 136 gfx::Rect work_area = screen->GetPrimaryDisplay().work_area();
141 views::TrayBubbleView::AnchorAlignment alignment = GetAnchorAlignment(); 137 views::TrayBubbleView::AnchorAlignment alignment = GetAnchorAlignment();
142 138
143 int max_height = work_area.height(); 139 int max_height = work_area.height();
(...skipping 26 matching lines...) Expand all
170 void WebNotificationTrayWin::HideMessageCenter() { 166 void WebNotificationTrayWin::HideMessageCenter() {
171 message_center_bubble_.reset(); 167 message_center_bubble_.reset();
172 } 168 }
173 169
174 void WebNotificationTrayWin::UpdateMessageCenter() { 170 void WebNotificationTrayWin::UpdateMessageCenter() {
175 if (message_center_bubble_.get()) 171 if (message_center_bubble_.get())
176 message_center_bubble_->bubble()->ScheduleUpdate(); 172 message_center_bubble_->bubble()->ScheduleUpdate();
177 } 173 }
178 174
179 void WebNotificationTrayWin::UpdatePopups() { 175 void WebNotificationTrayWin::UpdatePopups() {
180 if (popup_bubble_.get()) 176 if (popup_collection_.get())
181 popup_bubble_->bubble()->ScheduleUpdate(); 177 popup_collection_->UpdatePopups();
182 }; 178 };
183 179
184 void WebNotificationTrayWin::OnMessageCenterTrayChanged() { 180 void WebNotificationTrayWin::OnMessageCenterTrayChanged() {
185 UpdateStatusIcon(); 181 UpdateStatusIcon();
186 } 182 }
187 183
188 gfx::Rect WebNotificationTrayWin::GetMessageCenterAnchor() { 184 gfx::Rect WebNotificationTrayWin::GetMessageCenterAnchor() {
189 return GetMouseAnchorRect(mouse_click_point_); 185 return GetMouseAnchorRect(mouse_click_point_);
190 } 186 }
191 187
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 gfx::Screen* screen = gfx::Screen::GetNativeScreen(); 233 gfx::Screen* screen = gfx::Screen::GetNativeScreen();
238 mouse_click_point_ = screen->GetCursorScreenPoint(); 234 mouse_click_point_ = screen->GetCursorScreenPoint();
239 message_center_tray_->ToggleMessageCenterBubble(); 235 message_center_tray_->ToggleMessageCenterBubble();
240 } 236 }
241 237
242 void WebNotificationTrayWin::HideBubbleWithView( 238 void WebNotificationTrayWin::HideBubbleWithView(
243 const views::TrayBubbleView* bubble_view) { 239 const views::TrayBubbleView* bubble_view) {
244 if (message_center_bubble_.get() && 240 if (message_center_bubble_.get() &&
245 bubble_view == message_center_bubble_->bubble_view()) { 241 bubble_view == message_center_bubble_->bubble_view()) {
246 message_center_tray_->HideMessageCenterBubble(); 242 message_center_tray_->HideMessageCenterBubble();
247 } else if (popup_bubble_.get() &&
248 bubble_view == popup_bubble_->bubble_view()) {
249 message_center_tray_->HidePopupBubble();
250 } 243 }
251 } 244 }
252 245
253 void WebNotificationTrayWin::AddQuietModeMenu(StatusIcon* status_icon) { 246 void WebNotificationTrayWin::AddQuietModeMenu(StatusIcon* status_icon) {
254 DCHECK(status_icon); 247 DCHECK(status_icon);
255 status_icon->SetContextMenu(message_center_tray_->CreateQuietModeMenu()); 248 status_icon->SetContextMenu(message_center_tray_->CreateQuietModeMenu());
256 } 249 }
257 250
258 message_center::MessageCenterBubble* 251 message_center::MessageCenterBubble*
259 WebNotificationTrayWin::GetMessageCenterBubbleForTest() { 252 WebNotificationTrayWin::GetMessageCenterBubbleForTest() {
260 if (!message_center_bubble_.get()) 253 if (!message_center_bubble_.get())
261 return NULL; 254 return NULL;
262 return static_cast<message_center::MessageCenterBubble*>( 255 return static_cast<message_center::MessageCenterBubble*>(
263 message_center_bubble_->bubble()); 256 message_center_bubble_->bubble());
264 } 257 }
265 258
266 message_center::MessagePopupBubble*
267 WebNotificationTrayWin::GetPopupBubbleForTest() {
268 if (!popup_bubble_.get())
269 return NULL;
270 return static_cast<message_center::MessagePopupBubble*>(
271 popup_bubble_->bubble());
272 }
273
274 } // namespace message_center 259 } // namespace message_center
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698