OLD | NEW |
(Empty) | |
| 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. |
| 4 |
| 5 #ifndef CHROME_BROWSER_CHROMEOS_FILE_SYSTEM_PROVIDER_NOTIFICATION_MANAGER_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_FILE_SYSTEM_PROVIDER_NOTIFICATION_MANAGER_H_ |
| 7 |
| 8 #include <map> |
| 9 #include <string> |
| 10 |
| 11 #include "base/callback.h" |
| 12 #include "base/memory/scoped_ptr.h" |
| 13 #include "chrome/browser/chromeos/file_system_provider/notification_manager_inte
rface.h" |
| 14 #include "chrome/browser/chromeos/file_system_provider/provided_file_system_info
.h" |
| 15 #include "chrome/browser/extensions/app_icon_loader.h" |
| 16 |
| 17 class Profile; |
| 18 |
| 19 namespace gfx { |
| 20 class Image; |
| 21 class ImageSkia; |
| 22 } // message gfx |
| 23 |
| 24 namespace message_center { |
| 25 class Notification; |
| 26 } // namespace message_center |
| 27 |
| 28 namespace chromeos { |
| 29 namespace file_system_provider { |
| 30 |
| 31 // Provided file systems's manager for showing notifications. Shows always |
| 32 // up to one notification. If more than one request is unresponsive, then |
| 33 // all of them will be aborted when clicking on the notification button. |
| 34 class NotificationManager : public NotificationManagerInterface, |
| 35 public extensions::AppIconLoader::Delegate { |
| 36 public: |
| 37 NotificationManager(Profile* profile, |
| 38 const ProvidedFileSystemInfo& file_system_info); |
| 39 virtual ~NotificationManager(); |
| 40 |
| 41 // NotificationManagerInterface overrides: |
| 42 virtual void ShowUnresponsiveNotification( |
| 43 int id, |
| 44 const NotificationCallback& callback) OVERRIDE; |
| 45 virtual void HideUnresponsiveNotification(int id) OVERRIDE; |
| 46 |
| 47 // Invoked when a button on the notification is clicked. |
| 48 void OnButtonClick(int button_index); |
| 49 |
| 50 // Invoked when the notification failed to show up. |
| 51 void OnError(); |
| 52 |
| 53 // Invoked when the notification got closed either by user or by system. |
| 54 void OnClose(); |
| 55 |
| 56 // extensions::AppIconLoader::Delegate overrides: |
| 57 virtual void SetAppImage(const std::string& id, |
| 58 const gfx::ImageSkia& image) OVERRIDE; |
| 59 |
| 60 private: |
| 61 typedef std::map<int, NotificationCallback> CallbackMap; |
| 62 |
| 63 // Creates a notification object for the actual state of the manager. |
| 64 scoped_ptr<message_center::Notification> CreateNotification(); |
| 65 |
| 66 // Handles a notification result by calling all registered callbacks and |
| 67 // clearing the list. |
| 68 void OnNotificationResult(NotificationResult result); |
| 69 |
| 70 Profile* profile_; // Not owned. |
| 71 ProvidedFileSystemInfo file_system_info_; |
| 72 CallbackMap callbacks_; |
| 73 scoped_ptr<extensions::AppIconLoader> icon_loader_; |
| 74 scoped_ptr<gfx::Image> extension_icon_; |
| 75 |
| 76 DISALLOW_COPY_AND_ASSIGN(NotificationManager); |
| 77 }; |
| 78 |
| 79 } // namespace file_system_provider |
| 80 } // namespace chromeos |
| 81 |
| 82 #endif // CHROME_BROWSER_CHROMEOS_FILE_SYSTEM_PROVIDER_NOTIFICATION_MANAGER_H_ |
OLD | NEW |