| 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_bubble.h" | 5 #include "ash/system/tray/system_tray_bubble.h" |
| 6 | 6 |
| 7 #include "ash/shell.h" | 7 #include "ash/shell.h" |
| 8 #include "ash/system/tray/system_tray.h" | 8 #include "ash/system/tray/system_tray.h" |
| 9 #include "ash/system/tray/system_tray_delegate.h" | 9 #include "ash/system/tray/system_tray_delegate.h" |
| 10 #include "ash/system/tray/system_tray_item.h" | 10 #include "ash/system/tray/system_tray_item.h" |
| (...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 329 ash::ANIMATE_BOTH); | 329 ash::ANIMATE_BOTH); |
| 330 ash::SetWindowVisibilityAnimationDuration( | 330 ash::SetWindowVisibilityAnimationDuration( |
| 331 bubble_widget_->GetNativeWindow(), | 331 bubble_widget_->GetNativeWindow(), |
| 332 base::TimeDelta::FromMilliseconds(kAnimationDurationForPopupMS)); | 332 base::TimeDelta::FromMilliseconds(kAnimationDurationForPopupMS)); |
| 333 | 333 |
| 334 bubble_view_->Show(); | 334 bubble_view_->Show(); |
| 335 } | 335 } |
| 336 | 336 |
| 337 void SystemTrayBubble::BubbleViewDestroyed() { | 337 void SystemTrayBubble::BubbleViewDestroyed() { |
| 338 DestroyItemViews(); | 338 DestroyItemViews(); |
| 339 bubble_view_ = NULL; |
| 339 } | 340 } |
| 340 | 341 |
| 341 gfx::Rect SystemTrayBubble::GetAnchorRect() const { | 342 gfx::Rect SystemTrayBubble::GetAnchorRect() const { |
| 342 gfx::Rect rect; | 343 gfx::Rect rect; |
| 343 views::Widget* widget = bubble_view()->anchor_widget(); | 344 views::Widget* widget = bubble_view()->anchor_widget(); |
| 344 if (widget->IsVisible()) { | 345 if (widget->IsVisible()) { |
| 345 rect = widget->GetWindowScreenBounds(); | 346 rect = widget->GetWindowScreenBounds(); |
| 346 if (anchor_type_ == ANCHOR_TYPE_TRAY) { | 347 if (anchor_type_ == ANCHOR_TYPE_TRAY) { |
| 347 if (tray_->shelf_alignment() == SHELF_ALIGNMENT_BOTTOM) { | 348 if (tray_->shelf_alignment() == SHELF_ALIGNMENT_BOTTOM) { |
| 348 rect.Inset( | 349 rect.Inset( |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 415 void SystemTrayBubble::RestartAutoCloseTimer() { | 416 void SystemTrayBubble::RestartAutoCloseTimer() { |
| 416 if (autoclose_delay_) | 417 if (autoclose_delay_) |
| 417 StartAutoCloseTimer(autoclose_delay_); | 418 StartAutoCloseTimer(autoclose_delay_); |
| 418 } | 419 } |
| 419 | 420 |
| 420 void SystemTrayBubble::Close() { | 421 void SystemTrayBubble::Close() { |
| 421 if (bubble_widget_) | 422 if (bubble_widget_) |
| 422 bubble_widget_->Close(); | 423 bubble_widget_->Close(); |
| 423 } | 424 } |
| 424 | 425 |
| 426 void SystemTrayBubble::SetVisible(bool is_visible) { |
| 427 if (!bubble_widget_) |
| 428 return; |
| 429 if (is_visible) |
| 430 bubble_widget_->Show(); |
| 431 else |
| 432 bubble_widget_->Hide(); |
| 433 } |
| 434 |
| 435 bool SystemTrayBubble::IsVisible() { |
| 436 return bubble_widget_ && bubble_widget_->IsVisible(); |
| 437 } |
| 438 |
| 425 void SystemTrayBubble::CreateItemViews(user::LoginStatus login_status) { | 439 void SystemTrayBubble::CreateItemViews(user::LoginStatus login_status) { |
| 426 for (std::vector<ash::SystemTrayItem*>::iterator it = items_.begin(); | 440 for (std::vector<ash::SystemTrayItem*>::iterator it = items_.begin(); |
| 427 it != items_.end(); | 441 it != items_.end(); |
| 428 ++it) { | 442 ++it) { |
| 429 views::View* view = NULL; | 443 views::View* view = NULL; |
| 430 switch (bubble_type_) { | 444 switch (bubble_type_) { |
| 431 case BUBBLE_TYPE_DEFAULT: | 445 case BUBBLE_TYPE_DEFAULT: |
| 432 view = (*it)->CreateDefaultView(login_status); | 446 view = (*it)->CreateDefaultView(login_status); |
| 433 break; | 447 break; |
| 434 case BUBBLE_TYPE_DETAILED: | 448 case BUBBLE_TYPE_DETAILED: |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 488 } | 502 } |
| 489 | 503 |
| 490 void SystemTrayBubble::OnWidgetClosing(views::Widget* widget) { | 504 void SystemTrayBubble::OnWidgetClosing(views::Widget* widget) { |
| 491 CHECK_EQ(bubble_widget_, widget); | 505 CHECK_EQ(bubble_widget_, widget); |
| 492 bubble_widget_ = NULL; | 506 bubble_widget_ = NULL; |
| 493 tray_->RemoveBubble(this); | 507 tray_->RemoveBubble(this); |
| 494 } | 508 } |
| 495 | 509 |
| 496 } // namespace internal | 510 } // namespace internal |
| 497 } // namespace ash | 511 } // namespace ash |
| OLD | NEW |