OLD | NEW |
| (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 CHROME_BROWSER_UI_VIEWS_ASH_BALLOON_COLLECTION_IMPL_ASH_H_ | |
6 #define CHROME_BROWSER_UI_VIEWS_ASH_BALLOON_COLLECTION_IMPL_ASH_H_ | |
7 | |
8 #include <set> | |
9 | |
10 #include "chrome/browser/chromeos/notifications/balloon_view_host_chromeos.h" /
/ MessageCallback | |
11 #include "chrome/browser/notifications/balloon_collection_impl.h" | |
12 #include "ui/message_center/message_center.h" | |
13 | |
14 class MessageCenterSettingsController; | |
15 | |
16 // Wrapper on top of ::BalloonCollectionImpl to provide integration between | |
17 // the Chrome notification UI and Ash notifications (ash::WebNotificationTray). | |
18 class BalloonCollectionImplAsh | |
19 : public BalloonCollectionImpl, | |
20 public message_center::MessageCenter::Delegate { | |
21 public: | |
22 BalloonCollectionImplAsh(); | |
23 virtual ~BalloonCollectionImplAsh(); | |
24 | |
25 // Overridden from BalloonCollectionImpl. | |
26 virtual void Add(const Notification& notification, | |
27 Profile* profile) OVERRIDE; | |
28 virtual bool HasSpace() const OVERRIDE; | |
29 | |
30 // Overridden from message_center::MessageCenter::Delegate. | |
31 virtual void NotificationRemoved(const std::string& notification_id, | |
32 bool by_user) OVERRIDE; | |
33 virtual void DisableExtension(const std::string& notification_id) OVERRIDE; | |
34 virtual void DisableNotificationsFromSource( | |
35 const std::string& notification_id) OVERRIDE; | |
36 virtual void ShowSettings(const std::string& notification_id) OVERRIDE; | |
37 virtual void ShowSettingsDialog(gfx::NativeView context) OVERRIDE; | |
38 virtual void OnClicked(const std::string& notification_id) OVERRIDE; | |
39 virtual void OnButtonClicked(const std::string& notification_id, | |
40 int button_index) OVERRIDE; | |
41 | |
42 // Adds a callback for WebUI message. Returns true if the callback | |
43 // is succssfully registered, or false otherwise. It fails to add if | |
44 // there is no notification that matches NotificationDelegate::id(), | |
45 // or a callback for given message already exists. The callback | |
46 // object is owned and deleted by callee. | |
47 bool AddWebUIMessageCallback( | |
48 const Notification& notification, | |
49 const std::string& message, | |
50 const chromeos::BalloonViewHost::MessageCallback& callback); | |
51 | |
52 // Updates the notification's content. It uses | |
53 // NotificationDelegate::id() to check the equality of notifications. | |
54 // Returns true if the notification has been updated. False if | |
55 // no corresponding notification is found. This will not change the | |
56 // visibility of the notification. | |
57 bool UpdateNotification(const Notification& notification); | |
58 | |
59 // On Ash this behaves the same as UpdateNotification. | |
60 bool UpdateAndShowNotification(const Notification& notification); | |
61 | |
62 protected: | |
63 // Creates a new balloon. Overridable by unit tests. The caller is | |
64 // responsible for freeing the pointer returned. | |
65 virtual Balloon* MakeBalloon(const Notification& notification, | |
66 Profile* profile) OVERRIDE; | |
67 | |
68 const extensions::Extension* GetBalloonExtension(Balloon* balloon); | |
69 | |
70 private: | |
71 scoped_ptr<MessageCenterSettingsController> settings_controller_; | |
72 | |
73 DISALLOW_COPY_AND_ASSIGN(BalloonCollectionImplAsh); | |
74 }; | |
75 | |
76 #endif // CHROME_BROWSER_UI_VIEWS_ASH_BALLOON_COLLECTION_IMPL_ASH_H_ | |
OLD | NEW |