Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(842)

Side by Side Diff: ash/system/tray/system_tray.cc

Issue 10514008: Add WebNotificationTray (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 8 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ash/system/tray/system_tray.h ('k') | ash/system/tray/system_tray_bubble.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 power_status_observer_(NULL), 138 power_status_observer_(NULL),
139 update_observer_(NULL), 139 update_observer_(NULL),
140 user_observer_(NULL), 140 user_observer_(NULL),
141 should_show_launcher_(false), 141 should_show_launcher_(false),
142 shelf_alignment_(SHELF_ALIGNMENT_BOTTOM), 142 default_bubble_height_(0),
143 default_bubble_height_(0) { 143 hide_notifications_(false) {
144 tray_container_ = new internal::SystemTrayContainer; 144 tray_container_ = new internal::SystemTrayContainer;
145 tray_container_->SetLayoutManager(new views::BoxLayout( 145 tray_container_->SetLayoutManager(new views::BoxLayout(
146 views::BoxLayout::kHorizontal, 0, 0, 0)); 146 views::BoxLayout::kHorizontal, 0, 0, 0));
147 tray_container_->set_border( 147 tray_container_->set_border(
148 views::Border::CreateEmptyBorder(1, 1, 1, 1)); 148 views::Border::CreateEmptyBorder(1, 1, 1, 1));
149 SetContents(tray_container_); 149 SetContents(tray_container_);
150 SetBorder(); 150 SetBorder();
151 } 151 }
152 152
153 SystemTray::~SystemTray() { 153 SystemTray::~SystemTray() {
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
291 } 291 }
292 292
293 void SystemTray::UpdateAfterShelfAlignmentChange(ShelfAlignment alignment) { 293 void SystemTray::UpdateAfterShelfAlignmentChange(ShelfAlignment alignment) {
294 for (std::vector<SystemTrayItem*>::iterator it = items_.begin(); 294 for (std::vector<SystemTrayItem*>::iterator it = items_.begin();
295 it != items_.end(); 295 it != items_.end();
296 ++it) { 296 ++it) {
297 (*it)->UpdateAfterShelfAlignmentChange(alignment); 297 (*it)->UpdateAfterShelfAlignmentChange(alignment);
298 } 298 }
299 } 299 }
300 300
301 void SystemTray::SetHideNotifications(bool hide_notifications) {
302 if (notification_bubble_.get())
303 notification_bubble_->SetVisible(!hide_notifications);
304 hide_notifications_ = hide_notifications;
305 }
306
307 bool SystemTray::IsBubbleVisible() const {
308 return bubble_.get() && bubble_->IsVisible();
309 }
310
301 bool SystemTray::CloseBubbleForTest() const { 311 bool SystemTray::CloseBubbleForTest() const {
302 if (!bubble_.get()) 312 if (!bubble_.get())
303 return false; 313 return false;
304 bubble_->Close(); 314 bubble_->Close();
305 return true; 315 return true;
306 } 316 }
307 317
308 // Private methods. 318 // Private methods.
309 319
310 void SystemTray::DestroyBubble() { 320 void SystemTray::DestroyBubble() {
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
455 anchor_type = SystemTrayBubble::ANCHOR_TYPE_TRAY; 465 anchor_type = SystemTrayBubble::ANCHOR_TYPE_TRAY;
456 } 466 }
457 SystemTrayBubble::InitParams init_params(anchor_type, shelf_alignment()); 467 SystemTrayBubble::InitParams init_params(anchor_type, shelf_alignment());
458 init_params.anchor = anchor; 468 init_params.anchor = anchor;
459 init_params.login_status = 469 init_params.login_status =
460 ash::Shell::GetInstance()->tray_delegate()->GetUserLoginStatus(); 470 ash::Shell::GetInstance()->tray_delegate()->GetUserLoginStatus();
461 int arrow_offset = GetTrayXOffset(notification_items_[0]); 471 int arrow_offset = GetTrayXOffset(notification_items_[0]);
462 if (arrow_offset >= 0) 472 if (arrow_offset >= 0)
463 init_params.arrow_offset = arrow_offset; 473 init_params.arrow_offset = arrow_offset;
464 notification_bubble_->InitView(init_params); 474 notification_bubble_->InitView(init_params);
475 if (hide_notifications_)
476 notification_bubble_->SetVisible(false);
465 } 477 }
466 478
467 void SystemTray::UpdateNotificationAnchor() { 479 void SystemTray::UpdateNotificationAnchor() {
468 if (!notification_bubble_.get()) 480 if (!notification_bubble_.get())
469 return; 481 return;
470 notification_bubble_->bubble_view()->UpdateAnchor(); 482 notification_bubble_->bubble_view()->UpdateAnchor();
471 // Ensure that the notification buble is above the launcher/status area. 483 // Ensure that the notification buble is above the launcher/status area.
472 notification_bubble_->bubble_view()->GetWidget()->StackAtTop(); 484 notification_bubble_->bubble_view()->GetWidget()->StackAtTop();
473 } 485 }
474 486
475 void SystemTray::SetBorder() { 487 void SystemTray::SetBorder() {
476 // Change the border padding for different shelf alignment. 488 // Change the border padding for different shelf alignment.
477 if (shelf_alignment_ == SHELF_ALIGNMENT_BOTTOM) { 489 if (shelf_alignment() == SHELF_ALIGNMENT_BOTTOM) {
478 set_border(views::Border::CreateEmptyBorder(0, 0, 490 set_border(views::Border::CreateEmptyBorder(0, 0,
479 kPaddingFromBottomOfScreenBottomAlignment, 491 kPaddingFromBottomOfScreenBottomAlignment,
480 kPaddingFromRightEdgeOfScreenBottomAlignment)); 492 kPaddingFromRightEdgeOfScreenBottomAlignment));
481 } else if (shelf_alignment_ == SHELF_ALIGNMENT_LEFT) { 493 } else if (shelf_alignment() == SHELF_ALIGNMENT_LEFT) {
482 set_border(views::Border::CreateEmptyBorder(0, 494 set_border(views::Border::CreateEmptyBorder(0,
483 kPaddingFromEdgeOfScreenVerticalAlignment, 495 kPaddingFromEdgeOfScreenVerticalAlignment,
484 kPaddingFromBottomOfScreenVerticalAlignment, 496 kPaddingFromBottomOfScreenVerticalAlignment,
485 kPaddingFromEdgeOfLauncherVerticalAlignment)); 497 kPaddingFromEdgeOfLauncherVerticalAlignment));
486 } else { 498 } else {
487 set_border(views::Border::CreateEmptyBorder(0, 499 set_border(views::Border::CreateEmptyBorder(0,
488 kPaddingFromEdgeOfLauncherVerticalAlignment, 500 kPaddingFromEdgeOfLauncherVerticalAlignment,
489 kPaddingFromBottomOfScreenVerticalAlignment, 501 kPaddingFromBottomOfScreenVerticalAlignment,
490 kPaddingFromEdgeOfScreenVerticalAlignment)); 502 kPaddingFromEdgeOfScreenVerticalAlignment));
491 } 503 }
492 } 504 }
493 505
494 void SystemTray::SetShelfAlignment(ShelfAlignment alignment) { 506 void SystemTray::SetShelfAlignment(ShelfAlignment alignment) {
495 if (alignment == shelf_alignment_) 507 if (alignment == shelf_alignment())
496 return; 508 return;
497 shelf_alignment_ = alignment; 509 internal::TrayBackgroundView::SetShelfAlignment(alignment);
498 UpdateAfterShelfAlignmentChange(alignment); 510 UpdateAfterShelfAlignmentChange(alignment);
499 SetBorder(); 511 SetBorder();
500 tray_container_->SetLayoutManager(new views::BoxLayout( 512 tray_container_->SetLayoutManager(new views::BoxLayout(
501 alignment == SHELF_ALIGNMENT_BOTTOM ? 513 alignment == SHELF_ALIGNMENT_BOTTOM ?
502 views::BoxLayout::kHorizontal : views::BoxLayout::kVertical, 514 views::BoxLayout::kHorizontal : views::BoxLayout::kVertical,
503 0, 0, 0)); 515 0, 0, 0));
504 } 516 }
505 517
506 bool SystemTray::PerformAction(const views::Event& event) { 518 bool SystemTray::PerformAction(const views::Event& event) {
507 // If we're already showing the default view, hide it; otherwise, show it 519 // If we're already showing the default view, hide it; otherwise, show it
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
549 561
550 void SystemTray::OnPaintFocusBorder(gfx::Canvas* canvas) { 562 void SystemTray::OnPaintFocusBorder(gfx::Canvas* canvas) {
551 // The tray itself expands to the right and bottom edge of the screen to make 563 // 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 564 // sure clicking on the edges brings up the popup. However, the focus border
553 // should be only around the container. 565 // should be only around the container.
554 if (GetWidget() && GetWidget()->IsActive()) 566 if (GetWidget() && GetWidget()->IsActive())
555 canvas->DrawFocusRect(tray_container_->bounds()); 567 canvas->DrawFocusRect(tray_container_->bounds());
556 } 568 }
557 569
558 } // namespace ash 570 } // namespace ash
OLDNEW
« no previous file with comments | « ash/system/tray/system_tray.h ('k') | ash/system/tray/system_tray_bubble.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698