tray_bubble_wrapper.h 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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
  3. // found in the LICENSE file.
  4. #ifndef ASH_SYSTEM_TRAY_TRAY_BUBBLE_WRAPPER_H_
  5. #define ASH_SYSTEM_TRAY_TRAY_BUBBLE_WRAPPER_H_
  6. #include "ash/ash_export.h"
  7. #include "ash/system/tray/tray_bubble_base.h"
  8. #include "ui/views/widget/widget_observer.h"
  9. #include "ui/wm/public/activation_change_observer.h"
  10. namespace ash {
  11. class TrayBackgroundView;
  12. class TrayBubbleView;
  13. // Creates and manages the Widget and EventFilter components of a bubble.
  14. // TODO(tetsui): Remove this and use TrayBubbleBase for all bubbles.
  15. class ASH_EXPORT TrayBubbleWrapper : public TrayBubbleBase,
  16. public ::wm::ActivationChangeObserver {
  17. public:
  18. // `event_handling` When set to false disables the tray's event filtering
  19. // and also ignores the activation events. Eche window is an example of a use
  20. // case in which we do not want the keyboard events (both inside and outside
  21. // of the bubble) be filtered and also we do not want activaion of other
  22. // windows closes the bubble.
  23. TrayBubbleWrapper(TrayBackgroundView* tray,
  24. TrayBubbleView* bubble_view,
  25. bool event_handling = true);
  26. TrayBubbleWrapper(const TrayBubbleWrapper&) = delete;
  27. TrayBubbleWrapper& operator=(const TrayBubbleWrapper&) = delete;
  28. ~TrayBubbleWrapper() override;
  29. // TrayBubbleBase overrides:
  30. TrayBackgroundView* GetTray() const override;
  31. TrayBubbleView* GetBubbleView() const override;
  32. views::Widget* GetBubbleWidget() const override;
  33. // views::WidgetObserver overrides:
  34. void OnWidgetDestroying(views::Widget* widget) override;
  35. void OnWidgetBoundsChanged(views::Widget* widget,
  36. const gfx::Rect& new_bounds) override;
  37. // ::wm::ActivationChangeObserver overrides:
  38. void OnWindowActivated(ActivationReason reason,
  39. aura::Window* gained_active,
  40. aura::Window* lost_active) override;
  41. TrayBackgroundView* tray() { return tray_; }
  42. TrayBubbleView* bubble_view() { return bubble_view_; }
  43. views::Widget* bubble_widget() { return bubble_widget_; }
  44. private:
  45. TrayBackgroundView* tray_;
  46. TrayBubbleView* bubble_view_; // unowned
  47. views::Widget* bubble_widget_;
  48. // When set to false disables the tray's event filtering
  49. // and also ignores the activation events. Eche window is an example of a use
  50. // case in which we do not want the keyboard events (both inside and outside
  51. // of the bubble) be filtered and also we do not want activaion of other
  52. // windows closes the bubble.
  53. const bool event_handling_;
  54. };
  55. } // namespace ash
  56. #endif // ASH_SYSTEM_TRAY_TRAY_BUBBLE_WRAPPER_H_