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" |
11 #include "base/bind.h" | 11 #include "base/bind.h" |
12 #include "base/message_loop.h" | 12 #include "base/message_loop.h" |
13 #include "grit/ash_strings.h" | 13 #include "grit/ash_strings.h" |
14 #include "grit/ui_resources.h" | 14 #include "grit/ui_resources.h" |
15 #include "ui/aura/window.h" | 15 #include "ui/aura/window.h" |
16 #include "ui/base/l10n/l10n_util.h" | 16 #include "ui/base/l10n/l10n_util.h" |
17 #include "ui/base/models/simple_menu_model.h" | 17 #include "ui/base/models/simple_menu_model.h" |
18 #include "ui/base/resource/resource_bundle.h" | 18 #include "ui/base/resource/resource_bundle.h" |
19 #include "ui/gfx/image/image_skia_operations.h" | 19 #include "ui/gfx/image/image_skia_operations.h" |
20 #include "ui/views/controls/button/button.h" | 20 #include "ui/views/controls/button/button.h" |
21 #include "ui/views/controls/button/menu_button.h" | 21 #include "ui/views/controls/button/menu_button.h" |
22 #include "ui/views/controls/button/menu_button_listener.h" | 22 #include "ui/views/controls/button/menu_button_listener.h" |
23 #include "ui/views/controls/label.h" | 23 #include "ui/views/controls/label.h" |
24 #include "ui/views/controls/menu/menu_model_adapter.h" | 24 #include "ui/views/controls/menu/menu_model_adapter.h" |
25 #include "ui/views/controls/menu/menu_runner.h" | 25 #include "ui/views/controls/menu/menu_runner.h" |
26 #include "ui/views/layout/box_layout.h" | 26 #include "ui/views/layout/box_layout.h" |
27 #include "ui/views/layout/fill_layout.h" | 27 #include "ui/views/layout/fill_layout.h" |
28 #include "ui/views/layout/grid_layout.h" | 28 #include "ui/views/layout/grid_layout.h" |
29 #include "ui/views/painter.h" | 29 #include "ui/views/painter.h" |
| 30 #include "ui/views/widget/widget_observer.h" |
30 | 31 |
31 namespace { | 32 namespace { |
32 | 33 |
33 // Tray constants | 34 // Tray constants |
34 const int kTrayContainerVeritcalPaddingBottomAlignment = 3; | 35 const int kTrayContainerVeritcalPaddingBottomAlignment = 3; |
35 const int kTrayContainerHorizontalPaddingBottomAlignment = 1; | 36 const int kTrayContainerHorizontalPaddingBottomAlignment = 1; |
36 const int kTrayContainerVerticalPaddingVerticalAlignment = 1; | 37 const int kTrayContainerVerticalPaddingVerticalAlignment = 1; |
37 const int kTrayContainerHorizontalPaddingVerticalAlignment = 0; | 38 const int kTrayContainerHorizontalPaddingVerticalAlignment = 0; |
38 const int kPaddingFromLeftEdgeOfSystemTrayBottomAlignment = 8; | 39 const int kPaddingFromLeftEdgeOfSystemTrayBottomAlignment = 8; |
39 const int kPaddingFromTopEdgeOfSystemTrayVerticalAlignment = 10; | 40 const int kPaddingFromTopEdgeOfSystemTrayVerticalAlignment = 10; |
(...skipping 500 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
540 | 541 |
541 WebNotificationTray* tray_; | 542 WebNotificationTray* tray_; |
542 internal::FixedSizedScrollView* scroller_; | 543 internal::FixedSizedScrollView* scroller_; |
543 views::View* scroll_content_; | 544 views::View* scroll_content_; |
544 internal::WebNotificationButtonView* button_view_; | 545 internal::WebNotificationButtonView* button_view_; |
545 | 546 |
546 DISALLOW_COPY_AND_ASSIGN(BubbleContentsView); | 547 DISALLOW_COPY_AND_ASSIGN(BubbleContentsView); |
547 }; | 548 }; |
548 | 549 |
549 class WebNotificationTray::Bubble : public internal::TrayBubbleView::Host, | 550 class WebNotificationTray::Bubble : public internal::TrayBubbleView::Host, |
550 public views::Widget::Observer { | 551 public views::WidgetObserver { |
551 public: | 552 public: |
552 explicit Bubble(WebNotificationTray* tray) | 553 explicit Bubble(WebNotificationTray* tray) |
553 : tray_(tray), | 554 : tray_(tray), |
554 bubble_view_(NULL), | 555 bubble_view_(NULL), |
555 bubble_widget_(NULL), | 556 bubble_widget_(NULL), |
556 contents_view_(NULL), | 557 contents_view_(NULL), |
557 ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)) { | 558 ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)) { |
558 views::View* anchor = tray->tray_container(); | 559 views::View* anchor = tray->tray_container(); |
559 views::BubbleBorder::ArrowLocation arrow_location; | 560 views::BubbleBorder::ArrowLocation arrow_location; |
560 int arrow_offset = 0; | 561 int arrow_offset = 0; |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
621 } | 622 } |
622 | 623 |
623 virtual void OnMouseExitedView() OVERRIDE { | 624 virtual void OnMouseExitedView() OVERRIDE { |
624 } | 625 } |
625 | 626 |
626 virtual void OnClickedOutsideView() OVERRIDE { | 627 virtual void OnClickedOutsideView() OVERRIDE { |
627 // May delete |this|. | 628 // May delete |this|. |
628 tray_->status_area_widget()->HideWebNotificationBubble(); | 629 tray_->status_area_widget()->HideWebNotificationBubble(); |
629 } | 630 } |
630 | 631 |
631 // Overridden from views::Widget::Observer. | 632 // Overridden from views::WidgetObserver: |
632 virtual void OnWidgetClosing(views::Widget* widget) OVERRIDE { | 633 virtual void OnWidgetClosing(views::Widget* widget) OVERRIDE { |
633 CHECK_EQ(bubble_widget_, widget); | 634 CHECK_EQ(bubble_widget_, widget); |
634 bubble_widget_ = NULL; | 635 bubble_widget_ = NULL; |
635 tray_->HideBubble(); // Will destroy |this|. | 636 tray_->HideBubble(); // Will destroy |this|. |
636 } | 637 } |
637 | 638 |
638 private: | 639 private: |
639 void UpdateBubbleView() { | 640 void UpdateBubbleView() { |
640 contents_view_->Update(tray_->notification_list()->notifications()); | 641 contents_view_->Update(tray_->notification_list()->notifications()); |
641 bubble_view_->Show(); | 642 bubble_view_->Show(); |
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
870 UpdateIcon(); | 871 UpdateIcon(); |
871 if (!bubble()) | 872 if (!bubble()) |
872 return; | 873 return; |
873 if (GetNotificationCount() == 0) | 874 if (GetNotificationCount() == 0) |
874 status_area_widget_->HideWebNotificationBubble(); | 875 status_area_widget_->HideWebNotificationBubble(); |
875 else | 876 else |
876 bubble_->ScheduleUpdate(); | 877 bubble_->ScheduleUpdate(); |
877 } | 878 } |
878 | 879 |
879 } // namespace ash | 880 } // namespace ash |
OLD | NEW |