summaryrefslogtreecommitdiffstats
path: root/chrome/browser/chromeos/extensions/file_browser_notifications.h
diff options
context:
space:
mode:
authorstevenjb@google.com <stevenjb@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2012-06-14 23:14:37 +0000
committerstevenjb@google.com <stevenjb@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2012-06-14 23:14:37 +0000
commite9abea4d758cc579079d7763b430d09b987a4f64 (patch)
treed0c2fa833c974d34d7916c704d816185dfb12393 /chrome/browser/chromeos/extensions/file_browser_notifications.h
parent4e76528d453e7aae31bc646a93448ca44c7cb19a (diff)
downloadchromium_src-e9abea4d758cc579079d7763b430d09b987a4f64.zip
chromium_src-e9abea4d758cc579079d7763b430d09b987a4f64.tar.gz
chromium_src-e9abea4d758cc579079d7763b430d09b987a4f64.tar.bz2
Add DesktopNotificationService::AddNotification
Convert BackgroundContentsService, FileBrowserNotifications, CloudPrintProxyService, and DesktopNotificationBalloon to use DesktopNotificationService::AdddNotification. Includes some significant re-factoring of FileBrowserNotifications to support Ash notifications (apologies). BUG=124914 TEST=Notification tests pass. Desktop notifications (e.g. cloud print, file browser) work with --ash-notify For CloudPrintProxyService: TBR=scottbyer@chromium.org Review URL: https://chromiumcodereview.appspot.com/10548052 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@142259 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/chromeos/extensions/file_browser_notifications.h')
-rw-r--r--chrome/browser/chromeos/extensions/file_browser_notifications.h91
1 files changed, 30 insertions, 61 deletions
diff --git a/chrome/browser/chromeos/extensions/file_browser_notifications.h b/chrome/browser/chromeos/extensions/file_browser_notifications.h
index c646581..039264a 100644
--- a/chrome/browser/chromeos/extensions/file_browser_notifications.h
+++ b/chrome/browser/chromeos/extensions/file_browser_notifications.h
@@ -6,13 +6,13 @@
#define CHROME_BROWSER_CHROMEOS_EXTENSIONS_FILE_BROWSER_NOTIFICATIONS_H_
#include <map>
+#include <set>
#include <string>
#include "base/basictypes.h"
-#include "base/memory/linked_ptr.h"
#include "base/memory/weak_ptr.h"
#include "base/string16.h"
-#include "chrome/browser/chromeos/notifications/system_notification.h"
+#include "base/time.h"
class Profile;
@@ -31,9 +31,6 @@ class FileBrowserNotifications
GDATA_SYNC_FAIL,
};
- typedef std::map<std::string, linked_ptr<chromeos::SystemNotification> >
- NotificationMap;
-
explicit FileBrowserNotifications(Profile* profile);
virtual ~FileBrowserNotifications();
@@ -49,76 +46,48 @@ class FileBrowserNotifications
void ManageNotificationOnGDataSyncProgress(int count);
void ManageNotificationOnGDataSyncFinish(bool success);
+ // Retreives message body based on |type|.
void ShowNotification(NotificationType type, const std::string& path);
- void ShowNotificationDelayed(NotificationType type,
- const std::string& path,
- base::TimeDelta delay);
+ // Primary method for showing a notification. Virtual for mock in unittest.
virtual void ShowNotificationWithMessage(NotificationType type,
const std::string& path,
const string16& message);
+ void ShowNotificationDelayed(NotificationType type,
+ const std::string& path,
+ base::TimeDelta delay);
+ // Primary method for hiding a notification. Virtual for mock in unittest.
virtual void HideNotification(NotificationType type, const std::string& path);
void HideNotificationDelayed(NotificationType type,
const std::string& path,
base::TimeDelta delay);
- const NotificationMap& notifications() const { return notifications_; }
-
- protected:
- virtual void PostDelayedShowNotificationTask(
- const std::string& notification_id,
- NotificationType type,
- const string16& message,
- base::TimeDelta delay);
- static void ShowNotificationDelayedTask(const std::string& notification_id,
- NotificationType type,
- const string16& message,
- base::WeakPtr<FileBrowserNotifications> self);
-
- virtual void PostDelayedHideNotificationTask(
- NotificationType type, const std::string path, base::TimeDelta delay);
- static void HideNotificationDelayedTask(NotificationType type,
- const std::string& path,
- base::WeakPtr<FileBrowserNotifications> self);
+ size_t GetNotificationCountForTest() const {
+ return notification_map_.size();
+ }
+ bool HasNotificationForTest(const std::string& id) const {
+ return notification_map_.find(id) != notification_map_.end();
+ }
private:
- struct MountRequestsInfo {
- bool mount_success_exists;
- bool fail_message_finalized;
- bool fail_notification_shown;
- bool non_parent_device_failed;
- bool device_notification_hidden;
- int fail_notifications_count;
-
- MountRequestsInfo() : mount_success_exists(false),
- fail_message_finalized(false),
- fail_notification_shown(false),
- non_parent_device_failed(false),
- device_notification_hidden(false),
- fail_notifications_count(0) {
- }
- };
+ class NotificationMessage;
+ struct MountRequestsInfo;
typedef std::map<std::string, MountRequestsInfo> MountRequestsMap;
-
- chromeos::SystemNotification* CreateNotification(const std::string& id,
- int title_id,
- int icon_id);
-
- void CreateNotificationId(NotificationType type,
- const std::string& path,
- std::string* id);
- int GetMessageId(NotificationType type);
- int GetIconId(NotificationType type);
- int GetTitleId(NotificationType type);
-
- void OnLinkClicked(const base::ListValue* arg);
- bool HasMoreInfoLink(NotificationType type);
- const string16& GetLinkText();
- chromeos::BalloonViewHost::MessageCallback GetLinkCallback();
-
- string16 link_text_;
- NotificationMap notifications_;
+ typedef std::map<std::string, NotificationMessage*> NotificationMap;
+
+ std::string CreateNotificationId(NotificationType type,
+ const std::string& path);
+ NotificationMessage* GetNotification(NotificationType type,
+ const std::string& path,
+ const string16& message);
+ void ShowNotificationById(NotificationType type,
+ const std::string& notification_id,
+ const string16& message);
+ void HideNotificationById(const std::string& id);
+
+ NotificationMap notification_map_;
+ std::set<std::string> hidden_notifications_;
MountRequestsMap mount_requests_;
Profile* profile_;