Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(437)

Side by Side Diff: ash/system/web_notification/web_notification_tray.h

Issue 10514008: Add WebNotificationTray (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix test (don't mirror bubble arrow) Created 8 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2012 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_NOTIFICATION_WEB_NOTIFICATION_TRAY_H_
6 #define ASH_SYSTEM_NOTIFICATION_WEB_NOTIFICATION_TRAY_H_
7 #pragma once
8
9 #include "ash/ash_export.h"
10 #include "ash/system/tray/tray_background_view.h"
11 #include "base/gtest_prod_util.h"
12 #include "ui/aura/event_filter.h"
13
14 class SkBitmap;
15
16 namespace aura {
17 class LocatedEvent;
18 }
19
20 namespace base {
21 class DictionaryValue;
22 }
23
24 namespace views {
25 class ImageView;
26 }
27
28 namespace ash {
29
30 namespace internal {
31 class WebNotificationList;
32 }
33
34 // Status area tray for showing browser and app notifications.
35 // Note: Not to be confused with system notifications (a NotificationView
36 // generated by a SystemTrayItem).
37
38 class ASH_EXPORT WebNotificationTray : public aura::EventFilter,
39 public internal::TrayBackgroundView {
40 public:
41 class Delegate {
42 public:
43 virtual ~Delegate() {}
44
45 // Called when the notification associated with |notification_id| is
46 // removed (i.e. closed by the user).
47 virtual void NotificationRemoved(const std::string& notifcation_id) = 0;
48
49 // Disables the extension associated with |notification_id|.
50 virtual void DisableExtension(const std::string& notifcation_id) = 0;
51
52 // Disables notifications from the source of |notification_id|.
53 virtual void DisableNotificationsFromSource(
54 const std::string& notifcation_id) = 0;
55
56 // Show the notification settings (from notifiation |notification_id|).
57 virtual void ShowSettings(const std::string& notifcation_id) = 0;
58 };
59
60 WebNotificationTray();
61 virtual ~WebNotificationTray();
62
63 // Overridden from aura::EventFilter.
64 virtual bool PreHandleKeyEvent(aura::Window* target,
65 aura::KeyEvent* event) OVERRIDE;
66 virtual bool PreHandleMouseEvent(aura::Window* target,
67 aura::MouseEvent* event) OVERRIDE;
68 virtual ui::TouchStatus PreHandleTouchEvent(aura::Window* target,
69 aura::TouchEvent* event) OVERRIDE;
70 virtual ui::GestureStatus PreHandleGestureEvent(
71 aura::Window* target,
72 aura::GestureEvent* event) OVERRIDE;
73
74 // Overridden from TrayBackgroundView.
75 virtual void SetShelfAlignment(ShelfAlignment alignment) OVERRIDE;
76
77 // Overridden from internal::ActionableView.
78 virtual bool PerformAction(const views::Event& event) OVERRIDE;
79
80 // Called once to set the delegate.
81 void SetDelegate(Delegate* delegate);
82
83 // Add a new notification. Use SetNotificationImage to set the icon image.
84 void AddNotification(const std::string& id,
85 const string16& title,
86 const string16& message,
87 const string16& source,
88 const std::string& extension);
89
90 // Remove an existing notification.
91 void RemoveNotification(const std::string& id);
92
93 // Set the notification image.
94 void SetNotificationImage(const std::string& id,
95 const SkBitmap& image);
96
97 // Disable all notifications matching notification |id|.
98 void DisableByExtension(const std::string& id);
99 void DisableByUrl(const std::string& id);
100
101 // Show the settings dialog (use notification matching |id| for the source
102 // browser context).
103 void ShowSettings(const std::string& id);
104
105 private:
106 class Bubble;
107 class BubbleContentsView;
108 FRIEND_TEST_ALL_PREFIXES(WebNotificationTrayTest, WebNotifications);
109
110 int GetNotificationCount() const;
111 void UpdateIcon();
112 void UpdateBubbleAndIcon();
113 void ProcessLocatedEvent(const aura::LocatedEvent& event);
114
115 const internal::WebNotificationList* notification_list() const {
116 return notification_list_.get();
117 }
118 views::View* tray_container() const { return tray_container_; }
119 Bubble* bubble() const { return bubble_.get(); }
120
121 scoped_ptr<internal::WebNotificationList> notification_list_;
122 scoped_ptr<Bubble> bubble_;
123 views::View* tray_container_;
124 views::ImageView* icon_;
125 Delegate* delegate_;
126
127 DISALLOW_COPY_AND_ASSIGN(WebNotificationTray);
128 };
129
130 } // namespace ash
131
132 #endif // ASH_SYSTEM_NOTIFICATION_WEB_NOTIFICATION_TRAY_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698