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

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: Rebase 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 StatusAreaWidget;
32 class WebNotificationList;
33 }
34
35 // Status area tray for showing browser and app notifications.
36 // Note: Not to be confused with system notifications (a NotificationView
37 // generated by a SystemTrayItem).
38
39 class ASH_EXPORT WebNotificationTray : public aura::EventFilter,
40 public internal::TrayBackgroundView {
41 public:
42 class Delegate {
43 public:
44 virtual ~Delegate() {}
45
46 // Called when the notification associated with |notification_id| is
47 // removed (i.e. closed by the user).
48 virtual void NotificationRemoved(const std::string& notifcation_id) = 0;
49
50 // Disables the extension associated with |notification_id|.
51 virtual void DisableExtension(const std::string& notifcation_id) = 0;
52
53 // Disables notifications from the source of |notification_id|.
54 virtual void DisableNotificationsFromSource(
55 const std::string& notifcation_id) = 0;
56
57 // Show the notification settings (from notifiation |notification_id|).
58 virtual void ShowSettings(const std::string& notifcation_id) = 0;
59 };
60
61 explicit WebNotificationTray(internal::StatusAreaWidget* status_area_widget);
62 virtual ~WebNotificationTray();
63
64 // Called once to set the delegate.
65 void SetDelegate(Delegate* delegate);
66
67 // Add a new notification. Use SetNotificationImage to set the icon image.
68 void AddNotification(const std::string& id,
69 const string16& title,
70 const string16& message,
71 const string16& source,
72 const std::string& extension);
73
74 // Remove an existing notification.
75 void RemoveNotification(const std::string& id);
76
77 // Set the notification image.
78 void SetNotificationImage(const std::string& id,
79 const SkBitmap& image);
80
81 // Disable all notifications matching notification |id|.
82 void DisableByExtension(const std::string& id);
83 void DisableByUrl(const std::string& id);
84
85 // Show the notification bubble. Should only be called by StatusAreaWidget.
86 void ShowBubble();
87
88 // Hide the notification bubble. Should only be called by StatusAreaWidget.
89 void HideBubble();
90
91 // Show the settings dialog (use notification matching |id| for the source
92 // browser context).
93 void ShowSettings(const std::string& id);
94
95 // Overridden from aura::EventFilter.
96 virtual bool PreHandleKeyEvent(aura::Window* target,
97 aura::KeyEvent* event) OVERRIDE;
98 virtual bool PreHandleMouseEvent(aura::Window* target,
99 aura::MouseEvent* event) OVERRIDE;
100 virtual ui::TouchStatus PreHandleTouchEvent(aura::Window* target,
101 aura::TouchEvent* event) OVERRIDE;
102 virtual ui::GestureStatus PreHandleGestureEvent(
103 aura::Window* target,
104 aura::GestureEvent* event) OVERRIDE;
105
106 // Overridden from TrayBackgroundView.
107 virtual void SetShelfAlignment(ShelfAlignment alignment) OVERRIDE;
108
109 // Overridden from internal::ActionableView.
110 virtual bool PerformAction(const views::Event& event) OVERRIDE;
111
112 private:
113 class Bubble;
114 class BubbleContentsView;
115 FRIEND_TEST_ALL_PREFIXES(WebNotificationTrayTest, WebNotifications);
116
117 int GetNotificationCount() const;
118 void UpdateIcon();
119 void UpdateBubbleAndIcon();
120 void ProcessLocatedEvent(const aura::LocatedEvent& event);
121
122 const internal::WebNotificationList* notification_list() const {
123 return notification_list_.get();
124 }
125 views::View* tray_container() const { return tray_container_; }
126 Bubble* bubble() const { return bubble_.get(); }
127
128 internal::StatusAreaWidget* status_area_widget_; // Unowned parent.
129 scoped_ptr<internal::WebNotificationList> notification_list_;
130 scoped_ptr<Bubble> bubble_;
131 views::View* tray_container_;
132 views::ImageView* icon_;
133 Delegate* delegate_;
134
135 DISALLOW_COPY_AND_ASSIGN(WebNotificationTray);
136 };
137
138 } // namespace ash
139
140 #endif // ASH_SYSTEM_NOTIFICATION_WEB_NOTIFICATION_TRAY_H_
OLDNEW
« no previous file with comments | « ash/system/tray/tray_background_view.cc ('k') | ash/system/web_notification/web_notification_tray.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698