[Metrics] Make MetricsStateManager take a callback param to check if UMA is enabled.
[chromium-blink-merge.git] / chrome / browser / ui / views / message_center / message_center_widget_delegate.h
blob9a21d9e7ddf88d1143f2cd2f5bbf95662df5dcf4
1 // Copyright 2013 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 CHROME_BROWSER_UI_VIEWS_MESSAGE_CENTER_MESSAGE_CENTER_WIDGET_DELEGATE_H_
6 #define CHROME_BROWSER_UI_VIEWS_MESSAGE_CENTER_MESSAGE_CENTER_WIDGET_DELEGATE_H_
8 #include "base/basictypes.h"
9 #include "base/compiler_specific.h"
10 #include "base/memory/weak_ptr.h"
11 #include "ui/gfx/point.h"
12 #include "ui/gfx/rect.h"
13 #include "ui/message_center/message_center.h"
14 #include "ui/message_center/message_center_tray.h"
15 #include "ui/message_center/message_center_tray_delegate.h"
16 #include "ui/message_center/views/message_center_view.h"
17 #include "ui/views/widget/widget_delegate.h"
18 #include "ui/views/widget/widget_observer.h"
20 namespace message_center {
22 enum Alignment {
23 ALIGNMENT_TOP = 1 << 0,
24 ALIGNMENT_LEFT = 1 << 1,
25 ALIGNMENT_BOTTOM = 1 << 2,
26 ALIGNMENT_RIGHT = 1 << 3,
27 ALIGNMENT_NONE = 1 << 4,
30 struct PositionInfo {
31 int max_height;
33 // Alignment of the message center relative to the center of the screen.
34 Alignment message_center_alignment;
36 // Alignment of the taskbar relative to the center of the screen.
37 Alignment taskbar_alignment;
39 // Point relative to which message center is positioned.
40 gfx::Point inital_anchor_point;
43 class WebNotificationTray;
44 class MessageCenterFrameView;
46 // MessageCenterWidgetDelegate is the message center's client view. It also
47 // creates the message center widget and sets the notifications.
49 ////////////////////////////////////////////////////////////////////////////////
50 class MessageCenterWidgetDelegate : public views::WidgetDelegate,
51 public message_center::MessageCenterView,
52 public views::WidgetObserver {
53 public:
54 MessageCenterWidgetDelegate(WebNotificationTray* tray,
55 MessageCenterTray* mc_tray,
56 bool initially_settings_visible,
57 const PositionInfo& pos_info);
58 virtual ~MessageCenterWidgetDelegate();
60 // WidgetDelegate overrides:
61 virtual View* GetContentsView() OVERRIDE;
62 virtual views::NonClientFrameView* CreateNonClientFrameView(
63 views::Widget* widget) OVERRIDE;
64 virtual void DeleteDelegate() OVERRIDE;
65 virtual views::Widget* GetWidget() OVERRIDE;
66 virtual const views::Widget* GetWidget() const OVERRIDE;
68 // WidgetObserver overrides:
69 virtual void OnWidgetActivationChanged(views::Widget* widget,
70 bool active) OVERRIDE;
71 virtual void OnWidgetClosing(views::Widget* widget) OVERRIDE;
73 // View overrides:
74 virtual void PreferredSizeChanged() OVERRIDE;
75 virtual gfx::Size GetPreferredSize() const OVERRIDE;
76 virtual gfx::Size GetMaximumSize() OVERRIDE;
77 virtual int GetHeightForWidth(int width) const OVERRIDE;
78 virtual bool AcceleratorPressed(const ui::Accelerator& accelerator) OVERRIDE;
80 private:
81 // Creates and initializes the message center widget.
82 void InitWidget();
84 // Shifts the message center anchor point such that the mouse click point is
85 // along the middle 60% of the width of the message center if taskbar is
86 // horizontal aligned. If vertically aligned, ensures that mouse click point
87 // is along the height of the message center (at least at a corner).
88 gfx::Point GetCorrectedAnchor(gfx::Size calculated_size);
90 // Calculates the message center bounds using the position info and the
91 // corrected anchor.
92 gfx::Rect GetMessageCenterBounds();
94 // Insets of the message center border (set in MessageCenterFrameView).
95 gfx::Insets border_insets_;
97 // Info necessary to calculate the estimated position of the message center.
98 PositionInfo pos_info_;
100 WebNotificationTray* tray_;
103 } // namespace message_center
105 #endif // CHROME_BROWSER_UI_VIEWS_MESSAGE_CENTER_MESSAGE_CENTER_WIDGET_DELEGATE_H_