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

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

Issue 12668009: Revert 188217 "Switch Windows to use the MessagePopupCollection" (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: 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 | Annotate | Revision Log
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_collection.h" 28 #include "ui/message_center/views/message_popup_bubble.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 popup_collection_.reset( 123 scoped_ptr<message_center::MessagePopupBubble> bubble(
124 new message_center::MessagePopupCollection(NULL, message_center())); 124 new message_center::MessagePopupBubble(message_center()));
125 popup_bubble_.reset(new internal::NotificationBubbleWrapperWin(
126 this,
127 bubble.Pass(),
128 internal::NotificationBubbleWrapperWin::BUBBLE_TYPE_POPUP));
125 return true; 129 return true;
126 } 130 }
127 131
128 void WebNotificationTrayWin::HidePopups() { 132 void WebNotificationTrayWin::HidePopups() {
129 popup_collection_.reset(); 133 popup_bubble_.reset();
130 } 134 }
131 135
132 bool WebNotificationTrayWin::ShowMessageCenter() { 136 bool WebNotificationTrayWin::ShowMessageCenter() {
133 scoped_ptr<message_center::MessageCenterBubble> bubble( 137 scoped_ptr<message_center::MessageCenterBubble> bubble(
134 new message_center::MessageCenterBubble(message_center())); 138 new message_center::MessageCenterBubble(message_center()));
135 gfx::Screen* screen = gfx::Screen::GetNativeScreen(); 139 gfx::Screen* screen = gfx::Screen::GetNativeScreen();
136 gfx::Rect work_area = screen->GetPrimaryDisplay().work_area(); 140 gfx::Rect work_area = screen->GetPrimaryDisplay().work_area();
137 views::TrayBubbleView::AnchorAlignment alignment = GetAnchorAlignment(); 141 views::TrayBubbleView::AnchorAlignment alignment = GetAnchorAlignment();
138 142
139 int max_height = work_area.height(); 143 int max_height = work_area.height();
(...skipping 26 matching lines...) Expand all
166 void WebNotificationTrayWin::HideMessageCenter() { 170 void WebNotificationTrayWin::HideMessageCenter() {
167 message_center_bubble_.reset(); 171 message_center_bubble_.reset();
168 } 172 }
169 173
170 void WebNotificationTrayWin::UpdateMessageCenter() { 174 void WebNotificationTrayWin::UpdateMessageCenter() {
171 if (message_center_bubble_.get()) 175 if (message_center_bubble_.get())
172 message_center_bubble_->bubble()->ScheduleUpdate(); 176 message_center_bubble_->bubble()->ScheduleUpdate();
173 } 177 }
174 178
175 void WebNotificationTrayWin::UpdatePopups() { 179 void WebNotificationTrayWin::UpdatePopups() {
176 if (popup_collection_.get()) 180 if (popup_bubble_.get())
177 popup_collection_->UpdatePopups(); 181 popup_bubble_->bubble()->ScheduleUpdate();
178 }; 182 };
179 183
180 void WebNotificationTrayWin::OnMessageCenterTrayChanged() { 184 void WebNotificationTrayWin::OnMessageCenterTrayChanged() {
181 UpdateStatusIcon(); 185 UpdateStatusIcon();
182 } 186 }
183 187
184 gfx::Rect WebNotificationTrayWin::GetMessageCenterAnchor() { 188 gfx::Rect WebNotificationTrayWin::GetMessageCenterAnchor() {
185 return GetMouseAnchorRect(mouse_click_point_); 189 return GetMouseAnchorRect(mouse_click_point_);
186 } 190 }
187 191
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 gfx::Screen* screen = gfx::Screen::GetNativeScreen(); 237 gfx::Screen* screen = gfx::Screen::GetNativeScreen();
234 mouse_click_point_ = screen->GetCursorScreenPoint(); 238 mouse_click_point_ = screen->GetCursorScreenPoint();
235 message_center_tray_->ToggleMessageCenterBubble(); 239 message_center_tray_->ToggleMessageCenterBubble();
236 } 240 }
237 241
238 void WebNotificationTrayWin::HideBubbleWithView( 242 void WebNotificationTrayWin::HideBubbleWithView(
239 const views::TrayBubbleView* bubble_view) { 243 const views::TrayBubbleView* bubble_view) {
240 if (message_center_bubble_.get() && 244 if (message_center_bubble_.get() &&
241 bubble_view == message_center_bubble_->bubble_view()) { 245 bubble_view == message_center_bubble_->bubble_view()) {
242 message_center_tray_->HideMessageCenterBubble(); 246 message_center_tray_->HideMessageCenterBubble();
247 } else if (popup_bubble_.get() &&
248 bubble_view == popup_bubble_->bubble_view()) {
249 message_center_tray_->HidePopupBubble();
243 } 250 }
244 } 251 }
245 252
246 void WebNotificationTrayWin::AddQuietModeMenu(StatusIcon* status_icon) { 253 void WebNotificationTrayWin::AddQuietModeMenu(StatusIcon* status_icon) {
247 DCHECK(status_icon); 254 DCHECK(status_icon);
248 status_icon->SetContextMenu(message_center_tray_->CreateQuietModeMenu()); 255 status_icon->SetContextMenu(message_center_tray_->CreateQuietModeMenu());
249 } 256 }
250 257
251 message_center::MessageCenterBubble* 258 message_center::MessageCenterBubble*
252 WebNotificationTrayWin::GetMessageCenterBubbleForTest() { 259 WebNotificationTrayWin::GetMessageCenterBubbleForTest() {
253 if (!message_center_bubble_.get()) 260 if (!message_center_bubble_.get())
254 return NULL; 261 return NULL;
255 return static_cast<message_center::MessageCenterBubble*>( 262 return static_cast<message_center::MessageCenterBubble*>(
256 message_center_bubble_->bubble()); 263 message_center_bubble_->bubble());
257 } 264 }
258 265
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
259 } // namespace message_center 274 } // namespace message_center
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698