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