Roll src/third_party/WebKit f36d5e0:68b67cd (svn 193299:193303)
[chromium-blink-merge.git] / ash / system / web_notification / ash_popup_alignment_delegate.h
blob1bbaa25913324b25cc3def2dd760d047e6b9e64d
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.
5 #ifndef ASH_SYSTEM_WEB_NOTIFICATION_ASH_POPUP_ALIGNMENT_DELEGATE_H_
6 #define ASH_SYSTEM_WEB_NOTIFICATION_ASH_POPUP_ALIGNMENT_DELEGATE_H_
8 #include "ash/ash_export.h"
9 #include "ash/shelf/shelf_layout_manager_observer.h"
10 #include "ash/shelf/shelf_types.h"
11 #include "ash/shell_observer.h"
12 #include "base/macros.h"
13 #include "ui/gfx/display_observer.h"
14 #include "ui/gfx/geometry/rect.h"
15 #include "ui/message_center/views/popup_alignment_delegate.h"
17 namespace aura {
18 class Window;
21 namespace gfx {
22 class Screen;
25 namespace ash {
27 class AshPopupAlignmentDelegateTest;
28 class ShelfLayoutManager;
29 class WebNotificationTrayTest;
31 // The PopupAlignmentDelegate subclass for Ash. It needs to handle alignment of
32 // the shelf and its autohide state.
33 class ASH_EXPORT AshPopupAlignmentDelegate
34 : public message_center::PopupAlignmentDelegate,
35 public ShelfLayoutManagerObserver,
36 public ShellObserver,
37 public gfx::DisplayObserver {
38 public:
39 AshPopupAlignmentDelegate();
40 ~AshPopupAlignmentDelegate() override;
42 // Start observing the system.
43 void StartObserving(gfx::Screen* screen, const gfx::Display& display);
45 // Sets the current height of the system tray so that the notification toasts
46 // can avoid it.
47 void SetSystemTrayHeight(int height);
49 // Overridden from message_center::PopupAlignmentDelegate:
50 int GetToastOriginX(const gfx::Rect& toast_bounds) const override;
51 int GetBaseLine() const override;
52 int GetWorkAreaBottom() const override;
53 bool IsTopDown() const override;
54 bool IsFromLeft() const override;
55 void RecomputeAlignment(const gfx::Display& display) override;
57 private:
58 friend class AshPopupAlignmentDelegateTest;
59 friend class WebNotificationTrayTest;
61 // Get the current alignment of the shelf.
62 ShelfAlignment GetAlignment() const;
64 // Update |shelf_| and start watching when it's first set. This should not
65 // be done in the constructor because the shelf might not be initialized at
66 // that point.
67 void UpdateShelf();
69 // Utility function to get the display which should be care about.
70 gfx::Display GetCurrentDisplay() const;
72 // Compute the new work area.
73 void UpdateWorkArea(const gfx::Display& display,
74 ShelfAutoHideState new_state);
76 // Overridden from ShellObserver:
77 void OnDisplayWorkAreaInsetsChanged() override;
79 // Overridden from ShelfLayoutManagerObserver:
80 void OnAutoHideStateChanged(ShelfAutoHideState new_state) override;
82 // Overridden from gfx::DisplayObserver:
83 void OnDisplayAdded(const gfx::Display& new_display) override;
84 void OnDisplayRemoved(const gfx::Display& old_display) override;
85 void OnDisplayMetricsChanged(const gfx::Display& display,
86 uint32_t metrics) override;
88 gfx::Screen* screen_;
89 gfx::Rect work_area_;
90 aura::Window* root_window_;
91 ShelfLayoutManager* shelf_;
92 int system_tray_height_;
94 DISALLOW_COPY_AND_ASSIGN(AshPopupAlignmentDelegate);
97 } // namespace ash
99 #endif // ASH_SYSTEM_WEB_NOTIFICATION_ASH_POPUP_ALIGNMENT_DELEGATE_H_