OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/chromeos/extensions/file_browser_notifications.h" | 5 #include "chrome/browser/chromeos/extensions/file_browser_notifications.h" |
6 | 6 |
7 #include "ash/ash_switches.h" | 7 #include "ash/ash_switches.h" |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 // Simple wrapper class to support ether old chromeos SystemNotifications or | 97 // Simple wrapper class to support ether old chromeos SystemNotifications or |
98 // new ash notifications. | 98 // new ash notifications. |
99 class FileBrowserNotifications::NotificationMessage { | 99 class FileBrowserNotifications::NotificationMessage { |
100 public: | 100 public: |
101 class Delegate : public NotificationDelegate { | 101 class Delegate : public NotificationDelegate { |
102 public: | 102 public: |
103 Delegate(const base::WeakPtr<FileBrowserNotifications>& host, | 103 Delegate(const base::WeakPtr<FileBrowserNotifications>& host, |
104 const std::string& id) | 104 const std::string& id) |
105 : host_(host), | 105 : host_(host), |
106 id_(id) {} | 106 id_(id) {} |
107 virtual ~Delegate() {} | |
108 virtual void Display() OVERRIDE {} | 107 virtual void Display() OVERRIDE {} |
109 virtual void Error() OVERRIDE {} | 108 virtual void Error() OVERRIDE {} |
110 virtual void Close(bool by_user) OVERRIDE { | 109 virtual void Close(bool by_user) OVERRIDE { |
111 if (host_) | 110 if (host_) |
112 host_->HideNotificationById(id_); | 111 host_->HideNotificationById(id_); |
113 } | 112 } |
114 virtual void Click() OVERRIDE { | 113 virtual void Click() OVERRIDE { |
115 // TODO(tbarzic): Show more info page once we have one. | 114 // TODO(tbarzic): Show more info page once we have one. |
116 } | 115 } |
117 virtual std::string id() const OVERRIDE { return id_; } | 116 virtual std::string id() const OVERRIDE { return id_; } |
118 virtual content::RenderViewHost* GetRenderViewHost() const OVERRIDE { | 117 virtual content::RenderViewHost* GetRenderViewHost() const OVERRIDE { |
119 return NULL; | 118 return NULL; |
120 } | 119 } |
121 | 120 |
122 private: | 121 private: |
| 122 virtual ~Delegate() {} |
| 123 |
123 base::WeakPtr<FileBrowserNotifications> host_; | 124 base::WeakPtr<FileBrowserNotifications> host_; |
124 std::string id_; | 125 std::string id_; |
125 | 126 |
126 DISALLOW_COPY_AND_ASSIGN(Delegate); | 127 DISALLOW_COPY_AND_ASSIGN(Delegate); |
127 }; | 128 }; |
128 | 129 |
129 NotificationMessage(FileBrowserNotifications* host, | 130 NotificationMessage(FileBrowserNotifications* host, |
130 Profile* profile, | 131 Profile* profile, |
131 NotificationType type, | 132 NotificationType type, |
132 const std::string& notification_id, | 133 const std::string& notification_id, |
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
391 void FileBrowserNotifications::HideNotificationById(const std::string& id) { | 392 void FileBrowserNotifications::HideNotificationById(const std::string& id) { |
392 NotificationMap::iterator it = notification_map_.find(id); | 393 NotificationMap::iterator it = notification_map_.find(id); |
393 if (it != notification_map_.end()) { | 394 if (it != notification_map_.end()) { |
394 delete it->second; | 395 delete it->second; |
395 notification_map_.erase(it); | 396 notification_map_.erase(it); |
396 } else { | 397 } else { |
397 // Mark as hidden so it does not get shown from a delayed task. | 398 // Mark as hidden so it does not get shown from a delayed task. |
398 hidden_notifications_.insert(id); | 399 hidden_notifications_.insert(id); |
399 } | 400 } |
400 } | 401 } |
OLD | NEW |