1116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch// Copyright 2014 The Chromium Authors. All rights reserved. 2116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch// Use of this source code is governed by a BSD-style license that can be 3116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch// found in the LICENSE file. 4116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch 5116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch#ifndef CHROME_BROWSER_CHROMEOS_FILE_SYSTEM_PROVIDER_NOTIFICATION_MANAGER_H_ 6116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch#define CHROME_BROWSER_CHROMEOS_FILE_SYSTEM_PROVIDER_NOTIFICATION_MANAGER_H_ 7116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch 8116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch#include <map> 9116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch#include <string> 10116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch 11116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch#include "base/callback.h" 12116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch#include "base/memory/scoped_ptr.h" 13116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch#include "chrome/browser/chromeos/file_system_provider/notification_manager_interface.h" 14116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch#include "chrome/browser/chromeos/file_system_provider/provided_file_system_info.h" 15116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch#include "chrome/browser/extensions/app_icon_loader.h" 16116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch 17116680a4aac90f2aa7413d9095a592090648e557Ben Murdochclass Profile; 18116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch 19116680a4aac90f2aa7413d9095a592090648e557Ben Murdochnamespace gfx { 20116680a4aac90f2aa7413d9095a592090648e557Ben Murdochclass Image; 21116680a4aac90f2aa7413d9095a592090648e557Ben Murdochclass ImageSkia; 22116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch} // message gfx 23116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch 24116680a4aac90f2aa7413d9095a592090648e557Ben Murdochnamespace message_center { 25116680a4aac90f2aa7413d9095a592090648e557Ben Murdochclass Notification; 26116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch} // namespace message_center 27116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch 28116680a4aac90f2aa7413d9095a592090648e557Ben Murdochnamespace chromeos { 29116680a4aac90f2aa7413d9095a592090648e557Ben Murdochnamespace file_system_provider { 30116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch 31116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch// Provided file systems's manager for showing notifications. Shows always 32116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch// up to one notification. If more than one request is unresponsive, then 33116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch// all of them will be aborted when clicking on the notification button. 34116680a4aac90f2aa7413d9095a592090648e557Ben Murdochclass NotificationManager : public NotificationManagerInterface, 35116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch public extensions::AppIconLoader::Delegate { 36116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch public: 37116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch NotificationManager(Profile* profile, 38116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch const ProvidedFileSystemInfo& file_system_info); 39116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch virtual ~NotificationManager(); 40116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch 41116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch // NotificationManagerInterface overrides: 42116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch virtual void ShowUnresponsiveNotification( 43116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch int id, 44116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch const NotificationCallback& callback) OVERRIDE; 45116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch virtual void HideUnresponsiveNotification(int id) OVERRIDE; 46116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch 47116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch // Invoked when a button on the notification is clicked. 48116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch void OnButtonClick(int button_index); 49116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch 50116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch // Invoked when the notification failed to show up. 51116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch void OnError(); 52116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch 53116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch // Invoked when the notification got closed either by user or by system. 54116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch void OnClose(); 55116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch 56116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch // extensions::AppIconLoader::Delegate overrides: 57116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch virtual void SetAppImage(const std::string& id, 58116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch const gfx::ImageSkia& image) OVERRIDE; 59116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch 60116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch private: 61116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch typedef std::map<int, NotificationCallback> CallbackMap; 62116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch 63116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch // Creates a notification object for the actual state of the manager. 64116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch scoped_ptr<message_center::Notification> CreateNotification(); 65116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch 66116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch // Handles a notification result by calling all registered callbacks and 67116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch // clearing the list. 68116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch void OnNotificationResult(NotificationResult result); 69116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch 70116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch Profile* profile_; // Not owned. 71116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch ProvidedFileSystemInfo file_system_info_; 72116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch CallbackMap callbacks_; 73116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch scoped_ptr<extensions::AppIconLoader> icon_loader_; 74116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch scoped_ptr<gfx::Image> extension_icon_; 75116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch 76116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch DISALLOW_COPY_AND_ASSIGN(NotificationManager); 77116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch}; 78116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch 79116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch} // namespace file_system_provider 80116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch} // namespace chromeos 81116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch 82116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch#endif // CHROME_BROWSER_CHROMEOS_FILE_SYSTEM_PROVIDER_NOTIFICATION_MANAGER_H_ 83