| 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_manager/file_manager_notificat
ions.h" | 5 #include "chrome/browser/chromeos/extensions/file_manager/file_manager_notificat
ions.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
| 9 #include "base/stl_util.h" | 9 #include "base/stl_util.h" |
| 10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
| (...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 312 hidden_notifications_.erase(notification_id); | 312 hidden_notifications_.erase(notification_id); |
| 313 ShowNotificationById(type, notification_id, message); | 313 ShowNotificationById(type, notification_id, message); |
| 314 } | 314 } |
| 315 | 315 |
| 316 void FileManagerNotifications::ShowNotificationDelayed( | 316 void FileManagerNotifications::ShowNotificationDelayed( |
| 317 NotificationType type, | 317 NotificationType type, |
| 318 const std::string& path, | 318 const std::string& path, |
| 319 base::TimeDelta delay) { | 319 base::TimeDelta delay) { |
| 320 std::string notification_id = GetNotificationId(type, path); | 320 std::string notification_id = GetNotificationId(type, path); |
| 321 hidden_notifications_.erase(notification_id); | 321 hidden_notifications_.erase(notification_id); |
| 322 MessageLoop::current()->PostDelayedTask( | 322 base::MessageLoop::current()->PostDelayedTask( |
| 323 FROM_HERE, | 323 FROM_HERE, |
| 324 base::Bind(&FileManagerNotifications::ShowNotificationById, AsWeakPtr(), | 324 base::Bind(&FileManagerNotifications::ShowNotificationById, |
| 325 type, notification_id, GetMessage(type)), | 325 AsWeakPtr(), |
| 326 type, |
| 327 notification_id, |
| 328 GetMessage(type)), |
| 326 delay); | 329 delay); |
| 327 } | 330 } |
| 328 | 331 |
| 329 void FileManagerNotifications::HideNotification(NotificationType type, | 332 void FileManagerNotifications::HideNotification(NotificationType type, |
| 330 const std::string& path) { | 333 const std::string& path) { |
| 331 std::string notification_id = GetNotificationId(type, path); | 334 std::string notification_id = GetNotificationId(type, path); |
| 332 HideNotificationById(notification_id); | 335 HideNotificationById(notification_id); |
| 333 } | 336 } |
| 334 | 337 |
| 335 void FileManagerNotifications::HideNotificationDelayed( | 338 void FileManagerNotifications::HideNotificationDelayed( |
| 336 NotificationType type, const std::string& path, base::TimeDelta delay) { | 339 NotificationType type, const std::string& path, base::TimeDelta delay) { |
| 337 MessageLoop::current()->PostDelayedTask( | 340 base::MessageLoop::current()->PostDelayedTask( |
| 338 FROM_HERE, | 341 FROM_HERE, |
| 339 base::Bind(&FileManagerNotifications::HideNotification, AsWeakPtr(), | 342 base::Bind( |
| 340 type, path), | 343 &FileManagerNotifications::HideNotification, AsWeakPtr(), type, path), |
| 341 delay); | 344 delay); |
| 342 } | 345 } |
| 343 | 346 |
| 344 void FileManagerNotifications::ShowNotificationById( | 347 void FileManagerNotifications::ShowNotificationById( |
| 345 NotificationType type, | 348 NotificationType type, |
| 346 const std::string& notification_id, | 349 const std::string& notification_id, |
| 347 const string16& message) { | 350 const string16& message) { |
| 348 if (hidden_notifications_.find(notification_id) != | 351 if (hidden_notifications_.find(notification_id) != |
| 349 hidden_notifications_.end()) { | 352 hidden_notifications_.end()) { |
| 350 // Notification was hidden after a delayed show was requested. | 353 // Notification was hidden after a delayed show was requested. |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 385 } | 388 } |
| 386 } | 389 } |
| 387 | 390 |
| 388 string16 FileManagerNotifications::GetNotificationMessageForTest( | 391 string16 FileManagerNotifications::GetNotificationMessageForTest( |
| 389 const std::string& id) const { | 392 const std::string& id) const { |
| 390 NotificationMap::const_iterator it = notification_map_.find(id); | 393 NotificationMap::const_iterator it = notification_map_.find(id); |
| 391 if (it == notification_map_.end()) | 394 if (it == notification_map_.end()) |
| 392 return string16(); | 395 return string16(); |
| 393 return it->second->message(); | 396 return it->second->message(); |
| 394 } | 397 } |
| OLD | NEW |