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/web_notification/web_notification_tray.h" | 5 #include "ash/system/web_notification/web_notification_tray.h" |
| 6 | 6 |
| 7 #include "ash/system/status_area_widget.h" | 7 #include "ash/system/status_area_widget.h" |
| 8 #include "ash/system/tray/tray_bubble_view.h" | 8 #include "ash/system/tray/tray_bubble_view.h" |
| 9 #include "ash/system/tray/tray_constants.h" | 9 #include "ash/system/tray/tray_constants.h" |
| 10 #include "ash/system/tray/tray_views.h" | 10 #include "ash/system/tray/tray_views.h" |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 36 const int kTrayContainerVerticalPaddingVerticalAlignment = 1; | 36 const int kTrayContainerVerticalPaddingVerticalAlignment = 1; |
| 37 const int kTrayContainerHorizontalPaddingVerticalAlignment = 0; | 37 const int kTrayContainerHorizontalPaddingVerticalAlignment = 0; |
| 38 const int kPaddingFromLeftEdgeOfSystemTrayBottomAlignment = 8; | 38 const int kPaddingFromLeftEdgeOfSystemTrayBottomAlignment = 8; |
| 39 const int kPaddingFromTopEdgeOfSystemTrayVerticalAlignment = 10; | 39 const int kPaddingFromTopEdgeOfSystemTrayVerticalAlignment = 10; |
| 40 const int kNotificationImageIconWidth = 40; | 40 const int kNotificationImageIconWidth = 40; |
| 41 const int kNotificationImageIconHeight = 25; | 41 const int kNotificationImageIconHeight = 25; |
| 42 const int kNotificationImageIconInset = 4; | 42 const int kNotificationImageIconInset = 4; |
| 43 | 43 |
| 44 // Web Notification Bubble constants | 44 // Web Notification Bubble constants |
| 45 const int kWebNotificationBubbleMinHeight = 80; | 45 const int kWebNotificationBubbleMinHeight = 80; |
| 46 const int kWebNotificationBubbleMaxHeight = 400; | 46 const int kWebNotificationBubbleMaxHeight = 480; |
| 47 // Delay laying out the Bubble until all notifications have been added and icons | 47 // Delay laying out the Bubble until all notifications have been added and icons |
| 48 // have had a chance to load. | 48 // have had a chance to load. |
| 49 const int kUpdateDelayMs = 50; | 49 const int kUpdateDelayMs = 50; |
| 50 // Limit the number of visible notifications. | 50 // Limit the number of visible notifications. |
| 51 const int kMaxVisibleNotifications = 100; | 51 const int kMaxVisibleNotifications = 100; |
| 52 | 52 |
| 53 // Individual notifications constants | 53 // Individual notifications constants |
| 54 const int kWebNotificationWidth = 400; | 54 const int kWebNotificationWidth = 320; |
| 55 const int kWebNotificationButtonWidth = 32; | 55 const int kWebNotificationButtonWidth = 32; |
| 56 const int kWebNotificationIconSize = 40; | 56 const int kWebNotificationIconSize = 40; |
| 57 | 57 |
| 58 // Menu constants | 58 // Menu constants |
| 59 const int kTogglePermissionCommand = 0; | 59 const int kTogglePermissionCommand = 0; |
| 60 const int kToggleExtensionCommand = 1; | 60 const int kToggleExtensionCommand = 1; |
| 61 const int kShowSettingsCommand = 2; | 61 const int kShowSettingsCommand = 2; |
| 62 | 62 |
| 63 // The image has three icons: 1 notifiaction, 2 notifications, and 3+. | 63 // The image has three icons: 1 notifiaction, 2 notifications, and 3+. |
| 64 gfx::ImageSkia GetNotificationImage(int notification_count) { | 64 gfx::ImageSkia GetNotificationImage(int notification_count) { |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 117 const string16& display_source, | 117 const string16& display_source, |
| 118 const std::string& extension_id) { | 118 const std::string& extension_id) { |
| 119 Notifications::iterator iter = GetNotification(id); | 119 Notifications::iterator iter = GetNotification(id); |
| 120 if (iter != notifications_.end()) { | 120 if (iter != notifications_.end()) { |
| 121 // Update existing notification. | 121 // Update existing notification. |
| 122 iter->title = title; | 122 iter->title = title; |
| 123 iter->message = message; | 123 iter->message = message; |
| 124 iter->display_source = display_source; | 124 iter->display_source = display_source; |
| 125 iter->extension_id = extension_id; | 125 iter->extension_id = extension_id; |
| 126 } else { | 126 } else { |
| 127 notifications_.push_back( | 127 notifications_.push_front( |
| 128 WebNotification(id, title, message, display_source, extension_id)); | 128 WebNotification(id, title, message, display_source, extension_id)); |
| 129 } | 129 } |
| 130 } | 130 } |
| 131 | 131 |
| 132 void UpdateNotificationMessage(const std::string& id, | 132 void UpdateNotificationMessage(const std::string& id, |
| 133 const string16& title, | 133 const string16& title, |
| 134 const string16& message) { | 134 const string16& message) { |
| 135 Notifications::iterator iter = GetNotification(id); | 135 Notifications::iterator iter = GetNotification(id); |
| 136 if (iter == notifications_.end()) | 136 if (iter == notifications_.end()) |
| 137 return; | 137 return; |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 335 !notification.display_source.empty()) { | 335 !notification.display_source.empty()) { |
| 336 menu_button_ = new views::MenuButton(NULL, string16(), this, true); | 336 menu_button_ = new views::MenuButton(NULL, string16(), this, true); |
| 337 menu_button_->set_border(views::Border::CreateEmptyBorder(0, 0, 0, 2)); | 337 menu_button_->set_border(views::Border::CreateEmptyBorder(0, 0, 0, 2)); |
| 338 } | 338 } |
| 339 | 339 |
| 340 views::GridLayout* layout = new views::GridLayout(this); | 340 views::GridLayout* layout = new views::GridLayout(this); |
| 341 SetLayoutManager(layout); | 341 SetLayoutManager(layout); |
| 342 | 342 |
| 343 views::ColumnSet* columns = layout->AddColumnSet(0); | 343 views::ColumnSet* columns = layout->AddColumnSet(0); |
| 344 | 344 |
| 345 columns->AddPaddingColumn(0, kTrayPopupPaddingHorizontal/2); | 345 int padding_width = kTrayPopupPaddingHorizontal/2; |
|
msw
2012/07/27 20:32:04
nit: const
stevenjb
2012/07/30 20:09:03
Done.
| |
| 346 columns->AddPaddingColumn(0, padding_width); | |
| 346 | 347 |
| 347 // Notification Icon. | 348 // Notification Icon. |
| 348 columns->AddColumn(views::GridLayout::CENTER, views::GridLayout::LEADING, | 349 columns->AddColumn(views::GridLayout::CENTER, views::GridLayout::LEADING, |
| 349 0, /* resize percent */ | 350 0, /* resize percent */ |
| 350 views::GridLayout::FIXED, | 351 views::GridLayout::FIXED, |
| 351 kWebNotificationIconSize, kWebNotificationIconSize); | 352 kWebNotificationIconSize, kWebNotificationIconSize); |
| 352 | 353 |
| 353 columns->AddPaddingColumn(0, kTrayPopupPaddingHorizontal/2); | 354 columns->AddPaddingColumn(0, padding_width); |
| 354 | 355 |
| 355 // Notification message text. | 356 // Notification message text. |
| 357 int message_width = kWebNotificationWidth - kWebNotificationIconSize - | |
|
msw
2012/07/27 20:32:04
nit: const
stevenjb
2012/07/30 20:09:03
Done.
| |
| 358 kWebNotificationButtonWidth - (padding_width * 3); | |
| 356 columns->AddColumn(views::GridLayout::FILL, views::GridLayout::LEADING, | 359 columns->AddColumn(views::GridLayout::FILL, views::GridLayout::LEADING, |
| 357 100, /* resize percent */ | 360 100, /* resize percent */ |
| 358 views::GridLayout::USE_PREF, 0, 0); | 361 views::GridLayout::FIXED, message_width, message_width); |
| 359 | 362 |
| 360 columns->AddPaddingColumn(0, kTrayPopupPaddingHorizontal/2); | 363 columns->AddPaddingColumn(0, padding_width); |
| 361 | 364 |
| 362 // Close and menu buttons. | 365 // Close and menu buttons. |
| 363 columns->AddColumn(views::GridLayout::CENTER, views::GridLayout::LEADING, | 366 columns->AddColumn(views::GridLayout::CENTER, views::GridLayout::LEADING, |
| 364 0, /* resize percent */ | 367 0, /* resize percent */ |
| 365 views::GridLayout::FIXED, | 368 views::GridLayout::FIXED, |
| 366 kWebNotificationButtonWidth, | 369 kWebNotificationButtonWidth, |
| 367 kWebNotificationButtonWidth); | 370 kWebNotificationButtonWidth); |
| 368 | 371 |
| 369 // Layout rows | 372 // Layout rows |
| 370 layout->AddPaddingRow(0, kTrayPopupPaddingBetweenItems); | 373 layout->AddPaddingRow(0, kTrayPopupPaddingBetweenItems); |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 475 | 478 |
| 476 private: | 479 private: |
| 477 WebNotificationTray* tray_; | 480 WebNotificationTray* tray_; |
| 478 TrayPopupTextButton* close_all_button_; | 481 TrayPopupTextButton* close_all_button_; |
| 479 | 482 |
| 480 DISALLOW_COPY_AND_ASSIGN(WebNotificationButtonView); | 483 DISALLOW_COPY_AND_ASSIGN(WebNotificationButtonView); |
| 481 }; | 484 }; |
| 482 | 485 |
| 483 } // namespace internal | 486 } // namespace internal |
| 484 | 487 |
| 488 using internal::TrayBubbleView; | |
| 485 using internal::WebNotificationList; | 489 using internal::WebNotificationList; |
| 486 using internal::WebNotificationView; | 490 using internal::WebNotificationView; |
| 487 | 491 |
| 488 class WebNotificationTray::BubbleContentsView : public views::View { | 492 class WebNotificationTray::BubbleContentsView : public views::View { |
| 489 public: | 493 public: |
| 490 explicit BubbleContentsView(WebNotificationTray* tray) | 494 explicit BubbleContentsView(WebNotificationTray* tray) |
| 491 : tray_(tray) { | 495 : tray_(tray) { |
| 492 set_border(views::Border::CreateSolidSidedBorder( | 496 set_border(views::Border::CreateSolidSidedBorder( |
| 493 1, 1, 1, 1, ash::kBorderDarkColor)); | 497 1, 1, 1, 1, ash::kBorderDarkColor)); |
| 494 | 498 |
| 495 SetLayoutManager( | 499 SetLayoutManager( |
| 496 new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 1)); | 500 new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 1)); |
| 497 set_background(views::Background::CreateSolidBackground(kBackgroundColor)); | 501 set_background(views::Background::CreateSolidBackground(kBackgroundColor)); |
| 498 | 502 |
| 499 scroll_content_ = new views::View; | 503 scroll_content_ = new views::View; |
| 500 scroll_content_->SetLayoutManager( | 504 scroll_content_->SetLayoutManager( |
| 501 new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 1)); | 505 new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 1)); |
| 506 | |
| 502 scroller_ = new internal::FixedSizedScrollView; | 507 scroller_ = new internal::FixedSizedScrollView; |
| 503 scroller_->SetContentsView(scroll_content_); | 508 scroller_->SetContentsView(scroll_content_); |
| 504 AddChildView(scroller_); | 509 AddChildView(scroller_); |
| 505 | 510 |
| 506 button_view_ = new internal::WebNotificationButtonView(tray); | 511 button_view_ = new internal::WebNotificationButtonView(tray); |
| 507 AddChildView(button_view_); | 512 AddChildView(button_view_); |
| 508 } | 513 } |
| 509 | 514 |
| 510 void Update(const WebNotificationList::Notifications& notifications) { | 515 void Update(const WebNotificationList::Notifications& notifications) { |
| 511 scroll_content_->RemoveAllChildViews(true); | 516 scroll_content_->RemoveAllChildViews(true); |
| 512 int num_children = notifications.size(); | 517 int num_children = 0; |
| 513 WebNotificationList::Notifications::const_iterator iter = | 518 for (WebNotificationList::Notifications::const_iterator iter = |
| 514 notifications.begin(); | 519 notifications.begin(); iter != notifications.end(); ++iter) { |
| 515 if (num_children > kMaxVisibleNotifications) { | |
| 516 std::advance(iter, num_children - kMaxVisibleNotifications); | |
| 517 num_children = kMaxVisibleNotifications; | |
| 518 } | |
| 519 for (; iter != notifications.end(); ++iter) { | |
| 520 WebNotificationView* view = new WebNotificationView(tray_, *iter); | 520 WebNotificationView* view = new WebNotificationView(tray_, *iter); |
| 521 scroll_content_->AddChildView(view); | 521 scroll_content_->AddChildView(view); |
| 522 if (++num_children >= kMaxVisibleNotifications) | |
| 523 break; | |
| 522 } | 524 } |
| 523 // Layout this first to set the preferred size of the scroller. | 525 SizeScrollContent(); |
| 524 PreferredSizeChanged(); | |
| 525 Layout(); | |
| 526 // Now layout the widget with this correctly sized. | |
| 527 PreferredSizeChanged(); | |
| 528 GetWidget()->GetRootView()->Layout(); | |
| 529 GetWidget()->GetRootView()->SchedulePaint(); | 526 GetWidget()->GetRootView()->SchedulePaint(); |
| 530 | |
| 531 // Scroll to show the most recent notification. | |
| 532 if (num_children > 0) { | |
| 533 scroll_content_->ScrollRectToVisible( | |
| 534 scroll_content_->child_at(num_children - 1)->bounds()); | |
| 535 } | |
| 536 } | |
| 537 | |
| 538 // Overridden from views::View: | |
| 539 virtual void Layout() OVERRIDE { | |
| 540 SizeScrollContent(); | |
| 541 views::View::Layout(); | |
| 542 } | 527 } |
| 543 | 528 |
| 544 private: | 529 private: |
| 545 void SizeScrollContent() { | 530 void SizeScrollContent() { |
| 546 gfx::Size scroll_size = scroll_content_->GetPreferredSize(); | 531 gfx::Size scroll_size = scroll_content_->GetPreferredSize(); |
| 547 int button_height = button_view_->GetPreferredSize().height(); | 532 int button_height = button_view_->GetPreferredSize().height(); |
| 548 int scroll_height = std::min( | 533 int scroll_height = std::min( |
| 549 std::max(scroll_size.height(), | 534 std::max(scroll_size.height(), |
| 550 kWebNotificationBubbleMinHeight - button_height), | 535 kWebNotificationBubbleMinHeight - button_height), |
| 551 kWebNotificationBubbleMaxHeight - button_height); | 536 kWebNotificationBubbleMaxHeight - button_height); |
| 552 if (scroll_height < scroll_size.height()) { | 537 scroll_size.set_height(scroll_height); |
| 553 scroll_size.set_height(scroll_height); | 538 scroller_->SetFixedSize(scroll_size); |
| 554 scroller_->SetFixedSize(scroll_size); | 539 scroller_->SizeToPreferredSize(); |
| 555 } else { | |
| 556 scroller_->SetFixedSize(gfx::Size()); | |
| 557 } | |
| 558 scroller_->InvalidateLayout(); | |
| 559 } | 540 } |
| 560 | 541 |
| 561 WebNotificationTray* tray_; | 542 WebNotificationTray* tray_; |
| 562 internal::FixedSizedScrollView* scroller_; | 543 internal::FixedSizedScrollView* scroller_; |
| 563 views::View* scroll_content_; | 544 views::View* scroll_content_; |
| 564 internal::WebNotificationButtonView* button_view_; | 545 internal::WebNotificationButtonView* button_view_; |
| 565 | 546 |
| 566 DISALLOW_COPY_AND_ASSIGN(BubbleContentsView); | 547 DISALLOW_COPY_AND_ASSIGN(BubbleContentsView); |
| 567 }; | 548 }; |
| 568 | 549 |
| 569 class WebNotificationTray::Bubble : public internal::TrayBubbleView::Host, | 550 class WebNotificationTray::Bubble : public TrayBubbleView::Host, |
| 570 public views::Widget::Observer { | 551 public views::Widget::Observer { |
| 571 public: | 552 public: |
| 572 explicit Bubble(WebNotificationTray* tray) | 553 explicit Bubble(WebNotificationTray* tray) |
| 573 : tray_(tray), | 554 : tray_(tray), |
| 574 bubble_view_(NULL), | 555 bubble_view_(NULL), |
| 575 bubble_widget_(NULL), | 556 bubble_widget_(NULL), |
| 576 contents_view_(NULL), | 557 contents_view_(NULL), |
| 577 ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)) { | 558 ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)) { |
| 578 views::View* anchor = tray->tray_container(); | 559 views::View* anchor = tray->tray_container(); |
| 579 views::BubbleBorder::ArrowLocation arrow_location; | 560 TrayBubbleView::InitParams init_params(TrayBubbleView::ANCHOR_TYPE_TRAY, |
| 580 int arrow_offset = 0; | 561 tray->shelf_alignment()); |
| 562 init_params.bubble_width = kWebNotificationWidth; | |
| 563 init_params.max_height = kWebNotificationBubbleMaxHeight; | |
| 581 if (tray_->shelf_alignment() == SHELF_ALIGNMENT_BOTTOM) { | 564 if (tray_->shelf_alignment() == SHELF_ALIGNMENT_BOTTOM) { |
| 582 arrow_location = views::BubbleBorder::BOTTOM_RIGHT; | 565 gfx::Rect bounds(anchor->width() / 2, 0, 0, 0); |
| 583 arrow_offset = anchor->GetContentsBounds().width() / 2; | 566 bounds = anchor->ConvertRectToWidget(bounds); |
|
msw
2012/07/27 20:32:04
nit: Use Point.
stevenjb
2012/07/30 20:09:03
Done.
| |
| 584 } else if (tray_->shelf_alignment() == SHELF_ALIGNMENT_LEFT) { | 567 init_params.arrow_offset = bounds.x(); |
| 585 arrow_location = views::BubbleBorder::LEFT_BOTTOM; | |
| 586 } else { | |
| 587 arrow_location = views::BubbleBorder::RIGHT_BOTTOM; | |
| 588 } | 568 } |
| 589 bubble_view_ = new internal::TrayBubbleView( | 569 bubble_view_ = TrayBubbleView::Create(anchor, this, init_params); |
| 590 anchor, arrow_location, this, false, kWebNotificationWidth); | |
| 591 bubble_view_->SetMaxHeight(kWebNotificationBubbleMaxHeight); | |
| 592 | |
| 593 bubble_widget_ = views::BubbleDelegateView::CreateBubble(bubble_view_); | |
| 594 | |
| 595 bubble_view_->SetAlignment(views::BubbleBorder::ALIGN_EDGE_TO_ANCHOR_EDGE); | |
| 596 bubble_widget_->non_client_view()->frame_view()->set_background(NULL); | |
| 597 bubble_view_->SetBubbleBorder(arrow_offset); | |
| 598 | |
| 599 bubble_widget_->AddObserver(this); | |
| 600 | 570 |
| 601 contents_view_ = new BubbleContentsView(tray); | 571 contents_view_ = new BubbleContentsView(tray); |
| 602 bubble_view_->AddChildView(contents_view_); | 572 bubble_view_->AddChildView(contents_view_); |
| 603 | 573 |
| 604 InitializeHost(bubble_widget_, tray_); | 574 bubble_widget_ = views::BubbleDelegateView::CreateBubble(bubble_view_); |
| 575 bubble_widget_->AddObserver(this); | |
| 576 | |
| 577 PostCreateBubble(bubble_widget_, bubble_view_, tray_); | |
| 605 | 578 |
| 606 ScheduleUpdate(); | 579 ScheduleUpdate(); |
| 607 } | 580 } |
| 608 | 581 |
| 609 virtual ~Bubble() { | 582 virtual ~Bubble() { |
| 610 if (bubble_view_) | 583 if (bubble_view_) |
| 611 bubble_view_->reset_host(); | 584 bubble_view_->reset_host(); |
| 612 if (bubble_widget_) { | 585 if (bubble_widget_) { |
| 613 bubble_widget_->RemoveObserver(this); | 586 bubble_widget_->RemoveObserver(this); |
| 614 bubble_widget_->Close(); | 587 bubble_widget_->Close(); |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 625 } | 598 } |
| 626 | 599 |
| 627 views::Widget* bubble_widget() const { return bubble_widget_; } | 600 views::Widget* bubble_widget() const { return bubble_widget_; } |
| 628 | 601 |
| 629 // Overridden from TrayBubbleView::Host. | 602 // Overridden from TrayBubbleView::Host. |
| 630 virtual void BubbleViewDestroyed() OVERRIDE { | 603 virtual void BubbleViewDestroyed() OVERRIDE { |
| 631 bubble_view_ = NULL; | 604 bubble_view_ = NULL; |
| 632 contents_view_ = NULL; | 605 contents_view_ = NULL; |
| 633 } | 606 } |
| 634 | 607 |
| 635 virtual gfx::Rect GetAnchorRect() const OVERRIDE { | |
| 636 gfx::Rect anchor_rect = tray_->tray_container()->GetBoundsInScreen(); | |
| 637 return anchor_rect; | |
| 638 } | |
| 639 | |
| 640 virtual void OnMouseEnteredView() OVERRIDE { | 608 virtual void OnMouseEnteredView() OVERRIDE { |
| 641 } | 609 } |
| 642 | 610 |
| 643 virtual void OnMouseExitedView() OVERRIDE { | 611 virtual void OnMouseExitedView() OVERRIDE { |
| 644 } | 612 } |
| 645 | 613 |
| 646 virtual void OnClickedOutsideView() OVERRIDE { | 614 virtual void OnClickedOutsideView() OVERRIDE { |
| 647 // May delete |this|. | 615 // May delete |this|. |
| 648 tray_->status_area_widget()->HideWebNotificationBubble(); | 616 tray_->status_area_widget()->HideWebNotificationBubble(); |
| 649 } | 617 } |
| 650 | 618 |
| 651 // Overridden from views::Widget::Observer. | 619 // Overridden from views::Widget::Observer. |
| 652 virtual void OnWidgetClosing(views::Widget* widget) OVERRIDE { | 620 virtual void OnWidgetClosing(views::Widget* widget) OVERRIDE { |
| 653 CHECK_EQ(bubble_widget_, widget); | 621 CHECK_EQ(bubble_widget_, widget); |
| 654 bubble_widget_ = NULL; | 622 bubble_widget_ = NULL; |
| 655 tray_->HideBubble(); // Will destroy |this|. | 623 tray_->HideBubble(); // Will destroy |this|. |
| 656 } | 624 } |
| 657 | 625 |
| 658 private: | 626 private: |
| 659 void UpdateBubbleView() { | 627 void UpdateBubbleView() { |
| 660 contents_view_->Update(tray_->notification_list()->notifications()); | 628 contents_view_->Update(tray_->notification_list()->notifications()); |
| 661 bubble_view_->Show(); | 629 bubble_view_->Show(); |
| 630 bubble_view_->UpdateBubble(); | |
| 662 } | 631 } |
| 663 | 632 |
| 664 WebNotificationTray* tray_; | 633 WebNotificationTray* tray_; |
| 665 internal::TrayBubbleView* bubble_view_; | 634 TrayBubbleView* bubble_view_; |
| 666 views::Widget* bubble_widget_; | 635 views::Widget* bubble_widget_; |
| 667 BubbleContentsView* contents_view_; | 636 BubbleContentsView* contents_view_; |
| 668 base::WeakPtrFactory<Bubble> weak_ptr_factory_; | 637 base::WeakPtrFactory<Bubble> weak_ptr_factory_; |
| 669 | 638 |
| 670 DISALLOW_COPY_AND_ASSIGN(Bubble); | 639 DISALLOW_COPY_AND_ASSIGN(Bubble); |
| 671 }; | 640 }; |
| 672 | 641 |
| 673 WebNotificationTray::WebNotificationTray( | 642 WebNotificationTray::WebNotificationTray( |
| 674 internal::StatusAreaWidget* status_area_widget) | 643 internal::StatusAreaWidget* status_area_widget) |
| 675 : status_area_widget_(status_area_widget), | 644 : status_area_widget_(status_area_widget), |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 810 } | 779 } |
| 811 | 780 |
| 812 void WebNotificationTray::SetShelfAlignment(ShelfAlignment alignment) { | 781 void WebNotificationTray::SetShelfAlignment(ShelfAlignment alignment) { |
| 813 internal::TrayBackgroundView::SetShelfAlignment(alignment); | 782 internal::TrayBackgroundView::SetShelfAlignment(alignment); |
| 814 SetTrayContainerBorder(); | 783 SetTrayContainerBorder(); |
| 815 SetBorder(); | 784 SetBorder(); |
| 816 tray_container_->SetLayoutManager(new views::BoxLayout( | 785 tray_container_->SetLayoutManager(new views::BoxLayout( |
| 817 alignment == SHELF_ALIGNMENT_BOTTOM ? | 786 alignment == SHELF_ALIGNMENT_BOTTOM ? |
| 818 views::BoxLayout::kHorizontal : views::BoxLayout::kVertical, | 787 views::BoxLayout::kHorizontal : views::BoxLayout::kVertical, |
| 819 0, 0, 0)); | 788 0, 0, 0)); |
| 789 // Destroy any existing bubble so that it will be rebuilt correctly. | |
| 790 bubble_.reset(); | |
| 820 } | 791 } |
| 821 | 792 |
| 822 bool WebNotificationTray::PerformAction(const views::Event& event) { | 793 bool WebNotificationTray::PerformAction(const views::Event& event) { |
| 823 if (bubble()) { | 794 if (bubble()) { |
| 824 status_area_widget_->HideWebNotificationBubble(); | 795 status_area_widget_->HideWebNotificationBubble(); |
| 825 } else { | 796 } else { |
| 826 status_area_widget_->ShowWebNotificationBubble( | 797 status_area_widget_->ShowWebNotificationBubble( |
| 827 internal::StatusAreaWidget::USER_ACTION); | 798 internal::StatusAreaWidget::USER_ACTION); |
| 828 } | 799 } |
| 829 return true; | 800 return true; |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 887 UpdateIcon(); | 858 UpdateIcon(); |
| 888 if (!bubble()) | 859 if (!bubble()) |
| 889 return; | 860 return; |
| 890 if (GetNotificationCount() == 0) | 861 if (GetNotificationCount() == 0) |
| 891 status_area_widget_->HideWebNotificationBubble(); | 862 status_area_widget_->HideWebNotificationBubble(); |
| 892 else | 863 else |
| 893 bubble_->ScheduleUpdate(); | 864 bubble_->ScheduleUpdate(); |
| 894 } | 865 } |
| 895 | 866 |
| 896 } // namespace ash | 867 } // namespace ash |
| OLD | NEW |