OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef ASH_COMMON_SYSTEM_WEB_NOTIFICATION_ASH_POPUP_ALIGNMENT_DELEGATE_H_ | |
6 #define ASH_COMMON_SYSTEM_WEB_NOTIFICATION_ASH_POPUP_ALIGNMENT_DELEGATE_H_ | |
7 | |
8 #include <stdint.h> | |
9 | |
10 #include "ash/ash_export.h" | |
11 #include "ash/common/shelf/wm_shelf_observer.h" | |
12 #include "ash/common/shell_observer.h" | |
13 #include "ash/public/cpp/shelf_types.h" | |
14 #include "base/macros.h" | |
15 #include "ui/display/display_observer.h" | |
16 #include "ui/gfx/geometry/rect.h" | |
17 #include "ui/message_center/views/popup_alignment_delegate.h" | |
18 | |
19 namespace display { | |
20 class Screen; | |
21 } | |
22 | |
23 namespace ash { | |
24 | |
25 class AshPopupAlignmentDelegateTest; | |
26 class WebNotificationTrayTest; | |
27 class WmShelf; | |
28 | |
29 // The PopupAlignmentDelegate subclass for Ash. It needs to handle alignment of | |
30 // the shelf and its autohide state. | |
31 class ASH_EXPORT AshPopupAlignmentDelegate | |
32 : public message_center::PopupAlignmentDelegate, | |
33 public WmShelfObserver, | |
34 public ShellObserver, | |
35 public display::DisplayObserver { | |
36 public: | |
37 explicit AshPopupAlignmentDelegate(WmShelf* shelf); | |
38 ~AshPopupAlignmentDelegate() override; | |
39 | |
40 // Start observing the system. | |
41 void StartObserving(display::Screen* screen, const display::Display& display); | |
42 | |
43 // Sets the current height of the system tray bubble (or legacy notification | |
44 // bubble) so that web notification toasts can avoid it. | |
45 void SetTrayBubbleHeight(int height); | |
46 | |
47 // Returns the current tray bubble height or 0 if there is no bubble. | |
48 int tray_bubble_height_for_test() const { return tray_bubble_height_; } | |
49 | |
50 // Overridden from message_center::PopupAlignmentDelegate: | |
51 int GetToastOriginX(const gfx::Rect& toast_bounds) const override; | |
52 int GetBaseLine() const override; | |
53 gfx::Rect GetWorkArea() const override; | |
54 bool IsTopDown() const override; | |
55 bool IsFromLeft() const override; | |
56 void RecomputeAlignment(const display::Display& display) override; | |
57 void ConfigureWidgetInitParamsForContainer( | |
58 views::Widget* widget, | |
59 views::Widget::InitParams* init_params) override; | |
60 | |
61 private: | |
62 friend class AshPopupAlignmentDelegateTest; | |
63 friend class WebNotificationTrayTest; | |
64 | |
65 // Get the current alignment of the shelf. | |
66 ShelfAlignment GetAlignment() const; | |
67 | |
68 // Utility function to get the display which should be care about. | |
69 display::Display GetCurrentDisplay() const; | |
70 | |
71 // Compute the new work area. | |
72 void UpdateWorkArea(); | |
73 | |
74 // WmShelfObserver: | |
75 void WillChangeVisibilityState(ShelfVisibilityState new_state) override; | |
76 void OnAutoHideStateChanged(ShelfAutoHideState new_state) override; | |
77 | |
78 // Overridden from display::DisplayObserver: | |
79 void OnDisplayAdded(const display::Display& new_display) override; | |
80 void OnDisplayRemoved(const display::Display& old_display) override; | |
81 void OnDisplayMetricsChanged(const display::Display& display, | |
82 uint32_t metrics) override; | |
83 | |
84 display::Screen* screen_; | |
85 gfx::Rect work_area_; | |
86 WmShelf* shelf_; | |
87 int tray_bubble_height_; | |
88 | |
89 DISALLOW_COPY_AND_ASSIGN(AshPopupAlignmentDelegate); | |
90 }; | |
91 | |
92 } // namespace ash | |
93 | |
94 #endif // ASH_COMMON_SYSTEM_WEB_NOTIFICATION_ASH_POPUP_ALIGNMENT_DELEGATE_H_ | |
OLD | NEW |