Chromium Code Reviews| 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 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 291 ash::ANIMATE_BOTH); | 291 ash::ANIMATE_BOTH); |
| 292 ash::SetWindowVisibilityAnimationDuration( | 292 ash::SetWindowVisibilityAnimationDuration( |
| 293 bubble_widget_->GetNativeWindow(), | 293 bubble_widget_->GetNativeWindow(), |
| 294 base::TimeDelta::FromMilliseconds(kAnimationDurationForPopupMS)); | 294 base::TimeDelta::FromMilliseconds(kAnimationDurationForPopupMS)); |
| 295 | 295 |
| 296 bubble_view_->Show(); | 296 bubble_view_->Show(); |
| 297 } | 297 } |
| 298 | 298 |
| 299 void SystemTrayBubble::BubbleViewDestroyed() { | 299 void SystemTrayBubble::BubbleViewDestroyed() { |
| 300 DestroyItemViews(); | 300 DestroyItemViews(); |
| 301 bubble_view_ = NULL; | |
|
stevenjb
2012/06/13 19:05:02
I added this here also, just to be safe.
| |
| 301 } | 302 } |
| 302 | 303 |
| 303 gfx::Rect SystemTrayBubble::GetAnchorRect() const { | 304 gfx::Rect SystemTrayBubble::GetAnchorRect() const { |
| 304 gfx::Rect rect; | 305 gfx::Rect rect; |
| 305 views::Widget* widget = bubble_view()->anchor_widget(); | 306 views::Widget* widget = bubble_view()->anchor_widget(); |
| 306 if (widget->IsVisible()) { | 307 if (widget->IsVisible()) { |
| 307 rect = widget->GetWindowScreenBounds(); | 308 rect = widget->GetWindowScreenBounds(); |
| 308 if (anchor_type_ == ANCHOR_TYPE_TRAY) { | 309 if (anchor_type_ == ANCHOR_TYPE_TRAY) { |
| 309 if (tray_->shelf_alignment() == SHELF_ALIGNMENT_BOTTOM) { | 310 if (tray_->shelf_alignment() == SHELF_ALIGNMENT_BOTTOM) { |
| 310 rect.Inset( | 311 rect.Inset( |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 377 void SystemTrayBubble::RestartAutoCloseTimer() { | 378 void SystemTrayBubble::RestartAutoCloseTimer() { |
| 378 if (autoclose_delay_) | 379 if (autoclose_delay_) |
| 379 StartAutoCloseTimer(autoclose_delay_); | 380 StartAutoCloseTimer(autoclose_delay_); |
| 380 } | 381 } |
| 381 | 382 |
| 382 void SystemTrayBubble::Close() { | 383 void SystemTrayBubble::Close() { |
| 383 if (bubble_widget_) | 384 if (bubble_widget_) |
| 384 bubble_widget_->Close(); | 385 bubble_widget_->Close(); |
| 385 } | 386 } |
| 386 | 387 |
| 388 void SystemTrayBubble::SetVisible(bool is_visible) { | |
| 389 if (!bubble_widget_) | |
| 390 return; | |
| 391 if (is_visible) | |
| 392 bubble_widget_->Show(); | |
| 393 else | |
| 394 bubble_widget_->Hide(); | |
| 395 } | |
| 396 | |
| 397 bool SystemTrayBubble::IsVisible() { | |
| 398 return bubble_widget_ && bubble_widget_->IsVisible(); | |
| 399 } | |
| 400 | |
| 387 void SystemTrayBubble::CreateItemViews(user::LoginStatus login_status) { | 401 void SystemTrayBubble::CreateItemViews(user::LoginStatus login_status) { |
| 388 for (std::vector<ash::SystemTrayItem*>::iterator it = items_.begin(); | 402 for (std::vector<ash::SystemTrayItem*>::iterator it = items_.begin(); |
| 389 it != items_.end(); | 403 it != items_.end(); |
| 390 ++it) { | 404 ++it) { |
| 391 views::View* view = NULL; | 405 views::View* view = NULL; |
| 392 switch (bubble_type_) { | 406 switch (bubble_type_) { |
| 393 case BUBBLE_TYPE_DEFAULT: | 407 case BUBBLE_TYPE_DEFAULT: |
| 394 view = (*it)->CreateDefaultView(login_status); | 408 view = (*it)->CreateDefaultView(login_status); |
| 395 break; | 409 break; |
| 396 case BUBBLE_TYPE_DETAILED: | 410 case BUBBLE_TYPE_DETAILED: |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 450 } | 464 } |
| 451 | 465 |
| 452 void SystemTrayBubble::OnWidgetClosing(views::Widget* widget) { | 466 void SystemTrayBubble::OnWidgetClosing(views::Widget* widget) { |
| 453 CHECK_EQ(bubble_widget_, widget); | 467 CHECK_EQ(bubble_widget_, widget); |
| 454 bubble_widget_ = NULL; | 468 bubble_widget_ = NULL; |
| 455 tray_->RemoveBubble(this); | 469 tray_->RemoveBubble(this); |
| 456 } | 470 } |
| 457 | 471 |
| 458 } // namespace internal | 472 } // namespace internal |
| 459 } // namespace ash | 473 } // namespace ash |
| OLD | NEW |