| 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/extensions/app_notification_manager.h" | 5 #include "chrome/browser/extensions/app_notification_manager.h" |
| 6 | 6 |
| 7 #include "base/auto_reset.h" | 7 #include "base/auto_reset.h" |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/file_path.h" | 9 #include "base/file_path.h" |
| 10 #include "base/location.h" | 10 #include "base/location.h" |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 // it in error paths. | 102 // it in error paths. |
| 103 linked_ptr<AppNotification> linked_item(item); | 103 linked_ptr<AppNotification> linked_item(item); |
| 104 if (!loaded()) | 104 if (!loaded()) |
| 105 return false; | 105 return false; |
| 106 const std::string& extension_id = item->extension_id(); | 106 const std::string& extension_id = item->extension_id(); |
| 107 AppNotificationList& list = GetAllInternal(extension_id); | 107 AppNotificationList& list = GetAllInternal(extension_id); |
| 108 list.push_back(linked_item); | 108 list.push_back(linked_item); |
| 109 | 109 |
| 110 SyncAddChange(*linked_item); | 110 SyncAddChange(*linked_item); |
| 111 | 111 |
| 112 sort(list.begin(), list.end(), AppNotificationSortPredicate); | 112 std::sort(list.begin(), list.end(), AppNotificationSortPredicate); |
| 113 | 113 |
| 114 if (list.size() > AppNotificationManager::kMaxNotificationPerApp) { | 114 if (list.size() > AppNotificationManager::kMaxNotificationPerApp) { |
| 115 AppNotification* removed = list.begin()->get(); | 115 AppNotification* removed = list.begin()->get(); |
| 116 SyncRemoveChange(*removed); | 116 SyncRemoveChange(*removed); |
| 117 list.erase(list.begin()); | 117 list.erase(list.begin()); |
| 118 } | 118 } |
| 119 | 119 |
| 120 if (storage_.get()) { | 120 if (storage_.get()) { |
| 121 BrowserThread::PostTask( | 121 BrowserThread::PostTask( |
| 122 BrowserThread::FILE, | 122 BrowserThread::FILE, |
| (...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 544 AppNotification* notification = new AppNotification( | 544 AppNotification* notification = new AppNotification( |
| 545 false, base::Time::FromInternalValue(specifics.creation_timestamp_ms()), | 545 false, base::Time::FromInternalValue(specifics.creation_timestamp_ms()), |
| 546 specifics.guid(), specifics.app_id(), | 546 specifics.guid(), specifics.app_id(), |
| 547 specifics.title(), specifics.body_text()); | 547 specifics.title(), specifics.body_text()); |
| 548 if (specifics.has_link_text()) | 548 if (specifics.has_link_text()) |
| 549 notification->set_link_text(specifics.link_text()); | 549 notification->set_link_text(specifics.link_text()); |
| 550 if (specifics.has_link_url()) | 550 if (specifics.has_link_url()) |
| 551 notification->set_link_url(GURL(specifics.link_url())); | 551 notification->set_link_url(GURL(specifics.link_url())); |
| 552 return notification; | 552 return notification; |
| 553 } | 553 } |
| OLD | NEW |