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

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

Issue 18247002: Remove the most obvious dead code from message center. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Move MessageCenterButtonBar into cc file to hide implementation. Created 7 years, 5 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/web_notification_tray.h" 5 #include "ash/system/web_notification/web_notification_tray.h"
6 6
7 #include "ash/root_window_controller.h" 7 #include "ash/root_window_controller.h"
8 #include "ash/shelf/shelf_layout_manager.h" 8 #include "ash/shelf/shelf_layout_manager.h"
9 #include "ash/shell.h" 9 #include "ash/shell.h"
10 #include "ash/shell_window_ids.h" 10 #include "ash/shell_window_ids.h"
(...skipping 11 matching lines...) Expand all
22 #include "grit/ui_strings.h" 22 #include "grit/ui_strings.h"
23 #include "ui/aura/root_window.h" 23 #include "ui/aura/root_window.h"
24 #include "ui/aura/window.h" 24 #include "ui/aura/window.h"
25 #include "ui/base/l10n/l10n_util.h" 25 #include "ui/base/l10n/l10n_util.h"
26 #include "ui/base/resource/resource_bundle.h" 26 #include "ui/base/resource/resource_bundle.h"
27 #include "ui/gfx/screen.h" 27 #include "ui/gfx/screen.h"
28 #include "ui/message_center/message_center_tray_delegate.h" 28 #include "ui/message_center/message_center_tray_delegate.h"
29 #include "ui/message_center/message_center_util.h" 29 #include "ui/message_center/message_center_util.h"
30 #include "ui/message_center/views/message_bubble_base.h" 30 #include "ui/message_center/views/message_bubble_base.h"
31 #include "ui/message_center/views/message_center_bubble.h" 31 #include "ui/message_center/views/message_center_bubble.h"
32 #include "ui/message_center/views/message_popup_bubble.h"
33 #include "ui/message_center/views/message_popup_collection.h" 32 #include "ui/message_center/views/message_popup_collection.h"
34 #include "ui/views/bubble/tray_bubble_view.h" 33 #include "ui/views/bubble/tray_bubble_view.h"
35 #include "ui/views/controls/button/custom_button.h" 34 #include "ui/views/controls/button/custom_button.h"
36 #include "ui/views/controls/image_view.h" 35 #include "ui/views/controls/image_view.h"
37 #include "ui/views/controls/label.h" 36 #include "ui/views/controls/label.h"
38 #include "ui/views/controls/menu/menu_runner.h" 37 #include "ui/views/controls/menu/menu_runner.h"
39 38
40 #if defined(OS_CHROMEOS) 39 #if defined(OS_CHROMEOS)
41 40
42 namespace message_center { 41 namespace message_center {
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 SetVisible(false); 184 SetVisible(false);
186 message_center_tray_.reset(new message_center::MessageCenterTray( 185 message_center_tray_.reset(new message_center::MessageCenterTray(
187 this, 186 this,
188 message_center::MessageCenter::Get())); 187 message_center::MessageCenter::Get()));
189 OnMessageCenterTrayChanged(); 188 OnMessageCenterTrayChanged();
190 } 189 }
191 190
192 WebNotificationTray::~WebNotificationTray() { 191 WebNotificationTray::~WebNotificationTray() {
193 // Release any child views that might have back pointers before ~View(). 192 // Release any child views that might have back pointers before ~View().
194 message_center_bubble_.reset(); 193 message_center_bubble_.reset();
195 popup_bubble_.reset();
196 popup_collection_.reset(); 194 popup_collection_.reset();
197 } 195 }
198 196
199 // Public methods. 197 // Public methods.
200 198
201 bool WebNotificationTray::ShowMessageCenterInternal(bool show_settings) { 199 bool WebNotificationTray::ShowMessageCenterInternal(bool show_settings) {
202 if (!ShouldShowMessageCenter()) 200 if (!ShouldShowMessageCenter())
203 return false; 201 return false;
204 202
205 should_block_shelf_auto_hide_ = true; 203 should_block_shelf_auto_hide_ = true;
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
265 else 263 else
266 message_center_tray_->ShowPopupBubble(); 264 message_center_tray_->ShowPopupBubble();
267 } 265 }
268 266
269 bool WebNotificationTray::ShowPopups() { 267 bool WebNotificationTray::ShowPopups() {
270 if (status_area_widget()->login_status() == user::LOGGED_IN_LOCKED || 268 if (status_area_widget()->login_status() == user::LOGGED_IN_LOCKED ||
271 message_center_bubble() || 269 message_center_bubble() ||
272 !status_area_widget()->ShouldShowWebNotifications()) { 270 !status_area_widget()->ShouldShowWebNotifications()) {
273 return false; 271 return false;
274 } 272 }
275 if (message_center::IsRichNotificationEnabled()) { 273
276 // No bubble wrappers here, since |popup_collection_| is not a bubble but a 274 popup_collection_.reset(new message_center::MessagePopupCollection(
277 // collection of widgets. 275 ash::Shell::GetContainer(
278 popup_collection_.reset(new message_center::MessagePopupCollection( 276 GetWidget()->GetNativeView()->GetRootWindow(),
279 ash::Shell::GetContainer( 277 internal::kShellWindowId_StatusContainer),
280 GetWidget()->GetNativeView()->GetRootWindow(), 278 message_center(),
281 internal::kShellWindowId_StatusContainer), 279 message_center_tray_.get()));
282 message_center(), 280
283 message_center_tray_.get()));
284 } else {
285 message_center::MessagePopupBubble* popup_bubble =
286 new message_center::MessagePopupBubble(message_center());
287 popup_bubble_.reset(new internal::WebNotificationBubbleWrapper(
288 this, popup_bubble));
289 }
290 return true; 281 return true;
291 } 282 }
292 283
293 void WebNotificationTray::UpdatePopups() {
294 if (popup_bubble())
295 popup_bubble()->bubble()->ScheduleUpdate();
296 };
297
298 void WebNotificationTray::HidePopups() { 284 void WebNotificationTray::HidePopups() {
299 popup_bubble_.reset();
300 popup_collection_.reset(); 285 popup_collection_.reset();
301 } 286 }
302 287
303 // Private methods. 288 // Private methods.
304 289
305 bool WebNotificationTray::ShouldShowMessageCenter() { 290 bool WebNotificationTray::ShouldShowMessageCenter() {
306 return status_area_widget()->login_status() != user::LOGGED_IN_LOCKED && 291 return status_area_widget()->login_status() != user::LOGGED_IN_LOCKED &&
307 !(status_area_widget()->system_tray() && 292 !(status_area_widget()->system_tray() &&
308 status_area_widget()->system_tray()->HasNotificationBubble()); 293 status_area_widget()->system_tray()->HasNotificationBubble());
309 } 294 }
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
358 bool WebNotificationTray::ShouldBlockLauncherAutoHide() const { 343 bool WebNotificationTray::ShouldBlockLauncherAutoHide() const {
359 return should_block_shelf_auto_hide_; 344 return should_block_shelf_auto_hide_;
360 } 345 }
361 346
362 bool WebNotificationTray::IsMessageCenterBubbleVisible() const { 347 bool WebNotificationTray::IsMessageCenterBubbleVisible() const {
363 return (message_center_bubble() && 348 return (message_center_bubble() &&
364 message_center_bubble()->bubble()->IsVisible()); 349 message_center_bubble()->bubble()->IsVisible());
365 } 350 }
366 351
367 bool WebNotificationTray::IsMouseInNotificationBubble() const { 352 bool WebNotificationTray::IsMouseInNotificationBubble() const {
368 if (!popup_bubble()) 353 return false;
369 return false;
370 return popup_bubble()->bubble_view()->GetBoundsInScreen().Contains(
371 Shell::GetScreen()->GetCursorScreenPoint());
372 } 354 }
373 355
374 void WebNotificationTray::ShowMessageCenterBubble() { 356 void WebNotificationTray::ShowMessageCenterBubble() {
375 if (!IsMessageCenterBubbleVisible()) 357 if (!IsMessageCenterBubbleVisible())
376 message_center_tray_->ShowMessageCenterBubble(); 358 message_center_tray_->ShowMessageCenterBubble();
377 } 359 }
378 360
379 void WebNotificationTray::SetShelfAlignment(ShelfAlignment alignment) { 361 void WebNotificationTray::SetShelfAlignment(ShelfAlignment alignment) {
380 if (alignment == shelf_alignment()) 362 if (alignment == shelf_alignment())
381 return; 363 return;
382 internal::TrayBackgroundView::SetShelfAlignment(alignment); 364 internal::TrayBackgroundView::SetShelfAlignment(alignment);
383 tray_container()->set_border(NULL); 365 tray_container()->set_border(NULL);
384 // Destroy any existing bubble so that it will be rebuilt correctly. 366 // Destroy any existing bubble so that it will be rebuilt correctly.
385 message_center_tray_->HideMessageCenterBubble(); 367 message_center_tray_->HideMessageCenterBubble();
386 message_center_tray_->HidePopupBubble(); 368 message_center_tray_->HidePopupBubble();
387 } 369 }
388 370
389 void WebNotificationTray::AnchorUpdated() { 371 void WebNotificationTray::AnchorUpdated() {
390 if (popup_bubble()) {
391 popup_bubble()->bubble_view()->UpdateBubble();
392 // Ensure that the notification buble is above the launcher/status area.
393 popup_bubble()->bubble_view()->GetWidget()->StackAtTop();
394 UpdateBubbleViewArrow(popup_bubble()->bubble_view());
395 }
396 if (message_center_bubble()) { 372 if (message_center_bubble()) {
397 message_center_bubble()->bubble_view()->UpdateBubble(); 373 message_center_bubble()->bubble_view()->UpdateBubble();
398 UpdateBubbleViewArrow(message_center_bubble()->bubble_view()); 374 UpdateBubbleViewArrow(message_center_bubble()->bubble_view());
399 } 375 }
400 } 376 }
401 377
402 base::string16 WebNotificationTray::GetAccessibleNameForTray() { 378 base::string16 WebNotificationTray::GetAccessibleNameForTray() {
403 return l10n_util::GetStringUTF16( 379 return l10n_util::GetStringUTF16(
404 IDS_MESSAGE_CENTER_ACCESSIBLE_NAME); 380 IDS_MESSAGE_CENTER_ACCESSIBLE_NAME);
405 } 381 }
406 382
407 void WebNotificationTray::HideBubbleWithView( 383 void WebNotificationTray::HideBubbleWithView(
408 const views::TrayBubbleView* bubble_view) { 384 const views::TrayBubbleView* bubble_view) {
409 if (message_center_bubble() && 385 if (message_center_bubble() &&
410 bubble_view == message_center_bubble()->bubble_view()) { 386 bubble_view == message_center_bubble()->bubble_view()) {
411 message_center_tray_->HideMessageCenterBubble(); 387 message_center_tray_->HideMessageCenterBubble();
412 } else if ((popup_bubble() && bubble_view == popup_bubble()->bubble_view()) || 388 } else if (popup_collection_.get()) {
413 popup_collection_.get()) {
414 message_center_tray_->HidePopupBubble(); 389 message_center_tray_->HidePopupBubble();
415 } 390 }
416 } 391 }
417 392
418 bool WebNotificationTray::PerformAction(const ui::Event& event) { 393 bool WebNotificationTray::PerformAction(const ui::Event& event) {
419 if (ShouldShowQuietModeMenu(event)) { 394 if (ShouldShowQuietModeMenu(event)) {
420 ShowQuietModeMenu(event); 395 ShowQuietModeMenu(event);
421 return true; 396 return true;
422 } 397 }
423 398
424 if (message_center_bubble()) 399 if (message_center_bubble())
425 message_center_tray_->HideMessageCenterBubble(); 400 message_center_tray_->HideMessageCenterBubble();
426 else 401 else
427 message_center_tray_->ShowMessageCenterBubble(); 402 message_center_tray_->ShowMessageCenterBubble();
428 return true; 403 return true;
429 } 404 }
430 405
431 void WebNotificationTray::BubbleViewDestroyed() { 406 void WebNotificationTray::BubbleViewDestroyed() {
432 if (message_center_bubble()) 407 if (message_center_bubble())
433 message_center_bubble()->bubble()->BubbleViewDestroyed(); 408 message_center_bubble()->bubble()->BubbleViewDestroyed();
434 if (popup_bubble())
435 popup_bubble()->bubble()->BubbleViewDestroyed();
436 } 409 }
437 410
438 void WebNotificationTray::OnMouseEnteredView() { 411 void WebNotificationTray::OnMouseEnteredView() {}
439 if (popup_bubble())
440 popup_bubble()->bubble()->OnMouseEnteredView();
441 }
442 412
443 void WebNotificationTray::OnMouseExitedView() { 413 void WebNotificationTray::OnMouseExitedView() {}
444 if (popup_bubble())
445 popup_bubble()->bubble()->OnMouseExitedView();
446 }
447 414
448 base::string16 WebNotificationTray::GetAccessibleNameForBubble() { 415 base::string16 WebNotificationTray::GetAccessibleNameForBubble() {
449 return GetAccessibleNameForTray(); 416 return GetAccessibleNameForTray();
450 } 417 }
451 418
452 gfx::Rect WebNotificationTray::GetAnchorRect( 419 gfx::Rect WebNotificationTray::GetAnchorRect(
453 views::Widget* anchor_widget, 420 views::Widget* anchor_widget,
454 views::TrayBubbleView::AnchorType anchor_type, 421 views::TrayBubbleView::AnchorType anchor_type,
455 views::TrayBubbleView::AnchorAlignment anchor_alignment) { 422 views::TrayBubbleView::AnchorAlignment anchor_alignment) {
456 return GetBubbleAnchorRect(anchor_widget, anchor_type, anchor_alignment); 423 return GetBubbleAnchorRect(anchor_widget, anchor_type, anchor_alignment);
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
524 } 491 }
525 492
526 message_center::MessageCenterBubble* 493 message_center::MessageCenterBubble*
527 WebNotificationTray::GetMessageCenterBubbleForTest() { 494 WebNotificationTray::GetMessageCenterBubbleForTest() {
528 if (!message_center_bubble()) 495 if (!message_center_bubble())
529 return NULL; 496 return NULL;
530 return static_cast<message_center::MessageCenterBubble*>( 497 return static_cast<message_center::MessageCenterBubble*>(
531 message_center_bubble()->bubble()); 498 message_center_bubble()->bubble());
532 } 499 }
533 500
534 message_center::MessagePopupBubble*
535 WebNotificationTray::GetPopupBubbleForTest() {
536 if (!popup_bubble())
537 return NULL;
538 return static_cast<message_center::MessagePopupBubble*>(
539 popup_bubble()->bubble());
540 }
541
542 } // namespace ash 501 } // namespace ash
OLDNEW
« no previous file with comments | « ash/system/web_notification/web_notification_tray.h ('k') | ash/system/web_notification/web_notification_tray_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698