| 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 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 369 message_center_bubble->SetMaxHeight(std::max(0, | 369 message_center_bubble->SetMaxHeight(std::max(0, |
| 370 max_height - GetTraySpacing())); | 370 max_height - GetTraySpacing())); |
| 371 if (show_settings) | 371 if (show_settings) |
| 372 message_center_bubble->SetSettingsVisible(); | 372 message_center_bubble->SetSettingsVisible(); |
| 373 message_center_bubble_.reset( | 373 message_center_bubble_.reset( |
| 374 new internal::WebNotificationBubbleWrapper(this, message_center_bubble)); | 374 new internal::WebNotificationBubbleWrapper(this, message_center_bubble)); |
| 375 | 375 |
| 376 status_area_widget()->SetHideSystemNotifications(true); | 376 status_area_widget()->SetHideSystemNotifications(true); |
| 377 GetShelfLayoutManager()->UpdateAutoHideState(); | 377 GetShelfLayoutManager()->UpdateAutoHideState(); |
| 378 button_->SetBubbleVisible(true); | 378 button_->SetBubbleVisible(true); |
| 379 SetDrawBackgroundAsActive(true); |
| 379 return true; | 380 return true; |
| 380 } | 381 } |
| 381 | 382 |
| 382 bool WebNotificationTray::ShowMessageCenter() { | 383 bool WebNotificationTray::ShowMessageCenter() { |
| 383 return ShowMessageCenterInternal(false /* show_settings */); | 384 return ShowMessageCenterInternal(false /* show_settings */); |
| 384 } | 385 } |
| 385 | 386 |
| 386 void WebNotificationTray::HideMessageCenter() { | 387 void WebNotificationTray::HideMessageCenter() { |
| 387 if (!message_center_bubble()) | 388 if (!message_center_bubble()) |
| 388 return; | 389 return; |
| 390 SetDrawBackgroundAsActive(false); |
| 389 message_center_bubble_.reset(); | 391 message_center_bubble_.reset(); |
| 390 should_block_shelf_auto_hide_ = false; | 392 should_block_shelf_auto_hide_ = false; |
| 391 show_message_center_on_unlock_ = false; | 393 show_message_center_on_unlock_ = false; |
| 392 status_area_widget()->SetHideSystemNotifications(false); | 394 status_area_widget()->SetHideSystemNotifications(false); |
| 393 GetShelfLayoutManager()->UpdateAutoHideState(); | 395 GetShelfLayoutManager()->UpdateAutoHideState(); |
| 394 button_->SetBubbleVisible(false); | 396 button_->SetBubbleVisible(false); |
| 395 } | 397 } |
| 396 | 398 |
| 397 void WebNotificationTray::SetSystemTrayHeight(int height) { | 399 void WebNotificationTray::SetSystemTrayHeight(int height) { |
| 398 work_area_observer_->SetSystemTrayHeight(height); | 400 work_area_observer_->SetSystemTrayHeight(height); |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 561 bool in_quiet_mode = message_center()->IsQuietMode(); | 563 bool in_quiet_mode = message_center()->IsQuietMode(); |
| 562 message_center()->SetQuietMode(!in_quiet_mode); | 564 message_center()->SetQuietMode(!in_quiet_mode); |
| 563 return; | 565 return; |
| 564 } | 566 } |
| 565 base::TimeDelta expires_in = command_id == kEnableQuietModeDay ? | 567 base::TimeDelta expires_in = command_id == kEnableQuietModeDay ? |
| 566 base::TimeDelta::FromDays(1): | 568 base::TimeDelta::FromDays(1): |
| 567 base::TimeDelta::FromHours(1); | 569 base::TimeDelta::FromHours(1); |
| 568 message_center()->EnterQuietModeWithExpire(expires_in); | 570 message_center()->EnterQuietModeWithExpire(expires_in); |
| 569 } | 571 } |
| 570 | 572 |
| 571 bool WebNotificationTray::IsPressed() { | |
| 572 return IsMessageCenterBubbleVisible(); | |
| 573 } | |
| 574 | |
| 575 void WebNotificationTray::ButtonPressed(views::Button* sender, | 573 void WebNotificationTray::ButtonPressed(views::Button* sender, |
| 576 const ui::Event& event) { | 574 const ui::Event& event) { |
| 577 DCHECK_EQ(button_, sender); | 575 DCHECK_EQ(button_, sender); |
| 578 PerformAction(event); | 576 PerformAction(event); |
| 579 } | 577 } |
| 580 | 578 |
| 581 void WebNotificationTray::OnMessageCenterTrayChanged() { | 579 void WebNotificationTray::OnMessageCenterTrayChanged() { |
| 582 // Do not update the tray contents directly. Multiple change events can happen | 580 // Do not update the tray contents directly. Multiple change events can happen |
| 583 // consecutively, and calling Update in the middle of those events will show | 581 // consecutively, and calling Update in the middle of those events will show |
| 584 // intermediate unread counts for a moment. | 582 // intermediate unread counts for a moment. |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 628 | 626 |
| 629 message_center::MessageCenterBubble* | 627 message_center::MessageCenterBubble* |
| 630 WebNotificationTray::GetMessageCenterBubbleForTest() { | 628 WebNotificationTray::GetMessageCenterBubbleForTest() { |
| 631 if (!message_center_bubble()) | 629 if (!message_center_bubble()) |
| 632 return NULL; | 630 return NULL; |
| 633 return static_cast<message_center::MessageCenterBubble*>( | 631 return static_cast<message_center::MessageCenterBubble*>( |
| 634 message_center_bubble()->bubble()); | 632 message_center_bubble()->bubble()); |
| 635 } | 633 } |
| 636 | 634 |
| 637 } // namespace ash | 635 } // namespace ash |
| OLD | NEW |