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/tray/system_tray.h" | 5 #include "ash/system/tray/system_tray.h" |
6 | 6 |
7 #include "ash/shell.h" | 7 #include "ash/shell.h" |
8 #include "ash/shell/panel_window.h" | 8 #include "ash/shell/panel_window.h" |
9 #include "ash/shell_window_ids.h" | 9 #include "ash/shell_window_ids.h" |
10 #include "ash/system/audio/tray_volume.h" | 10 #include "ash/system/audio/tray_volume.h" |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 brightness_observer_(NULL), | 131 brightness_observer_(NULL), |
132 caps_lock_observer_(NULL), | 132 caps_lock_observer_(NULL), |
133 clock_observer_(NULL), | 133 clock_observer_(NULL), |
134 drive_observer_(NULL), | 134 drive_observer_(NULL), |
135 ime_observer_(NULL), | 135 ime_observer_(NULL), |
136 locale_observer_(NULL), | 136 locale_observer_(NULL), |
137 network_observer_(NULL), | 137 network_observer_(NULL), |
138 update_observer_(NULL), | 138 update_observer_(NULL), |
139 user_observer_(NULL), | 139 user_observer_(NULL), |
140 should_show_launcher_(false), | 140 should_show_launcher_(false), |
141 default_bubble_height_(0) { | 141 default_bubble_height_(0), |
| 142 hide_notifications_(false) { |
142 tray_container_ = new internal::SystemTrayContainer; | 143 tray_container_ = new internal::SystemTrayContainer; |
143 tray_container_->SetLayoutManager(new views::BoxLayout( | 144 tray_container_->SetLayoutManager(new views::BoxLayout( |
144 views::BoxLayout::kHorizontal, 0, 0, 0)); | 145 views::BoxLayout::kHorizontal, 0, 0, 0)); |
145 tray_container_->set_border( | 146 tray_container_->set_border( |
146 views::Border::CreateEmptyBorder(1, 1, 1, 1)); | 147 views::Border::CreateEmptyBorder(1, 1, 1, 1)); |
147 SetContents(tray_container_); | 148 SetContents(tray_container_); |
148 SetBorder(); | 149 SetBorder(); |
149 } | 150 } |
150 | 151 |
151 SystemTray::~SystemTray() { | 152 SystemTray::~SystemTray() { |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
291 } | 292 } |
292 | 293 |
293 void SystemTray::UpdateAfterShelfAlignmentChange(ShelfAlignment alignment) { | 294 void SystemTray::UpdateAfterShelfAlignmentChange(ShelfAlignment alignment) { |
294 for (std::vector<SystemTrayItem*>::iterator it = items_.begin(); | 295 for (std::vector<SystemTrayItem*>::iterator it = items_.begin(); |
295 it != items_.end(); | 296 it != items_.end(); |
296 ++it) { | 297 ++it) { |
297 (*it)->UpdateAfterShelfAlignmentChange(alignment); | 298 (*it)->UpdateAfterShelfAlignmentChange(alignment); |
298 } | 299 } |
299 } | 300 } |
300 | 301 |
| 302 void SystemTray::SetHideNotifications(bool hide_notifications) { |
| 303 if (notification_bubble_.get()) |
| 304 notification_bubble_->SetVisible(!hide_notifications); |
| 305 hide_notifications_ = hide_notifications; |
| 306 } |
| 307 |
| 308 bool SystemTray::IsBubbleVisible() const { |
| 309 return bubble_.get() && bubble_->IsVisible(); |
| 310 } |
| 311 |
301 bool SystemTray::CloseBubbleForTest() const { | 312 bool SystemTray::CloseBubbleForTest() const { |
302 if (!bubble_.get()) | 313 if (!bubble_.get()) |
303 return false; | 314 return false; |
304 bubble_->Close(); | 315 bubble_->Close(); |
305 return true; | 316 return true; |
306 } | 317 } |
307 | 318 |
308 // Private methods. | 319 // Private methods. |
309 | 320 |
310 void SystemTray::DestroyBubble() { | 321 void SystemTray::DestroyBubble() { |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
455 anchor_type = SystemTrayBubble::ANCHOR_TYPE_TRAY; | 466 anchor_type = SystemTrayBubble::ANCHOR_TYPE_TRAY; |
456 } | 467 } |
457 SystemTrayBubble::InitParams init_params(anchor_type, shelf_alignment()); | 468 SystemTrayBubble::InitParams init_params(anchor_type, shelf_alignment()); |
458 init_params.anchor = anchor; | 469 init_params.anchor = anchor; |
459 init_params.login_status = | 470 init_params.login_status = |
460 ash::Shell::GetInstance()->tray_delegate()->GetUserLoginStatus(); | 471 ash::Shell::GetInstance()->tray_delegate()->GetUserLoginStatus(); |
461 int arrow_offset = GetTrayXOffset(notification_items_[0]); | 472 int arrow_offset = GetTrayXOffset(notification_items_[0]); |
462 if (arrow_offset >= 0) | 473 if (arrow_offset >= 0) |
463 init_params.arrow_offset = arrow_offset; | 474 init_params.arrow_offset = arrow_offset; |
464 notification_bubble_->InitView(init_params); | 475 notification_bubble_->InitView(init_params); |
| 476 if (hide_notifications_) |
| 477 notification_bubble_->SetVisible(false); |
465 } | 478 } |
466 | 479 |
467 void SystemTray::UpdateNotificationAnchor() { | 480 void SystemTray::UpdateNotificationAnchor() { |
468 if (!notification_bubble_.get()) | 481 if (!notification_bubble_.get()) |
469 return; | 482 return; |
470 notification_bubble_->bubble_view()->UpdateAnchor(); | 483 notification_bubble_->bubble_view()->UpdateAnchor(); |
471 // Ensure that the notification buble is above the launcher/status area. | 484 // Ensure that the notification buble is above the launcher/status area. |
472 notification_bubble_->bubble_view()->GetWidget()->StackAtTop(); | 485 notification_bubble_->bubble_view()->GetWidget()->StackAtTop(); |
473 } | 486 } |
474 | 487 |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
549 | 562 |
550 void SystemTray::OnPaintFocusBorder(gfx::Canvas* canvas) { | 563 void SystemTray::OnPaintFocusBorder(gfx::Canvas* canvas) { |
551 // The tray itself expands to the right and bottom edge of the screen to make | 564 // The tray itself expands to the right and bottom edge of the screen to make |
552 // sure clicking on the edges brings up the popup. However, the focus border | 565 // sure clicking on the edges brings up the popup. However, the focus border |
553 // should be only around the container. | 566 // should be only around the container. |
554 if (GetWidget() && GetWidget()->IsActive()) | 567 if (GetWidget() && GetWidget()->IsActive()) |
555 canvas->DrawFocusRect(tray_container_->bounds()); | 568 canvas->DrawFocusRect(tray_container_->bounds()); |
556 } | 569 } |
557 | 570 |
558 } // namespace ash | 571 } // namespace ash |
OLD | NEW |