| 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/common/system/web_notification/web_notification_tray.h" | 5 #include "ash/common/system/web_notification/web_notification_tray.h" |
| 6 | 6 |
| 7 #include "ash/common/material_design/material_design_controller.h" | 7 #include "ash/common/material_design/material_design_controller.h" |
| 8 #include "ash/common/session/session_state_delegate.h" | 8 #include "ash/common/session/session_state_delegate.h" |
| 9 #include "ash/common/shelf/shelf_constants.h" | 9 #include "ash/common/shelf/shelf_constants.h" |
| 10 #include "ash/common/shelf/wm_shelf.h" | 10 #include "ash/common/shelf/wm_shelf.h" |
| (...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 377 TrayBackgroundView* anchor_tray = this; | 377 TrayBackgroundView* anchor_tray = this; |
| 378 if (IsHorizontalAlignment(shelf_alignment())) { | 378 if (IsHorizontalAlignment(shelf_alignment())) { |
| 379 anchor_tray = WmShelf::ForWindow(status_area_window_) | 379 anchor_tray = WmShelf::ForWindow(status_area_window_) |
| 380 ->GetStatusAreaWidget() | 380 ->GetStatusAreaWidget() |
| 381 ->system_tray(); | 381 ->system_tray(); |
| 382 } | 382 } |
| 383 | 383 |
| 384 message_center_bubble_.reset(new WebNotificationBubbleWrapper( | 384 message_center_bubble_.reset(new WebNotificationBubbleWrapper( |
| 385 this, anchor_tray, message_center_bubble)); | 385 this, anchor_tray, message_center_bubble)); |
| 386 | 386 |
| 387 system_tray_->SetHideNotifications(true); | |
| 388 shelf()->UpdateAutoHideState(); | 387 shelf()->UpdateAutoHideState(); |
| 389 SetIsActive(true); | 388 SetIsActive(true); |
| 390 return true; | 389 return true; |
| 391 } | 390 } |
| 392 | 391 |
| 393 bool WebNotificationTray::ShowMessageCenter() { | 392 bool WebNotificationTray::ShowMessageCenter() { |
| 394 return ShowMessageCenterInternal(false /* show_settings */); | 393 return ShowMessageCenterInternal(false /* show_settings */); |
| 395 } | 394 } |
| 396 | 395 |
| 397 void WebNotificationTray::HideMessageCenter() { | 396 void WebNotificationTray::HideMessageCenter() { |
| 398 if (!message_center_bubble()) | 397 if (!message_center_bubble()) |
| 399 return; | 398 return; |
| 400 SetIsActive(false); | 399 SetIsActive(false); |
| 401 message_center_bubble_.reset(); | 400 message_center_bubble_.reset(); |
| 402 should_block_shelf_auto_hide_ = false; | 401 should_block_shelf_auto_hide_ = false; |
| 403 show_message_center_on_unlock_ = false; | 402 show_message_center_on_unlock_ = false; |
| 404 system_tray_->SetHideNotifications(false); | |
| 405 shelf()->UpdateAutoHideState(); | 403 shelf()->UpdateAutoHideState(); |
| 406 } | 404 } |
| 407 | 405 |
| 408 void WebNotificationTray::SetTrayBubbleHeight(int height) { | 406 void WebNotificationTray::SetTrayBubbleHeight(int height) { |
| 409 popup_alignment_delegate_->SetTrayBubbleHeight(height); | 407 popup_alignment_delegate_->SetTrayBubbleHeight(height); |
| 410 } | 408 } |
| 411 | 409 |
| 412 int WebNotificationTray::tray_bubble_height_for_test() const { | 410 int WebNotificationTray::tray_bubble_height_for_test() const { |
| 413 return popup_alignment_delegate_->tray_bubble_height_for_test(); | 411 return popup_alignment_delegate_->tray_bubble_height_for_test(); |
| 414 } | 412 } |
| 415 | 413 |
| 416 bool WebNotificationTray::ShowPopups() { | 414 bool WebNotificationTray::ShowPopups() { |
| 417 if (message_center_bubble()) | 415 if (message_center_bubble()) |
| 418 return false; | 416 return false; |
| 419 | 417 |
| 420 popup_collection_->DoUpdateIfPossible(); | 418 popup_collection_->DoUpdateIfPossible(); |
| 421 return true; | 419 return true; |
| 422 } | 420 } |
| 423 | 421 |
| 424 void WebNotificationTray::HidePopups() { | 422 void WebNotificationTray::HidePopups() { |
| 425 DCHECK(popup_collection_.get()); | 423 DCHECK(popup_collection_.get()); |
| 426 popup_collection_->MarkAllPopupsShown(); | 424 popup_collection_->MarkAllPopupsShown(); |
| 427 } | 425 } |
| 428 | 426 |
| 429 // Private methods. | 427 // Private methods. |
| 430 | 428 |
| 431 bool WebNotificationTray::ShouldShowMessageCenter() { | 429 bool WebNotificationTray::ShouldShowMessageCenter() { |
| 432 return WmShell::Get()->system_tray_delegate()->ShouldShowNotificationTray() && | 430 return WmShell::Get()->system_tray_delegate()->ShouldShowNotificationTray(); |
| 433 !system_tray_->HasNotificationBubble(); | |
| 434 } | 431 } |
| 435 | 432 |
| 436 bool WebNotificationTray::ShouldBlockShelfAutoHide() const { | 433 bool WebNotificationTray::ShouldBlockShelfAutoHide() const { |
| 437 return should_block_shelf_auto_hide_; | 434 return should_block_shelf_auto_hide_; |
| 438 } | 435 } |
| 439 | 436 |
| 440 bool WebNotificationTray::IsMessageCenterBubbleVisible() const { | 437 bool WebNotificationTray::IsMessageCenterBubbleVisible() const { |
| 441 return (message_center_bubble() && | 438 return (message_center_bubble() && |
| 442 message_center_bubble()->bubble()->IsVisible()); | 439 message_center_bubble()->bubble()->IsVisible()); |
| 443 } | 440 } |
| (...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 663 | 660 |
| 664 message_center::MessageCenterBubble* | 661 message_center::MessageCenterBubble* |
| 665 WebNotificationTray::GetMessageCenterBubbleForTest() { | 662 WebNotificationTray::GetMessageCenterBubbleForTest() { |
| 666 if (!message_center_bubble()) | 663 if (!message_center_bubble()) |
| 667 return nullptr; | 664 return nullptr; |
| 668 return static_cast<message_center::MessageCenterBubble*>( | 665 return static_cast<message_center::MessageCenterBubble*>( |
| 669 message_center_bubble()->bubble()); | 666 message_center_bubble()->bubble()); |
| 670 } | 667 } |
| 671 | 668 |
| 672 } // namespace ash | 669 } // namespace ash |
| OLD | NEW |