| 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, AsWeakPtr(), |
| 325 type, notification_id, GetMessage(type)), | 325 type, notification_id, GetMessage(type)), |
| 326 delay); | 326 delay); |
| 327 } | 327 } |
| 328 | 328 |
| 329 void FileManagerNotifications::HideNotification(NotificationType type, | 329 void FileManagerNotifications::HideNotification(NotificationType type, |
| 330 const std::string& path) { | 330 const std::string& path) { |
| 331 std::string notification_id = GetNotificationId(type, path); | 331 std::string notification_id = GetNotificationId(type, path); |
| 332 HideNotificationById(notification_id); | 332 HideNotificationById(notification_id); |
| 333 } | 333 } |
| 334 | 334 |
| 335 void FileManagerNotifications::HideNotificationDelayed( | 335 void FileManagerNotifications::HideNotificationDelayed( |
| 336 NotificationType type, const std::string& path, base::TimeDelta delay) { | 336 NotificationType type, const std::string& path, base::TimeDelta delay) { |
| 337 MessageLoop::current()->PostDelayedTask( | 337 base::MessageLoop::current()->PostDelayedTask( |
| 338 FROM_HERE, | 338 FROM_HERE, |
| 339 base::Bind(&FileManagerNotifications::HideNotification, AsWeakPtr(), | 339 base::Bind(&FileManagerNotifications::HideNotification, AsWeakPtr(), |
| 340 type, path), | 340 type, path), |
| 341 delay); | 341 delay); |
| 342 } | 342 } |
| 343 | 343 |
| 344 void FileManagerNotifications::ShowNotificationById( | 344 void FileManagerNotifications::ShowNotificationById( |
| 345 NotificationType type, | 345 NotificationType type, |
| 346 const std::string& notification_id, | 346 const std::string& notification_id, |
| 347 const string16& message) { | 347 const string16& message) { |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 385 } | 385 } |
| 386 } | 386 } |
| 387 | 387 |
| 388 string16 FileManagerNotifications::GetNotificationMessageForTest( | 388 string16 FileManagerNotifications::GetNotificationMessageForTest( |
| 389 const std::string& id) const { | 389 const std::string& id) const { |
| 390 NotificationMap::const_iterator it = notification_map_.find(id); | 390 NotificationMap::const_iterator it = notification_map_.find(id); |
| 391 if (it == notification_map_.end()) | 391 if (it == notification_map_.end()) |
| 392 return string16(); | 392 return string16(); |
| 393 return it->second->message(); | 393 return it->second->message(); |
| 394 } | 394 } |
| OLD | NEW |