1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
|
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_CHROMEOS_EXTENSIONS_FILE_BROWSER_NOTIFICATIONS_H_
#define CHROME_BROWSER_CHROMEOS_EXTENSIONS_FILE_BROWSER_NOTIFICATIONS_H_
#include <map>
#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"
class Profile;
class FileBrowserNotifications
: public base::SupportsWeakPtr<FileBrowserNotifications> {
public:
enum NotificationType {
DEVICE,
DEVICE_FAIL,
FORMAT_SUCCESS,
FORMAT_FAIL,
FORMAT_START,
FORMAT_START_FAIL,
GDATA_SYNC,
GDATA_SYNC_SUCCESS,
GDATA_SYNC_FAIL,
};
typedef std::map<std::string, linked_ptr<chromeos::SystemNotification> >
NotificationMap;
explicit FileBrowserNotifications(Profile* profile);
virtual ~FileBrowserNotifications();
void RegisterDevice(const std::string& path);
void UnregisterDevice(const std::string& path);
void ManageNotificationsOnMountCompleted(const std::string& system_path,
const std::string& label,
bool is_parent,
bool success,
bool is_unsupported);
void ManageNotificationOnGDataSyncProgress(int count);
void ManageNotificationOnGDataSyncFinish(bool success);
void ShowNotification(NotificationType type, const std::string& path);
void ShowNotificationDelayed(NotificationType type,
const std::string& path,
base::TimeDelta delay);
virtual void ShowNotificationWithMessage(NotificationType type,
const std::string& path,
const string16& message);
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);
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) {
}
};
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_;
MountRequestsMap mount_requests_;
Profile* profile_;
DISALLOW_COPY_AND_ASSIGN(FileBrowserNotifications);
};
#endif // CHROME_BROWSER_CHROMEOS_EXTENSIONS_FILE_BROWSER_NOTIFICATIONS_H_
|