| 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_SYSTEM_WEB_NOTIFICATION_ASH_POPUP_ALIGNMENT_DELEGATE_H_ | |
| 6 #define ASH_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/shelf_types.h" | |
| 12 #include "ash/common/shelf/wm_shelf_observer.h" | |
| 13 #include "ash/common/shell_observer.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 ShelfLayoutManager; | |
| 27 class WebNotificationTrayTest; | |
| 28 class WmShelf; | |
| 29 | |
| 30 // The PopupAlignmentDelegate subclass for Ash. It needs to handle alignment of | |
| 31 // the shelf and its autohide state. | |
| 32 class ASH_EXPORT AshPopupAlignmentDelegate | |
| 33 : public message_center::PopupAlignmentDelegate, | |
| 34 public WmShelfObserver, | |
| 35 public ShellObserver, | |
| 36 public display::DisplayObserver { | |
| 37 public: | |
| 38 explicit AshPopupAlignmentDelegate(WmShelf* shelf); | |
| 39 ~AshPopupAlignmentDelegate() override; | |
| 40 | |
| 41 // Start observing the system. | |
| 42 void StartObserving(display::Screen* screen, const display::Display& display); | |
| 43 | |
| 44 // Sets the current height of the system tray so that the notification toasts | |
| 45 // can avoid it. | |
| 46 void SetSystemTrayHeight(int height); | |
| 47 | |
| 48 // Returns the current system tray height. | |
| 49 int system_tray_height_for_test() const { return system_tray_height_; } | |
| 50 | |
| 51 // Overridden from message_center::PopupAlignmentDelegate: | |
| 52 int GetToastOriginX(const gfx::Rect& toast_bounds) const override; | |
| 53 int GetBaseLine() const override; | |
| 54 int GetWorkAreaBottom() const override; | |
| 55 bool IsTopDown() const override; | |
| 56 bool IsFromLeft() const override; | |
| 57 void RecomputeAlignment(const display::Display& display) override; | |
| 58 void ConfigureWidgetInitParamsForContainer( | |
| 59 views::Widget* widget, | |
| 60 views::Widget::InitParams* init_params) override; | |
| 61 | |
| 62 private: | |
| 63 friend class AshPopupAlignmentDelegateTest; | |
| 64 friend class WebNotificationTrayTest; | |
| 65 | |
| 66 // Get the current alignment of the shelf. | |
| 67 ShelfAlignment GetAlignment() const; | |
| 68 | |
| 69 // Utility function to get the display which should be care about. | |
| 70 display::Display GetCurrentDisplay() const; | |
| 71 | |
| 72 // Compute the new work area. | |
| 73 void UpdateWorkArea(); | |
| 74 | |
| 75 // Overridden from ShellObserver: | |
| 76 void OnDisplayWorkAreaInsetsChanged() override; | |
| 77 | |
| 78 // WmShelfObserver: | |
| 79 void WillChangeVisibilityState(ShelfVisibilityState new_state) override; | |
| 80 void OnAutoHideStateChanged(ShelfAutoHideState new_state) override; | |
| 81 | |
| 82 // Overridden from display::DisplayObserver: | |
| 83 void OnDisplayAdded(const display::Display& new_display) override; | |
| 84 void OnDisplayRemoved(const display::Display& old_display) override; | |
| 85 void OnDisplayMetricsChanged(const display::Display& display, | |
| 86 uint32_t metrics) override; | |
| 87 | |
| 88 display::Screen* screen_; | |
| 89 gfx::Rect work_area_; | |
| 90 WmShelf* shelf_; | |
| 91 int system_tray_height_; | |
| 92 | |
| 93 DISALLOW_COPY_AND_ASSIGN(AshPopupAlignmentDelegate); | |
| 94 }; | |
| 95 | |
| 96 } // namespace ash | |
| 97 | |
| 98 #endif // ASH_SYSTEM_WEB_NOTIFICATION_ASH_POPUP_ALIGNMENT_DELEGATE_H_ | |
| OLD | NEW |