| OLD | NEW |
| 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/ash_switches.h" | 7 #include "ash/ash_switches.h" |
| 8 #include "ash/root_window_controller.h" | 8 #include "ash/root_window_controller.h" |
| 9 #include "ash/shelf/shelf_layout_manager.h" | 9 #include "ash/shelf/shelf_layout_manager.h" |
| 10 #include "ash/shelf/shelf_layout_manager_observer.h" | 10 #include "ash/shelf/shelf_layout_manager_observer.h" |
| (...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 298 } | 298 } |
| 299 | 299 |
| 300 void WebNotificationTray::HidePopups() { | 300 void WebNotificationTray::HidePopups() { |
| 301 DCHECK(popup_collection_.get()); | 301 DCHECK(popup_collection_.get()); |
| 302 popup_collection_->MarkAllPopupsShown(); | 302 popup_collection_->MarkAllPopupsShown(); |
| 303 } | 303 } |
| 304 | 304 |
| 305 // Private methods. | 305 // Private methods. |
| 306 | 306 |
| 307 bool WebNotificationTray::ShouldShowMessageCenter() { | 307 bool WebNotificationTray::ShouldShowMessageCenter() { |
| 308 return status_area_widget()->login_status() != user::LOGGED_IN_LOCKED && | 308 return !(status_area_widget()->system_tray() && |
| 309 !(status_area_widget()->system_tray() && | 309 status_area_widget()->system_tray()->HasNotificationBubble()); |
| 310 status_area_widget()->system_tray()->HasNotificationBubble()); | |
| 311 } | 310 } |
| 312 | 311 |
| 313 bool WebNotificationTray::ShouldBlockShelfAutoHide() const { | 312 bool WebNotificationTray::ShouldBlockShelfAutoHide() const { |
| 314 return should_block_shelf_auto_hide_; | 313 return should_block_shelf_auto_hide_; |
| 315 } | 314 } |
| 316 | 315 |
| 317 bool WebNotificationTray::IsMessageCenterBubbleVisible() const { | 316 bool WebNotificationTray::IsMessageCenterBubbleVisible() const { |
| 318 return (message_center_bubble() && | 317 return (message_center_bubble() && |
| 319 message_center_bubble()->bubble()->IsVisible()); | 318 message_center_bubble()->bubble()->IsVisible()); |
| 320 } | 319 } |
| 321 | 320 |
| 322 bool WebNotificationTray::IsMouseInNotificationBubble() const { | 321 bool WebNotificationTray::IsMouseInNotificationBubble() const { |
| 323 return false; | 322 return false; |
| 324 } | 323 } |
| 325 | 324 |
| 326 void WebNotificationTray::ShowMessageCenterBubble() { | 325 void WebNotificationTray::ShowMessageCenterBubble() { |
| 327 if (!IsMessageCenterBubbleVisible()) | 326 if (!IsMessageCenterBubbleVisible()) |
| 328 message_center_tray_->ShowMessageCenterBubble(); | 327 message_center_tray_->ShowMessageCenterBubble(); |
| 329 } | 328 } |
| 330 | 329 |
| 331 void WebNotificationTray::UpdateAfterLoginStatusChange( | 330 void WebNotificationTray::UpdateAfterLoginStatusChange( |
| 332 user::LoginStatus login_status) { | 331 user::LoginStatus login_status) { |
| 332 message_center()->SetLockedState(login_status == user::LOGGED_IN_LOCKED); |
| 333 OnMessageCenterTrayChanged(); | 333 OnMessageCenterTrayChanged(); |
| 334 } | 334 } |
| 335 | 335 |
| 336 void WebNotificationTray::SetShelfAlignment(wm::ShelfAlignment alignment) { | 336 void WebNotificationTray::SetShelfAlignment(wm::ShelfAlignment alignment) { |
| 337 if (alignment == shelf_alignment()) | 337 if (alignment == shelf_alignment()) |
| 338 return; | 338 return; |
| 339 TrayBackgroundView::SetShelfAlignment(alignment); | 339 TrayBackgroundView::SetShelfAlignment(alignment); |
| 340 tray_container()->SetBorder(views::Border::NullBorder()); | 340 tray_container()->SetBorder(views::Border::NullBorder()); |
| 341 // Destroy any existing bubble so that it will be rebuilt correctly. | 341 // Destroy any existing bubble so that it will be rebuilt correctly. |
| 342 message_center_tray_->HideMessageCenterBubble(); | 342 message_center_tray_->HideMessageCenterBubble(); |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 405 } | 405 } |
| 406 return ShowMessageCenterInternal(true /* show_settings */); | 406 return ShowMessageCenterInternal(true /* show_settings */); |
| 407 } | 407 } |
| 408 | 408 |
| 409 bool WebNotificationTray::IsContextMenuEnabled() const { | 409 bool WebNotificationTray::IsContextMenuEnabled() const { |
| 410 user::LoginStatus login_status = status_area_widget()->login_status(); | 410 user::LoginStatus login_status = status_area_widget()->login_status(); |
| 411 bool userAddingRunning = ash::Shell::GetInstance() | 411 bool userAddingRunning = ash::Shell::GetInstance() |
| 412 ->session_state_delegate() | 412 ->session_state_delegate() |
| 413 ->IsInSecondaryLoginScreen(); | 413 ->IsInSecondaryLoginScreen(); |
| 414 | 414 |
| 415 return login_status != user::LOGGED_IN_NONE | 415 return login_status != user::LOGGED_IN_NONE && !userAddingRunning; |
| 416 && login_status != user::LOGGED_IN_LOCKED && !userAddingRunning; | |
| 417 } | 416 } |
| 418 | 417 |
| 419 message_center::MessageCenterTray* WebNotificationTray::GetMessageCenterTray() { | 418 message_center::MessageCenterTray* WebNotificationTray::GetMessageCenterTray() { |
| 420 return message_center_tray_.get(); | 419 return message_center_tray_.get(); |
| 421 } | 420 } |
| 422 | 421 |
| 423 bool WebNotificationTray::IsCommandIdChecked(int command_id) const { | 422 bool WebNotificationTray::IsCommandIdChecked(int command_id) const { |
| 424 if (command_id != kToggleQuietMode) | 423 if (command_id != kToggleQuietMode) |
| 425 return false; | 424 return false; |
| 426 return message_center()->IsQuietMode(); | 425 return message_center()->IsQuietMode(); |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 474 button_->SetUnreadCount(message_center->UnreadNotificationCount()); | 473 button_->SetUnreadCount(message_center->UnreadNotificationCount()); |
| 475 if (IsMessageCenterBubbleVisible()) | 474 if (IsMessageCenterBubbleVisible()) |
| 476 button_->SetState(views::CustomButton::STATE_PRESSED); | 475 button_->SetState(views::CustomButton::STATE_PRESSED); |
| 477 else | 476 else |
| 478 button_->SetState(views::CustomButton::STATE_NORMAL); | 477 button_->SetState(views::CustomButton::STATE_NORMAL); |
| 479 bool userAddingRunning = ash::Shell::GetInstance() | 478 bool userAddingRunning = ash::Shell::GetInstance() |
| 480 ->session_state_delegate() | 479 ->session_state_delegate() |
| 481 ->IsInSecondaryLoginScreen(); | 480 ->IsInSecondaryLoginScreen(); |
| 482 | 481 |
| 483 SetVisible((status_area_widget()->login_status() != user::LOGGED_IN_NONE) && | 482 SetVisible((status_area_widget()->login_status() != user::LOGGED_IN_NONE) && |
| 484 (status_area_widget()->login_status() != user::LOGGED_IN_LOCKED) && | |
| 485 !userAddingRunning); | 483 !userAddingRunning); |
| 486 Layout(); | 484 Layout(); |
| 487 SchedulePaint(); | 485 SchedulePaint(); |
| 488 } | 486 } |
| 489 | 487 |
| 490 void WebNotificationTray::ClickedOutsideBubble() { | 488 void WebNotificationTray::ClickedOutsideBubble() { |
| 491 // Only hide the message center | 489 // Only hide the message center |
| 492 if (!message_center_bubble()) | 490 if (!message_center_bubble()) |
| 493 return; | 491 return; |
| 494 | 492 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 507 | 505 |
| 508 message_center::MessageCenterBubble* | 506 message_center::MessageCenterBubble* |
| 509 WebNotificationTray::GetMessageCenterBubbleForTest() { | 507 WebNotificationTray::GetMessageCenterBubbleForTest() { |
| 510 if (!message_center_bubble()) | 508 if (!message_center_bubble()) |
| 511 return NULL; | 509 return NULL; |
| 512 return static_cast<message_center::MessageCenterBubble*>( | 510 return static_cast<message_center::MessageCenterBubble*>( |
| 513 message_center_bubble()->bubble()); | 511 message_center_bubble()->bubble()); |
| 514 } | 512 } |
| 515 | 513 |
| 516 } // namespace ash | 514 } // namespace ash |
| OLD | NEW |