| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #ifndef ASH_SYSTEM_WEB_NOTIFICATION_ASH_POPUP_ALIGNMENT_DELEGATE_H_ | 5 #ifndef ASH_SYSTEM_WEB_NOTIFICATION_ASH_POPUP_ALIGNMENT_DELEGATE_H_ |
| 6 #define ASH_SYSTEM_WEB_NOTIFICATION_ASH_POPUP_ALIGNMENT_DELEGATE_H_ | 6 #define ASH_SYSTEM_WEB_NOTIFICATION_ASH_POPUP_ALIGNMENT_DELEGATE_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include "ash/ash_export.h" | 10 #include "ash/ash_export.h" |
| 11 #include "ash/shelf/shelf_layout_manager_observer.h" | 11 #include "ash/shelf/shelf_layout_manager_observer.h" |
| 12 #include "ash/shelf/shelf_types.h" | 12 #include "ash/shelf/shelf_types.h" |
| 13 #include "ash/shell_observer.h" | 13 #include "ash/shell_observer.h" |
| 14 #include "base/macros.h" | 14 #include "base/macros.h" |
| 15 #include "ui/gfx/display_observer.h" | 15 #include "ui/display/display_observer.h" |
| 16 #include "ui/gfx/geometry/rect.h" | 16 #include "ui/gfx/geometry/rect.h" |
| 17 #include "ui/message_center/views/popup_alignment_delegate.h" | 17 #include "ui/message_center/views/popup_alignment_delegate.h" |
| 18 | 18 |
| 19 namespace aura { | 19 namespace aura { |
| 20 class Window; | 20 class Window; |
| 21 } | 21 } |
| 22 | 22 |
| 23 namespace gfx { | 23 namespace gfx { |
| 24 class Screen; | 24 class Screen; |
| 25 } | 25 } |
| 26 | 26 |
| 27 namespace display { |
| 28 using Screen = gfx::Screen; |
| 29 } |
| 30 |
| 27 namespace ash { | 31 namespace ash { |
| 28 | 32 |
| 29 class AshPopupAlignmentDelegateTest; | 33 class AshPopupAlignmentDelegateTest; |
| 30 class ShelfLayoutManager; | 34 class ShelfLayoutManager; |
| 31 class WebNotificationTrayTest; | 35 class WebNotificationTrayTest; |
| 32 | 36 |
| 33 // The PopupAlignmentDelegate subclass for Ash. It needs to handle alignment of | 37 // The PopupAlignmentDelegate subclass for Ash. It needs to handle alignment of |
| 34 // the shelf and its autohide state. | 38 // the shelf and its autohide state. |
| 35 class ASH_EXPORT AshPopupAlignmentDelegate | 39 class ASH_EXPORT AshPopupAlignmentDelegate |
| 36 : public message_center::PopupAlignmentDelegate, | 40 : public message_center::PopupAlignmentDelegate, |
| 37 public ShelfLayoutManagerObserver, | 41 public ShelfLayoutManagerObserver, |
| 38 public ShellObserver, | 42 public ShellObserver, |
| 39 public gfx::DisplayObserver { | 43 public display::DisplayObserver { |
| 40 public: | 44 public: |
| 41 explicit AshPopupAlignmentDelegate(ShelfLayoutManager* shelf); | 45 explicit AshPopupAlignmentDelegate(ShelfLayoutManager* shelf); |
| 42 ~AshPopupAlignmentDelegate() override; | 46 ~AshPopupAlignmentDelegate() override; |
| 43 | 47 |
| 44 // Start observing the system. | 48 // Start observing the system. |
| 45 void StartObserving(gfx::Screen* screen, const gfx::Display& display); | 49 void StartObserving(display::Screen* screen, const display::Display& display); |
| 46 | 50 |
| 47 // Sets the current height of the system tray so that the notification toasts | 51 // Sets the current height of the system tray so that the notification toasts |
| 48 // can avoid it. | 52 // can avoid it. |
| 49 void SetSystemTrayHeight(int height); | 53 void SetSystemTrayHeight(int height); |
| 50 | 54 |
| 51 // Overridden from message_center::PopupAlignmentDelegate: | 55 // Overridden from message_center::PopupAlignmentDelegate: |
| 52 int GetToastOriginX(const gfx::Rect& toast_bounds) const override; | 56 int GetToastOriginX(const gfx::Rect& toast_bounds) const override; |
| 53 int GetBaseLine() const override; | 57 int GetBaseLine() const override; |
| 54 int GetWorkAreaBottom() const override; | 58 int GetWorkAreaBottom() const override; |
| 55 bool IsTopDown() const override; | 59 bool IsTopDown() const override; |
| 56 bool IsFromLeft() const override; | 60 bool IsFromLeft() const override; |
| 57 void RecomputeAlignment(const gfx::Display& display) override; | 61 void RecomputeAlignment(const display::Display& display) override; |
| 58 | 62 |
| 59 private: | 63 private: |
| 60 friend class AshPopupAlignmentDelegateTest; | 64 friend class AshPopupAlignmentDelegateTest; |
| 61 friend class WebNotificationTrayTest; | 65 friend class WebNotificationTrayTest; |
| 62 | 66 |
| 63 // Get the current alignment of the shelf. | 67 // Get the current alignment of the shelf. |
| 64 wm::ShelfAlignment GetAlignment() const; | 68 wm::ShelfAlignment GetAlignment() const; |
| 65 | 69 |
| 66 // Utility function to get the display which should be care about. | 70 // Utility function to get the display which should be care about. |
| 67 gfx::Display GetCurrentDisplay() const; | 71 display::Display GetCurrentDisplay() const; |
| 68 | 72 |
| 69 // Compute the new work area. | 73 // Compute the new work area. |
| 70 void UpdateWorkArea(); | 74 void UpdateWorkArea(); |
| 71 | 75 |
| 72 // Overridden from ShellObserver: | 76 // Overridden from ShellObserver: |
| 73 void OnDisplayWorkAreaInsetsChanged() override; | 77 void OnDisplayWorkAreaInsetsChanged() override; |
| 74 | 78 |
| 75 // Overridden from ShelfLayoutManagerObserver: | 79 // Overridden from ShelfLayoutManagerObserver: |
| 76 void WillChangeVisibilityState(ShelfVisibilityState new_state) override; | 80 void WillChangeVisibilityState(ShelfVisibilityState new_state) override; |
| 77 void OnAutoHideStateChanged(ShelfAutoHideState new_state) override; | 81 void OnAutoHideStateChanged(ShelfAutoHideState new_state) override; |
| 78 | 82 |
| 79 // Overridden from gfx::DisplayObserver: | 83 // Overridden from display::DisplayObserver: |
| 80 void OnDisplayAdded(const gfx::Display& new_display) override; | 84 void OnDisplayAdded(const display::Display& new_display) override; |
| 81 void OnDisplayRemoved(const gfx::Display& old_display) override; | 85 void OnDisplayRemoved(const display::Display& old_display) override; |
| 82 void OnDisplayMetricsChanged(const gfx::Display& display, | 86 void OnDisplayMetricsChanged(const display::Display& display, |
| 83 uint32_t metrics) override; | 87 uint32_t metrics) override; |
| 84 | 88 |
| 85 gfx::Screen* screen_; | 89 display::Screen* screen_; |
| 86 gfx::Rect work_area_; | 90 gfx::Rect work_area_; |
| 87 ShelfLayoutManager* shelf_; | 91 ShelfLayoutManager* shelf_; |
| 88 int system_tray_height_; | 92 int system_tray_height_; |
| 89 | 93 |
| 90 DISALLOW_COPY_AND_ASSIGN(AshPopupAlignmentDelegate); | 94 DISALLOW_COPY_AND_ASSIGN(AshPopupAlignmentDelegate); |
| 91 }; | 95 }; |
| 92 | 96 |
| 93 } // namespace ash | 97 } // namespace ash |
| 94 | 98 |
| 95 #endif // ASH_SYSTEM_WEB_NOTIFICATION_ASH_POPUP_ALIGNMENT_DELEGATE_H_ | 99 #endif // ASH_SYSTEM_WEB_NOTIFICATION_ASH_POPUP_ALIGNMENT_DELEGATE_H_ |
| OLD | NEW |